[gnome-boxes] app: Use Gtk.Stack for page changes



commit f3bd8a3db659371c7e444ed4df501a61c13abde7
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Feb 10 12:42:19 2014 +0000

    app: Use Gtk.Stack for page changes
    
    Use a Gtk.Stack with slide-right/left animations to change from/to main
    page to/from display page.

 src/app.vala             |   31 +++++++++++++++++++++++--------
 src/display-page.vala    |    2 +-
 src/machine.vala         |    2 +-
 src/notificationbar.vala |    4 ++--
 4 files changed, 27 insertions(+), 12 deletions(-)
---
diff --git a/src/app.vala b/src/app.vala
index 9872275..f270cd3 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -62,9 +62,26 @@ private class Boxes.App: GLib.Object, Boxes.UI {
                 window.unfullscreen ();
         }
     }
+    public AppPage page {
+        get {
+            if (stack.get_visible_child_name () == "display-page")
+                return AppPage.DISPLAY;
+            else
+                return AppPage.MAIN;
+        }
+        set {
+            if (value == AppPage.DISPLAY) {
+                stack.transition_type = Gtk.StackTransitionType.SLIDE_RIGHT;
+                stack.set_visible_child_name ("display-page");
+            } else {
+                stack.transition_type = Gtk.StackTransitionType.SLIDE_LEFT;
+                stack.set_visible_child_name ("main-page");
+            }
+        }
+    }
 
     private bool maximized { get { return WindowState.MAXIMIZED in window.get_window ().get_state (); } }
-    public Gtk.Notebook notebook;
+    private Gtk.Stack stack;
     public ClutterWidget embed;
     public Clutter.Stage stage;
     public Clutter.BinLayout stage_bin;
@@ -520,17 +537,15 @@ private class Boxes.App: GLib.Object, Boxes.UI {
         var main_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
         window.add (main_vbox);
 
-        notebook = new Gtk.Notebook ();
-        notebook.show_border = false;
-        notebook.show_tabs = false;
-        main_vbox.add (notebook);
+        stack = new Gtk.Stack ();
+        main_vbox.add (stack);
 
         var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0);
         vbox.halign = Gtk.Align.FILL;
         vbox.valign = Gtk.Align.FILL;
         vbox.hexpand = true;
         vbox.vexpand = true;
-        notebook.append_page (vbox, null);
+        stack.add_named (vbox, "main-page");
 
         searchbar = new Searchbar ();
         vbox.add (searchbar);
@@ -539,7 +554,7 @@ private class Boxes.App: GLib.Object, Boxes.UI {
         vbox.add (embed);
 
         display_page = new DisplayPage ();
-        notebook.append_page (display_page, null);
+        stack.add_named (display_page, "display-page");
 
         selectionbar = new Selectionbar ();
         main_vbox.add (selectionbar);
@@ -648,7 +663,7 @@ private class Boxes.App: GLib.Object, Boxes.UI {
     }
 
     private void set_main_ui_state () {
-        notebook.page = Boxes.AppPage.MAIN;
+        stack.set_visible_child_name ("main-page");
     }
 
     private void ui_state_changed () {
diff --git a/src/display-page.vala b/src/display-page.vala
index 6278386..4ad35d7 100644
--- a/src/display-page.vala
+++ b/src/display-page.vala
@@ -142,7 +142,7 @@ private class Boxes.DisplayPage: Gtk.Box {
             return false;
         });
 
-        App.app.notebook.page = Boxes.AppPage.DISPLAY;
+        App.app.page = Boxes.AppPage.DISPLAY;
         widget.grab_focus ();
     }
 
diff --git a/src/machine.vala b/src/machine.vala
index da95e72..df2ec5f 100644
--- a/src/machine.vala
+++ b/src/machine.vala
@@ -518,7 +518,7 @@ private abstract class Boxes.Machine: Boxes.CollectionItem, Boxes.IPropertiesPro
             break;
         case Boxes.UIState.DISPLAY:
             if (previous_ui_state == UIState.PROPERTIES)
-                App.app.notebook.page = Boxes.AppPage.DISPLAY;
+                App.app.page = Boxes.AppPage.DISPLAY;
 
             break;
 
diff --git a/src/notificationbar.vala b/src/notificationbar.vala
index 79a6bfe..a81f062 100644
--- a/src/notificationbar.vala
+++ b/src/notificationbar.vala
@@ -26,7 +26,7 @@ private class Boxes.Notificationbar: GLib.Object {
         Gdk.RGBA transparent = { 0, 0, 0, 0};
         gtk_actor.get_widget ().override_background_color (0, transparent);
 
-        App.app.notebook.notify["page"].connect ( () => {
+        App.app.notify["page"].connect ( () => {
             foreach (var w in active_notifications) {
                 var parent = w.get_parent () as Container;
                 if (parent != null)
@@ -89,7 +89,7 @@ private class Boxes.Notificationbar: GLib.Object {
     }
 
     private void add_notification (Widget w) {
-        if (App.app.notebook.page == AppPage.MAIN)
+        if (App.app.page == AppPage.MAIN)
             top_grid.attach (w, 0, 0, 1, 1);
         else
             App.app.display_page.add_notification (w);


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