forked from AuroraMiddleware/gtk
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.
This commit is contained in:
parent
a28e76f09c
commit
6e9fd6832a
@ -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.
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user