[gtk/inspector-tweaks: 5/7] inspector: Redo the object page switcher



commit 5371055495440ca6e91587c5b5c8b47c4951b7f8
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Apr 2 23:07:51 2019 +0000

    inspector: Redo the object page switcher
    
    The combobox for page switching was not very good.
    Instead, do a sidebar that can be hidden.

 gtk/inspector/gtkstackcombo.c | 280 ------------------------------------------
 gtk/inspector/gtkstackcombo.h |  46 -------
 gtk/inspector/init.c          |   2 -
 gtk/inspector/meson.build     |   1 -
 gtk/inspector/window.c        |  19 +++
 gtk/inspector/window.h        |   1 +
 gtk/inspector/window.ui       | 277 ++++++++++++++++++++++-------------------
 7 files changed, 169 insertions(+), 457 deletions(-)
---
diff --git a/gtk/inspector/init.c b/gtk/inspector/init.c
index 51360e7c1c..6c9230fca5 100644
--- a/gtk/inspector/init.c
+++ b/gtk/inspector/init.c
@@ -44,7 +44,6 @@
 #include "statistics.h"
 #include "visual.h"
 #include "window.h"
-#include "gtkstackcombo.h"
 
 #include "gtkmagnifierprivate.h"
 
@@ -78,7 +77,6 @@ gtk_inspector_init (void)
   g_type_ensure (GTK_TYPE_INSPECTOR_STATISTICS);
   g_type_ensure (GTK_TYPE_INSPECTOR_VISUAL);
   g_type_ensure (GTK_TYPE_INSPECTOR_WINDOW);
-  g_type_ensure (GTK_TYPE_STACK_COMBO);
 
   if (extension_point == NULL)
     {
diff --git a/gtk/inspector/meson.build b/gtk/inspector/meson.build
index e0b740783a..b67da21bd4 100644
--- a/gtk/inspector/meson.build
+++ b/gtk/inspector/meson.build
@@ -9,7 +9,6 @@ inspector_sources = files(
   'fpsoverlay.c',
   'general.c',
   'graphdata.c',
-  'gtkstackcombo.c',
   'gtktreemodelcssnode.c',
   'highlightoverlay.c',
   'init.c',
diff --git a/gtk/inspector/window.c b/gtk/inspector/window.c
index 8e012a3d96..2fae04950c 100644
--- a/gtk/inspector/window.c
+++ b/gtk/inspector/window.c
@@ -52,6 +52,7 @@
 #include "gtkstack.h"
 #include "gtktreeviewcolumn.h"
 #include "gtkwindowgroup.h"
+#include "gtkrevealer.h"
 
 G_DEFINE_TYPE (GtkInspectorWindow, gtk_inspector_window, GTK_TYPE_WINDOW)
 
@@ -267,6 +268,22 @@ object_details_changed (GtkWidget          *combo,
   gtk_stack_set_visible_child_name (GTK_STACK (iw->object_center_stack), "title");
 }
 
+static void
+toggle_sidebar (GtkWidget          *button,
+                GtkInspectorWindow *iw)
+{
+  if (gtk_revealer_get_child_revealed (GTK_REVEALER (iw->sidebar_revealer)))
+    {
+      gtk_revealer_set_reveal_child (GTK_REVEALER (iw->sidebar_revealer), FALSE);
+      gtk_button_set_icon_name (GTK_BUTTON (button), "go-next-symbolic");
+    }
+  else
+    {
+      gtk_revealer_set_reveal_child (GTK_REVEALER (iw->sidebar_revealer), TRUE);
+      gtk_button_set_icon_name (GTK_BUTTON (button), "go-previous-symbolic");
+    }
+}
+
 static void
 gtk_inspector_window_realize (GtkWidget *widget)
 {
@@ -322,6 +339,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, misc_info);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, controllers);
   gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, magnifier);
+  gtk_widget_class_bind_template_child (widget_class, GtkInspectorWindow, sidebar_revealer);
 
   gtk_widget_class_bind_template_callback (widget_class, gtk_inspector_on_inspect);
   gtk_widget_class_bind_template_callback (widget_class, on_object_activated);
