[gtk+] inspector: Show the buildable ID in the misc tab



commit d97fd540acd80fd553933a5450b71b1a42626c39
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Jul 24 08:29:12 2014 -0400

    inspector: Show the buildable ID in the misc tab
    
    This is useful, since you sometimes want to use it as #id in css.

 gtk/inspector/misc-info.c  |   18 +++++++++++++++++-
 gtk/inspector/misc-info.ui |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 1 deletions(-)
---
diff --git a/gtk/inspector/misc-info.c b/gtk/inspector/misc-info.c
index db4153f..8ef5314 100644
--- a/gtk/inspector/misc-info.c
+++ b/gtk/inspector/misc-info.c
@@ -24,6 +24,7 @@
 
 #include "gtktypebuiltins.h"
 #include "gtktreeview.h"
+#include "gtkbuildable.h"
 #include "gtklabel.h"
 #include "gtkframe.h"
 
@@ -34,6 +35,8 @@ struct _GtkInspectorMiscInfoPrivate {
 
   GtkWidget *state_row;
   GtkWidget *state;
+  GtkWidget *buildable_id_row;
+  GtkWidget *buildable_id;
   GtkWidget *default_widget_row;
   GtkWidget *default_widget;
   GtkWidget *default_widget_button;
@@ -211,7 +214,7 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
       sl->priv->object = NULL;
     }
 
-  if (!GTK_IS_WIDGET (object))
+  if (!GTK_IS_WIDGET (object) && !GTK_IS_BUILDABLE (object))
     {
       gtk_widget_hide (GTK_WIDGET (sl));
       return;
@@ -234,6 +237,17 @@ gtk_inspector_misc_info_set_object (GtkInspectorMiscInfo *sl,
       gtk_widget_hide (sl->priv->state_row);
     }
 
+  if (GTK_IS_BUILDABLE (object))
+    {
+      gtk_label_set_text (GTK_LABEL (sl->priv->buildable_id),
+                          gtk_buildable_get_name (GTK_BUILDABLE (object)));
+      gtk_widget_show (sl->priv->buildable_id_row);
+    }
+  else
+    {
+      gtk_widget_hide (sl->priv->buildable_id_row);
+    }
+
   if (GTK_IS_WINDOW (object))
     {
       gtk_widget_show (sl->priv->default_widget_row);
@@ -314,6 +328,8 @@ gtk_inspector_misc_info_class_init (GtkInspectorMiscInfoClass *klass)
   gtk_widget_class_set_template_from_resource (widget_class, "/org/gtk/inspector/misc-info.ui");
    gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, state_row);
    gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, state);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, buildable_id_row);
+   gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, buildable_id);
    gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, default_widget_row);
    gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, default_widget);
    gtk_widget_class_bind_template_child_private (widget_class, GtkInspectorMiscInfo, default_widget_button);
diff --git a/gtk/inspector/misc-info.ui b/gtk/inspector/misc-info.ui
index a32b4f1..c91e7ee 100644
--- a/gtk/inspector/misc-info.ui
+++ b/gtk/inspector/misc-info.ui
@@ -47,6 +47,40 @@
               </object>
             </child>
             <child>
+              <object class="GtkListBoxRow" id="buildable_id_row">
+                <property name="visible">True</property>
+                <property name="activatable">False</property>
+                <child>
+                  <object class="GtkBox">
+                    <property name="visible">True</property>
+                    <property name="orientation">horizontal</property>
+                    <property name="margin">10</property>
+                    <property name="spacing">40</property>
+                    <child>
+                      <object class="GtkLabel" id="buildable_id_label">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Buildable ID</property>
+                        <property name="halign">start</property>
+                        <property name="valign">baseline</property>
+                        <property name="xalign">0.0</property>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkLabel" id="buildable_id">
+                        <property name="visible">True</property>
+                        <property name="selectable">True</property>
+                        <property name="halign">end</property>
+                        <property name="valign">baseline</property>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+            <child>
               <object class="GtkListBoxRow" id="default_widget_row">
                 <property name="visible">True</property>
                 <property name="activatable">False</property>
@@ -140,6 +174,7 @@
     <property name="mode">horizontal</property>
     <widgets>
       <widget name="state_label"/>
+      <widget namel="buildable_id_label"/>
       <widget name="default_widget_label"/>
       <widget name="focus_widget_label"/>
     </widgets>


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