I've been trying to get the "names" of all GtkWidgets in a GtkBuilder object.
I've managed to get all objects from the builder object via gtk_builder_get_objects()
and store them in a GSList.
However, when I use gtk_widget_get_name()
on the gobjects (which i cast to GtkWidgets), I get generic names such as "GtkWindow" and "GtkButton" instead of "window1" or "button1" that are displayed in glade.
Any help would be extremely appreciated and would make this programmer very happy.
The "Gtk. Builder class" allows user interfaces to be designed without writing code. The class describes the interface in an Extensible Markup Language (XML) file and then loads the XML description at runtime and creating the objects automatically.
I am doing the exact same thing. I was able to get the id=
strings from the .glade
file using
gtk_buildable_get_name()
as specified here.
Note: Prior to 2.20, GtkBuilder was setting the "name" property of constructed widgets to the "id" attribute. In GTK+ 2.20 or newer, you have to use gtk_buildable_get_name()
instead of gtk_widget_get_name()
to obtain the "id", or set the "name" property in your UI definition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With