@@ -330,6 +348,7 @@ gtk_inspector_window_class_init (GtkInspectorWindowClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, close_object_details);
   gtk_widget_class_bind_template_callback (widget_class, object_details_changed);
   gtk_widget_class_bind_template_callback (widget_class, notify_node);
+  gtk_widget_class_bind_template_callback (widget_class, toggle_sidebar);
 }
 
 static GdkDisplay *
diff --git a/gtk/inspector/window.h b/gtk/inspector/window.h
index 6e3c5f6647..a6dafde9e4 100644
--- a/gtk/inspector/window.h
+++ b/gtk/inspector/window.h
@@ -71,6 +71,7 @@ typedef struct
   GtkWidget *misc_info;
   GtkWidget *controllers;
   GtkWidget *magnifier;
+  GtkWidget *sidebar_revealer;
 
   GtkWidget *selected_widget;
 
diff --git a/gtk/inspector/window.ui b/gtk/inspector/window.ui
index a63a265ed1..8f20480b97 100644
--- a/gtk/inspector/window.ui
+++ b/gtk/inspector/window.ui
@@ -1,3 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
 <interface domain="gtk40">
   <object class="GtkAdjustment" id="magnification_adjustment">
     <property name="lower">1.0</property>
@@ -207,43 +208,89 @@
                     <property name="name">object-details</property>
                     <property name="child">
                       <object class="GtkBox">
-                        <property name="orientation">vertical</property>
                         <child>
-                          <object class="GtkCenterBox">
-                            <child type="start">
-                              <object class="GtkBox">
-                                <property name="spacing">10</property>
-                                <child>
-                                  <object class="GtkStackCombo" id="stackcombo">
-                                    <property name="margin">6</property>
-                                    <property name="stack">object_details</property>
+                          <object class="GtkRevealer" id="sidebar_revealer">
+                            <property name="transition-type">slide-right</property>
+                            <property name="reveal-child">1</property>
+                            <child>
+                              <object class="GtkStackSidebar">
+                                <property name="stack">object_details</property>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
+                          <object class="GtkBox">
+                            <property name="orientation">vertical</property>
+                            <child>
+                              <object class="GtkCenterBox">
+                                <child type="start">
+                                  <object class="GtkBox">
+                                    <property name="spacing">10</property>
+                                    <child>
+                                      <object class="GtkButton">
+                                        <property name="icon-name">go-previous-symbolic</property>
+                                        <property name="tooltip-text" translatable="yes">Toggle 
Sidebar</property>
+                                        <property name="relief">none</property>
+                                        <property name="margin-start">6</property>
+                                        <property name="halign">center</property>
+                                        <property name="valign">center</property>
+                                        <signal name="clicked" handler="toggle_sidebar"/>
+                                      </object>
+                                    </child>
+                                    <child>
+                                      <object class="GtkStack" id="object_start_stack">
+                                        <child>
+                                          <object class="GtkStackPage">
+                                            <property name="name">empty</property>
+                                            <property name="child">
+                                              <object class="GtkBox"/>
+                                            </property>
+                                          </object>
+                                        </child>
+                                        <child>
+                                          <object class="GtkStackPage">
+                                            <property name="name">magnifier</property>
+                                            <property name="child">
+                                              <object class="GtkScale">
+                                                <property name="width-request">150</property>
+                                                <property name="draw-value">0</property>
+                                                <property 
name="adjustment">magnification_adjustment</property>
+                                                <marks>
+                                                  <mark value="1.0" position="bottom"/>
+                                                  <mark value="2.0" position="bottom"/>
+                                                  <mark value="3.0" position="bottom"/>
+                                                  <mark value="4.0" position="bottom"/>
+                                                  <mark value="5.0" position="bottom"/>
+                                                </marks>
+                                              </object>
+                                            </property>
+                                          </object>
+                                        </child>
+                                      </object>
+                                    </child>
                                   </object>
                                 </child>
-                                <child>
-                                  <object class="GtkStack" id="object_start_stack">
+                                <child type="center">
+                                  <object class="GtkStack" id="object_center_stack">
+                                    <property name="transition-type">crossfade</property>
+                                    <property name="hexpand">1</property>
+                                    <property name="halign">center</property>
                                     <child>
                                       <object class="GtkStackPage">
