<?php
if( !extension_loaded('gtk')) {
dl( 'php_gtk.' . PHP_SHLIB_SUFFIX);
}
function show_popup($event, $menu) {
if($event->button == 3) {
$menu->popup(null, null, null, $event->button, $event->time);
}
}
$window = &new GtkWindow();
$window->set_default_size(350, 450);
$window->connect_object('destroy', array('gtk', 'main_quit'));
$menu = &new GtkMenu();
$accel = $menu->ensure_uline_accel_group();
$open = &new GtkMenuItem("Open");
$open->lock_accelerators();
$menu->append($open);
$save = &new GtkMenuItem("Save as ...");
$save->lock_accelerators();
$menu->append($save);
$separator = &new GtkMenuItem();
$separator->set_sensitive(false);
$menu->append($separator);
$exit = &new GtkMenuItem("");
$accel_label = $exit->child;
$accel_key = $accel_label->parse_uline("E_xit");
$exit->add_accelerator('activate', $accel, $accel_key, GDK_CONTROL_MASK,
GTK_ACCEL_VISIBLE);
$exit->lock_accelerators();
$exit->connect_object('activate', array('gtk', 'main_quit'));
$menu->append($exit);
$menu->show_all();
$label = &new GtkLabel( 'Right-click here to see the menu');
$window->add( $label);
$window->add_events(GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK);
$window->connect_object('button-press-event', 'show_popup', $menu);
$window->show_all();
gtk::main();
?>
|