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



commit 4de1f9a62011f44afd095e47c536338bebe92afc
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Jul 18 08:17:07 2014 +0200

    collection-view: Drop use of AppWindow singleton
    
    Instead of using the AppWindow singleton, CollectionView 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/app-window.vala      |    2 +-
 src/collection-view.vala |   20 ++++++++++++--------
 2 files changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 9ba9fe3..12588c3 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -108,7 +108,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
         topbar.setup_ui (this);
         wizard.setup_ui (this);
         display_page.setup_ui (this);
-        view.setup_ui ();
+        view.setup_ui (this);
         selectionbar.setup_ui ();
     }
 
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 6af1adb..5b7c6f2 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -10,6 +10,8 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
     public UIState previous_ui_state { get; protected set; }
     public UIState ui_state { get; protected set; }
 
+    private AppWindow window;
+
     private Category _category;
     public Category category {
         get { return _category; }
@@ -39,10 +41,12 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
         notify["ui-state"].connect (ui_state_changed);
     }
 
-    public void setup_ui () {
-        App.window.notify["selection-mode"].connect (() => {
-            set_selection_mode (App.window.selection_mode);
-            if (!App.window.selection_mode)
+    public void setup_ui (AppWindow window) {
+        this.window = window;
+
+        window.notify["selection-mode"].connect (() => {
+            set_selection_mode (window.selection_mode);
+            if (!window.selection_mode)
                 unselect_all (); // Reset selection on exiting selection mode
         });
     }
@@ -147,7 +151,7 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
         });
         item.set_data<ulong> ("under_construct_id", under_construct_id);
 
-        item.set_state (App.window.ui_state);
+        item.set_state (window.ui_state);
     }
 
     public List<CollectionItem> get_selected_items () {
@@ -272,20 +276,20 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
             var item = get_item_for_path (path);
             if (item is LibvirtMachine && (item as LibvirtMachine).importing)
                 return;
-            App.window.select_item (item);
+            window.select_item (item);
         });
         view_selection_changed.connect (() => {
             queue_draw ();
             App.app.notify_property ("selected-items");
         });
         selection_mode_request.connect (() => {
-            App.window.selection_mode = true;
+            window.selection_mode = true;
         });
         show_all ();
     }
 
     public void select (SelectionCriteria selection) {
-        App.window.selection_mode = true;
+        window.selection_mode = true;
 
         model_filter.foreach ( (filter_model, filter_path, filter_iter) => {
             Gtk.TreeIter iter;


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