[gtk+] inspector: Hide tabs instead of making them insensitive



commit 965533740792caee059cdaa13655a10da4fb6734
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 9 23:57:57 2014 -0400

    inspector: Hide tabs instead of making them insensitive

 modules/inspector/classes-list.c |   13 ++++++++-----
 modules/inspector/classes-list.h |    4 ++--
 modules/inspector/css-editor.c   |   23 ++++++++++++++---------
 modules/inspector/css-editor.h   |    4 ++--
 modules/inspector/prop-list.c    |   31 +++++++++++++++++++++----------
 modules/inspector/signals-list.c |    2 --
 modules/inspector/window.c       |   17 +++--------------
 modules/inspector/window.ui      |    3 ---
 8 files changed, 50 insertions(+), 47 deletions(-)
---
diff --git a/modules/inspector/classes-list.c b/modules/inspector/classes-list.c
index cc5efbc..069881f 100644
--- a/modules/inspector/classes-list.c
+++ b/modules/inspector/classes-list.c
@@ -226,7 +226,7 @@ cleanup_context (GtkInspectorClassesList *cl)
 
   gtk_list_store_clear (cl->priv->model);
   cl->priv->context = NULL;
-  gtk_widget_set_sensitive (GTK_WIDGET (cl), FALSE);
+  gtk_widget_hide (GTK_WIDGET (cl));
 }
 
 static void
@@ -239,8 +239,8 @@ remove_dead_object (gpointer data, GObject *dead_object)
 }
 
 void
