[polari] appNotification: Dismiss undo notifications on shutdown



commit fec3606455503b03f73ef9220b1b1d74c9b8c11e
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Mar 17 16:31:37 2016 +0100

    appNotification: Dismiss undo notifications on shutdown
    
    When the user removes an account, we only hide it initially to give
    the user the chance to undo the action. Currently when we quit while
    the undo notification is still shown, the account gets stuck in the
    hidden state - make sure to properly dismiss the notification in that
    case so that the hidden account is actually removed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=763872

 src/appNotifications.js |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/src/appNotifications.js b/src/appNotifications.js
index cceeba1..c94348e 100644
--- a/src/appNotifications.js
+++ b/src/appNotifications.js
@@ -1,3 +1,4 @@
+const Gio = imports.gi.Gio;
 const Gtk = imports.gi.Gtk;
 const Pango = imports.gi.Pango;
 const Tp = imports.gi.TelepathyGLib;
@@ -79,15 +80,26 @@ const UndoNotification = new Lang.Class({
 
         this._undo = false;
 
+        this.connect('destroy', Lang.bind(this, this._onDestroy));
+
         this.addButton(_("Undo"), Lang.bind(this, function() {
             this._undo = true;
         }));
 
+        this._app = Gio.Application.get_default();
+        this._shutdownId = this._app.connect('prepare-shutdown',
+                                             Lang.bind(this, this.close));
     },
 
     close: function() {
         this.emit(this._undo ? 'undo' : 'closed');
         this.parent();
+    },
+
+    _onDestroy: function() {
+        if (this._shutdownId)
+            this._app.disconnect(this._shutdownId);
+        this._shutdownId = 0;
     }
 });
 


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