forked from AuroraMiddleware/gtk
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
This commit is contained in:
parent
9e3c937175
commit
1d332bbb44
@ -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:
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user