[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Suggestions about g_signal_connect_data and/or g_object_set_data_full
- From: "Tristan Van Berkom" <tvb gnome org>
- To: "Rodrigo Miguel" <rodrmigu gmail com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: Suggestions about g_signal_connect_data and/or g_object_set_data_full
- Date: Sat, 3 Jan 2009 10:49:54 -0500
On Fri, Jan 2, 2009 at 2:35 PM, Rodrigo Miguel <rodrmigu gmail com> wrote:
> Hello all,
>
> I've the code below, so here are just a couple of questions:
>
> 1) I'm curious, if I close the app by clicking the button that calls
> gtk_main_quit, instead of forceing the window to be destroyed, it
> doesn't call my GClosureNotify/GDestroyNotify functions. So, I wrote a
> small code that list all toplevels and then destroy it, so it's
> working pretty well so far, just curious if that's the normal
> behavior.
Thats normal behavior, you have to destroy your widgets if you
want to free the memory (usually thats not important at quit time
though).
> 2) in the line below: "gtk_container_add(GTK_CONTAINER (window),
> button);", if I forget to create a relation between button widget to
> another container, the GClosureNotify/GDestroyNotify will not be
> called too. I know that's a bad programming practice, but it would
> happen in a large program and have a orphan widget. So, is there any
> way to overcome this issue?
Gtk+ is not supposed to work if you forget to use it correctly ;-)
Normally I would couple the signal_connect() and the container_add() in
the same code segment, bottom line is you are responsible for knowing
when to connect/disconnect/block your signal callbacks.
(in the above situation it would be safe, to add the child at a later time,
since you already know the button will not be clicked by a user until
its added to the ui and shown).
Cheers,
-Tristan
PS: Consider using GtkBuilder to build your widgets instead of
writing that code by hand ;-)
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]