Compare commits

...

2 Commits

Author SHA1 Message Date
Matthias Clasen
61f7ac09bc Replace some uses of custom buildables
Use string syntax instead of <attributes>
for PangoAttrList in a few places.
2022-01-18 12:49:01 -05:00
Matthias Clasen
688085cfaf builder: Parse some pango types
PangoAttrList and PangoFontDescription
have from-string apis, so we can just
support them as property values.
2022-01-18 12:34:58 -05:00
2 changed files with 36 additions and 6 deletions

View File

@@ -45,9 +45,7 @@
<object class="GtkLabel">
<property name="xalign">0</property>
<property name="label" translatable="yes">Font Features</property>
<attributes>
<attribute name="weight" value="bold"></attribute>
</attributes>
<property name="attributes" translatable="yes">0 -1 weight bold</property>
</object>
</child>
<child>
@@ -75,9 +73,7 @@
<object class="GtkLabel" id="variations_heading">
<property name="label" translatable="yes">Font Variations</property>
<property name="xalign">0</property>
<attributes>
<attribute name="weight" value="bold"></attribute>
</attributes>
<property name="attributes" translatable="yes">0 -1 weight bold</property>
</object>
</child>
<child>

View File

@@ -2322,6 +2322,40 @@ 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_FONT_DESCRIPTION))
{
PangoFontDescription *desc;
desc = pango_font_description_from_string (string);
if (desc)
g_value_take_boxed (value, desc);
else
{
g_set_error (error,
GTK_BUILDER_ERROR,
GTK_BUILDER_ERROR_INVALID_VALUE,
"Could not parse '%s' as a %s",
string, G_VALUE_TYPE_NAME (value));
ret = FALSE;
}
}
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 '%s' as a %s",
string, G_VALUE_TYPE_NAME (value));
ret = FALSE;
}
}
else
{
g_set_error (error,