[polari/wip/fmuellner/window-experiments: 16/30] mainWindow: Move notification queues here



commit 45f0724a1275ac4c793056215391782c6aa7207d
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jul 14 06:23:08 2016 +0200

    mainWindow: Move notification queues here
    
    It is odd to have non-toplevel widgets managed by the application,
    and as widgets are restricted to a single parent, letting windows
    add some UI attached to a singleton won't work when we start allowing
    multiple windows.

 src/application.js |    6 ++----
 src/ircParser.js   |    2 +-
 src/mainWindow.js  |   11 +++++++----
 src/utils.js       |    2 +-
 4 files changed, 11 insertions(+), 10 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 9f1d613..a414751 100644
--- a/src/application.js
+++ b/src/application.js
@@ -57,8 +57,6 @@ const Application = new Lang.Class({
         this._settings = new Gio.Settings({ schema_id: 'org.gnome.Polari' });
 
         this.pasteManager = new PasteManager.PasteManager();
-        this.notificationQueue = new AppNotifications.NotificationQueue();
-        this.commandOutputQueue = new AppNotifications.CommandOutputQueue();
 
         let actionEntries = [
           { name: 'show-join-dialog',
@@ -237,7 +235,7 @@ const Application = new Lang.Class({
             let label = _("Failed to open link");
             let n = new AppNotifications.MessageNotification(label,
                                                              'dialog-error-symbolic');
-            this.notificationQueue.addNotification(n);
+            this.active_window.notificationQueue.addNotification(n);
         }
 
         return [success, server, port, room];
@@ -578,7 +576,7 @@ const Application = new Lang.Class({
             function() {
                 let label = _("%s removed.").format(account.display_name);
                 let n = new AppNotifications.UndoNotification(label);
-                this.notificationQueue.addNotification(n);
+                this.active_window.notificationQueue.addNotification(n);
 
                 n.connect('closed', function() {
                     account.remove_async(function(a, res) {
diff --git a/src/ircParser.js b/src/ircParser.js
index 2be4e04..425ee16 100644
--- a/src/ircParser.js
+++ b/src/ircParser.js
@@ -287,7 +287,7 @@ const IrcParser = new Lang.Class({
         }
 
         if (output)
-            this._app.commandOutputQueue.addNotification(output);
+            this._app.active_window.commandOutputQueue.addNotification(output);
         return retval;
     },
 
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 4fb8d9e..295051b 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -135,15 +135,17 @@ const MainWindow = new Lang.Class({
         this._isMaximized = false;
         this._isFullscreen = false;
 
-        let app = this.application;
-        this._overlay.add_overlay(app.notificationQueue);
-        this._overlay.add_overlay(app.commandOutputQueue);
+        this.notificationQueue = new AppNotifications.NotificationQueue();
+        this._overlay.add_overlay(this.notificationQueue);
+
+        this.commandOutputQueue = new AppNotifications.CommandOutputQueue();
+        this._overlay.add_overlay(this.commandOutputQueue);
 
         // command output notifications should not pop up over
         // the input area, but appear to emerge from it, so
         // set up an appropriate margin
         this._roomStack.bind_property('entry-area-height',
-                                      app.commandOutputQueue, 'margin-bottom',
+                                      this.commandOutputQueue, 'margin-bottom',
                                       GObject.BindingFlags.SYNC_CREATE);
 
         // Make sure user-list button is at least as wide as icon buttons
@@ -173,6 +175,7 @@ const MainWindow = new Lang.Class({
 
         this._updateUserListLabel();
 
+        let app = this.application;
         this._userListAction = app.lookup_action('user-list');
 
         app.connect('action-state-changed::user-list', Lang.bind(this,
diff --git a/src/utils.js b/src/utils.js
index edb9e5d..c431304 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -180,7 +180,7 @@ function openURL(url, timestamp) {
     } catch(e) {
         let n = new AppNotifications.SimpleOutput(_("Failed to open link"));
         let app = Gio.Application.get_default();
-        app.notificationQueue.addNotification(n);
+        app.active_window.notificationQueue.addNotification(n);
         debug("failed to open %s: %s".format(url, e.message));
     }
 }


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