[gnome-boxes/wip/less-actors: 38/39] sidebar: Derive from Gtk.Revealer



commit 9663fa1e5d30508218b8fda705d1ef3de72dcf8d
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Feb 19 13:33:59 2014 +0000

    sidebar: Derive from Gtk.Revealer
    
    And hence making Boxes.Revealer redundant.
    
    It doesn't exactly work though:
    
    * Container actor doesn't update its visibility based visibility of child.
    
    * Doesn't expand vertically for some reason.
    
    These will be fixed when we replace the containing actors with gtk
    widgets in the following patches.

 data/ui/sidebar.ui |  464 +++++++++++++++++++++++++++-------------------------
 src/app.vala       |    8 +-
 src/sidebar.vala   |   11 +-
 3 files changed, 245 insertions(+), 238 deletions(-)
---
diff --git a/data/ui/sidebar.ui b/data/ui/sidebar.ui
index 80de61c..878c482 100644
--- a/data/ui/sidebar.ui
+++ b/data/ui/sidebar.ui
@@ -2,309 +2,321 @@
 <interface>
   <!-- interface-requires gtk+ 3.9 -->
 
-  <template class="BoxesSidebar" parent="GtkNotebook">
+  <template class="BoxesSidebar" parent="GtkRevealer">
     <property name="visible">True</property>
     <property name="width-request">100</property>
-    <property name="show-tabs">False</property>
+    <property name="transition-type">slide-right</property>
+    <property name="vexpand">True</property>
     <style>
       <class name="sidebar"/>
     </style>
 
-    <!-- Separate page for each UI state -->
-
-    <!-- Collection -->
-    <child>
-      <object class="GtkBox" id="collection_vbox">
-        <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">0</property>
-      </object>
-    </child>
-
-    <!-- Wizard -->
     <child>
-      <object class="GtkBox" id="wizard_vbox">
+      <object class="GtkNotebook" id="notebook">
         <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">0</property>
-
-        <child>
-          <object class="GtkLabel" id="wizard_intro_label">
-            <property name="visible">True</property>
-            <property name="label" translatable="yes">Introduction</property>
-            <property name="margin-left">25</property>
-            <property name="halign">start</property>
-            <style>
-              <class name="boxes-step-label"/>
-            </style>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">10</property>
-          </packing>
-        </child>
-
-        <child>
-          <object class="GtkLabel" id="wizard_source_label">
-            <property name="visible">True</property>
-            <property name="label" translatable="yes">Source Selection</property>
-            <property name="margin-left">25</property>
-            <property name="halign">start</property>
-            <style>
-              <class name="boxes-step-label"/>
-            </style>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">10</property>
-          </packing>
-        </child>
-
-        <child>
-          <object class="GtkLabel" id="wizard_preparation_label">
-            <property name="visible">True</property>
-            <property name="label" translatable="yes">Preparation</property>
-            <property name="margin-left">25</property>
-            <property name="halign">start</property>
-            <style>
-              <class name="boxes-step-label"/>
-            </style>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">10</property>
-          </packing>
-        </child>
-
-        <child>
-          <object class="GtkLabel" id="wizard_setup_label">
-            <property name="visible">True</property>
-            <property name="label" translatable="yes">Setup</property>
-            <property name="margin-left">25</property>
-            <property name="halign">start</property>
-            <style>
-              <class name="boxes-step-label"/>
-            </style>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">10</property>
-          </packing>
-        </child>
-
-        <child>
-          <object class="GtkLabel" id="wizard_review_label">
-            <property name="visible">True</property>
-            <property name="label" translatable="yes">Review</property>
-            <property name="margin-left">25</property>
-            <property name="halign">start</property>
-            <style>
-              <class name="boxes-step-label"/>
-            </style>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">10</property>
-          </packing>
-        </child>
-      </object>
-    </child>
+        <property name="show-tabs">False</property>
+        <property name="vexpand">True</property>
+        <style>
+          <class name="sidebar"/>
+        </style>
 
-    <!-- Properties -->
-    <child>
-      <object class="GtkBox" id="props_vbox">
-        <property name="visible">True</property>
-        <property name="orientation">vertical</property>
-        <property name="spacing">10</property>
+        <!-- Separate page for each UI state -->
 
+        <!-- Collection -->
         <child>
