[gnome-boxes] selectionbar: Drop use of AppWindow singleton



commit 57fa554aefc9b52cc7e8a72b28205b46108b31ce
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Jul 18 08:22:43 2014 +0200

    selectionbar: Drop use of AppWindow singleton
    
    Instead of using the AppWindow singleton, Selectionbar 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/selectionbar.vala |   18 +++++++++++-------
 2 files changed, 12 insertions(+), 8 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index 12588c3..e4e04e5 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -109,7 +109,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
         wizard.setup_ui (this);
         display_page.setup_ui (this);
         view.setup_ui (this);
-        selectionbar.setup_ui ();
+        selectionbar.setup_ui (this);
     }
 
     private void save_window_geometry () {
diff --git a/src/selectionbar.vala b/src/selectionbar.vala
index ef56a1a..e979067 100644
--- a/src/selectionbar.vala
+++ b/src/selectionbar.vala
@@ -12,6 +12,8 @@ private class Boxes.Selectionbar: Gtk.Revealer {
     [GtkChild]
     private Gtk.Button properties_btn;
 
+    private AppWindow window;
+
     construct {
         App.app.notify["selected-items"].connect (() => {
             update_favorite_btn ();
@@ -21,9 +23,11 @@ private class Boxes.Selectionbar: Gtk.Revealer {
         });
     }
 
-    public void setup_ui () {
-        App.window.notify["selection-mode"].connect (() => {
-            reveal_child = App.window.selection_mode;
+    public void setup_ui (AppWindow window) {
+        this.window = window;
+
+        window.notify["selection-mode"].connect (() => {
+            reveal_child = window.selection_mode;
         });
     }
 
@@ -40,7 +44,7 @@ private class Boxes.Selectionbar: Gtk.Revealer {
             machine.config.set_category ("favorite", favorite_btn.active);
         }
 
-        App.window.selection_mode = false;
+        window.selection_mode = false;
     }
 
     [GtkCallback]
@@ -53,13 +57,13 @@ private class Boxes.Selectionbar: Gtk.Revealer {
                 try {
                     machine.save.end (result);
                 } catch (GLib.Error e) {
-                    App.window.notificationbar.display_error (_("Pausing '%s' failed").printf 
(machine.name));
+                    window.notificationbar.display_error (_("Pausing '%s' failed").printf (machine.name));
                 }
             });
         }
 
         pause_btn.sensitive = false;
-        App.window.selection_mode = false;
+        window.selection_mode = false;
     }
 
     [GtkCallback]
@@ -69,7 +73,7 @@ private class Boxes.Selectionbar: Gtk.Revealer {
 
     [GtkCallback]
     private void on_properties_btn_clicked () {
-        App.window.show_properties ();
+        window.show_properties ();
     }
 
     private void update_favorite_btn () {


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