Merge branch 'builder-parse-attributes' into 'main'

builder: Parse PangoAttrList values

See merge request GNOME/gtk!5228
This commit is contained in:
Matthias Clasen 2022-11-19 02:49:23 +00:00
commit ab530b9e5a
3 changed files with 43 additions and 0 deletions

View File

@ -2325,6 +2325,23 @@ gtk_builder_value_from_string_type (GtkBuilder *builder,
{
g_value_take_boxed (value, g_bytes_new (string, strlen (string)));
}
else if (G_VALUE_HOLDS (value, PANGO_TYPE_ATTR_LIST))
{
PangoAttrList *attrs;
attrs = pango_attr_list_from_string (string);
if (attrs)
g_value_take_boxed (value, attrs);
else
{
g_set_error (error,
GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_INVALID_VALUE,
"Could not parse PangoAttrList '%s'",
string);
ret = FALSE;
}
}
else
{
g_set_error (error,

View File

@ -0,0 +1 @@
SUCCESS

View File

@ -0,0 +1,25 @@
<!-- test all valid label attributes -->
<interface>
<object class="GtkLabel">
<property name="attributes">
5 10 language de
0 -1 style italic
0 -1 weight bold
0 -1 variant normal
0 -1 stretch ultra-expanded
0 -1 underline double
0 -1 strikethrough true
0 -1 gravity north
0 -1 gravity-hint line
0 -1 family "sans"
0 -1 size 10
0 -1 absolute-size 10
0 -1 font-desc "Cantarell 11"
0 -1 foreground yellow
0 -1 background red
0 -1 underline-color green
0 -1 strikethrough-color purple
0 -1 scale 1.5
</property>
</object>
</interface>