[polari/gnome-3-22] app: Stop using a private property to track the main window



commit 4e12776fc2fd99cc9087026e8b145e74620d712e
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jul 14 16:04:43 2016 +0200

    app: Stop using a private property to track the main window
    
    We will eventually allow running without open windows, and possibly
    with multiple windows as well, at which point using a private property
    to track the main window gets in the way more than it helps, so adapt
    the code to either use the :active-window or iterate over all windows
    as appropriate.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=770749

 src/application.js |   33 ++++++++++++++++-----------------
 1 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 898bff0..c6d19e2 100644
--- a/src/application.js
+++ b/src/application.js
@@ -30,7 +30,6 @@ const Application = new Lang.Class({
                       flags: Gio.ApplicationFlags.HANDLES_OPEN });
 
         GLib.set_application_name('Polari');
-        this._window = null;
         this._retryData = new Map();
     },
 
@@ -153,17 +152,17 @@ const Application = new Lang.Class({
             this._telepathyClient = new TelepathyClient.TelepathyClient(params);
         }
 
-        if (!this._window) {
-            this._window = new MainWindow.MainWindow({ application: this });
-            this._window.connect('destroy',
-                                 () => { this.emit('prepare-shutdown'); });
-            this._window.connect('notify::active-room',
-                                 () => { this.emit('room-focus-changed'); });
-            this._window.connect('notify::is-active',
-                                 () => { this.emit('room-focus-changed'); });
-            this._window.show_all();
+        if (!this.active_window) {
+            let window = new MainWindow.MainWindow({ application: this });
+            window.connect('destroy',
+                           () => { this.emit('prepare-shutdown'); });
+            window.connect('notify::active-room',
+                           () => { this.emit('room-focus-changed'); });
+            window.connect('notify::is-active',
+                           () => { this.emit('room-focus-changed'); });
+            window.show_all();
         }
-        this._window.present();
+        this.active_window.present();
     },
 
     vfunc_window_added: function(window) {
@@ -294,13 +293,13 @@ const Application = new Lang.Class({
     },
 
     _onShowJoinDialog: function() {
-        this._window.showJoinRoomDialog();
+        this.active_window.showJoinRoomDialog();
     },
 
     _maybePresent: function(time) {
         let [present, ] = Tp.user_action_time_should_present(time);
 
-        if (!this._window || present)
+        if (!this.active_window || present)
             this.activate();
     },
 
@@ -417,7 +416,7 @@ const Application = new Lang.Class({
     },
 
     _onLeaveCurrentRoom: function() {
-        let room = this._window.active_room;
+        let room = this.active_window.active_room;
         if (!room)
             return;
         let action = this.lookup_action('leave-room');
@@ -463,7 +462,7 @@ const Application = new Lang.Class({
         let accountPath = parameter.deep_unpack();
         let account = this._accountsMonitor.lookupAccount(accountPath);
         let dialog = new Connections.ConnectionProperties(account);
-        dialog.transient_for = this._window;
+        dialog.transient_for = this.active_window;
         dialog.connect('response', Lang.bind(this,
             function(w, response) {
                 w.destroy();
@@ -509,7 +508,7 @@ const Application = new Lang.Class({
             website_label: _("Learn more about Polari"),
             website: 'https://wiki.gnome.org/Apps/Polari',
 
-            transient_for: this._window,
+            transient_for: this.active_window,
             modal: true
         };
 
@@ -522,6 +521,6 @@ const Application = new Lang.Class({
     },
 
     _onQuit: function() {
-        this._window.destroy();
+        this.get_windows().reverse().forEach(w => { w.destroy(); });
     }
 });


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