[gtk+] inspector: Minimal support for attributes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Minimal support for attributes
- Date: Sun, 11 May 2014 02:23:34 +0000 (UTC)
commit 86adead8037ba9d6369ff7a48268f42c3bf982d2
Author: Matthias Clasen <mclasen redhat com>
Date: Thu May 8 10:16:58 2014 -0400
inspector: Minimal support for attributes
Show mapping information for cell renderer properties; no editing
yet.
modules/inspector/prop-list.c | 44 ++++++++++++++++++++++++++++++--------
modules/inspector/prop-list.ui | 17 +++++++++++++++
modules/inspector/widget-tree.c | 5 +++-
3 files changed, 55 insertions(+), 11 deletions(-)
---
diff --git a/modules/inspector/prop-list.c b/modules/inspector/prop-list.c
index 6d10928..047ef0c 100644
--- a/modules/inspector/prop-list.c
+++ b/modules/inspector/prop-list.c
@@ -32,7 +32,8 @@ enum
COLUMN_DEFINED_AT,
COLUMN_OBJECT,
COLUMN_TOOLTIP,
- COLUMN_WRITABLE
+ COLUMN_WRITABLE,
+ COLUMN_ATTRIBUTE
};
enum
@@ -51,6 +52,7 @@ struct _GtkInspectorPropListPrivate
GtkWidget *widget_tree;
GtkCellRenderer *value_renderer;
gboolean child_properties;
+ GtkTreeViewColumn *attribute_column;
};
G_DEFINE_TYPE_WITH_PRIVATE (GtkInspectorPropList, gtk_inspector_prop_list, GTK_TYPE_TREE_VIEW)
@@ -85,9 +87,6 @@ get_property (GObject *object,
case PROP_CHILD_PROPERTIES:
g_value_set_boolean (value, pl->priv->child_properties);
- g_object_set (pl->priv->value_renderer,
- "is-child-property", pl->priv->child_properties,
- NULL);
break;
default:
@@ -113,6 +112,9 @@ set_property (GObject *object,
case PROP_CHILD_PROPERTIES:
pl->priv->child_properties = g_value_get_boolean (value);
+ g_object_set (pl->priv->value_renderer,
+ "is-child-property", pl->priv->child_properties,
+ NULL);
break;
default:
@@ -140,6 +142,7 @@ gtk_inspector_prop_list_class_init (GtkInspectorPropListClass *klass)
gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/prop-list.ui");
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorPropList, model);
gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorPropList, value_renderer);
+ gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorPropList, attribute_column);
}
static void
@@ -148,9 +151,10 @@ gtk_inspector_prop_list_update_prop (GtkInspectorPropList *pl,
GParamSpec *prop)
{
GValue gvalue = {0};
- gchar *value;
+ gchar *value = NULL;
+ gchar *attribute = NULL;
- g_value_init(&gvalue, prop->value_type);
+ g_value_init (&gvalue, prop->value_type);
if (pl->priv->child_properties)
{
GtkWidget *parent;
@@ -172,19 +176,36 @@ gtk_inspector_prop_list_update_prop (GtkInspectorPropList *pl,
}
else
{
- value = g_strdup_value_contents(&gvalue);
+ value = g_strdup_value_contents (&gvalue);
+ }
+
+ if (GTK_IS_CELL_RENDERER (pl->priv->object))
+ {
+ gpointer *area;
+ gint column = -1;
+
+ area = g_object_get_data (pl->priv->object, "gtk-inspector-cell-area");
+ if (area)
+ column = gtk_cell_area_attribute_get_column (GTK_CELL_AREA (area),
+ GTK_CELL_RENDERER (pl->priv->object),
+ prop->name);
+
+ if (column != -1)
+ attribute = g_strdup_printf ("%d", column);
}
gtk_list_store_set (pl->priv->model, iter,
COLUMN_NAME, prop->name,
- COLUMN_VALUE, value ? value : g_strdup (""),
+ COLUMN_VALUE, value ? value : "",
COLUMN_DEFINED_AT, g_type_name (prop->owner_type),
COLUMN_OBJECT, pl->priv->object,
COLUMN_TOOLTIP, g_param_spec_get_blurb (prop),
COLUMN_WRITABLE, (prop->flags & G_PARAM_WRITABLE) != 0,
+ COLUMN_ATTRIBUTE, attribute ? attribute : "",
-1);
g_free (value);
+ g_free (attribute);
g_value_unset (&gvalue);
}
@@ -280,12 +301,15 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
pl->priv->signal_cnxs =
g_list_prepend (pl->priv->signal_cnxs,
- GINT_TO_POINTER (g_signal_connect(object, signal_name,
- G_CALLBACK
(gtk_inspector_prop_list_prop_changed_cb), pl)));
+ GINT_TO_POINTER (g_signal_connect (object, signal_name,
+ G_CALLBACK
(gtk_inspector_prop_list_prop_changed_cb), pl)));
g_free (signal_name);
}
+ g_object_set (pl->priv->attribute_column,
+ "visible", !pl->priv->child_properties && GTK_IS_CELL_RENDERER (object),
+ NULL);
return TRUE;
}
diff --git a/modules/inspector/prop-list.ui b/modules/inspector/prop-list.ui
index ed92009..19dc006 100644
--- a/modules/inspector/prop-list.ui
+++ b/modules/inspector/prop-list.ui
@@ -8,6 +8,7 @@
<column type="GObject"/>
<column type="gchararray"/>
<column type="gboolean"/>
+ <column type="gchararray"/>
</columns>
</object>
<template class="GtkInspectorPropList" parent="GtkTreeView">
@@ -49,6 +50,22 @@
</object>
</child>
<child>
+ <object class="GtkTreeViewColumn" id="attribute_column">
+ <property name="title" translatable="yes">Attribute</property>
+ <property name="resizable">True</property>
+ <child>
+ <object class="GtkCellRendererText">
+ <property name="scale">0.8</property>
+ <property name="editable">False</property>
+ </object>
+ <attributes>
+ <attribute name="text">6</attribute>
+ <attribute name="sensitive">5</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
<object class="GtkTreeViewColumn">
<property name="title" translatable="yes">Defined At</property>
<child>
diff --git a/modules/inspector/widget-tree.c b/modules/inspector/widget-tree.c
index 84cbecd..f10085d 100644
--- a/modules/inspector/widget-tree.c
+++ b/modules/inspector/widget-tree.c
@@ -194,7 +194,7 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
-1);
g_hash_table_insert (wt->priv->iters, object, gtk_tree_iter_copy (&iter));
- g_free(address);
+ g_free (address);
if (GTK_IS_CONTAINER (object))
{
@@ -223,11 +223,14 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
{
GList *cells, *l;
GObject *cell;
+ GtkCellArea *area;
+ area = gtk_cell_layout_get_area (GTK_CELL_LAYOUT (object));
cells = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (object));
for (l = cells; l; l = l->next)
{
cell = l->data;
+ g_object_set_data (cell, "gtk-inspector-cell-area", area);
gtk_inspector_widget_tree_append_object (wt, cell, &iter, NULL);
}
g_list_free (cells);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]