[gtk+/parasite2] inspector: Improve handling of object-valued properties



commit e7f7c3babada0eac86b99ead9ebc424a915c3626
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu May 8 01:26:17 2014 -0400

    inspector: Improve handling of object-valued properties
    
    When showing the objects in the tree, use the property name
    as the name thats shown in the list. This makes it easier
    to differentiate e.g. hadjustment and vadjustment in a
    GtkScrolledWindow.

 modules/inspector/property-cell-renderer.c |    2 +-
 modules/inspector/widget-tree.c            |   15 ++++++++-------
 modules/inspector/widget-tree.h            |    3 ++-
 3 files changed, 11 insertions(+), 9 deletions(-)
---
diff --git a/modules/inspector/property-cell-renderer.c b/modules/inspector/property-cell-renderer.c
index 10d9898..770554a 100644
--- a/modules/inspector/property-cell-renderer.c
+++ b/modules/inspector/property-cell-renderer.c
@@ -274,7 +274,7 @@ start_editing (GtkCellRenderer      *renderer,
             }
           else if (gtk_inspector_widget_tree_find_object (widget_tree, r->priv->object, &iter))
             {
-              gtk_inspector_widget_tree_append_object (widget_tree, prop_object, &iter);
+              gtk_inspector_widget_tree_append_object (widget_tree, prop_object, &iter, prop->name);
               gtk_inspector_widget_tree_select_object (widget_tree, prop_object);
             }
           else
diff --git a/modules/inspector/widget-tree.c b/modules/inspector/widget-tree.c
index 3dc585a..eda0c6e 100644
--- a/modules/inspector/widget-tree.c
+++ b/modules/inspector/widget-tree.c
@@ -74,7 +74,7 @@ gtk_inspector_widget_tree_init (GtkInspectorWidgetTree *wt)
                                            (GDestroyNotify) gtk_tree_iter_free);
   gtk_widget_init_template (GTK_WIDGET (wt));
 
-  gtk_inspector_widget_tree_append_object (wt, G_OBJECT (gtk_settings_get_default ()), NULL);
+  gtk_inspector_widget_tree_append_object (wt, G_OBJECT (gtk_settings_get_default ()), NULL, NULL);
 }
 
 static void
@@ -137,17 +137,17 @@ on_container_forall (GtkWidget *widget,
                      gpointer   data)
 {
   FindAllData *d = data;
-  gtk_inspector_widget_tree_append_object (d->wt, G_OBJECT (widget), d->iter);
+  gtk_inspector_widget_tree_append_object (d->wt, G_OBJECT (widget), d->iter, NULL);
 }
 
 void
 gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
                                          GObject                *object,
-                                         GtkTreeIter            *parent_iter)
+                                         GtkTreeIter            *parent_iter,
+                                         const gchar            *name)
 {
   GtkTreeIter iter;
   const gchar *class_name = G_OBJECT_CLASS_NAME (G_OBJECT_GET_CLASS (object));
-  const gchar *name = NULL;
   gchar *address;
   gboolean realized;
   gboolean mapped;
@@ -160,7 +160,8 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
   if (is_widget)
     {
       GtkWidget *widget = GTK_WIDGET (object);
-      name = gtk_widget_get_name (GTK_WIDGET (object));
+       if (name == NULL)
+         name = gtk_widget_get_name (GTK_WIDGET (object));
       realized = gtk_widget_get_realized  (widget);
       mapped = gtk_widget_get_mapped (widget);
       visible = gtk_widget_get_visible (widget);
@@ -212,8 +213,8 @@ gtk_inspector_widget_tree_scan (GtkInspectorWidgetTree *wt,
 {
   gtk_tree_store_clear (wt->priv->model);
   g_hash_table_remove_all (wt->priv->iters);
-  gtk_inspector_widget_tree_append_object (wt, G_OBJECT (gtk_settings_get_default ()), NULL);
-  gtk_inspector_widget_tree_append_object (wt, G_OBJECT (window), NULL);
+  gtk_inspector_widget_tree_append_object (wt, G_OBJECT (gtk_settings_get_default ()), NULL, NULL);
+  gtk_inspector_widget_tree_append_object (wt, G_OBJECT (window), NULL, NULL);
 
   gtk_tree_view_columns_autosize (GTK_TREE_VIEW (wt));
 }
diff --git a/modules/inspector/widget-tree.h b/modules/inspector/widget-tree.h
index d3616e2..5a880a6 100644
--- a/modules/inspector/widget-tree.h
+++ b/modules/inspector/widget-tree.h
@@ -65,7 +65,8 @@ void       gtk_inspector_widget_tree_select_object       (GtkInspectorWidgetTree
                                                           GObject                *object);
 void       gtk_inspector_widget_tree_append_object       (GtkInspectorWidgetTree *wt,
                                                           GObject                *object,
-                                                          GtkTreeIter            *parent_iter);
+                                                          GtkTreeIter            *parent_iter,
+                                                          const gchar            *name);
 gboolean   gtk_inspector_widget_tree_find_object         (GtkInspectorWidgetTree *wt,
                                                           GObject                *object,
                                                           GtkTreeIter            *iter);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]