function create_event_watcher() { static $dialog = null; static $event_watcher_enter_id = 0; static $event_watcher_leave_id = 0; if (!$dialog) { $dialog = new GtkDialog(); $dialog->connect_object('destroy', 'event_watcher_down', &$event_watcher_enter_id, &$event_watcher_leave_id); $dialog->connect_object('destroy', create_function('$w', '$w = null;'), &$dialog); $dialog->set_title('Event Watcher'); $dialog->set_border_width(0); $dialog->set_usize(200, 110); $vbox = $dialog->vbox; $action_area = $dialog->action_area; $button =& new GtkToggleButton('Activate Watch'); $button->connect_object('clicked', 'event_watcher_toggle', &$event_watcher_enter_id, &$event_watcher_leave_id); $button->set_border_width(10); $vbox->pack_start($button); $button->show(); $button =& new GtkButton('Close'); $button->connect_object('clicked', 'event_watcher_down', &$event_watcher_enter_id, &$event_watcher_leave_id); $button->connect_object('clicked', array($dialog, 'destroy')); $button->set_flags(GTK_CAN_DEFAULT); $action_area->pack_start($button); $button->grab_default(); $button->show(); } if (!($dialog->flags() & GTK_VISIBLE)) { $dialog->show(); } else { $dialog->destroy(); } }