mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-27 07:56:14 +01:00
GMenuMarkup: fixes uncovered by roundtrip testing
The print function was forgetting to emit type information for attributes, and the parser was not handling types properly either.
This commit is contained in:
parent
d5a1b674f5
commit
a2aeea7acd
@ -238,7 +238,7 @@ g_menu_markup_start_element (GMarkupParseContext *context,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
state->type = typestr ? g_variant_type_new (typestr) : NULL;
|
state->type = typestr ? g_variant_type_new (typestr) : g_variant_type_copy (G_VARIANT_TYPE_STRING);
|
||||||
state->string = g_string_new (NULL);
|
state->string = g_string_new (NULL);
|
||||||
state->attribute = g_quark_from_string (name);
|
state->attribute = g_quark_from_string (name);
|
||||||
state->context = g_strdup (context);
|
state->context = g_strdup (context);
|
||||||
@ -320,7 +320,7 @@ g_menu_markup_end_element (GMarkupParseContext *context,
|
|||||||
if ((value = g_variant_parse (state->type, text, NULL, NULL, error)))
|
if ((value = g_variant_parse (state->type, text, NULL, NULL, error)))
|
||||||
{
|
{
|
||||||
/* Deal with translatable string attributes */
|
/* Deal with translatable string attributes */
|
||||||
if (state->domain && state->translatable && state->type &&
|
if (state->domain && state->translatable &&
|
||||||
g_variant_type_equal (state->type, G_VARIANT_TYPE_STRING))
|
g_variant_type_equal (state->type, G_VARIANT_TYPE_STRING))
|
||||||
{
|
{
|
||||||
const gchar *msgid;
|
const gchar *msgid;
|
||||||
@ -343,11 +343,8 @@ g_menu_markup_end_element (GMarkupParseContext *context,
|
|||||||
g_variant_unref (value);
|
g_variant_unref (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state->type)
|
|
||||||
{
|
|
||||||
g_variant_type_free (state->type);
|
g_variant_type_free (state->type);
|
||||||
state->type = NULL;
|
state->type = NULL;
|
||||||
}
|
|
||||||
|
|
||||||
g_free (state->context);
|
g_free (state->context);
|
||||||
state->context = NULL;
|
state->context = NULL;
|
||||||
@ -634,12 +631,13 @@ g_menu_markup_print_string (GString *string,
|
|||||||
{
|
{
|
||||||
gchar *printed;
|
gchar *printed;
|
||||||
gchar *str;
|
gchar *str;
|
||||||
|
const gchar *type;
|
||||||
|
|
||||||
printed = g_variant_print (value, TRUE);
|
printed = g_variant_print (value, TRUE);
|
||||||
str = g_markup_printf_escaped ("<attribute name='%s'>%s</attribute>\n", name, printed);
|
type = g_variant_type_peek_string (g_variant_get_type (value));
|
||||||
|
str = g_markup_printf_escaped ("<attribute name='%s' type='%s'>%s</attribute>\n", name, type, printed);
|
||||||
indent_string (contents, indent + tabstop);
|
indent_string (contents, indent + tabstop);
|
||||||
g_string_append (contents, str);
|
g_string_append (contents, str);
|
||||||
g_variant_unref (value);
|
|
||||||
g_free (printed);
|
g_free (printed);
|
||||||
g_free (str);
|
g_free (str);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user