-          <object class="GtkTreeView" id="props_tree_view">
+          <object class="GtkBox" id="collection_vbox">
             <property name="visible">True</property>
-            <property name="headers-visible">False</property>
-            <property name="activate-on-single-click">True</property>
-            <property name="model">props_model_filter</property>
-            <signal name="row_activated" handler="on_props_row_activated"/>
-            <style>
-              <class name="boxes-bg"/>
-            </style>
-
-            <child>
-              <object class="GtkTreeViewColumn" id="text-column">
-                <property name="title"></property>
-                <child>
-                  <object class="GtkCellRendererText" id="text-renderer">
-                    <property name="visible">True</property>
-                    <property name="xpad">20</property>
-                    <property name="weight">700</property>
-                  </object>
-                  <attributes>
-                    <attribute name="text">0</attribute>
-                  </attributes>
-                </child>
-              </object>
-            </child>
-
-            <child internal-child="selection">
-              <object class="GtkTreeSelection" id="props_selection">
-                <property name="mode">browse</property>
-              </object>
-            </child>
+            <property name="orientation">vertical</property>
+            <property name="spacing">0</property>
           </object>
-
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="padding">0</property>
-          </packing>
         </child>
 
+        <!-- Wizard -->
         <child>
-          <object class="GtkGrid" id="props_grid">
+          <object class="GtkBox" id="wizard_vbox">
             <property name="visible">True</property>
-            <property name="column-homogeneous">False</property>
-            <property name="column-spacing">2</property>
-            <property name="row-spacing">10</property>
-            <property name="margin-left">10</property>
-            <property name="margin-right">10</property>
-            <property name="margin-top">10</property>
-            <property name="margin-bottom">30</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">0</property>
 
             <child>
-              <object class="GtkImage" id="screenshot">
+              <object class="GtkLabel" id="wizard_intro_label">
                 <property name="visible">True</property>
-                <property name="width-request">180</property>
-                <property name="height-request">134</property>
+                <property name="label" translatable="yes">Introduction</property>
+                <property name="margin-left">25</property>
+                <property name="halign">start</property>
+                <style>
+                  <class name="boxes-step-label"/>
+                </style>
               </object>
-
               <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">0</property>
-                <property name="width">6</property>
-                <property name="height">1</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">10</property>
               </packing>
             </child>
 
             <child>
-              <object class="GtkLabel" id="cpu_label">
+              <object class="GtkLabel" id="wizard_source_label">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">CPU:</property>
+                <property name="label" translatable="yes">Source Selection</property>
+                <property name="margin-left">25</property>
+                <property name="halign">start</property>
                 <style>
-                  <class name="boxes-graph-label"/>
+                  <class name="boxes-step-label"/>
                 </style>
               </object>
-
               <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">10</property>
               </packing>
             </child>
 
             <child>
-              <object class="BoxesMiniGraph" id="cpu_graph">
+              <object class="GtkLabel" id="wizard_preparation_label">
                 <property name="visible">True</property>
-                <property name="ymax">100</property>
-                <property name="npoints">20</property>
+                <property name="label" translatable="yes">Preparation</property>
+                <property name="margin-left">25</property>
+                <property name="halign">start</property>
+                <style>
+                  <class name="boxes-step-label"/>
+                </style>
               </object>
-
               <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">10</property>
               </packing>
             </child>
 
             <child>
-              <object class="GtkLabel" id="io_label">
+              <object class="GtkLabel" id="wizard_setup_label">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">I/O:</property>
+                <property name="label" translatable="yes">Setup</property>
+                <property name="margin-left">25</property>
+                <property name="halign">start</property>
                 <style>
-                  <class name="boxes-graph-label"/>
+                  <class name="boxes-step-label"/>
                 </style>
               </object>
-
               <packing>
-                <property name="left-attach">2</property>
-                <property name="top-attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">10</property>
               </packing>
             </child>
 
             <child>
-              <object class="BoxesMiniGraph" id="io_graph">
+              <object class="GtkLabel" id="wizard_review_label">
                 <property name="visible">True</property>
-                <property name="ymax">20</property>
+                <property name="label" translatable="yes">Review</property>
+                <property name="margin-left">25</property>
+                <property name="halign">start</property>
+                <style>
+                  <class name="boxes-step-label"/>
+                </style>
               </object>
-
               <packing>
