Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GtkBuilder and "names"

Tags:

c

gtk

gtkbuilder

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.

like image 591
seininn Avatar asked Nov 25 '11 00:11

seininn


People also ask

What is GTK builder?

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.


1 Answers

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.

like image 186
user1240935 Avatar answered Oct 18 '22 00:10

user1240935