dash: Improve DND to dash and allow reordering

Show a positional indicator where a new favorite will be added and
make the favorites re-orderable. Also allow the removal of favorites
using drag-and-drop according to the mockups.

https://bugzilla.gnome.org/show_bug.cgi?id=634948
This commit is contained in:
Florian Müllner
2010-11-08 02:51:02 +01:00
parent 5fef9188c9
commit b59daac6f3
6 changed files with 318 additions and 17 deletions

View File

@ -63,7 +63,7 @@ AppFavorites.prototype = {
return appId in this._favorites;
},
_addFavorite: function(appId) {
_addFavorite: function(appId, pos) {
if (appId in this._favorites)
return false;
@ -73,14 +73,17 @@ AppFavorites.prototype = {
return false;
let ids = this._getIds();
ids.push(appId);
if (pos == -1)
ids.push(appId);
else
ids.splice(pos, 0, appId);
global.settings.set_strv(this.FAVORITE_APPS_KEY, ids);
this._favorites[appId] = app;
return true;
},
addFavorite: function(appId) {
if (!this._addFavorite(appId))
addFavoriteAtPos: function(appId, pos) {
if (!this._addFavorite(appId, pos))
return;
let app = Shell.AppSystem.get_default().get_app(appId);
@ -90,6 +93,15 @@ AppFavorites.prototype = {
}));
},
addFavorite: function(appId) {
this.addFavoriteAtPos(appId, -1);
},
moveFavoriteToPos: function(appId, pos) {
this._removeFavorite(appId);
this._addFavorite(appId, pos);
},
_removeFavorite: function(appId) {
if (!appId in this._favorites)
return false;
@ -100,13 +112,16 @@ AppFavorites.prototype = {
},
removeFavorite: function(appId) {
let ids = this._getIds();
let pos = ids.indexOf(appId);
let app = this._favorites[appId];
if (!this._removeFavorite(appId))
return;
Main.overview.shellInfo.setMessage(_("%s has been removed from your favorites.").format(app.get_name()),
Lang.bind(this, function () {
this._addFavorite(appId);
this._addFavorite(appId, pos);
}));
}
};