-                                        <property name="name">empty</property>
+                                        <property name="name">title</property>
                                         <property name="child">
-                                          <object class="GtkBox"/>
+                                          <object class="GtkLabel" id="object_title"/>
                                         </property>
                                       </object>
                                     </child>
                                     <child>
                                       <object class="GtkStackPage">
-                                        <property name="name">magnifier</property>
+                                        <property name="name">prop-search</property>
                                         <property name="child">
-                                          <object class="GtkScale">
-                                            <property name="width-request">150</property>
-                                            <property name="draw-value">0</property>
-                                            <property name="adjustment">magnification_adjustment</property>
-                                            <marks>
-                                              <mark value="1.0" position="bottom"/>
-                                              <mark value="2.0" position="bottom"/>
-                                              <mark value="3.0" position="bottom"/>
-                                              <mark value="4.0" position="bottom"/>
-                                              <mark value="5.0" position="bottom"/>
-                                            </marks>
+                                          <object class="GtkSearchEntry" id="prop_search_entry">
+                                            <property name="margin">6</property>
+                                            <property name="max-width-chars">40</property>
                                           </object>
                                         </property>
                                       </object>
@@ -252,127 +299,101 @@
                                 </child>
                               </object>
                             </child>
-                            <child type="center">
-                              <object class="GtkStack" id="object_center_stack">
-                                <property name="transition-type">crossfade</property>
-                                <property name="hexpand">1</property>
-                                <property name="halign">center</property>
+                            <child>
+                              <object class="GtkStack" id="object_details">
+                                <signal name="notify::visible-child" handler="object_details_changed"/>
                                 <child>
                                   <object class="GtkStackPage">
-                                    <property name="name">title</property>
+                                    <property name="name">misc</property>
+                                    <property name="title" translatable="yes">Miscellaneous</property>
                                     <property name="child">
-                                      <object class="GtkLabel" id="object_title"/>
+                                      <object class="GtkInspectorMiscInfo" id="misc_info">
+                                        <property name="object-tree">object_tree</property>
+                                      </object>
                                     </property>
                                   </object>
                                 </child>
                                 <child>
                                   <object class="GtkStackPage">
-                                    <property name="name">prop-search</property>
+                                    <property name="name">properties</property>
+                                    <property name="title" translatable="yes">Properties</property>
                                     <property name="child">
-                                      <object class="GtkSearchEntry" id="prop_search_entry">
-                                        <property name="margin">6</property>
-                                        <property name="max-width-chars">40</property>
+                                      <object class="GtkInspectorPropList" id="prop_list">
+                                        <property name="object-tree">object_tree</property>
+                                        <property name="search-entry">prop_search_entry</property>
                                       </object>
                                     </property>
                                   </object>
                                 </child>
-                              </object>
-                            </child>
-                          </object>
-                        </child>
-                        <child>
-                          <object class="GtkStack" id="object_details">
-                            <signal name="notify::visible-child" handler="object_details_changed"/>
-                            <child>
-                              <object class="GtkStackPage">
-                                <property name="name">misc</property>
-                                <property name="title" translatable="yes">Miscellaneous</property>
-                                <property name="child">
-                                  <object class="GtkInspectorMiscInfo" id="misc_info">
-                                    <property name="object-tree">object_tree</property>
+                                <child>
+                                  <object class="GtkStackPage">
+                                    <property name="name">css-nodes</property>
+                                    <property name="title" translatable="yes">CSS Nodes</property>
+                                    <property name="child">
+                                      <object class="GtkInspectorCssNodeTree" id="widget_css_node_tree">
+                                        <signal name="notify::node" handler="notify_node"/>
+                                      </object>
+                                    </property>
                                   </object>
