RE: GtkSwitch — lack of specific signal
Colomban wrote : I suppose this is all described somewhere - where?(I am new to gtk application programming). Check the documentation [1] ;) For example, for GtkWidget's signals see [2] or for GtkWindow see [3]... and so on. Cheers, Colomban [1] http://library.gnome.org/devel/gtk/stable/ [2] http://library.gnome.org/devel/gtk/stable/GtkWidget.html#GtkWidget.signal-details [3] http://library.gnome.org/devel/gtk/stable/GtkWindow.html#GtkWindow.signal-details I checked. notify::active is not mentioned anywhere in any of those! (I used my browser's find - can you find it mentioned somewhere?) Cheers, John Lumby ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: GtkSwitch — lack of specific signal
Hello. I checked. notify::active is not mentioned anywhere in any of those! (I used my browser's find - can you find it mentioned somewhere?) Cheers, John Lumby Those two links were just examples that demonstrate how signal handler's prototype can be obtained. Notify signal is part of GObject. When searching for a signals that are relevant to particula widget, you start by examining signals listed in widget's API docs, after those signals you inspect signals of it's parent, ... (API docs for each widget have a section named Object Hierarchy that lists relationships of objects). I would suggest that you install Devhelp and -doc packages of GTK/GLib/Cairo to make your life a bit easier. Cheers, Tadej -- Tadej Borovšak tadeboro.blogspot.com tadeb...@gmail.com tadej.borov...@gmail.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkSwitch — lack of specific signal
Le 05/03/2011 16:36, Tadej Borovšak a écrit : Hello. I checked. notify::active is not mentioned anywhere in any of those! (I used my browser's find - can you find it mentioned somewhere?) Cheers, John Lumby Those two links were just examples that demonstrate how signal handler's prototype can be obtained. Notify signal is part of GObject. When searching for a signals that are relevant to particula widget, you start by examining signals listed in widget's API docs, after those signals you inspect signals of it's parent, ... (API docs for each widget have a section named Object Hierarchy that lists relationships of objects). And the syntax of signals is signal-name::detail [1], with the ::detail part being optional (and rarely used, the only common use is with GObjet's notify signal [2]). Cheers, Colomban [1] http://library.gnome.org/devel/gobject/stable/signal.html#signal-detail [2] http://library.gnome.org/devel/gobject/stable/gobject-The-Base-Object-Type.html#GObject-notify ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkSwitch — lack of specific signal
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 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkSwitch — lack of specific signal
On Fri, Mar 04, 2011 at 12:45:18PM -0500, John Lumby wrote: 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've never used GtkSwitch but from a quick glance at the docs I suppose you have to connect to notify::active, i.e. watch changes of the property active. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkSwitch — lack of specific signal
On 2011-03-04 at 12:45, John Lumby wrote: 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. you can use notify::active. ciao, Emmanuele. -- W: http://www.emmanuelebassi.name B: http://blogs.gnome.org/ebassi ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: GtkSwitch — lack of specific signal
Hello. Thanks both. I tried notify::active and it works as well as event-after but still the data pointer argument is bad on entry to the callback(it's not zero but not a valid GTK_WIDGET either). I don't know why - maybe something related to GtkSwitch or maybe a mistake in my code somewhere. Cheers, John Lumby Are you sure your functions has the right prototype? GObject::notify signal handlers should have callbacks defined like this: void notify_callback (GObject*obj, GParamSpec *pspec, gpointer *data) { /* La la la */ } Cheers, Tadej -- Tadej Borovšak tadeboro.blogspot.com tadeb...@gmail.com tadej.borov...@gmail.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
RE: GtkSwitch — lack of specific signal
A! Thank you Tadej.No, mine had only two parameters, the obj ptr and the data ptr.I added the paramspec in between and now all works perfectly. By the way - this seems a bit unpleasant, that some callbacks have a prototype of (objptr, dataptr) and others have (objptr, paramspec, dataptr).How would I know which one to use? Is it that some are in the gtk layer (2 params) but other like notify::active are in the gdk layer (3 params)?And I kind of feel something should have alerted me although I don't know what - I guess the compiler doesn't know. I suppose this is all described somewhere - where?(I am new to gtk application programming). Cheers, John Subject: RE: GtkSwitch — lack of specific signal From: tadeb...@gmail.com To: johnlu...@hotmail.com CC: gtk-app-devel-list@gnome.org Date: Sat, 5 Mar 2011 02:50:05 +0100 Hello. Thanks both. I tried notify::active and it works as well as event-after but still the data pointer argument is bad on entry to the callback(it's not zero but not a valid GTK_WIDGET either). I don't know why - maybe something related to GtkSwitch or maybe a mistake in my code somewhere. Cheers, John Lumby Are you sure your functions has the right prototype? GObject::notify signal handlers should have callbacks defined like this: void notify_callback (GObject*obj, GParamSpec *pspec, gpointer *data) { /* La la la */ } Cheers, Tadej -- Tadej Borovšak tadeboro.blogspot.com tadeb...@gmail.com tadej.borov...@gmail.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkSwitch — lack of specific signal
Le 05/03/2011 03:17, John Lumby a écrit : A! Thank you Tadej.No, mine had only two parameters, the obj ptr and the data ptr.I added the paramspec in between and now all works perfectly. By the way - this seems a bit unpleasant, that some callbacks have a prototype of (objptr, dataptr) and others have (objptr, paramspec, dataptr).How would I know which one to use? Is it that some are in the gtk layer (2 params) but other like notify::active are in the gdk layer (3 params)?And I kind of feel something should have alerted me although I don't know what - I guess the compiler doesn't know. I suppose this is all described somewhere - where?(I am new to gtk application programming). Check the documentation [1] ;) For example, for GtkWidget's signals see [2] or for GtkWindow see [3]... and so on. Cheers, Colomban [1] http://library.gnome.org/devel/gtk/stable/ [2] http://library.gnome.org/devel/gtk/stable/GtkWidget.html#GtkWidget.signal-details [3] http://library.gnome.org/devel/gtk/stable/GtkWindow.html#GtkWindow.signal-details Cheers, John Subject: RE: GtkSwitch — lack of specific signal From: tadeb...@gmail.com To: johnlu...@hotmail.com CC: gtk-app-devel-list@gnome.org Date: Sat, 5 Mar 2011 02:50:05 +0100 Hello. Thanks both. I tried notify::active and it works as well as event-after but still the data pointer argument is bad on entry to the callback(it's not zero but not a valid GTK_WIDGET either). I don't know why - maybe something related to GtkSwitch or maybe a mistake in my code somewhere. Cheers, John Lumby Are you sure your functions has the right prototype? GObject::notify signal handlers should have callbacks defined like this: void notify_callback (GObject*obj, GParamSpec *pspec, gpointer *data) { /* La la la */ } Cheers, Tadej -- Tadej Borovšak tadeboro.blogspot.com tadeb...@gmail.com tadej.borov...@gmail.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list