[gtk+/parasite2] inspector: Avoid size changes of button path



commit 8cbd158a5de723de123138fb0aa8961b056964f0
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 9 23:57:38 2014 -0400

    inspector: Avoid size changes of button path

 modules/inspector/button-path.c  |   35 +++++++++++++++++-------------
 modules/inspector/button-path.h  |    4 +-
 modules/inspector/button-path.ui |   44 +++++++++++++++++++++++++++----------
 modules/inspector/window.c       |    8 ++++--
 4 files changed, 59 insertions(+), 32 deletions(-)
---
diff --git a/modules/inspector/button-path.c b/modules/inspector/button-path.c
index 339d4a1..6019143 100644
--- a/modules/inspector/button-path.c
+++ b/modules/inspector/button-path.c
@@ -54,28 +54,33 @@ gtk_inspector_button_path_new (void)
 }
 
 void
-gtk_inspector_button_path_set_widget (GtkInspectorButtonPath *bp,
-                                      GtkWidget          *widget)
+gtk_inspector_button_path_set_object (GtkInspectorButtonPath *bp,
+                                      GObject                *object)
 {
-  gchar *path, **words;
-  gint i;
-  GtkWidget *b;
   GtkContainer *box = GTK_CONTAINER (bp->priv->button_box);
+  GtkWidget *b;
 
   gtk_container_foreach (box, (GtkCallback)gtk_widget_destroy, NULL);
 
-  path = gtk_widget_path_to_string (gtk_widget_get_path (widget));
-  words = g_strsplit (path, " ", 0);
-
-  for (i = 0; i < g_strv_length (words); i++)
+  if (GTK_IS_WIDGET (object))
     {
-      b = gtk_button_new_with_label (words[i]);
-      gtk_widget_show (b);
-      gtk_container_add (box, b);
-    }
+      GtkWidget *widget = GTK_WIDGET (object);
+      gchar *path, **words;
+      gint i;
 
-  g_strfreev (words);
-  g_free (path);
+      path = gtk_widget_path_to_string (gtk_widget_get_path (widget));
+      words = g_strsplit (path, " ", 0);
+
+      for (i = 0; i < g_strv_length (words); i++)
+        {
+          b = gtk_button_new_with_label (words[i]);
+          gtk_widget_show (b);
+          gtk_container_add (box, b);
+        }
+
+      g_strfreev (words);
+      g_free (path);
+    }
 }
 
 // vim: set et sw=2 ts=2:
diff --git a/modules/inspector/button-path.h b/modules/inspector/button-path.h
index 32f3d93..6ee59b3 100644
--- a/modules/inspector/button-path.h
+++ b/modules/inspector/button-path.h
@@ -51,8 +51,8 @@ G_BEGIN_DECLS
 
 GType      gtk_inspector_button_path_get_type   (void);
 GtkWidget *gtk_inspector_button_path_new        (void);
-void       gtk_inspector_button_path_set_widget (GtkInspectorButtonPath *bp,
-                                                 GtkWidget              *widget);
+void       gtk_inspector_button_path_set_object (GtkInspectorButtonPath *bp,
+                                                 GObject                *object);
 
 G_END_DECLS
 
diff --git a/modules/inspector/button-path.ui b/modules/inspector/button-path.ui
index b586f41..5f832f7 100644
--- a/modules/inspector/button-path.ui
+++ b/modules/inspector/button-path.ui
@@ -9,22 +9,34 @@
         <property name="vscrollbar-policy">never</property>
         <property name="hexpand">True</property>
         <child>
-          <object class="GtkButtonBox" id="button_box">
-            <property name="visible">True</property>
+          <object class="GtkBox">
             <property name="orientation">horizontal</property>
-            <property name="hexpand">True</property>
-            <property name="margin">6</property>
-            <property name="spacing">0</property>
-            <property name="layout-style">start</property>
-            <style>
-              <class name="linked"/>
-            </style>
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkButton" id="placeholder">
+                <property name="margin">6</property>
+                <property name="label">X</property>
+              </object>
+            </child>
             <child>
-              <object class="GtkLabel">
+              <object class="GtkButtonBox" id="button_box">
+                <property name="orientation">horizontal</property>
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">Choose a widget through the inspector</property>
                 <property name="hexpand">True</property>
-                <property name="xalign">0.5</property>
+                <property name="margin">6</property>
+                <property name="spacing">0</property>
+                <property name="layout-style">start</property>
+                <style>
+                  <class name="linked"/>
+                </style>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Choose a widget through the 
inspector</property>
+                    <property name="hexpand">True</property>
+                    <property name="xalign">0.5</property>
+                  </object>
+                </child>
               </object>
             </child>
           </object>
@@ -32,4 +44,12 @@
       </object>
     </child>
   </template>
+  <object class="GtkSizeGroup">
+    <property name="mode">vertical</property>
+    <property name="ignore-hidden">False</property>
+    <widgets>
+      <widget name="placeholder"/>
+      <widget name="button_box"/>
+    </widgets>
+  </object>
 </interface>
diff --git a/modules/inspector/window.c b/modules/inspector/window.c
index 04790b2..499129f 100644
--- a/modules/inspector/window.c
+++ b/modules/inspector/window.c
@@ -75,20 +75,22 @@ on_widget_tree_selection_changed (GtkInspectorWidgetTree *wt,
       gtk_inspector_prop_list_set_object (GTK_INSPECTOR_PROP_LIST (iw->child_prop_list), selected);
       gtk_inspector_signals_list_set_object (GTK_INSPECTOR_SIGNALS_LIST (iw->signals_list), selected);
       gtk_inspector_object_hierarchy_set_object (GTK_INSPECTOR_OBJECT_HIERARCHY (iw->object_hierarchy), 
selected);
+      gtk_inspector_button_path_set_object (GTK_INSPECTOR_BUTTON_PATH (iw->button_path), selected);
 
       if (GTK_IS_WIDGET (selected))
         {
           GtkWidget *widget = GTK_WIDGET (selected);
 
           gtk_inspector_flash_widget (iw, widget);
-          gtk_inspector_button_path_set_widget (GTK_INSPECTOR_BUTTON_PATH (iw->button_path), widget);
           gtk_inspector_classes_list_set_widget (GTK_INSPECTOR_CLASSES_LIST (iw->classes_list), widget);
           gtk_inspector_css_editor_set_widget (GTK_INSPECTOR_CSS_EDITOR (iw->widget_css_editor), widget);
+          gtk_widget_set_visible (iw->classes_list, TRUE);
+          gtk_widget_set_visible (iw->widget_css_editor, TRUE);
         }
       else
         {
-          gtk_widget_set_sensitive (iw->classes_list, FALSE);
-          gtk_widget_set_sensitive (iw->widget_css_editor, FALSE);
+          gtk_widget_set_visible (iw->classes_list, FALSE);
+          gtk_widget_set_visible (iw->widget_css_editor, FALSE);
         }
     }
 }


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