Compare commits
3 Commits
citadel
...
wip/fmuell
Author | SHA1 | Date | |
---|---|---|---|
|
3f5f4d8a44 | ||
|
1f21516021 | ||
|
901a089b45 |
@ -1,5 +1,6 @@
|
|||||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||||
|
|
||||||
|
const AppStream = imports.gi.AppStreamGlib;
|
||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
@ -8,42 +9,16 @@ const Main = imports.ui.main;
|
|||||||
|
|
||||||
// In alphabetical order
|
// In alphabetical order
|
||||||
const RENAMED_DESKTOP_IDS = {
|
const RENAMED_DESKTOP_IDS = {
|
||||||
'baobab.desktop': 'org.gnome.baobab.desktop',
|
|
||||||
'cheese.desktop': 'org.gnome.Cheese.desktop',
|
|
||||||
'dconf-editor.desktop': 'ca.desrt.dconf-editor.desktop',
|
|
||||||
'empathy.desktop': 'org.gnome.Empathy.desktop',
|
'empathy.desktop': 'org.gnome.Empathy.desktop',
|
||||||
'epiphany.desktop': 'org.gnome.Epiphany.desktop',
|
'epiphany.desktop': 'org.gnome.Epiphany.desktop',
|
||||||
'evolution.desktop': 'org.gnome.Evolution.desktop',
|
'evolution.desktop': 'org.gnome.Evolution.desktop',
|
||||||
'file-roller.desktop': 'org.gnome.FileRoller.desktop',
|
|
||||||
'gcalctool.desktop': 'org.gnome.Calculator.desktop',
|
'gcalctool.desktop': 'org.gnome.Calculator.desktop',
|
||||||
'geary.desktop': 'org.gnome.Geary.desktop',
|
'geary.desktop': 'org.gnome.Geary.desktop',
|
||||||
'gedit.desktop': 'org.gnome.gedit.desktop',
|
|
||||||
'glchess.desktop': 'gnome-chess.desktop',
|
|
||||||
'glines.desktop': 'five-or-more.desktop',
|
|
||||||
'gnect.desktop': 'four-in-a-row.desktop',
|
|
||||||
'gnibbles.desktop': 'org.gnome.Nibbles.desktop',
|
'gnibbles.desktop': 'org.gnome.Nibbles.desktop',
|
||||||
'gnobots2.desktop': 'gnome-robots.desktop',
|
|
||||||
'gnome-boxes.desktop': 'org.gnome.Boxes.desktop',
|
|
||||||
'gnome-calculator.desktop': 'org.gnome.Calculator.desktop',
|
'gnome-calculator.desktop': 'org.gnome.Calculator.desktop',
|
||||||
'gnome-clocks.desktop': 'org.gnome.clocks.desktop',
|
|
||||||
'gnome-contacts.desktop': 'org.gnome.Contacts.desktop',
|
|
||||||
'gnome-documents.desktop': 'org.gnome.Documents.desktop',
|
|
||||||
'gnome-font-viewer.desktop': 'org.gnome.font-viewer.desktop',
|
|
||||||
'gnome-nibbles.desktop': 'org.gnome.Nibbles.desktop',
|
'gnome-nibbles.desktop': 'org.gnome.Nibbles.desktop',
|
||||||
'gnome-music.desktop': 'org.gnome.Music.desktop',
|
'gnome-music.desktop': 'org.gnome.Music.desktop',
|
||||||
'gnome-photos.desktop': 'org.gnome.Photos.desktop',
|
|
||||||
'gnome-screenshot.desktop': 'org.gnome.Screenshot.desktop',
|
|
||||||
'gnome-software.desktop': 'org.gnome.Software.desktop',
|
|
||||||
'gnome-terminal.desktop': 'org.gnome.Terminal.desktop',
|
|
||||||
'gnome-tweaks.desktop': 'org.gnome.tweaks.desktop',
|
'gnome-tweaks.desktop': 'org.gnome.tweaks.desktop',
|
||||||
'gnome-weather.desktop': 'org.gnome.Weather.Application.desktop',
|
|
||||||
'gnomine.desktop': 'gnome-mines.desktop',
|
|
||||||
'gnotravex.desktop': 'gnome-tetravex.desktop',
|
|
||||||
'gnotski.desktop': 'gnome-klotski.desktop',
|
|
||||||
'gtali.desktop': 'tali.desktop',
|
|
||||||
'nautilus.desktop': 'org.gnome.Nautilus.desktop',
|
|
||||||
'polari.desktop': 'org.gnome.Polari.desktop',
|
|
||||||
'totem.desktop': 'org.gnome.Totem.desktop',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var AppFavorites = new Lang.Class({
|
var AppFavorites = new Lang.Class({
|
||||||
@ -52,6 +27,21 @@ var AppFavorites = new Lang.Class({
|
|||||||
FAVORITE_APPS_KEY: 'favorite-apps',
|
FAVORITE_APPS_KEY: 'favorite-apps',
|
||||||
|
|
||||||
_init() {
|
_init() {
|
||||||
|
let loadFlags = AppStream.StoreLoadFlags.APP_INFO_SYSTEM |
|
||||||
|
AppStream.StoreLoadFlags.APP_INFO_USER |
|
||||||
|
AppStream.StoreLoadFlags.APPDATA |
|
||||||
|
AppStream.StoreLoadFlags.DESKTOP;
|
||||||
|
this._appDataReady = false;
|
||||||
|
this._appDataStore = new AppStream.Store();
|
||||||
|
this._appDataStore.load_async(loadFlags, null, (store, res) => {
|
||||||
|
try {
|
||||||
|
this._appDataReady = store.load_finish(res);
|
||||||
|
this.reload();
|
||||||
|
} catch(e) {
|
||||||
|
log('Failed to load AppData store: ' + e.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this._favorites = {};
|
this._favorites = {};
|
||||||
global.settings.connect('changed::' + this.FAVORITE_APPS_KEY, this._onFavsChanged.bind(this));
|
global.settings.connect('changed::' + this.FAVORITE_APPS_KEY, this._onFavsChanged.bind(this));
|
||||||
this.reload();
|
this.reload();
|
||||||
@ -69,12 +59,26 @@ var AppFavorites = new Lang.Class({
|
|||||||
// Map old desktop file names to the current ones
|
// Map old desktop file names to the current ones
|
||||||
let updated = false;
|
let updated = false;
|
||||||
ids = ids.map(id => {
|
ids = ids.map(id => {
|
||||||
let newId = RENAMED_DESKTOP_IDS[id];
|
let appData = null;
|
||||||
|
if (this._appDataReady)
|
||||||
|
appData = this._appDataStore.get_app_by_id_with_fallbacks(id) ||
|
||||||
|
this._appDataStore.get_app_by_provide(AppStream.ProvideKind.ID, id);
|
||||||
|
|
||||||
|
let newId = appData != null ? appData.get_id() : undefined;
|
||||||
|
if (newId !== undefined &&
|
||||||
|
newId !== id &&
|
||||||
|
appSys.lookup_app(newId) != null) {
|
||||||
|
updated = true;
|
||||||
|
return newId;
|
||||||
|
}
|
||||||
|
|
||||||
|
newId = RENAMED_DESKTOP_IDS[id];
|
||||||
if (newId !== undefined &&
|
if (newId !== undefined &&
|
||||||
appSys.lookup_app(newId) != null) {
|
appSys.lookup_app(newId) != null) {
|
||||||
updated = true;
|
updated = true;
|
||||||
return newId;
|
return newId;
|
||||||
}
|
}
|
||||||
|
|
||||||
return id;
|
return id;
|
||||||
});
|
});
|
||||||
// ... and write back the updated desktop file names
|
// ... and write back the updated desktop file names
|
||||||
|
Loading…
Reference in New Issue
Block a user