-gtk_inspector_classes_list_set_widget (GtkInspectorClassesList *cl,
-                                       GtkWidget               *widget)
+gtk_inspector_classes_list_set_object (GtkInspectorClassesList *cl,
+                                       GObject                 *object)
 {
   GHashTable *hash_context;
   GtkTreeIter tree_iter;
@@ -248,9 +248,12 @@ gtk_inspector_classes_list_set_widget (GtkInspectorClassesList *cl,
 
   cleanup_context (cl);
 
-  gtk_widget_set_sensitive (GTK_WIDGET (cl), TRUE);
+  if (!GTK_IS_WIDGET (object))
+    return;
 
-  cl->priv->context = gtk_widget_get_style_context (widget);
+  gtk_widget_show (GTK_WIDGET (cl));
+
+  cl->priv->context = gtk_widget_get_style_context (GTK_WIDGET (cl));
 
   g_object_weak_ref (G_OBJECT (cl->priv->context), remove_dead_object, cl);
 
diff --git a/modules/inspector/classes-list.h b/modules/inspector/classes-list.h
index 6dfc0db..9eaf39c 100644
--- a/modules/inspector/classes-list.h
+++ b/modules/inspector/classes-list.h
@@ -50,8 +50,8 @@ G_BEGIN_DECLS
 
 GType      gtk_inspector_classes_list_get_type   (void);
 GtkWidget *gtk_inspector_classes_list_new        (void);
-void       gtk_inspector_classes_list_set_widget (GtkInspectorClassesList *cl,
-                                                  GtkWidget               *widget);
+void       gtk_inspector_classes_list_set_object (GtkInspectorClassesList *cl,
+                                                  GObject                 *object);
 
 G_END_DECLS
 
diff --git a/modules/inspector/css-editor.c b/modules/inspector/css-editor.c
index d5a59b9..861ad54 100644
--- a/modules/inspector/css-editor.c
+++ b/modules/inspector/css-editor.c
@@ -226,7 +226,6 @@ constructed (GObject *object)
 {
   GtkInspectorCssEditor *ce = GTK_INSPECTOR_CSS_EDITOR (object);
 
-  gtk_widget_set_sensitive (GTK_WIDGET (ce), ce->priv->global);
   create_provider (ce);
   apply_system_font (ce);
   set_initial_text (ce);
@@ -309,12 +308,12 @@ remove_dead_object (gpointer data, GObject *dead_object)
   GtkInspectorCssEditor *ce = data;
 
   ce->priv->context = NULL;
-  gtk_widget_set_sensitive (GTK_WIDGET (ce), ce->priv->global);
+  gtk_widget_hide (GTK_WIDGET (ce));
 }
 
 void
-gtk_inspector_css_editor_set_widget (GtkInspectorCssEditor *ce,
-                                     GtkWidget             *widget)
+gtk_inspector_css_editor_set_object (GtkInspectorCssEditor *ce,
+                                     GObject               *object)
 {
   gchar *text;
   GtkCssProvider *provider;
@@ -322,19 +321,25 @@ gtk_inspector_css_editor_set_widget (GtkInspectorCssEditor *ce,
   g_return_if_fail (GTK_INSPECTOR_IS_CSS_EDITOR (ce));
   g_return_if_fail (!ce->priv->global);
 
-  gtk_widget_set_sensitive (GTK_WIDGET (ce), TRUE);
-
   if (ce->priv->context)
     {
       g_object_weak_unref (G_OBJECT (ce->priv->context), remove_dead_object, ce);
       text = get_current_text (GTK_TEXT_BUFFER (ce->priv->text));
       g_object_set_data_full (G_OBJECT (ce->priv->context),
                               GTK_INSPECTOR_CSS_EDITOR_TEXT,
-                              text,
-                              g_free);
+                              text, g_free);
+      ce->priv->context = NULL;
     }
 
-  ce->priv->context = gtk_widget_get_style_context (widget);
+  if (!GTK_IS_WIDGET (object))
+    {
+      gtk_widget_hide (GTK_WIDGET (ce));
+      return;
+    }
+
+  gtk_widget_show (GTK_WIDGET (ce));
+
+  ce->priv->context = gtk_widget_get_style_context (GTK_WIDGET (object));
 
   provider = g_object_get_data (G_OBJECT (ce->priv->context), GTK_INSPECTOR_CSS_EDITOR_PROVIDER);
   if (!provider)
diff --git a/modules/inspector/css-editor.h b/modules/inspector/css-editor.h
index 08ee4e0..bd8eb76 100644
--- a/modules/inspector/css-editor.h
+++ b/modules/inspector/css-editor.h
@@ -50,8 +50,8 @@ G_BEGIN_DECLS
 
 GType      gtk_inspector_css_editor_get_type   (void);
 GtkWidget *gtk_inspector_css_editor_new        (gboolean               global);
-void       gtk_inspector_css_editor_set_widget (GtkInspectorCssEditor *ce,
-                                                GtkWidget             *widget);
+void       gtk_inspector_css_editor_set_object (GtkInspectorCssEditor *ce,
+                                                GObject               *object);
 
 G_END_DECLS
 
diff --git a/modules/inspector/prop-list.c b/modules/inspector/prop-list.c
index 68d5074..f9eda27 100644
--- a/modules/inspector/prop-list.c
+++ b/modules/inspector/prop-list.c
@@ -239,8 +239,6 @@ static void remove_dead_object (gpointer data, GObject *dead_object);
 static void
 cleanup_object (GtkInspectorPropList *pl)
 {
-  gtk_widget_set_sensitive (GTK_WIDGET (pl), FALSE);
-
   if (pl->priv->object)
     g_object_weak_unref (pl->priv->object, remove_dead_object, pl);
 
@@ -282,29 +280,41 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
 
   pl->priv->object = object;
 
-  g_object_weak_ref (object, remove_dead_object, pl);
+  if (!object)
+    {
+      gtk_widget_hide (GTK_WIDGET (pl));
+      return TRUE;
+    }
 
-  g_object_set (pl->priv->attribute_column,
-                "visible", !pl->priv->child_properties && GTK_IS_CELL_RENDERER (object),
-                NULL);
+  g_object_weak_ref (object, remove_dead_object, pl);
 
   if (pl->priv->child_properties)
     {
       GtkWidget *parent;
 
       if (!GTK_IS_WIDGET (object))
-        return TRUE;
+        {
+          gtk_widget_hide (GTK_WIDGET (pl));
+          return TRUE;
+        }
 
       parent = gtk_widget_get_parent (GTK_WIDGET (object));
       if (!parent)
-        return TRUE;
+        {
+          gtk_widget_hide (GTK_WIDGET (pl));
+          return TRUE;
+        }
+
+      gtk_tree_view_column_set_visible (pl->priv->attribute_column, FALSE);
 
       props = gtk_container_class_list_child_properties (G_OBJECT_GET_CLASS (parent), &num_properties);
     }
   else
-    props = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), &num_properties);
+    {
+      gtk_tree_view_column_set_visible (pl->priv->attribute_column, GTK_IS_CELL_RENDERER (object));
 
-  gtk_widget_set_sensitive (GTK_WIDGET (pl), TRUE);
+      props = g_object_class_list_properties (G_OBJECT_GET_CLASS (object), &num_properties);
+    }
 
   for (i = 0; i < num_properties; i++)
     {
@@ -326,6 +336,7 @@ gtk_inspector_prop_list_set_object (GtkInspectorPropList *pl,
                         G_CALLBACK (gtk_inspector_prop_list_prop_changed_cb),
                         pl);
 
+  gtk_widget_show (GTK_WIDGET (pl));
   return TRUE;
 }
 
diff --git a/modules/inspector/signals-list.c b/modules/inspector/signals-list.c
index f511e2a..276b4e6 100644
--- a/modules/inspector/signals-list.c
+++ b/modules/inspector/signals-list.c
@@ -121,8 +121,6 @@ gtk_inspector_signals_list_set_object (GtkInspectorSignalsList *sl,
 {
   gtk_list_store_clear (sl->priv->model);
 
-  gtk_widget_set_sensitive (GTK_WIDGET (sl), TRUE);
-
   read_signals_from_object (sl, object);
 }
 
diff --git a/modules/inspector/window.c b/modules/inspector/window.c
index 499129f..d93d204 100644
--- a/modules/inspector/window.c
+++ b/modules/inspector/window.c
@@ -76,22 +76,11 @@ on_widget_tree_selection_changed (GtkInspectorWidgetTree *wt,
       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);
+      gtk_inspector_classes_list_set_object (GTK_INSPECTOR_CLASSES_LIST (iw->classes_list), selected);
+      gtk_inspector_css_editor_set_object (GTK_INSPECTOR_CSS_EDITOR (iw->widget_css_editor), selected);
 
       if (GTK_IS_WIDGET (selected))
-        {
-          GtkWidget *widget = GTK_WIDGET (selected);
-
-          gtk_inspector_flash_widget (iw, 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_visible (iw->classes_list, FALSE);
-          gtk_widget_set_visible (iw->widget_css_editor, FALSE);
-        }
+        gtk_inspector_flash_widget (iw, GTK_WIDGET (selected));
     }
 }
 
diff --git a/modules/inspector/window.ui b/modules/inspector/window.ui
index c78faa6..75044c2 100644
--- a/modules/inspector/window.ui
+++ b/modules/inspector/window.ui
@@ -154,7 +154,6 @@
                     </child> 
                     <child>
                       <object class="GtkInspectorPropList" id="child_prop_list">
-                        <property name="visible">True</property>
                         <property name="child-properties">True</property>
                         <property name="widget-tree">widget_tree</property>
                       </object>
@@ -167,7 +166,6 @@
                     </child> 
                     <child>
                       <object class="GtkInspectorClassesList" id="classes_list">
-                        <property name="visible">True</property>
                       </object>
                     </child>
                     <child type="tab">
@@ -178,7 +176,6 @@
                     </child> 
                     <child>
                       <object class="GtkInspectorCssEditor" id="widget_css_editor">
-                        <property name="visible">True</property>
                         <property name="global">False</property>
                       </object>
                     </child>


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