[baobab/animated-notebook: 2/2] window: replace GtkNotebook with animated CcNotebook



commit 7b04a20bf90c0cbb915d8c69e5d3efc8339f60e1
Author: Stefano Facchini <stefano facchini gmail com>
Date:   Thu Oct 18 14:41:17 2012 +0200

    window: replace GtkNotebook with animated CcNotebook

 src/baobab-main-window.ui |   55 ++++++++++++++++++++++++--------------------
 src/baobab-window.vala    |   17 ++++++-------
 2 files changed, 38 insertions(+), 34 deletions(-)
---
diff --git a/src/baobab-main-window.ui b/src/baobab-main-window.ui
index b8802f1..0996a99 100644
--- a/src/baobab-main-window.ui
+++ b/src/baobab-main-window.ui
@@ -16,28 +16,7 @@
   <object class="GtkGrid" id="window-contents">
     <property name="visible">True</property>
     <property name="orientation">vertical</property>
-    <child>
-      <object class="GdMainToolbar" id="home-toolbar">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="vexpand">False</property>
-        <style>
-          <class name="menubar"/>
-          <class name="baobab-toolbar"/>
-        </style>
-      </object>
-    </child>
-    <child>
-      <object class="GdMainToolbar" id="result-toolbar">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="vexpand">False</property>
-        <style>
-          <class name="menubar"/>
-          <class name="baobab-toolbar"/>
-        </style>
-      </object>
-    </child>
+
     <child>
       <object class="GtkInfoBar" id="infobar">
         <property name="visible">False</property>
@@ -97,17 +76,25 @@
       </object>
     </child>
     <child>
-      <object class="GtkNotebook" id="main-notebook">
+      <object class="CcNotebook" id="main-notebook">
         <property name="visible">True</property>
         <property name="can_focus">True</property>
-        <property name="show_tabs">False</property> -->
-        <property name="show_border">False</property> -->
         <child>
           <object class="GtkGrid" id="home-page">
             <property name="can_focus">False</property>
             <property name="visible">True</property>
             <property name="orientation">vertical</property>
             <child>
+              <object class="GdMainToolbar" id="home-toolbar">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <style>
+                  <class name="menubar"/>
+                  <class name="baobab-toolbar"/>
+                </style>
+              </object>
+            </child>
+            <child>
               <object class="GtkScrolledWindow" id="location-scrolled-window">
                 <property name="visible">True</property>
                 <property name="vexpand">True</property>
@@ -134,6 +121,24 @@
           <object class="GtkGrid" id="result-page">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GdMainToolbar" id="result-toolbar">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="vexpand">False</property>
+                <style>
+                  <class name="menubar"/>
+                  <class name="baobab-toolbar"/>
+                </style>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">-1</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
             <child>
               <object class="GtkScrolledWindow" id="scrolled-window">
                 <property name="visible">True</property>
diff --git a/src/baobab-window.vala b/src/baobab-window.vala
index cb2ef7a..dfa2630 100644
--- a/src/baobab-window.vala
+++ b/src/baobab-window.vala
@@ -24,8 +24,9 @@ namespace Baobab {
 
     public class Window : Gtk.ApplicationWindow {
         Settings ui_settings;
-        Gtk.Notebook main_notebook;
-        Gd.MainToolbar home_toolbar;
+        Cc.Notebook main_notebook;
+        Gtk.Grid home_page;
+        Gtk.Grid result_page;
         Gd.MainToolbar result_toolbar;
         Gtk.InfoBar infobar;
         Gtk.Label infobar_primary;
@@ -109,7 +110,9 @@ namespace Baobab {
             }
 
             // Cache some objects from the builder.
-            main_notebook = builder.get_object ("main-notebook") as Gtk.Notebook;
+            main_notebook = builder.get_object ("main-notebook") as Cc.Notebook;
+            home_page = builder.get_object ("home-page") as Gtk.Grid;
+            result_page = builder.get_object ("result-page") as Gtk.Grid;
             infobar = builder.get_object ("infobar") as Gtk.InfoBar;
             infobar_primary = builder.get_object ("infobar-primary-label") as Gtk.Label;
             infobar_secondary = builder.get_object ("infobar-secondary-label") as Gtk.Label;
@@ -125,7 +128,6 @@ namespace Baobab {
 
             // Home page toolbar
             var toolbar = builder.get_object ("home-toolbar") as Gd.MainToolbar;
-            home_toolbar = toolbar;
             var menu_button = toolbar.add_menu ("emblem-system-symbolic", null, false) as Gtk.MenuButton;
             menu_button.set_menu_model (menu_model);
             toolbar.set_labels (_("Devices and locations"), null);
@@ -488,21 +490,18 @@ namespace Baobab {
         }
 
         void set_ui_state (UIPage page, bool busy) {
-            home_toolbar.visible = (page == UIPage.HOME);
-            result_toolbar.visible = (page == UIPage.RESULT);
-
             set_busy (busy);
 
             if (page == UIPage.HOME) {
                 var action = lookup_action ("reload") as SimpleAction;
                 action.set_enabled (false);
+                main_notebook.select_page (home_page, true);
             } else {
                 var action = lookup_action ("reload") as SimpleAction;
                 action.set_enabled (true);
                 result_toolbar.set_labels (active_location.name, null);
+                main_notebook.select_page (result_page, true);
             }
-
-            main_notebook.page = page;
         }
 
         void first_row_has_child (Gtk.TreeModel model, Gtk.TreePath path, Gtk.TreeIter iter) {



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