RE: [PHP-GTK] Destroy Gtk default handler
| From: | Nghia | Date: | Sun, 08 Jan 2006 23:04:03 +0000 |
| Subject: | RE: [PHP-GTK] Destroy Gtk default handler | ||
| References: | 1 | Groups: | php.gtk.general |
| Request: | Send a blank email to php-gtk-general+get-6511@lists.php.net to get a copy of this message | ||
Try this
function CloseDialog($dialog) {
die;
}
A very crude method, but I you wanted the program to quit right? Your
original code will only close the dialog window, not the main window. If you
wanted to do that then you can also do:
function CloseDialog($dialog) {
global $main;
$dialog->destroy();
$main->destroy();
}
-----Original Message-----
From: kioto [mailto:kioto@fadelabor.net]
Sent: Saturday, 7 January 2006 11:20 PM
To: php-gtk-general@lists.php.net
Subject: [PHP-GTK] Destroy Gtk default handler
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.
--
PHP-GTK General Mailing List (http://gtk.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php