[gnome-shell/eos3.8: 37/255] iconGridLayout: Add support for a destroy callback in ShellInfo



commit fc285e88ec084f55bbfc0b0e1cd638ea1b1f14fb
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 9863d14c10..a0a32a9320 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -30,6 +30,14 @@ var ShellInfo = class {
     constructor() {
         this._source = null;
         this._undoCallback = null;
+        this._destroyCallback = null;
+    }
+
+    _onDestroy() {
+        if (this._destroyCallback)
+            this._destroyCallback();
+
+        this._destroyCallback = null;
     }
 
     _onUndoClicked() {
@@ -45,10 +53,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();
@@ -64,10 +74,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]