- GtkBuilder ignores .ui file
- #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;
- }
- <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>
- <?xml version="1.0" encoding="UTF-8"?>
- <interface>
- <!-- interface-requires gtk+ 3.0 -->
- <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>
- int main (int argc, char *argv[])
- {
- GtkBuilder *builder;
- GtkWidget *window;
- gtk_init (&argc, &argv);
- builder = gtk_builder_new ();
- gtk_builder_add_from_file (builder, "tutorial.xml", NULL);
- window = GTK_WIDGET (gtk_builder_get_object (builder, "Window"));
- g_object_unref (G_OBJECT (builder));
- gtk_widget_show (window);
- gtk_main ();
- return 0;
- }
- <property name="visible">True</property>
- gtk_widget_show (window);