From cceac0d8fbce8caa5e631c6204e0b2e0e4522bb3 Mon Sep 17 00:00:00 2001 From: Kalev Lember Date: Tue, 22 Jul 2014 14:16:48 +0200 Subject: [PATCH] appFavorites: Automatically update desktop file names in user settings This adds a table with mappings for GNOME apps that have recently renamed their desktop files, and uses that to update the desktop names saved in user settings with the new values. https://bugzilla.gnome.org/show_bug.cgi?id=729429 --- js/ui/appFavorites.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/js/ui/appFavorites.js b/js/ui/appFavorites.js index b3896213c..77e3c5595 100644 --- a/js/ui/appFavorites.js +++ b/js/ui/appFavorites.js @@ -6,6 +6,26 @@ const Signals = imports.signals; const Main = imports.ui.main; +const RENAMED_DESKTOP_IDS = { + 'baobab.desktop': 'org.gnome.baobab.desktop', + 'cheese.desktop': 'org.gnome.Cheese.desktop', + 'dconf-editor.desktop': 'ca.desrt.dconf-editor.desktop', + 'file-roller.desktop': 'org.gnome.FileRoller.desktop', + 'gcalctool.desktop': 'gnome-calculator.desktop', + 'gedit.desktop': 'org.gnome.gedit.desktop', + 'glchess.desktop': 'gnome-chess.desktop', + 'gnome-clocks.desktop': 'org.gnome.clocks.desktop', + 'gnome-documents.desktop': 'org.gnome.Documents.desktop', + 'gnome-font-viewer.desktop': 'org.gnome.font-viewer.desktop', + 'gnome-photos.desktop': 'org.gnome.Photos.desktop', + 'gnome-screenshot.desktop': 'org.gnome.Screenshot.desktop', + 'gnome-software.desktop': 'org.gnome.Software.desktop', + 'gnome-weather.desktop': 'org.gnome.Weather.Application.desktop', + 'gnomine.desktop': 'gnome-mines.desktop', + 'nautilus.desktop': 'org.gnome.Nautilus.desktop', + 'polari.desktop': 'org.gnome.Polari.desktop', +}; + const AppFavorites = new Lang.Class({ Name: 'AppFavorites', @@ -24,6 +44,21 @@ const AppFavorites = new Lang.Class({ reload: function() { let ids = global.settings.get_strv(this.FAVORITE_APPS_KEY); + + // Map old desktop file names to the current ones + let updated = false; + ids = ids.map(function (id) { + let newId = RENAMED_DESKTOP_IDS[id]; + if (newId !== undefined) { + updated = true; + return newId; + } + return id; + }); + // ... and write back the updated desktop file names + if (updated) + global.settings.set_strv(this.FAVORITE_APPS_KEY, ids); + let appSys = Shell.AppSystem.get_default(); let apps = ids.map(function (id) { return appSys.lookup_app(id);