summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2013-11-17 20:15:54 -0500
committerMatthias Clasen <mclasen@redhat.com>2013-11-18 06:00:02 -0500
commitdf455db2e320be73cbc39a67e69eeeee19375aba (patch)
tree06466d92e9c316088fdc3f3f2f6f594cc94986f6 /testsuite
parentc7870385c3075ec330618cba3d86bebc92816a61 (diff)
downloadgtk+-df455db2e320be73cbc39a67e69eeeee19375aba.tar.gz
GtkBuilder: Make IDs optional
One requirement of .ui files is that each object must have an ID, even if it is never referred to or directly loaded from the code. This makes editing .ui files much more onerous than it has to be, due to the frequent need to invent new IDs, while avoiding clashes. This commit makes IDs optional in the XML. They only need to be provided for objects which are referred to or explictly loaded from the code. Since GtkBuilder needs IDs for its own internal accounting, we create IDs of the form ___object_N___ if not specified in the XML. https://bugzilla.gnome.org/show_bug.cgi?id=712553
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/gtk/builder.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/testsuite/gtk/builder.c b/testsuite/gtk/builder.c
index 08582623c5..d20fba6a61 100644
--- a/testsuite/gtk/builder.c
+++ b/testsuite/gtk/builder.c
@@ -2728,6 +2728,53 @@ test_expose_object (void)
g_object_unref (image);
}
+static void
+test_no_ids (void)
+{
+ GtkBuilder *builder;
+ GError *error = NULL;
+ GObject *obj;
+ const gchar buffer[] =
+ "<interface>"
+ " <object class=\"GtkInfoBar\">"
+ " <child internal-child=\"content_area\">"
+ " <object class=\"GtkHBox\">"
+ " <child>"
+ " <object class=\"GtkLabel\">"
+ " <property name=\"label\" translatable=\"yes\">Message</property>"
+ " </object>"
+ " <packing>"
+ " <property name='expand'>False</property>"
+ " </packing>"
+ " </child>"
+ " </object>"
+ " </child>"
+ " <child internal-child=\"action_area\">"
+ " <object class=\"GtkVButtonBox\">"
+ " <child>"
+ " <object class=\"GtkButton\" id=\"button_ok\">"
+ " <property name=\"label\">gtk-ok</property>"
+ " <property name=\"use-stock\">yes</property>"
+ " </object>"
+ " </child>"
+ " </object>"
+ " </child>"
+ " <action-widgets>"
+ " <action-widget response=\"1\">button_ok</action-widget>"
+ " </action-widgets>"
+ " </object>"
+ "</interface>";
+
+ builder = gtk_builder_new ();
+ gtk_builder_add_from_string (builder, buffer, -1, &error);
+ g_assert (error == NULL);
+
+ obj = gtk_builder_get_object (builder, "button_ok");
+ g_assert (GTK_IS_BUTTON (obj));
+
+ g_object_unref (builder);
+}
+
int
main (int argc, char **argv)
{
@@ -2777,6 +2824,7 @@ main (int argc, char **argv)
g_test_add_func ("/Builder/GMenu", test_gmenu);
g_test_add_func ("/Builder/LevelBar", test_level_bar);
g_test_add_func ("/Builder/Expose Object", test_expose_object);
+ g_test_add_func ("/Builder/No IDs", test_no_ids);
return g_test_run();
}