Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Remove from panel #319

Closed
wants to merge 3 commits into from

2 participants

@doverton51

Changed menu.js so that the context menu displays "Remove From Panel" if the app is already in the panel, and removes it when clicked.

@clefebvre
Owner

Thanks for the commits on this. However I find them overkill. This can be achieved by using the context menu on the panel launchers themselves, where it feels more natural.

Of course, the same could be said about the favorites... but we keep the remove there for now as we're not 100% happy with the favorites context menu and the way it shows up.

@clefebvre clefebvre closed this
@doverton51

That's fair enough - I guess the main reason I wanted this in was because it allowed me to quickly remove something I'd added to the panel by accident, without leaving the menu. Also I can't see any utility in being able to add the same app to the panel several times.

Maybe the 'Add to Panel' option should be removed if the app is in the panel already?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 9, 2012
  1. @doverton51
Commits on Feb 11, 2012
  1. @doverton51
Commits on Feb 12, 2012
  1. @doverton51
This page is out of date. Refresh to see the latest.
Showing with 23 additions and 4 deletions.
  1. +23 −4 js/ui/menu.js
View
27 js/ui/menu.js
@@ -47,13 +47,22 @@ ApplicationContextMenuItem.prototype = {
},
activate: function (event) {
+ let settings;
+ let desktopFiles;
+
switch (this._action){
case "add_to_panel":
- let settings = new Gio.Settings({ schema: 'org.cinnamon' });
- let desktopFiles = settings.get_strv('panel-launchers');
+ settings = new Gio.Settings({ schema: 'org.cinnamon' });
+ desktopFiles = settings.get_strv('panel-launchers');
desktopFiles.push(this._appButton.app.get_id());
settings.set_strv('panel-launchers', desktopFiles);
break;
+ case "remove_from_panel":
+ settings = new Gio.Settings({ schema: 'org.cinnamon' });
+ desktopFiles = settings.get_strv('panel-launchers');
+ desktopFiles.splice(desktopFiles.indexOf(this._appButton.app.get_id()),1)
+ settings.set_strv('panel-launchers', desktopFiles);
+ break;
case "add_to_desktop":
let file = Gio.file_new_for_path(this._appButton.app.get_app_info().get_filename());
let destFile = Gio.file_new_for_path(USER_DESKTOP_PATH+"/"+this._appButton.app.get_id());
@@ -123,8 +132,18 @@ GenericApplicationButton.prototype = {
children[i].destroy();
}
let menuItem;
- menuItem = new ApplicationContextMenuItem(this, _("Add to panel"), "add_to_panel");
- this.menu.addMenuItem(menuItem);
+
+ let settings = new Gio.Settings({ schema: 'org.cinnamon' });
+ let desktopFiles = settings.get_strv('panel-launchers');
+
+ if (desktopFiles.indexOf(this.app.get_id()) == -1){
+ menuItem = new ApplicationContextMenuItem(this, _("Add to panel"), "add_to_panel");
+ this.menu.addMenuItem(menuItem);
+ }else{
+ menuItem = new ApplicationContextMenuItem(this, _("Remove from panel"), "remove_from_panel");
+ this.menu.addMenuItem(menuItem);
+ }
+
if (USER_DESKTOP_PATH){
menuItem = new ApplicationContextMenuItem(this, _("Add to desktop"), "add_to_desktop");
this.menu.addMenuItem(menuItem);
Something went wrong with that request. Please try again.