Re: How to set a button setting via extension?



Sorry, I should have mentioned: Gnome-Shell 3.10
I know the extension you linked, but it is not 3.10 compatible.

Meanwhile, I found another solution:
Modding the example extension to suspend is really easy.
It's just:


const St = imports.gi.St;
const Main = imports.ui.main;
const LoginManager = imports.misc.loginManager;

let button, loginManager;
loginManager = LoginManager.getLoginManager();

function _suspend() {
    loginManager.suspend();
}

function init() {
    button = new St.Bin({ style_class: 'panel-button',
                          reactive: true,
                          can_focus: true,
                          x_fill: true,
                          y_fill: false,
                          track_hover: true });
    let icon = new St.Icon({ icon_name: 'media-playback-pause-symbolic',
                             style_class: 'system-status-icon' });

    button.set_child(icon);
    button.connect('button-press-event', _suspend);
}

function enable() {
    Main.panel._rightBox.insert_child_at_index(button, 0);
}

function disable() {
    Main.panel._rightBox.remove_child(button);
}


2013/11/16 Clemens <clemens lab21 org>
maybe this one: https://extensions.gnome.org/extension/5/alternative-status-menu/



Am 16.11.2013 06:57, schrieb Bazon Bloch:
Hello,

in /usr/share/gnome-shell/js/ui/status/system.js I prefer to have
        this._altSwitcher = new AltSwitcher(this._suspendAction, this._powerOffAction);
in line 352 instead of the default
        this._altSwitcher = new AltSwitcher(this._powerOffAction, this._suspendAction);

as my switching of that setting breaks with every Gnome-Shell update, I'd like to have that set by an extension.
My problems starting this are:

1. IMHO, the cleanest way would be to address that button and change its settings. But:
    (a) what does "this" stands for here? I tried PanelMenu.SystemIndicator._altSwitcher (with PanelMenu = imports.ui.panelMenu), but didn't reach it that way.
    (b) Is there a way at all to change from (this._powerOffAction, this._suspendAction) to (this._suspendAction, this._powerOffAction) for an existing button?

2. If 1 doesn't work, what would be the best way?
    (a) Try to monkeypatch the _createSubMenu() function in the indicator class? or
    (b) Remove the old button and create a new one in its place instead? (how?)

thanks,
Bazon

reference:
I'm talking about /usr/share/gnome-shell/js/ui/status/system.js:
....
const PanelMenu = imports.ui.panelMenu;
...
const Indicator = new Lang.Class({
    Name: 'SystemIndicator',
    Extends: PanelMenu.SystemIndicator,

    _createSubMenu: function() {
        let item;
        ...
        item = new PopupMenu.PopupBaseMenuItem({ reactive: false,
                                                 can_focus: false });
        ...

        this._suspendAction = this._createActionButton('media-playback-pause-symbolic', _("Suspend"));
        this._suspendAction.connect('clicked', Lang.bind(this, this._onSuspendClicked));

        this._powerOffAction = this._createActionButton('system-shutdown-symbolic', _("Power Off"));
        this._powerOffAction.connect('clicked', Lang.bind(this, this._onPowerOffClicked));

        this._altSwitcher = new AltSwitcher(this._suspendAction, this._powerOffAction);
        item.actor.add(this._altSwitcher.actor, { expand: true, x_fill: false });

        this._actionsItem = item;
        this.menu.addMenuItem(item);
    },
});


_______________________________________________
gnome-shell-list mailing list
gnome-shell-list gnome org
https://mail.gnome.org/mailman/listinfo/gnome-shell-list


-- 
00:56 <soreau> Maybe Canonical is just a division of Microsoft hired to try and take down Linux
00:56 <RAOF> Our secret is out!!!!!111111



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]