-                <property name="left-attach">3</property>
-                <property name="top-attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">10</property>
               </packing>
             </child>
+          </object>
+        </child>
+
+        <!-- Properties -->
+        <child>
+          <object class="GtkBox" id="props_vbox">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <property name="spacing">10</property>
 
             <child>
-              <object class="GtkLabel" id="net_label">
+              <object class="GtkTreeView" id="props_tree_view">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">Net:</property>
+                <property name="headers-visible">False</property>
+                <property name="activate-on-single-click">True</property>
+                <property name="model">props_model_filter</property>
+                <signal name="row_activated" handler="on_props_row_activated"/>
                 <style>
-                  <class name="boxes-graph-label"/>
+                  <class name="boxes-bg"/>
                 </style>
-              </object>
 
-              <packing>
-                <property name="left-attach">4</property>
-                <property name="top-attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
+                <child>
+                  <object class="GtkTreeViewColumn" id="text-column">
+                    <property name="title"></property>
+                    <child>
+                      <object class="GtkCellRendererText" id="text-renderer">
+                        <property name="visible">True</property>
+                        <property name="xpad">20</property>
+                        <property name="weight">700</property>
+                      </object>
+                      <attributes>
+                        <attribute name="text">0</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                </child>
 
-            <child>
-              <object class="BoxesMiniGraph" id="net_graph">
-                <property name="visible">True</property>
-                <property name="ymax">20</property>
+                <child internal-child="selection">
+                  <object class="GtkTreeSelection" id="props_selection">
+                    <property name="mode">browse</property>
+                  </object>
+                </child>
               </object>
 
               <packing>
-                <property name="left-attach">5</property>
-                <property name="top-attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="expand">True</property>
+                <property name="fill">True</property>
+                <property name="padding">0</property>
               </packing>
             </child>
 
             <child>
-              <object class="GtkButton" id="shutdown_button">
+              <object class="GtkGrid" id="props_grid">
                 <property name="visible">True</property>
-                <property name="use-underline">True</property>
-                <property name="label" translatable="yes">Force Shutdown</property>
-                <signal name="clicked" handler="on_shutdown_button_clicked"/>
+                <property name="column-homogeneous">False</property>
+                <property name="column-spacing">2</property>
+                <property name="row-spacing">10</property>
+                <property name="margin-left">10</property>
+                <property name="margin-right">10</property>
+                <property name="margin-top">10</property>
+                <property name="margin-bottom">30</property>
+
+                <child>
+                  <object class="GtkImage" id="screenshot">
+                    <property name="visible">True</property>
+                    <property name="width-request">180</property>
+                    <property name="height-request">134</property>
+                  </object>
+
+                  <packing>
+                    <property name="left-attach">0</property>
+                    <property name="top-attach">0</property>
+                    <property name="width">6</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+
+                <child>
+                  <object class="GtkLabel" id="cpu_label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">CPU:</property>
+                    <style>
+                      <class name="boxes-graph-label"/>
+                    </style>
+                  </object>
+
+                  <packing>
+                    <property name="left-attach">0</property>
+                    <property name="top-attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+
+                <child>
+                  <object class="BoxesMiniGraph" id="cpu_graph">
+                    <property name="visible">True</property>
+                    <property name="ymax">100</property>
+                    <property name="npoints">20</property>
+                  </object>
+
+                  <packing>
+                    <property name="left-attach">1</property>
+                    <property name="top-attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+
+                <child>
+                  <object class="GtkLabel" id="io_label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">I/O:</property>
+                    <style>
+                      <class name="boxes-graph-label"/>
+                    </style>
+                  </object>
+
+                  <packing>
+                    <property name="left-attach">2</property>
+                    <property name="top-attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+
+                <child>
+                  <object class="BoxesMiniGraph" id="io_graph">
+                    <property name="visible">True</property>
+                    <property name="ymax">20</property>
+                  </object>
+
+                  <packing>
+                    <property name="left-attach">3</property>
+                    <property name="top-attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+
+                <child>
+                  <object class="GtkLabel" id="net_label">
+                    <property name="visible">True</property>
+                    <property name="label" translatable="yes">Net:</property>
+                    <style>
+                      <class name="boxes-graph-label"/>
+                    </style>
+                  </object>
+
+                  <packing>
+                    <property name="left-attach">4</property>
+                    <property name="top-attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+
+                <child>
+                  <object class="BoxesMiniGraph" id="net_graph">
+                    <property name="visible">True</property>
+                    <property name="ymax">20</property>
+                  </object>
+
+                  <packing>
+                    <property name="left-attach">5</property>
+                    <property name="top-attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+
+                <child>
+                  <object class="GtkButton" id="shutdown_button">
+                    <property name="visible">True</property>
+                    <property name="use-underline">True</property>
+                    <property name="label" translatable="yes">Force Shutdown</property>
+                    <signal name="clicked" handler="on_shutdown_button_clicked"/>
+                  </object>
+
+                  <packing>
+                    <property name="left-attach">0</property>
+                    <property name="top-attach">2</property>
+                    <property name="width">6</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
               </object>
 
               <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">2</property>
