Re: glade problem

From: Date: Fri, 21 Sep 2001 16:31:30 +0000
Subject: Re: glade problem
References: 1 2  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-136@lists.php.net to get a copy of this message
Oki, ... found what was really missing ... return true; I had been testing with function delete_child( $widget ) { $widget->hide(); } which still caused problems. Adding "return true;" at the end fixed it. At this moment I seem to recall reading somewhere that a signal handler should return true to indicate it has finished off the signal, and no further (default) consecutive handlers shoudl be called ... function delete_child( $widget ) { $widget->hide(); return true; } Great, I knew I was missing something like this. What still bothers me though is the fact that if I connect both the delete and destroy signal handlers ... $child->connect( 'delete_event', 'delete_child' ); $child->connect( 'destroy_event', 'destroy_child' ); function delete_child( $widget ) { print "delete\n"; $widget->hide(); } function destroy_child( $widget ) { print "destroy\n"; $widget->hide(); } I only see the delete handler called ... and the problem persists. So apparantly it's not the destroy signal that is called. Anyhow, it makes sense now and I can continue in a clean way what I was doing. C On Fri, 2001-09-21 at 14:19, Steph wrote: > 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 > > > -- > 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 (#136) next »