PDA

View Full Version : [GTK]how to manage multiple Gtk windows?



sujoy
April 2nd, 2009, 04:35 PM
I have the main window and the about dialog in one glade file and a preferences window in another glade file.

The problem is that I can show the preferences window, but havent yet managed to destroy it. I tried using both the delete event and the destroy signal, still, nothing works(read no activity whatsoever). However, once I close the main window, I can then close the preferences window normally. :confused:

Can someone please guide me to a solution or even a link maybe?

main.c file here (http://dpaste.com/22632/)
callback.c file here (http://dpaste.com/22633/)
preferences.c file here (http://dpaste.com/22634/)

gui.xml file here (http://dpaste.com/22636/)
preferences.xml file here (http://dpaste.com/22637/)

Another strange thing is that, after preferences window is displayed, if i click the close button on the main_window i quit the main window instantly and then i can click on the close button in preferences to close it normally. However, if after displaying preferences, I click on the quit menu, then nothing happens, and i can either click quit again or close the main_window both of which directly quits the application.

kknd
April 2nd, 2009, 08:04 PM
gtk_widget_destroy() destroyes widgets (whoa). But I usually don't destroy widgets that will be used again, I just hide then ( gtk_widget_hide ).

nvteighen
April 2nd, 2009, 08:29 PM
gtk_widget_destroy() destroyes widgets (whoa). But I usually don't destroy widgets that will be used again, I just hide then ( gtk_widget_hide ).
Well, because destroying widgets means to deallocate them.

kknd
April 2nd, 2009, 09:04 PM
Well, because destroying widgets means to deallocate them.

Yes. Instead of creating, using, destroying, creating, using, destroying I prefer create, use, hide, show, use, hide, etc.

sujoy
April 3rd, 2009, 05:16 AM
Yes I tried gtk_widget_destroy and hide both. Found something interesting that I hadn't noticed before, the preferences window is just displayed, but it is not responsive, that is the button in there is not clickable at all.

kknd
April 4th, 2009, 11:58 PM
Showing a container doesn't shows it's content. You need to do a gtk_widget_show_all to recursively show the contents.

slavik
April 5th, 2009, 03:09 AM
why not combine averything into a single file?

sujoy
April 5th, 2009, 11:21 AM
why not combine averything into a single file?

Yes I could definitely do that. But this is more of a learning expedition for me than actually making a production system, hence I am just playing around with the options I have.