-                <property name="width">6</property>
-                <property name="height">1</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="padding">0</property>
               </packing>
             </child>
           </object>
-
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="padding">0</property>
-          </packing>
         </child>
       </object>
     </child>
diff --git a/src/app.vala b/src/app.vala
index 2d13a3c..5b2da86 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -89,7 +89,6 @@ private class Boxes.App: GLib.Object, Boxes.UI {
     public Searchbar searchbar;
     public Topbar topbar;
     public Notificationbar notificationbar;
-    public Boxes.Revealer sidebar_revealer;
     public Sidebar sidebar;
     public Selectionbar selectionbar;
     public uint duration;
@@ -617,12 +616,7 @@ private class Boxes.App: GLib.Object, Boxes.UI {
 
         below_bin_actor.add_child (hbox_actor);
 
-        sidebar_revealer = new Boxes.Revealer (false);
-        sidebar_revealer.name = "sidebar-revealer";
-        sidebar_revealer.y_expand = true;
-        hbox_actor.add_child (sidebar_revealer);
-        sidebar_revealer.unreveal ();
-        sidebar_revealer.add (sidebar.actor);
+        hbox_actor.add_child (sidebar.actor);
 
         var content_bin_actor = new Clutter.Actor ();
         content_bin_actor.name = "content-bin";
diff --git a/src/sidebar.vala b/src/sidebar.vala
index 9e7483e..b2a3363 100644
--- a/src/sidebar.vala
+++ b/src/sidebar.vala
@@ -10,7 +10,7 @@ private enum Boxes.SidebarPage {
 }
 
 [GtkTemplate (ui = "/org/gnome/Boxes/ui/sidebar.ui")]
-private class Boxes.Sidebar: Gtk.Notebook, Boxes.UI {
+private class Boxes.Sidebar: Gtk.Revealer, Boxes.UI {
     public Clutter.Actor actor { get { return gtk_actor; } }
     public UIState previous_ui_state { get; protected set; }
     public UIState ui_state { get; protected set; }
@@ -18,6 +18,8 @@ private class Boxes.Sidebar: Gtk.Notebook, Boxes.UI {
     private GtkClutter.Actor gtk_actor; // the sidebar box
 
     [GtkChild]
+    private Gtk.Notebook notebook;
+    [GtkChild]
     private Gtk.Box wizard_vbox;
     [GtkChild]
     private Gtk.Label wizard_intro_label;
@@ -81,12 +83,12 @@ private class Boxes.Sidebar: Gtk.Notebook, Boxes.UI {
         switch (ui_state) {
         case UIState.WIZARD:
         case UIState.PROPERTIES:
-            App.app.sidebar_revealer.reveal ();
-            page = ui_state == UIState.WIZARD ? SidebarPage.WIZARD : SidebarPage.PROPERTIES;
+            reveal_child = true;
+            notebook.page = ui_state == UIState.WIZARD ? SidebarPage.WIZARD : SidebarPage.PROPERTIES;
             break;
 
         default:
-            App.app.sidebar_revealer.unreveal ();
+            reveal_child = false;
             break;
         }
     }
@@ -97,7 +99,6 @@ private class Boxes.Sidebar: Gtk.Notebook, Boxes.UI {
         gtk_actor = new GtkClutter.Actor.with_contents (this);
         gtk_actor.get_widget ().get_style_context ().add_class ("boxes-bg");
         gtk_actor.name = "sidebar";
-        gtk_actor.x_expand = true;
         gtk_actor.y_expand = true;
     }
 


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