[gtk+] inspector: Add a Label column



commit e9cc8590517381cfc90c7f25d7afbbc95c3f1400
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu May 8 21:15:09 2014 -0400

    inspector: Add a Label column
    
    Move the UI strings over to that column, and use the buildable
    ID for the name column, where available.

 modules/inspector/widget-tree.c  |   30 +++++++++++++++++++++---------
 modules/inspector/widget-tree.ui |   24 ++++++++++++++++++++----
 2 files changed, 41 insertions(+), 13 deletions(-)
---
diff --git a/modules/inspector/widget-tree.c b/modules/inspector/widget-tree.c
index df81096..165339a 100644
--- a/modules/inspector/widget-tree.c
+++ b/modules/inspector/widget-tree.c
@@ -31,6 +31,7 @@ enum
   OBJECT,
   OBJECT_TYPE,
   OBJECT_NAME,
+  OBJECT_LABEL,
   OBJECT_ADDRESS,
   SENSITIVE
 };
@@ -75,7 +76,7 @@ object_data_free (gpointer data)
 
   gtk_tree_iter_free (od->iter);
 
-  if (od->map_handler)
+  if (g_signal_handler_is_connected (od->object, od->map_handler))
     {
       g_signal_handler_disconnect (od->object, od->map_handler);
       g_signal_handler_disconnect (od->object, od->unmap_handler);
@@ -184,7 +185,9 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
   gchar *address;
   gboolean mapped;
   ObjectData *od;
+  const gchar *label;
 
+  label = NULL;
   mapped = FALSE;
 
   if (GTK_IS_WIDGET (object))
@@ -197,16 +200,24 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
 
   if (name == NULL || g_strcmp0 (name, class_name) == 0)
     {
-      if (GTK_IS_LABEL (object))
-        name = gtk_label_get_text (GTK_LABEL (object));
-      else if (GTK_IS_BUTTON (object))
-        name = gtk_button_get_label (GTK_BUTTON (object));
-      else if (GTK_IS_WINDOW (object))
-        name = gtk_window_get_title (GTK_WINDOW (object));
-      else
-        name = "";
+      if (GTK_IS_BUILDABLE (object))
+        name = gtk_buildable_get_name (GTK_BUILDABLE (object));
     }
 
+  if (name == NULL)
+    name = "";
+
+  if (GTK_IS_LABEL (object))
+    label = gtk_label_get_text (GTK_LABEL (object));
+  else if (GTK_IS_BUTTON (object))
+    label = gtk_button_get_label (GTK_BUTTON (object));
+  else if (GTK_IS_WINDOW (object))
+    label = gtk_window_get_title (GTK_WINDOW (object));
+  else if (GTK_IS_TREE_VIEW_COLUMN (object))
+    label = gtk_tree_view_column_get_title (GTK_TREE_VIEW_COLUMN (object));
+  else
+    label = "";
+
   address = g_strdup_printf ("%p", object);
 
   gtk_tree_store_append (wt->priv->model, &iter, parent_iter);
@@ -214,6 +225,7 @@ gtk_inspector_widget_tree_append_object (GtkInspectorWidgetTree *wt,
                       OBJECT, object,
                       OBJECT_TYPE, class_name,
                       OBJECT_NAME, name,
+                      OBJECT_LABEL, label,
                       OBJECT_ADDRESS, address,
                       SENSITIVE, !GTK_IS_WIDGET (object) || mapped,
                       -1);
diff --git a/modules/inspector/widget-tree.ui b/modules/inspector/widget-tree.ui
index 5b94e00..7451884 100644
--- a/modules/inspector/widget-tree.ui
+++ b/modules/inspector/widget-tree.ui
@@ -6,6 +6,7 @@
       <column type="gchararray"/>
       <column type="gchararray"/>
       <column type="gchararray"/>
+      <column type="gchararray"/>
       <column type="gboolean"/>
     </columns>
   </object>
@@ -28,7 +29,7 @@
           </object>
           <attributes>
             <attribute name="text">1</attribute>
-            <attribute name="sensitive">4</attribute>
+            <attribute name="sensitive">5</attribute>
           </attributes>
         </child>
       </object>
@@ -43,7 +44,22 @@
           </object>
           <attributes>
             <attribute name="text">2</attribute>
-            <attribute name="sensitive">4</attribute>
+            <attribute name="sensitive">5</attribute>
+          </attributes>
+        </child>
+      </object>
+    </child>
+    <child>
+      <object class="GtkTreeViewColumn">
+        <property name="title" translatable="yes">Label</property>
+        <property name="resizable">True</property>
+        <child>
+          <object class="GtkCellRendererText">
+            <property name="scale">0.8</property>
+          </object>
+          <attributes>
+            <attribute name="text">3</attribute>
+            <attribute name="sensitive">5</attribute>
           </attributes>
         </child>
       </object>
@@ -58,8 +74,8 @@
             <property name="family">monospace</property>
           </object>
           <attributes>
-            <attribute name="text">3</attribute>
-            <attribute name="sensitive">4</attribute>
+            <attribute name="text">4</attribute>
+            <attribute name="sensitive">5</attribute>
           </attributes>
         </child>
       </object>


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