Destroy Gtk default handler

From: Date: Sat, 07 Jan 2006 12:20:10 +0000
Subject: Destroy Gtk default handler
Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-6507@lists.php.net to get a copy of this message
Hi all, i have a simple question about PHP-GTk1 on the destroy handler. I need to start a dialog message to show info to the user before close the main application and call the default destroy handler with gtk::main_quit. I have write a little snippet of code to explain the question: <?php error_reporting(E_ALL); if (!extension_loaded('gtk')) { dl('php_gtk.' . PHP_SHLIB_SUFFIX); } function CloseWin() { Gtk::main_quit(); } function CheckInput($input) { if ($input->get_text() == "") {
       $dialog =& new GtkDialog();
       $dialog->set_policy(true, false, false);
       $dialog->set_position(GTK_WIN_POS_CENTER);
       $dialog->set_title("Dialog Window");
       $dialog->set_border_width(8);
       $dialog->connect('destroy', 'closewin');
       $dialog_vbox = $dialog->vbox;
       $dialog_action_area = $dialog->action_area;
       $user_info_label =& new GtkLabel("The input field is empty, insert a value please");
       $user_info_label->set_line_wrap(true);
       $user_info_label->set_justify(GTK_JUSTIFY_LEFT);
       $dialog_vbox->pack_start($user_info_label);
       $user_info_label->show();
       $box =& new GtkHButtonBox();
       $ok_button = & new GtkButton("OK");
       $ok_button->connect_object('clicked', 'closedialog', $dialog);
       $box->pack_start($ok_button);
       $dialog_action_area->pack_start($box);
       $dialog->show_all();
       Gtk::main();      }
} function CloseDialog($dialog) { $dialog->destroy(); } $main =& new GtkWindow(); $main->set_title("Test destroy handler"); $main->set_position(GTK_WIN_POS_CENTER); $main->set_border_width(6); $main->connect_object('destroy', 'closewin'); /*** VBox Layout */ $Vbox =& new GtkVBox(); /*** GtkEntry field */ $input =& new GtkEntry(); $input->set_editable(true); /*** GtkHButtonBox */ $ButtonBox =& new GtkHButtonBox(); $ButtonBox->set_layout(GTK_BUTTONBOX_END); /*** GtkButton controls: apply button and cancel button */ $applyButton =& new GtkButton('Apply'); $applyButton->connect_object('clicked', 'checkinput', $input); //$applyButton->connect('clicked', 'closewin'); $cancelButton =& new GtkButton('Cancel'); $cancelButton->connect('clicked', 'closewin'); $ButtonBox->pack_start($applyButton); $ButtonBox->pack_start($cancelButton); $Vbox->pack_start($input); $Vbox->pack_start($ButtonBox); $main->add($Vbox); $main->show_all(); Gtk::main(); ?> When i click on $applyButton i want to check the input values and show an alert if the GtkEntry is empty, and later call the destroy handler to quit from the app. Thanks so much to all.

« previous php.gtk.general (#6507) next »