I know it's possible to import specific objects from a glade file using:
builder.add_objects_from_file("example.glade", ("button1", "button2"))
But as you can see, I have to pass a list of the objects I want to import.
Is there a way to import everything in the .glade file? All the objects without having to specify their names here?
When you use gtk_builder_add_objects_from_file
, you are merging specific objects to an existing GtkBuilder instance which will then instantiate those same objects. Using this function/method is only useful if you need a specific set of objects from a UI definition file.
The normal use of GtkBuilder
, would be to load it entirely and then retrieve the object you want to deal with gtk_builder_get_object
. But if your goal is to retrieve all the objects, then use gtk_builder_get_objects
which will return a GSList
. Using this function/method assumes that you already loaded a UI definition file from a file or from another possible source.
As documented:
GSList *gtk_builder_get_objects (GtkBuilder *builder);
Gets all objects that have been constructed by builder . Note that this function does not increment the reference counts of the returned objects.
Returns
a newly-allocated GSList containing all the objects constructed by the GtkBuilder instance. It should be freed by g_slist_free().