[gtk+] inspector: Do a better job with readonly properties
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Do a better job with readonly properties
- Date: Thu, 10 Mar 2016 03:00:23 +0000 (UTC)
commit 6e9fd6832a69e36313a4385f37d0b72a3f032ee9
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Mar 9 21:42:08 2016 -0500
inspector: Do a better job with readonly properties
Say if they are non-writable or construct-only, and also
gray out construct-only properties in the list.
gtk/inspector/prop-editor.c | 14 ++++++++++++++
gtk/inspector/prop-list.c | 6 +++++-
2 files changed, 19 insertions(+), 1 deletions(-)
---
diff --git a/gtk/inspector/prop-editor.c b/gtk/inspector/prop-editor.c
index 1f1bca8..03debe0 100644
--- a/gtk/inspector/prop-editor.c
+++ b/gtk/inspector/prop-editor.c
@@ -1712,6 +1712,20 @@ constructed (GObject *object)
can_modify = ((spec->flags & G_PARAM_WRITABLE) != 0 &&
(spec->flags & G_PARAM_CONSTRUCT_ONLY) == 0);
+ if ((spec->flags & G_PARAM_CONSTRUCT_ONLY) != 0)
+ label = gtk_label_new ("(construct-only)");
+ else if ((spec->flags & G_PARAM_WRITABLE) == 0)
+ label = gtk_label_new ("(not writable)");
+ else
+ label = NULL;
+
+ if (label)
+ {
+ gtk_widget_show (label);
+ gtk_style_context_add_class (gtk_widget_get_style_context (label), GTK_STYLE_CLASS_DIM_LABEL);
+ gtk_container_add (GTK_CONTAINER (editor), label);
+ }
+
/* By reaching this, we already know the property is readable.
* Since all we can do for a GObject is dive down into it's properties
* and inspect bindings and such, pretend to be mutable.
diff --git a/gtk/inspector/prop-list.c b/gtk/inspector/prop-list.c
index c02ba56..e946444 100644
--- a/gtk/inspector/prop-list.c
+++ b/gtk/inspector/prop-list.c
@@ -412,6 +412,7 @@ gtk_inspector_prop_list_update_prop (GtkInspectorPropList *pl,
gchar *value;
gchar *type;
gchar *attribute = NULL;
+ gboolean writable;
g_value_init (&gvalue, prop->value_type);
if (pl->priv->child_properties)
@@ -447,13 +448,16 @@ gtk_inspector_prop_list_update_prop (GtkInspectorPropList *pl,
attribute = g_strdup_printf ("%d", column);
}
+ writable = ((prop->flags & G_PARAM_WRITABLE) != 0) &&
+ ((prop->flags & G_PARAM_CONSTRUCT_ONLY) == 0);
+
gtk_list_store_set (pl->priv->model, iter,
COLUMN_NAME, prop->name,
COLUMN_VALUE, value ? value : "",
COLUMN_TYPE, type ? type : "",
COLUMN_DEFINED_AT, g_type_name (prop->owner_type),
COLUMN_TOOLTIP, g_param_spec_get_blurb (prop),
- COLUMN_WRITABLE, (prop->flags & G_PARAM_WRITABLE) != 0,
+ COLUMN_WRITABLE, writable,
COLUMN_ATTRIBUTE, attribute ? attribute : "",
-1);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]