[polari/wip/fmuellner/fix-close-on-quit] appNotification: Fix account removal on quit



commit 13c8c3589574d16ba3c34d4f6258f333a5f859ac
Author: Florian Müllner <fmuellner gnome org>
Date:   Sat Oct 28 22:18:37 2017 +0200

    appNotification: Fix account removal on quit
    
    Application::prepare-shutdown is emitted when the window is destroyed,
    after all its children has been destroyed as well - any signal connected
    to an AppNotification has been disconnected by then, so even if we called
    close as intended it wouldn't have any effect. So to get the intended
    behavior, run close() when the notification is destroyed without being
    closed before.

 src/appNotifications.js | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
---
diff --git a/src/appNotifications.js b/src/appNotifications.js
index c7edff3..559f29c 100644
--- a/src/appNotifications.js
+++ b/src/appNotifications.js
@@ -1,4 +1,3 @@
-const Gio = imports.gi.Gio;
 const GObject = imports.gi.GObject;
 const Gtk = imports.gi.Gtk;
 const Pango = imports.gi.Pango;
@@ -76,26 +75,21 @@ var UndoNotification = GObject.registerClass({
         super._init(label);
 
         this._undo = false;
+        this._closed = false;
 
-        this.connect('destroy', Lang.bind(this, this._onDestroy));
+        this.connect('destroy', () => { this.close(); });
 
         this.addButton(_("Undo"), () => { this._undo = true; });
-
-        this._app = Gio.Application.get_default();
-        this._shutdownId = this._app.connect('prepare-shutdown',
-                                             Lang.bind(this, this.close));
     }
 
     close() {
+        if (this._closed)
+            return;
+
+        this._closed = true;
         this.emit(this._undo ? 'undo' : 'closed');
         super.close();
     }
-
-    _onDestroy() {
-        if (this._shutdownId)
-            this._app.disconnect(this._shutdownId);
-        this._shutdownId = 0;
-    }
 });
 
 var CommandOutputNotification = GObject.registerClass(


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