-                                </property>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="GtkStackPage">
-                                <property name="name">properties</property>
-                                <property name="title" translatable="yes">Properties</property>
-                                <property name="child">
-                                  <object class="GtkInspectorPropList" id="prop_list">
-                                    <property name="object-tree">object_tree</property>
-                                    <property name="search-entry">prop_search_entry</property>
+                                </child>
+                                <child>
+                                  <object class="GtkStackPage">
+                                    <property name="name">size-groups</property>
+                                    <property name="title" translatable="yes">Size Groups</property>
+                                    <property name="child">
+                                      <object class="GtkInspectorSizeGroups" id="size_groups"/>
+                                    </property>
                                   </object>
-                                </property>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="GtkStackPage">
-                                <property name="name">css-nodes</property>
-                                <property name="title" translatable="yes">CSS Nodes</property>
-                                <property name="child">
-                                  <object class="GtkInspectorCssNodeTree" id="widget_css_node_tree">
-                                    <signal name="notify::node" handler="notify_node"/>
+                                </child>
+                                <child>
+                                  <object class="GtkStackPage">
+                                    <property name="name">data</property>
+                                    <property name="title" translatable="yes">Data</property>
+                                    <property name="child">
+                                      <object class="GtkInspectorDataList" id="data_list"/>
+                                    </property>
                                   </object>
-                                </property>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="GtkStackPage">
-                                <property name="name">size-groups</property>
-                                <property name="title" translatable="yes">Size Groups</property>
-                                <property name="child">
-                                  <object class="GtkInspectorSizeGroups" id="size_groups"/>
-                                </property>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="GtkStackPage">
-                                <property name="name">data</property>
-                                <property name="title" translatable="yes">Data</property>
-                                <property name="child">
-                                  <object class="GtkInspectorDataList" id="data_list"/>
-                                </property>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="GtkStackPage">
-                                <property name="name">actions</property>
-                                <property name="title" translatable="yes">Actions</property>
-                                <property name="child">
-                                  <object class="GtkInspectorActions" id="actions"/>
-                                </property>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="GtkStackPage">
-                                <property name="name">menu</property>
-                                <property name="title" translatable="yes">Menu</property>
-                                <property name="child">
-                                  <object class="GtkInspectorMenu" id="menu"/>
-                                </property>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="GtkStackPage">
-                                <property name="name">controllers</property>
-                                <property name="title" translatable="yes">Controllers</property>
-                                <property name="child">
-                                  <object class="GtkInspectorControllers" id="controllers">
-                                    <property name="object-tree">object_tree</property>
+                                </child>
+                                <child>
+                                  <object class="GtkStackPage">
+                                    <property name="name">actions</property>
+                                    <property name="title" translatable="yes">Actions</property>
+                                    <property name="child">
+                                      <object class="GtkInspectorActions" id="actions"/>
+                                    </property>
                                   </object>
-                                </property>
-                              </object>
-                            </child>
-                            <child>
-                              <object class="GtkStackPage">
-                                <property name="name">magnifier</property>
-                                <property name="title" translatable="yes">Magnifier</property>
-                                <property name="child">
-                                  <object class="GtkInspectorMagnifier" id="magnifier">
-                                    <property name="adjustment">magnification_adjustment</property>
+                                </child>
+                                <child>
+                                  <object class="GtkStackPage">
+                                    <property name="name">menu</property>
+                                    <property name="title" translatable="yes">Menu</property>
+                                    <property name="child">
+                                      <object class="GtkInspectorMenu" id="menu"/>
+                                    </property>
                                   </object>
-                                </property>
+                                </child>
+                                <child>
+                                  <object class="GtkStackPage">
+                                    <property name="name">controllers</property>
+                                    <property name="title" translatable="yes">Controllers</property>
+                                    <property name="child">
+                                      <object class="GtkInspectorControllers" id="controllers">
+                                        <property name="object-tree">object_tree</property>
+                                      </object>
+                                    </property>
+                                  </object>
+                                </child>
+                                <child>
+                                  <object class="GtkStackPage">
+                                    <property name="name">magnifier</property>
+                                    <property name="title" translatable="yes">Magnifier</property>
+                                    <property name="child">
+                                      <object class="GtkInspectorMagnifier" id="magnifier">
+                                        <property name="adjustment">magnification_adjustment</property>
+                                      </object>
+                                    </property>
+                                  </object>
+                                </child>
                               </object>
                             </child>
                           </object>


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