Re: gtk_signal_emit_by_name ()



mrl netbank com br writes:

As I saw at the GTK+ 1.2 API, gtk_signal_emit_by_name() sends a
signal to the widget, causing this to execute the default and the
user handlers.  I'm using a togglebutton to show a window, and when
this is closed, the button should turn off. I was trying to handle
delete-event at this window and in this handle I was just calling
gtk_signal_emit_by_name (button, "toggled", button).  (button is
casted from GtkWidget to GtkObject with GTK_OBJECT()) and return
TRUE, to gtk+ doesn't erase my window.  What I noticed is that I
click on the WM close button, and nothing happen.. the delete-event
handler is called, the gtk_signal_emit_by_name() is called, but no
signal is propagated.  Do you have any idea why this is ocurring?


gtk_signal_emit_by_name() can only be used on "action signals"
(signals with the GTK_RUN_ACTION flag). I believe the docs have a note
by each signal indicating whether it's an action signal. An action
signal is one that just invokes an action on the widget, and doesn't
require any special setup or shutdown or other conditions to be
emitted. Trying to emit non-action signals in user code will often
confuse GTK.

In this case I think gtk_toggle_button_set_active() would really work 
fine, wouldn't it? Maybe:
 gtk_toggle_button_set_active (toggle, ! toggle->active);

Havoc



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