[gnome-boxes] collection-toolbar: Drop use of AppWindow singleton



commit c8870187fb06dfa419ad654c000af3a9ece5b875
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Jul 18 07:34:09 2014 +0200

    collection-toolbar: Drop use of AppWindow singleton
    
    Instead of using the AppWindow singleton, CollectionToolbar now has its
    own reference to AppWindow that it receives through a parameter to
    setup_ui().
    
    This is needed to drop the use of AppWindow singleton and therefore to
    make multiple windows possible.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=732098

 src/collection-toolbar.vala |   19 ++++++++++---------
 src/topbar.vala             |    2 +-
 2 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/src/collection-toolbar.vala b/src/collection-toolbar.vala
index 6463000..5be4e18 100644
--- a/src/collection-toolbar.vala
+++ b/src/collection-toolbar.vala
@@ -14,15 +14,16 @@ private class Boxes.CollectionToolbar: HeaderBar {
     [GtkChild]
     private Button new_btn;
 
+    private AppWindow window;
+
     construct {
         var back_icon = (get_direction () == TextDirection.RTL)? "go-previous-rtl-symbolic" :
                                                                  "go-previous-symbolic";
         back_image.set_from_icon_name (back_icon, IconSize.MENU);
     }
 
-    public void setup_ui () {
-        assert (App.window != null);
-        assert (App.window.searchbar != null);
+    public void setup_ui (AppWindow window) {
+        this.window = window;
 
         update_select_btn ();
         App.app.collection.item_added.connect (update_select_btn);
@@ -32,24 +33,24 @@ private class Boxes.CollectionToolbar: HeaderBar {
         App.app.collection.item_added.connect (update_search_btn);
         App.app.collection.item_removed.connect (update_search_btn);
 
-        search_btn.bind_property ("active", App.window.searchbar, "search-mode-enabled", 
BindingFlags.BIDIRECTIONAL);
+        search_btn.bind_property ("active", window.searchbar, "search-mode-enabled", 
BindingFlags.BIDIRECTIONAL);
 
-        App.window.notify["ui-state"].connect (ui_state_changed);
+        window.notify["ui-state"].connect (ui_state_changed);
     }
 
     [GtkCallback]
     private void on_new_btn_clicked () {
-        App.window.set_state (UIState.WIZARD);
+        window.set_state (UIState.WIZARD);
     }
 
     [GtkCallback]
     private void on_back_btn_clicked () {
-        App.window.set_state (UIState.COLLECTION);
+        window.set_state (UIState.COLLECTION);
     }
 
     [GtkCallback]
     private void on_select_btn_clicked () {
-        App.window.selection_mode = true;
+        window.selection_mode = true;
     }
 
     private void update_search_btn () {
@@ -65,7 +66,7 @@ private class Boxes.CollectionToolbar: HeaderBar {
     }
 
     private void ui_state_changed () {
-        switch (App.window.ui_state) {
+        switch (window.ui_state) {
         case UIState.COLLECTION:
             back_btn.hide ();
             select_btn.show ();
diff --git a/src/topbar.vala b/src/topbar.vala
index f781a21..28a4190 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -109,7 +109,7 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
         toolbar.bind_property ("title", display_toolbar, "title", BindingFlags.SYNC_CREATE);
         toolbar.bind_property ("subtitle", display_toolbar, "subtitle", BindingFlags.SYNC_CREATE);
 
-        collection_toolbar.setup_ui ();
+        collection_toolbar.setup_ui (window);
         selection_toolbar.setup_ui ();
     }
 


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