[polari/wip/fmuellner/window-experiments: 347/356] mainWindow: Move notification queues here



commit f1c0676d34e212a0a8215e931c64490aefe6b49a
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. Just let the window manage its own notification
    queues and access them through the apps' :active-window property.

 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 3cb65ad..4b1084b 100644
--- a/src/application.js
+++ b/src/application.js
@@ -237,8 +237,6 @@ const Application = new Lang.Class({
                                       Lang.bind(this, this._onAccountStatusChanged));
 
         this.pasteManager = new PasteManager.PasteManager();
-        this.notificationQueue = new AppNotifications.NotificationQueue();
-        this.commandOutputQueue = new AppNotifications.CommandOutputQueue();
 
         let provider = new Gtk.CssProvider();
         let uri = 'resource:///org/gnome/Polari/css/application.css';
@@ -347,7 +345,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];
@@ -553,7 +551,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 0f39e86..31d7b84 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 229c3fb..ac54726 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -141,15 +141,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
@@ -176,6 +178,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 afa86b2..40b2583 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -183,7 +183,7 @@ function openURL(url, timestamp) {
             Gtk.show_uri (Gdk.Screen.get_default(), url, timestamp);
     } catch(e) {
         let n = new AppNotifications.SimpleOutput(_("Failed to open link"));
-        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]