[gtk/parse-pango-types: 1/2] builder: Parse some pango types
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/parse-pango-types: 1/2] builder: Parse some pango types
- Date: Tue, 18 Jan 2022 17:50:10 +0000 (UTC)
commit 688085cfafd4dd00dea23e9040fb25ae66783d7c
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Jan 18 12:34:58 2022 -0500
builder: Parse some pango types
PangoAttrList and PangoFontDescription
have from-string apis, so we can just
support them as property values.
gtk/gtkbuilder.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
---
diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c
index 545699c45c..7e04498db5 100644
--- a/gtk/gtkbuilder.c
+++ b/gtk/gtkbuilder.c
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]