[gnome-shell/T27795: 49/138] iconGridLayout: Add support for a destroy callback in ShellInfo



commit 1f6216350fd141a36784415399164ac1465ddf86
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Fri Jun 30 01:23:56 2017 +0000

    iconGridLayout: Add support for a destroy callback in ShellInfo
    
    This is required to properly implement the removeIcon() method in
    IconGridLayout, which uses it to provide an "Undo" functionality
    when removing an icon from the desktop.
    
    https://phabricator.endlessm.com/T17661

 js/ui/overview.js | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
---
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 492c3e7315..9bdee7c696 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -31,6 +31,14 @@ var ShellInfo = class {
     constructor() {
         this._source = null;
         this._undoCallback = null;
+        this._destroyCallback = null;
+    }
+
+    _onDestroy() {
+        if (this._destroyCallback)
+            this._destroyCallback();
+
+        this._destroyCallback = null;
     }
 
     _onUndoClicked() {
@@ -46,10 +54,12 @@ var ShellInfo = class {
         options = Params.parse(options, {
             undoCallback: null,
             forFeedback: false,
+            destroyCallback: null,
         });
 
         let undoCallback = options.undoCallback;
         let forFeedback = options.forFeedback;
+        let destroyCallback = options.destroyCallback;
 
         if (this._source == null) {
             this._source = new MessageTray.SystemNotificationSource();
@@ -65,10 +75,17 @@ var ShellInfo = class {
             notification.setTransient(true);
             notification.setForFeedback(forFeedback);
         } else {
+            // as we reuse the notification, ensure that the previous _destroyCallback() is called
+            if (this._destroyCallback)
+                this._destroyCallback();
+
             notification = this._source.notifications[0];
             notification.update(text, null, { clear: true });
         }
 
+        this._destroyCallback = destroyCallback;
+        notification.connect('destroy', this._onDestroy.bind(this));
+
         this._undoCallback = undoCallback;
         if (undoCallback)
             notification.addAction(_("Undo"), this._onUndoClicked.bind(this));


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