I am trying to create a really simple GUI using GtkBuilder and glade. To achieve this, I follow the official Gtk + 3 Reference Manual. The only difference from the source code is that I donโt connect to widget signals for simplicity (and therefore also removed their callback function):
#include <gtk/gtk.h> int main (int argc, char *argv[]) { GtkBuilder *builder; GObject *window; GObject *button; gtk_init (&argc, &argv); /* Construct a GtkBuilder instance and load our UI description */ builder = gtk_builder_new (); gtk_builder_add_from_file (builder, "builder.ui", NULL); gtk_main (); return 0; }
The file "builder.ui" used in the tutorial is as follows:
<interface> <object id="window" class="GtkWindow"> <property name="visible">True</property> <property name="title">Grid</property> <property name="border-width">10</property> <child> <object id="grid" class="GtkGrid"> <property name="visible">True</property> <child> <object id="button1" class="GtkButton"> <property name="visible">True</property> <property name="label">Button 1</property> </object> <packing> <property name="left-attach">0</property> <property name="top-attach">0</property> </packing> </child> <child> <object id="button2" class="GtkButton"> <property name="visible">True</property> <property name="label">Button 2</property> </object> <packing> <property name="left-attach">1</property> <property name="top-attach">0</property> </packing> </child> <child> <object id="quit" class="GtkButton"> <property name="visible">True</property> <property name="label">Quit</property> </object> <packing> <property name="left-attach">0</property> <property name="top-attach">1</property> <property name="width">2</property> </packing> </child> </object> <packing> </packing> </child> </object> </interface>
... and does not cause any problems. The program compiles and creates the desired window. However, when I try to use my own .ui file (generated by glade 3.10.0), I don't get any result at all. The application enters mainloop, and the window does not appear. The GUI file I'm using is:
<?xml version="1.0" encoding="UTF-8"?> <interface> <object class="GtkWindow" id="Window"> <property name="can_focus">False</property> <property name="border_width">15</property> <child> <object class="GtkLabel" id="fooLabel"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="label" translatable="yes">foobar</property> </object> </child> </object> </interface>
What am I doing wrong?
source share