[gnome-shell/wip/rstrode/login-screen-extensions: 55/134] extensionSystem: Show notification when updates are available




commit 64c7548ecce321bb6c069959e0ff9eb721162f91
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Jan 26 23:47:24 2020 +0100

    extensionSystem: Show notification when updates are available
    
    Now that the extensions app has the ability to handle updates, we
    can use it as source of updates notifications.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/issues/1968

 js/ui/extensionSystem.js | 39 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 38 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index 36a248dc16..805e08caea 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -1,11 +1,12 @@
 // -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
 
-const { GLib, Gio, St } = imports.gi;
+const { GLib, Gio, GObject, St } = imports.gi;
 const Signals = imports.signals;
 
 const ExtensionUtils = imports.misc.extensionUtils;
 const FileUtils = imports.misc.fileUtils;
 const Main = imports.ui.main;
+const MessageTray = imports.ui.messageTray;
 
 const { ExtensionState, ExtensionType } = ExtensionUtils;
 
@@ -17,6 +18,7 @@ var ExtensionManager = class {
     constructor() {
         this._initted = false;
         this._enabled = false;
+        this._updateNotified = false;
 
         this._extensions = new Map();
         this._enabledExtensions = [];
@@ -173,6 +175,18 @@ var ExtensionManager = class {
 
         extension.hasUpdate = true;
         this.emit('extension-state-changed', extension);
+
+        if (!this._updateNotified) {
+            this._updateNotified = true;
+
+            let source = new ExtensionUpdateSource();
+            Main.messageTray.add(source);
+
+            let notification = new MessageTray.Notification(source,
+                _('Extension Updates Available'),
+                _('Extension updates are ready to be installed.'));
+            source.notify(notification);
+        }
     }
 
     logExtensionError(uuid, error) {
@@ -521,3 +535,26 @@ var ExtensionManager = class {
     }
 };
 Signals.addSignalMethods(ExtensionManager.prototype);
+
+class ExtensionUpdateSource extends MessageTray.Source {
+    constructor() {
+        const appSys = Shell.AppSystem.get_default();
+        this._app = appSys.lookup_app('gnome-shell-extension-prefs.desktop');
+
+        super(this._app.get_name());
+    }
+
+    getIcon() {
+        return this._app.app_info.get_icon();
+    }
+
+    _createPolicy() {
+        return new MessageTray.NotificationApplicationPolicy(this._app.id);
+    }
+
+    open() {
+        this._app.activate();
+        Main.overview.hide();
+        Main.panel.closeCalendar();
+    }
+}


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