Nesting Calls to gtk::main() to Create a Login Window
| From: | dpgirago at mdanderson dot org | Date: | Fri, 20 Aug 2004 15:48:57 +0000 |
| Subject: | Nesting Calls to gtk::main() to Create a Login Window | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-4975@lists.php.net to get a copy of this message | ||
Hello PHP-GTK Listers,
I've been playing with the GtkDialog Widget as I need to make a Login
Window to access an application. I was just about to post this test code
to the Wiki when I realized that clicking the OK button does not close the
first window before opening up the second window. However clicking on the
'X' button does destroy the first window and open the second one as
intended. I did see the entry in the manual for GtkDialog and the
suggestion about nesting calls to gtk::main(), and it seems as if I'm on
the right track. Can someone please suggest how I can get the button click
to close the first window before opening the second one?
<?php
dl("php_gtk." . (strstr(PHP_OS, "WIN") ? "dll" : "so"));
function quit_routine($window)
{
global $windowOneClosed;
$windowOneClosed = TRUE;
gtk::main_quit();
}
function quit_routine2($window)
{
global $windowOneClosed;
gtk::main_quit();
}
$windowOneClosed = FALSE;
$dialog = &new GtkDialog();
$dialog->set_policy(true, false, false);
$dialog->set_position(GTK_WIN_POS_CENTER);
$dialog->set_title("Dialog Window");
$dialog->connect("destroy", "quit_routine");
$dialog->show();
$dialog_vbox = $dialog->vbox;
$dialog_action_area = $dialog->action_area;
$user_info_label = &new GtkLabel("Some Important Information");
$dialog_vbox->pack_start($user_info_label);
$user_info_label->show();
$ok_button = &new GtkButton("OK");
$dialog_action_area->pack_start($ok_button);
$ok_button->connect("clicked", "quit_routine");
$ok_button->show();
gtk::main();
if($windowOneClosed)
{
$window2 = &new GtkWindow();
$window2->set_title("Quit Window");
$window2->connect("destroy", "quit_routine2");
$window2->show();
gtk::main();
}
?>
Thanks very much,
dave