Gtk + Glade: widgets that use the same signal handler. How to distinguish them from each other?

Now I have a window that includes many buttons that perform this behavior, so it’s natural to use the same signal handler for them. But, however, after the signal, I just can not distinguish them from each other. Yes, I have a pointer to an object, but I can’t say that this is the first button, the second button or something else.

I assumed that the "Name" attribute (I set it togglebutton1) in the meadow can be obtained using the function gtk_widget_get_name, but I'm wrong, instead I got "GtkToggleButton". Xml file says <object class="GtkToggleButton" id="togglebutton1">.

Anyway, to use the id property, or is there a better solution for identifying thoses buttons? Many thanks.

+3
source share
1 answer

The reason you return the value as "GTKToggleButton" is because you did not manually set the name with gtk_widget_set_name. According to GTK documentation:

Widget names are the default widget type (for example, "GtkButton") or can be specified for a specific application using gtk_widget_set_name ().

, gtk_widget_set_name, , , gtk_widget_path, . , ..

: gtk_buildable_get_name, XML-. , gtk_widget_set_name. , XML- GTKBuilder.

+3

All Articles