[EMAIL PROTECTED] wrote:
>
> Hi,
>
> I wrote a user interface with glade in which there is a sub window (called
> from a main window).
>
> To exit from this subwindow I setup a File->exit menu.
>
> In the exit function I reset some variables.
>
> Of course I saw some users exiting from the subwindow by clicking the cross
> icon (in the top rigth angle of the window).
> And this way my variables are not reset.
>
> Is there a way to avoid this ?
>
> Thank you
>
> Philippe
>
I usually do this by connecting to the "destroy" signal of an object.
Example:
...
gchar *filename;
mainwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (mainwin);
subwin = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_widget_show (subwin);
gtk_signal_connect (GTK_OBJECT (subwin), "destroy",
GTK_SIGNAL_FUNC (subwin_cb_destroy), mainwin);
/* example of binding a variable to a widget */
filename = g_strdup("Blah");
gtk_object_set_data (GTK_OBJECT (subwin), "fname", filename);
...
void
subwin_cb_destroy (GtkWidget *subwin, GtkWidget *mainwin)
{
gchar *filename;
<reset some variables>
filename = gtk_object_get_data (GTK_OBJECT (subwin), "fname");
g_free (filename);
}
This will take care of both exit methods as it relies on when the object
gets destroyed.
If you have variables that are local to the routines that handle a
widget, I find it easiest to use gtk_object_set_data to bind a variable
to a widget. In this example we are binding a file name pointer that was
allocated, so it should be free'd when the subwin gets destroyed. We are
also passing a variable via the "gtk_signal_connect" call, mainwin,
which is convenient for single variables.
Hope that helps. Lates..
Josh Green
_______________________________________________
Glade-devel maillist - [EMAIL PROTECTED]
http://lists.helixcode.com/mailman/listinfo/glade-devel