Re: How to identify a particular checkbutton ?



>I thought with gtk_object_set_data_full I can put a gchar *key and latter I ca
>n "pull" this value again in callback function, manipulate this string and ext
>ract what checkbutton is, but isn't, the key works how as a "index" to data pa
>ssed by gtk_object_set_data... but this is not what I want.
>living & learning.

you can do that, sure. but its more cumbersome and completely
unnecessary. in the solution i outlined for you, your handler *knows*
which button it is handling a "toggled" event for. nothing more is needed.

my example was slightly wrong, however, and actually its even easier
than i suggested. the signal handler prototype was wrong:

    gtk_signal_connect(GTK_CHECK_BUTTON(button), "toggled", 
                       (GtkSignalFunc) your_signal_handler, NULL);

 
 void
 your_handler (GtkWidget *widget)
 {
       GtkCheckButton *button = GTK_CHECK_BUTTON(widget);
       ...
 }

all GTK+ events pass the widget on which they occured as the first
argument to the handler. you don't even need to pass a pointer to the
button because GTK does it for you.

--p



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