glade problem
| From: | Christophe VG | Date: | Fri, 21 Sep 2001 13:04:28 +0000 |
| Subject: | glade problem | ||
| Groups: | php.gtk.general | ||
| Request: | Send a blank email to php-gtk-general+get-133@lists.php.net to get a copy of this message | ||
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