[gnome-boxes] Use AppWindow's 'selection-mode' prop instead of App's



commit 9228ecc8a86db7b32a2c1489d322b1d54355aa2a
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Wed Jul 16 10:53:12 2014 +0200

    Use AppWindow's 'selection-mode' prop instead of App's
    
    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         |    4 ++--
 src/app.vala                |    5 +----
 src/collection-toolbar.vala |    2 +-
 src/collection-view.vala    |   10 +++++-----
 src/selection-toolbar.vala  |    2 +-
 src/selectionbar.vala       |    8 ++++----
 src/topbar.vala             |    8 ++++----
 7 files changed, 18 insertions(+), 21 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 8d11106..b562829 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -187,7 +187,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
     public void show_properties () {
         var selected_items = view.get_selected_items ();
 
-        App.app.selection_mode = false;
+        selection_mode = false;
 
         // Show for the first selected item
         foreach (var item in selected_items) {
@@ -212,7 +212,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
     }
 
     public void select_item (CollectionItem item) {
-        if (App.app.ui_state == UIState.COLLECTION && !App.app.selection_mode) {
+        if (App.app.ui_state == UIState.COLLECTION && !selection_mode) {
             current_item = item;
 
             if (current_item is Machine) {
diff --git a/src/app.vala b/src/app.vala
index 883966a..58f8056 100644
--- a/src/app.vala
+++ b/src/app.vala
@@ -161,7 +161,6 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
 
         window = new Boxes.AppWindow (this);
         window.setup_ui ();
-        bind_property ("selection-mode", window, "selection-mode", BindingFlags.BIDIRECTIONAL);
         set_state (UIState.COLLECTION);
 
         window.present ();
@@ -434,8 +433,6 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
         debug ("Running boxes suspended");
     }
 
-    public bool selection_mode { get; set; }
-
     public List<CollectionItem> selected_items {
         owned get { return window.view.get_selected_items (); }
     }
@@ -484,7 +481,7 @@ private class Boxes.App: Gtk.Application, Boxes.UI {
         if (num_selected == 0)
             return;
 
-        selection_mode = false;
+        window.selection_mode = false;
 
         var message = (num_selected == 1) ? _("Box '%s' has been deleted").printf (selected_items.data.name) 
:
                                             ngettext ("%u box has been deleted",
diff --git a/src/collection-toolbar.vala b/src/collection-toolbar.vala
index ab6f38a..aba7a9f 100644
--- a/src/collection-toolbar.vala
+++ b/src/collection-toolbar.vala
@@ -49,7 +49,7 @@ private class Boxes.CollectionToolbar: HeaderBar {
 
     [GtkCallback]
     private void on_select_btn_clicked () {
-        App.app.selection_mode = true;
+        App.window.selection_mode = true;
     }
 
     private void update_search_btn () {
diff --git a/src/collection-view.vala b/src/collection-view.vala
index 79c136a..d9fc3be 100644
--- a/src/collection-view.vala
+++ b/src/collection-view.vala
@@ -40,9 +40,9 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
     }
 
     public void setup_ui () {
-        App.app.notify["selection-mode"].connect (() => {
-            set_selection_mode (App.app.selection_mode);
-            if (!App.app.selection_mode)
+        App.window.notify["selection-mode"].connect (() => {
+            set_selection_mode (App.window.selection_mode);
+            if (!App.window.selection_mode)
                 unselect_all (); // Reset selection on exiting selection mode
         });
     }
@@ -279,13 +279,13 @@ private class Boxes.CollectionView: Gd.MainView, Boxes.UI {
             App.app.notify_property ("selected-items");
         });
         selection_mode_request.connect (() => {
-            App.app.selection_mode = true;
+            App.window.selection_mode = true;
         });
         show_all ();
     }
 
     public void select (SelectionCriteria selection) {
-        App.app.selection_mode = true;
+        App.window.selection_mode = true;
 
         model_filter.foreach ( (filter_model, filter_path, filter_iter) => {
             Gtk.TreeIter iter;
diff --git a/src/selection-toolbar.vala b/src/selection-toolbar.vala
index 997861f..75154ef 100644
--- a/src/selection-toolbar.vala
+++ b/src/selection-toolbar.vala
@@ -10,7 +10,7 @@ private class Boxes.SelectionToolbar: HeaderBar {
 
     [GtkCallback]
     private void on_cancel_btn_clicked () {
-        App.app.selection_mode = false;
+        App.window.selection_mode = false;
     }
 
     construct {
diff --git a/src/selectionbar.vala b/src/selectionbar.vala
index 53b78ce..ef56a1a 100644
--- a/src/selectionbar.vala
+++ b/src/selectionbar.vala
@@ -22,8 +22,8 @@ private class Boxes.Selectionbar: Gtk.Revealer {
     }
 
     public void setup_ui () {
-        App.app.notify["selection-mode"].connect (() => {
-            reveal_child = App.app.selection_mode;
+        App.window.notify["selection-mode"].connect (() => {
+            reveal_child = App.window.selection_mode;
         });
     }
 
@@ -40,7 +40,7 @@ private class Boxes.Selectionbar: Gtk.Revealer {
             machine.config.set_category ("favorite", favorite_btn.active);
         }
 
-        App.app.selection_mode = false;
+        App.window.selection_mode = false;
     }
 
     [GtkCallback]
@@ -59,7 +59,7 @@ private class Boxes.Selectionbar: Gtk.Revealer {
         }
 
         pause_btn.sensitive = false;
-        App.app.selection_mode = false;
+        App.window.selection_mode = false;
     }
 
     [GtkCallback]
diff --git a/src/topbar.vala b/src/topbar.vala
index f047331..09467f1 100644
--- a/src/topbar.vala
+++ b/src/topbar.vala
@@ -53,8 +53,8 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
     public void click_cancel_button () {
         switch (App.app.ui_state) {
         case UIState.COLLECTION:
-            if (App.app.selection_mode)
-                App.app.selection_mode = false;
+            if (App.window.selection_mode)
+                App.window.selection_mode = false;
             return;
         case UIState.WIZARD:
             wizard_toolbar.cancel_btn.clicked ();
@@ -98,8 +98,8 @@ private class Boxes.Topbar: Gtk.Stack, Boxes.UI {
     public void setup_ui () {
         assert (App.window != null);
 
-        App.app.notify["selection-mode"].connect (() => {
-            page = App.app.selection_mode ?
+        App.window.notify["selection-mode"].connect (() => {
+            page = App.window.selection_mode ?
                 TopbarPage.SELECTION : page = TopbarPage.COLLECTION;
         });
 


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