Re: glade problem

From: Date: Fri, 21 Sep 2001 14:19:31 +0000
Subject: Re: glade problem
References: 1  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-135@lists.php.net to get a copy of this message
The default handler for the delete-event signal is destroy(); so if you don't have a handler in place for it this is what will happen. Give it your own handler function with hide() and that ought to sort it. Or am I missing something? ----- Original Message ----- From: "Christophe VG" <Christophe.VanGinneken@ubizen.com> To: <php-gtk-general@lists.php.net> Sent: Friday, September 21, 2001 2:04 PM Subject: [PHP-GTK] glade problem While discovering the possiblities of PHP-GTK and glade I keep running into the same problem. This is the situation: I create a GUI using glade consisting of two windows. The first window which is visible at startup has one button with one signal handler defined on_button1_clicked. The second window is set to visible=false. This is the php code that goes with it ... <? // load dynamic PHP-GTK library dl( 'php_gtk.' . (strstr(PHP_OS, 'WIN') ? 'dll' : 'so')); // init Glade GUI $gx = &new GladeXML( 'project2.glade' ); $wnd = $gx->get_widget( 'window1' ); $wnd->connect( 'delete_event', create_function('','gtk::main_quit();')); function on_button1_clicked() { // get the second window from glade and show it global $gx; $wnd = $gx->get_widget( 'window2' ); $wnd->show(); } // connect event / signal handlers and start Gtk main loop $gx->signal_autoconnect(); Gtk::main(); ?> The goal is to have the second window appear whenever I press the button on the first window. This works nicely ... the first time only. After removing the window by pressing the window's close button, it get completely deleted. Which causes a consecutive ->show() call to error. Changing the on_button1_clicked function to: function on_button1_clicked() { // reload the glade project $gx = &new GladeXML( 'project2.glade' ); $wnd = $gx->get_widget( 'window2' ); $wnd->show(); } fixes the problem, but only in a very "local hack" solution. I have the impression that a better solution can be found in catching the delete_event on the second window ... and then ... Here's where I get stuck ... I can't seem to find a way to tell GTK not to execute the delete signal and just hide the window. After some trial and error attempts I also tried to write the code by hand which in fact results in the same problems, I need to build a new GtkWindow object inside the function that shows the window. I've attached the glade project file in attachement if you want to test. Any comments, links to more docs, ... anything is welcome, cause I guess it's just a stupid thingie I'm overlooking. C -------------------------------------------------------------------------------- -- PHP-GTK General Mailing List (http://gtk.php.net/) To unsubscribe, e-mail: php-gtk-general-unsubscribe@lists.php.net For additional commands, e-mail: php-gtk-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

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