auto-move-windows/prefs: filter out apps that don't exist

Recognize if the desktop file no longer exists and remove its
entry in GSettings, instead of crashing because of a null GAppInfo.
This commit is contained in:
Giovanni Campagna
2012-04-29 21:11:00 +02:00
parent e3f1091f2d
commit f77bf60bcb

View File

@@ -183,9 +183,13 @@ const Widget = new GObject.Class({
this._store.clear();
let currentItems = this._settings.get_strv(SETTINGS_KEY);
let validItems = [ ];
for (let i = 0; i < currentItems.length; i++) {
let [id, index] = currentItems[i].split(':');
let appInfo = Gio.DesktopAppInfo.new(id);
if (!appInfo)
continue;
validItems.push(currentItems[i]);
let iter = this._store.append();
let adj = new Gtk.Adjustment({ lower: 1,
@@ -196,6 +200,9 @@ const Widget = new GObject.Class({
[Columns.APPINFO, Columns.ICON, Columns.DISPLAY_NAME, Columns.WORKSPACE, Columns.ADJUSTMENT],
[appInfo, appInfo.get_icon(), appInfo.get_display_name(), parseInt(index), adj]);
}
if (validItems.length != currentItems.length) // some items were filtered out
this._settings.set_strv(SETTINGS_KEY, validItems);
},
_appendItem: function(id, workspace) {