summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-03-25 13:03:00 +0000
committerMatthias Clasen <mclasen@redhat.com>2022-03-25 13:03:00 +0000
commita1ddd3fead941bedf30a172048f65cf4b0e05c09 (patch)
treea9c3033efb61e143440958399e5ee05fbb2750f5
parent7b8bfb4c8039a6e1b990343a2950570a1d421e79 (diff)
parent79f0f4ee8e6dd1dc95f14e6b191eea219f797279 (diff)
downloadgtk+-a1ddd3fead941bedf30a172048f65cf4b0e05c09.tar.gz
Merge branch 'inspector-attributes' into 'main'
inspector: Allow viewing PangoAttrList properties See merge request GNOME/gtk!4596
-rw-r--r--gtk/inspector/prop-editor.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/gtk/inspector/prop-editor.c b/gtk/inspector/prop-editor.c
index 822e0ef722..db3d6f2c1b 100644
--- a/gtk/inspector/prop-editor.c
+++ b/gtk/inspector/prop-editor.c
@@ -360,6 +360,22 @@ intern_string_modified (GtkEntry *entry, ObjectProperty *p)
}
static void
+attr_list_modified (GtkEntry *entry, ObjectProperty *p)
+{
+ GValue val = G_VALUE_INIT;
+ PangoAttrList *attrs;
+
+ attrs = pango_attr_list_from_string (gtk_editable_get_text (GTK_EDITABLE (entry)));
+ if (!attrs)
+ return;
+
+ g_value_init (&val, PANGO_TYPE_ATTR_LIST);
+ g_value_take_boxed (&val, attrs);
+ set_property_value (p->obj, p->spec, &val);
+ g_value_unset (&val);
+}
+
+static void
string_changed (GObject *object, GParamSpec *pspec, gpointer data)
{
GtkEntry *entry = GTK_ENTRY (data);
@@ -385,6 +401,35 @@ string_changed (GObject *object, GParamSpec *pspec, gpointer data)
}
static void
+attr_list_changed (GObject *object, GParamSpec *pspec, gpointer data)
+{
+ GtkEntry *entry = GTK_ENTRY (data);
+ GValue val = G_VALUE_INIT;
+ char *str;
+ const char *text;
+ PangoAttrList *attrs;
+
+ g_value_init (&val, PANGO_TYPE_ATTR_LIST);
+ get_property_value (object, pspec, &val);
+
+ attrs = g_value_get_boxed (&val);
+ str = pango_attr_list_to_string (attrs);
+ if (str == NULL)
+ str = g_strdup ("");
+ text = gtk_editable_get_text (GTK_EDITABLE (entry));
+ if (g_strcmp0 (str, text) != 0)
+ {
+ block_controller (G_OBJECT (entry));
+ gtk_editable_set_text (GTK_EDITABLE (entry), str);
+ unblock_controller (G_OBJECT (entry));
+ }
+
+ g_free (str);
+
+ g_value_unset (&val);
+}
+
+static void
strv_modified (GtkInspectorStrvEditor *self, ObjectProperty *p)
{
GValue val = G_VALUE_INIT;
@@ -1168,6 +1213,18 @@ property_editor (GObject *object,
gtk_widget_set_halign (prop_edit, GTK_ALIGN_START);
gtk_widget_set_valign (prop_edit, GTK_ALIGN_CENTER);
}
+ else if (type == G_TYPE_PARAM_BOXED &&
+ G_PARAM_SPEC_VALUE_TYPE (spec) == PANGO_TYPE_ATTR_LIST)
+ {
+ prop_edit = gtk_entry_new ();
+
+ g_object_connect_property (object, spec,
+ G_CALLBACK (attr_list_changed),
+ prop_edit, G_OBJECT (prop_edit));
+
+ connect_controller (G_OBJECT (prop_edit), "changed",
+ object, spec, G_CALLBACK (attr_list_modified));
+ }
else if (type == GTK_TYPE_PARAM_SPEC_EXPRESSION)
{
GtkExpression *expression;