summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohan Dahlin <jdahlin@async.com.br>2007-10-24 09:46:31 +0000
committerJohan Dahlin <johan@src.gnome.org>2007-10-24 09:46:31 +0000
commit1d332bbb44f68165b46c119cd281774ea76d1a31 (patch)
tree1df5f1be6edbf1eba9d8aa8d53bea706eea0955b
parent9e3c937175e8302bfb1f90090e25e7ecd525130e (diff)
downloadgdk-pixbuf-1d332bbb44f68165b46c119cd281774ea76d1a31.tar.gz
Allow empty property nodes so we can set empty strings. (#486420, Xavier
2007-10-24 Johan Dahlin <jdahlin@async.com.br> * gtk/gtkbuilderparser.c (end_element): Allow empty property nodes so we can set empty strings. (#486420, Xavier Claessens) svn path=/trunk/; revision=18943
-rw-r--r--ChangeLog5
-rw-r--r--gtk/gtkbuilderparser.c27
-rw-r--r--tests/buildertest.c47
3 files changed, 45 insertions, 34 deletions
diff --git a/ChangeLog b/ChangeLog
index e0c567042..6ed403f7c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2007-10-24 Johan Dahlin <jdahlin@async.com.br>
+
+ * gtk/gtkbuilderparser.c (end_element): Allow empty property nodes
+ so we can set empty strings. (#486420, Xavier Claessens)
+
2007-10-23 Richard Hult <richard@imendio.com>
* gtk/gtkquartz.c:
diff --git a/gtk/gtkbuilderparser.c b/gtk/gtkbuilderparser.c
index 8833f397d..af3a826fd 100644
--- a/gtk/gtkbuilderparser.c
+++ b/gtk/gtkbuilderparser.c
@@ -139,24 +139,6 @@ error_invalid_tag (ParserData *data,
line_number, char_number, tag);
}
-static void
-error_missing_property_value (ParserData *data,
- GError **error)
-{
- gint line_number, char_number;
-
- g_markup_parse_context_get_position (data->ctx,
- &line_number,
- &char_number);
-
- g_set_error (error,
- GTK_BUILDER_ERROR,
- GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE,
- "%s:%d:%d <property> must have a value set",
- data->filename,
- line_number, char_number);
-}
-
gboolean
_gtk_builder_boolean_from_string (const gchar *string,
gboolean *value,
@@ -799,15 +781,6 @@ end_element (GMarkupParseContext *context,
PropertyInfo *prop_info = state_pop_info (data, PropertyInfo);
CommonInfo *info = state_peek_info (data, CommonInfo);
- if (!prop_info->data)
- {
- error_missing_property_value (data, error);
- free_property_info (prop_info);
- if (strcmp (info->tag.name, "object") == 0)
- free_object_info((ObjectInfo*)info);
- return;
- }
-
/* Normal properties */
if (strcmp (info->tag.name, "object") == 0)
{
diff --git a/tests/buildertest.c b/tests/buildertest.c
index f495f8833..72b25e033 100644
--- a/tests/buildertest.c
+++ b/tests/buildertest.c
@@ -76,13 +76,6 @@ gboolean test_parser (void)
g_return_val_if_fail (error->code == GTK_BUILDER_ERROR_INVALID_TAG, FALSE);
g_error_free (error);
- error = NULL;
- gtk_builder_add_from_string (builder, "<interface><object class=\"GtkWindow\" id=\"a\"><property name=\"type\"/></object></interface>", -1, &error);
- g_assert (error != NULL);
- g_return_val_if_fail (error->domain == GTK_BUILDER_ERROR, FALSE);
- g_return_val_if_fail (error->code == GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE, FALSE);
- g_error_free (error);
-
g_object_unref (builder);
return TRUE;
@@ -1507,6 +1500,42 @@ gboolean test_widget (void)
return TRUE;
}
+gboolean test_window (void)
+{
+ gchar *buffer1 =
+ "<interface>"
+ " <object class=\"GtkWindow\" id=\"window1\">"
+ " <property name=\"title\"></property>"
+ " </object>"
+ "</interface>";
+ gchar *buffer2 =
+ "<interface>"
+ " <object class=\"GtkWindow\" id=\"window1\">"
+ " </object>"
+ "</interface>";
+ GtkBuilder *builder;
+ GObject *window1;
+ gchar *title;
+
+ builder = builder_new_from_string (buffer1, -1, NULL);
+ window1 = gtk_builder_get_object (builder, "window1");
+ g_object_get (window1, "title", &title, NULL);
+ g_return_val_if_fail (strcmp (title, "") == 0, FALSE);
+ g_free (title);
+ gtk_widget_destroy (GTK_WIDGET (window1));
+ g_object_unref (builder);
+
+ builder = builder_new_from_string (buffer2, -1, NULL);
+ window1 = gtk_builder_get_object (builder, "window1");
+ g_return_val_if_fail (title != NULL, FALSE);
+ g_free (title);
+ gtk_widget_destroy (GTK_WIDGET (window1));
+ g_object_unref (builder);
+
+
+ return TRUE;
+}
+
static gboolean
test_value_from_string (void)
{
@@ -1810,5 +1839,9 @@ main (int argc, char **argv)
if (!test_reference_counting ())
g_error ("test_reference_counting failed");
+ g_print ("Testing window\n");
+ if (!test_window ())
+ g_error ("test_window failed");
+
return 0;
}