=?Windows-1252?Q?GtkSwitch_?= =?Windows-1252?Q?=97_lack_of_?= =?Windows-1252?Q?specific_s?= =?Windows-1252?Q?ignal?=




I have been playing with a small application using the new (in gtk3) GtkSwitch ("light switch" style) widget.
The reference manual does not mention any signal specific to this widget,   and I think it would be nice to 
have one.      I want a signal for when the state is toggled,  e.g. "switched".
I eventually (after a lot of trial and error) found I could almost do what I needed by using the 
"event-after" signal,  (snippet below),  but with that signal,  I found that the data pointer is null (zero) 
on entry to my callback.   I don't know if that is because it is not really valid to use a signal with this 
widget at all?  or some obscure bug?   or just maybe that gtk3 is a bit new?

By the way,   the trial-and-error part is that although I found many different signal types which were 
delivered to my cb,   the event-after was the only one that was delivered exactly once and once only,  after 
the user toggled the switch.

GtkWidget *do_light_switch (GtkWidget *do_widget){  [...] GtkSwitch *light_switch_widg;  GtkImage 
*light_on_image;
      g_signal_connect_object ( GTK_WIDGET (light_switch_widg), "event-after",                G_CALLBACK 
(turn_light_on_off) , GTK_WIDGET (light_on_image) , G_CONNECT_AFTER);

In my callback,  the data pointer is 0 (confirmed with gdb)  yet the pointer is set correctly in the above 
g_signal_connect_object .I eventually resorted to storing the value of the light_on_image in a static 
savearea and referencing it from there in the cb :
      save_light_on_image_ptr =  GTK_WIDGET (light_on_image);
(which worked and also confirmed that the pointer was set correctly at the time of the 
g_signal_connect_object).
Or can someone spot something I did wrong?
John Lumby
                                          


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