[gnome-shell/T27795: 24/138] Handle deprecated GSettings key org.gnome.shell.taskbar-pins gracefully



commit 262c467e8ab4de903979992255624c521575f9e6
Author: Mario Sanchez Prada <mario endlessm com>
Date:   Thu Sep 14 14:49:26 2017 +0100

    Handle deprecated GSettings key org.gnome.shell.taskbar-pins gracefully
    
    We introduced this key to split the dash from the taskbar icons in two
    separate lists that we could handle for pinning/unpinning purposes, but
    we are no longer using that so we can deprecated it now.
    
    Unfortunately, we can't simply ignore that key because that's where
    current users have their favorite apps configured, so we add this
    one-time hook to migrate any key that might be there into the actual
    key we'll be using from now on: 'favorite-apps' (from upstream).

 data/org.gnome.shell.gschema.xml.in | 11 ++++++++++-
 js/ui/appFavorites.js               |  9 +++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
---
diff --git a/data/org.gnome.shell.gschema.xml.in b/data/org.gnome.shell.gschema.xml.in
index cd7393bfe8..3fd4c818f5 100644
--- a/data/org.gnome.shell.gschema.xml.in
+++ b/data/org.gnome.shell.gschema.xml.in
@@ -124,7 +124,16 @@
         when a window is minimized.
       </description>
     </key>
-
+    <key name="taskbar-pins" type="as">
+      <default>[]</default>
+      <summary>List of desktop file IDs for applications pinned to taskbar (DEPRECATED)</summary>
+      <description>
+        The applications corresponding to these identifiers will be displayed in
+        the taskbar at the bottom of the Endless desktop. THIS IS DEPRECATED NOW:
+        any value in here will be automatically copied over to the favorite-apps
+        key by the shell on start, and then cleared from here.
+      </description>
+    </key>
     <child name="keybindings" schema="org.gnome.shell.keybindings"/>
   </schema>
 
diff --git a/js/ui/appFavorites.js b/js/ui/appFavorites.js
index 8bfebcfc12..cac84a0053 100644
--- a/js/ui/appFavorites.js
+++ b/js/ui/appFavorites.js
@@ -63,7 +63,16 @@ const RENAMED_DESKTOP_IDS = {
 class AppFavorites {
     constructor() {
         this.FAVORITE_APPS_KEY = 'favorite-apps';
+        this.TASKBAR_PINS_KEY_DEPRECATED = 'taskbar-pins';
         this._favorites = {};
+
+        // Handle deprecated taskbar-pins key gracefully, if present.
+        let oldIds = global.settings.get_strv(this.TASKBAR_PINS_KEY_DEPRECATED);
+        if (oldIds.length > 0) {
+            global.settings.set_strv(this.FAVORITE_APPS_KEY, oldIds);
+            global.settings.set_strv(this.TASKBAR_PINS_KEY_DEPRECATED, []);
+        }
+
         global.settings.connect(`changed::${this.FAVORITE_APPS_KEY}`, this._onFavsChanged.bind(this));
         this.reload();
     }


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