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



commit 4d57be73cf200f81e76b34e871ac1b88ce209c57
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Jul 18 07:36:47 2014 +0200

    selection-toolbar: Drop use of AppWindow singleton
    
    Instead of using the AppWindow singleton, SelectionToolbar 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/selection-toolbar.vala |   11 ++++++-----
 src/topbar.vala            |    2 +-
 2 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/selection-toolbar.vala b/src/selection-toolbar.vala
index 75154ef..0baf39c 100644
--- a/src/selection-toolbar.vala
+++ b/src/selection-toolbar.vala
@@ -8,9 +8,11 @@ private class Boxes.SelectionToolbar: HeaderBar {
     [GtkChild]
     private Label menu_button_label;
 
+    private AppWindow window;
+
     [GtkCallback]
     private void on_cancel_btn_clicked () {
-        App.window.selection_mode = false;
+        window.selection_mode = false;
     }
 
     construct {
@@ -19,9 +21,8 @@ private class Boxes.SelectionToolbar: HeaderBar {
         });
     }
 
-    public void setup_ui () {
-        assert (App.window != null);
-        assert (App.window.searchbar != null);
+    public void setup_ui (AppWindow window) {
+        this.window = window;
 
         update_selection_label ();
 
@@ -29,7 +30,7 @@ private class Boxes.SelectionToolbar: 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);
     }
 
     private void update_selection_label () {
diff --git a/src/topbar.vala b/src/topbar.vala
index 28a4190..00cf2ad 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -110,7 +110,7 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
         toolbar.bind_property ("subtitle", display_toolbar, "subtitle", BindingFlags.SYNC_CREATE);
 
         collection_toolbar.setup_ui (window);
-        selection_toolbar.setup_ui ();
+        selection_toolbar.setup_ui (window);
     }
 
     private void ui_state_changed () {


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