[gnome-boxes] auth-notfication: Drop use of AppWindow singleton



commit 7d23555ee03653372d05e637008c07f230cc4f41
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Fri Jul 18 08:38:26 2014 +0200

    auth-notfication: Drop use of AppWindow singleton
    
    Instead of using the AppWindow singleton to access the Searchbar,
    AuthNotification now has its own reference to Searchbar that it receives
    through a parameter to its constructor.
    
    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        |    1 +
 src/auth-notification.vala |   11 ++++++++---
 src/notificationbar.vala   |    5 ++++-
 3 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index e4e04e5..f0730fc 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -110,6 +110,7 @@ private class Boxes.AppWindow: Gtk.ApplicationWindow, Boxes.UI {
         display_page.setup_ui (this);
         view.setup_ui (this);
         selectionbar.setup_ui (this);
+        notificationbar.searchbar = searchbar;
     }
 
     private void save_window_geometry () {
diff --git a/src/auth-notification.vala b/src/auth-notification.vala
index c91f1f9..7dbc2d0 100644
--- a/src/auth-notification.vala
+++ b/src/auth-notification.vala
@@ -19,10 +19,13 @@ private class Boxes.AuthNotification: Gd.Notification {
     private AuthFunc? auth_func;
     private bool auth_pressed;
 
+    private Searchbar searchbar;
+
     public AuthNotification (string                         auth_string,
                              owned AuthFunc?                auth_func,
                              owned Notification.CancelFunc? cancel_func,
-                             bool                           need_username) {
+                             bool                           need_username,
+                             Searchbar                      searchbar) {
         show_close_button = false; // FIXME: Seems setting this from .UI file doesn't work
         title_label.label = auth_string;
 
@@ -35,18 +38,20 @@ private class Boxes.AuthNotification: Gd.Notification {
         username_entry.visible = need_username;
 
         this.auth_func = (owned) auth_func;
+
+        this.searchbar = searchbar;
     }
 
     [GtkCallback]
     private bool on_entry_focus_in_event () {
-        App.window.searchbar.enable_key_handler = false;
+        searchbar.enable_key_handler = false;
 
         return false;
     }
 
     [GtkCallback]
     private bool on_entry_focus_out_event () {
-        App.window.searchbar.enable_key_handler = true;
+        searchbar.enable_key_handler = true;
 
         return false;
     }
diff --git a/src/notificationbar.vala b/src/notificationbar.vala
index 44d1a38..462322c 100644
--- a/src/notificationbar.vala
+++ b/src/notificationbar.vala
@@ -6,6 +6,8 @@ private class Boxes.Notificationbar: Gtk.Grid {
 
     GLib.List<Widget> active_notifications;
 
+    public Searchbar searchbar;
+
     construct {
         valign = Gtk.Align.START;
         halign = Gtk.Align.CENTER;
@@ -53,7 +55,8 @@ private class Boxes.Notificationbar: Gtk.Grid {
         var notification = new Boxes.AuthNotification (auth_string,
                                                        (owned) auth_func,
                                                        (owned) cancel_func,
-                                                       need_username);
+                                                       need_username,
+                                                       searchbar);
 
         active_notifications.prepend (notification);
 


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