Re: Destroying window



gtk-ml brazina net wrote:

Hello,

I have the main application window and then I create another window
(toplevel).In this window I have some widgets - labels, entries and buttons.
I need to use one of these buttons as a "cancel" button, so it destroys
the window and all widgets in it.
I tried:

g_signal_connect(G_OBJECT(cancel_button), "clicked", gtk_widget_destroy,
another_window);
but it always destroys only that button :-(

Can you help me please ?

thx


Callbacks in gtk always take the object emitting the signal as first argument, so if you connect to a function that takes only one parameter (gtk_destroy_widget) it operates on the button which emits the signal. In general you have to check in the docs the prototype of the callback for the signal you are using since it may takes different args and may have to return a value and connect a proper callback function. In this particular case though you can use the following trick: g_signal_connect_swapped (G_OBJECT(cancel_button), "clicked", gtk_widget_destroy, another_window); so that another_window is passed as first arg to gtk_destroy_widget instead of cancel_button.

PS: a window with a cancel button that closes it... are you sure that GtkDialog and its "response" signal are not what you are looking for?



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