SOLVED Reorder panel launcher order (right-click menu)

Please post suggestions for improvement of Cinnamon here
https://github.com/linuxmint/Cinnamon
Post Reply
arnad
Level 1
Level 1
Posts: 23
Joined: Sun Mar 26, 2017 1:59 pm

SOLVED Reorder panel launcher order (right-click menu)

Post by arnad » Fri Nov 02, 2018 7:08 am

Linux Mint 19 Cinnamon

Hello everyone,

when I right-click on the panel launchers (e.g. Firefox), the applications-specific functions (e.g. Open a New Window, Open a New Private Window) are all the way on top, with the general functions (Launch, Add, Edit, Remove, Preferences) being closer to the task bar. Is it possible to change this order? I am usually using the application-specific functions and would like them closer to the task bar for faster access.

Basically, I would like to change it from this:
current.png
current.png (7.51 KiB) Viewed 151 times
to this:
wish.png
wish.png (7.49 KiB) Viewed 151 times
Greetings,

Arnad
Last edited by arnad on Tue Nov 06, 2018 9:29 am, edited 2 times in total.

Hoser Rob
Level 12
Level 12
Posts: 4456
Joined: Sat Dec 15, 2012 8:57 am

Re: Reorder panel launcher order (right-click menu)

Post by Hoser Rob » Fri Nov 02, 2018 9:49 am

You don't say which DE version you're using but I've never heard of this in any Linux DE. Linux is highly configurable but all that stiuff about you being able to do anything you want in Linux ain't true. In any case I suspect such a feature would slow the machine down more than you clicking the right item so there wouldn't be any point anyway really.

arnad
Level 1
Level 1
Posts: 23
Joined: Sun Mar 26, 2017 1:59 pm

Re: Reorder panel launcher order (right-click menu)

Post by arnad » Fri Nov 02, 2018 9:59 am

Edited the original post to include my version: Linux Mint 19 Cinnamon.
Hoser Rob wrote:
Fri Nov 02, 2018 9:49 am
In any case I suspect such a feature would slow the machine down more than you clicking the right item so there wouldn't be any point anyway really.
Why would it slow the machine? The order it is in currently must be configured in some file, so changing this should change the order, no? I am not averse to digging into config files or recompiling stuff if necessary.

User avatar
smurphos
Level 8
Level 8
Posts: 2215
Joined: Fri Sep 05, 2014 12:18 am
Location: Britisher...

Re: Reorder panel launcher order (right-click menu)

Post by smurphos » Sat Nov 03, 2018 1:09 am

Hi - this is a relatively straightforward edit of the panel-launcher applet's javascript.

1) Make a copy of the original applet in your local users applet folder
cp -r /usr/share/cinnamon/applets/panel-launchers@cinnamon.org ~/.local/share/cinnamon/applets

2) Open applet.js in a text editor.
xed ~/.local/share/cinnamon/applets/panel-launchers@cinnamon.org/applet.js

3) Navigate to this section and reorder as you wish. Save and then restart Cinnamon with Ctrl-Alt-Esc

Original...

Code: Select all

class PanelAppLauncherMenu extends Applet.AppletPopupMenu {
    constructor(launcher, orientation) {
        super(launcher, orientation);
        this._launcher = launcher;

        let appinfo = this._launcher.getAppInfo();

        this._actions = appinfo.list_actions();
        if (this._actions.length > 0) {
            for (let i = 0; i < this._actions.length; i++) {
                let actionName = this._actions[i];
                this.addAction(appinfo.get_action_name(actionName), Lang.bind(this, this._launchAction, actionName));
            }

            this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
        }

        let item = new PopupMenu.PopupIconMenuItem(_("Launch"), "media-playback-start", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onLaunchActivate));
        this.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Add"), "list-add", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onAddActivate));
        this.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Edit"), "document-properties", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onEditActivate));
        this.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Remove"), "window-close", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onRemoveActivate));
        this.addMenuItem(item);

        this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());

        let subMenu = new PopupMenu.PopupSubMenuMenuItem(_("Preferences"));
        this.addMenuItem(subMenu);

        item = new PopupMenu.PopupIconMenuItem(_("About..."), "dialog-question", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this._launcher._applet, this._launcher._applet.openAbout));
        subMenu.menu.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Configure..."), "system-run", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this._launcher._applet, this._launcher._applet.configureApplet));
        subMenu.menu.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Remove '%s'").format(_("Panel launchers")), "edit-delete", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, function() {
            AppletManager._removeAppletFromPanel(this._launcher._applet._uuid, this._launcher._applet.instance_id);
        }));
        subMenu.menu.addMenuItem(item);
    }
E.g to move the application specific settings to the bottom of the list it would be

Code: Select all

class PanelAppLauncherMenu extends Applet.AppletPopupMenu {
    constructor(launcher, orientation) {
        super(launcher, orientation);
        this._launcher = launcher;

        let appinfo = this._launcher.getAppInfo();

        let item = new PopupMenu.PopupIconMenuItem(_("Launch"), "media-playback-start", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onLaunchActivate));
        this.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Add"), "list-add", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onAddActivate));
        this.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Edit"), "document-properties", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onEditActivate));
        this.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Remove"), "window-close", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, this._onRemoveActivate));
        this.addMenuItem(item);

        this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());

        let subMenu = new PopupMenu.PopupSubMenuMenuItem(_("Preferences"));
        this.addMenuItem(subMenu);

        item = new PopupMenu.PopupIconMenuItem(_("About..."), "dialog-question", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this._launcher._applet, this._launcher._applet.openAbout));
        subMenu.menu.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Configure..."), "system-run", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this._launcher._applet, this._launcher._applet.configureApplet));
        subMenu.menu.addMenuItem(item);

        item = new PopupMenu.PopupIconMenuItem(_("Remove '%s'").format(_("Panel launchers")), "edit-delete", St.IconType.SYMBOLIC);
        item.connect('activate', Lang.bind(this, function() {
            AppletManager._removeAppletFromPanel(this._launcher._applet._uuid, this._launcher._applet.instance_id);
        }));
        subMenu.menu.addMenuItem(item);
        
        this._actions = appinfo.list_actions();
        if (this._actions.length > 0) {
            for (let i = 0; i < this._actions.length; i++) {
                let actionName = this._actions[i];
                this.addAction(appinfo.get_action_name(actionName), Lang.bind(this, this._launchAction, actionName));
            }

            this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
        }
    }

arnad
Level 1
Level 1
Posts: 23
Joined: Sun Mar 26, 2017 1:59 pm

Re: Reorder panel launcher order (right-click menu)

Post by arnad » Tue Nov 06, 2018 9:29 am

That worked exactly as advertised! Thank you very much. I was even able to add a separator between preferences and the application-specific options.

Post Reply

Return to “Cinnamon”