[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Closing a single window programmatically (was: RE: erasing(clean ing) drawing area)




On Fri, 25 Jun 1999, Sean Nichols wrote:
> 
> According to the tutorial, there's a neat little function for this sort of
> thing:
> 
> void gtk_signal_emit_by_name( GtkObject   *object,
>                               const gchar *name,
>                               ... );
> 
> (note I have no idea what the "..." stands for; I can use the function fine,
> without supplying anything there. I assume it's if I want to send more than
> one signal at once. I'm at work right now (on a 'doze box), so I can't
> easily check out the Gtk+ headers at the moment...)
> 

"..." is a variable argument list. In this case, you should provide the
arguments to the signal, followed by a location for the signal's return
value if any.

> So the really easy way to do this should be to
> 
> gtk_signal_emit_by_name( GTK_OBJECT( mywindow ), "destroy" );
> 

No, you can't do this. You must call gtk_widget_destroy() or
gtk_object_destroy(); you can't emit arbitrary signals unless the signals
have the GTK_RUN_ACTION flag set, which destroy doesn't.

> 
> Kepp in mind I haven't actually used this function for this purpose myself;
> it is possible that there are unforseen side-effects. For example, Gtk+
> supports signal propogation up the tree in your program. So, it's entirely
> possible that you may end up "destroy"ing other things as well. In which
> case, use the equivalent function:
> 

No, it isn't possible. Only signals which correspond to events are
propagated up the tree.

> void gtk_signal_emit_stop_by_name( GtkObject   *object,
>                                    const gchar *name );
> 
> hence:
> 
> gtk_signal_emit_stop_by_name( GTK_OBJECT( mywindow ), "destroy" );
> 

You should *never* call gtk_signal_emit_stop for the destroy signal; it
will leave the object half-destroyed and crash the program eventually.

Just use gtk_widget_destroy() to close your window. Ignore all this
gtk_signal stuff.

Havoc




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]