Score:0

Insert GNOME panel text to rightmost index

ru flag

I am the author of the extension Mock Universal Menu, and am working on the next update. The problem is, I want to insert my text to the rightmost index of the left box. I want to do this because as of now, after coming out from suspend, my extension goes to the left of the app menu (ex, Firefox, or Extensions), and after the activities button. So, my question is: Would it be possible to stop this behavior, and if not, how do I align it to the right of the left box.

My Code


'use strict';

const { St, Clutter } = imports.gi;

const Main = imports.ui.main;

let _myText;

class Extension {

    enable() {
    const _myText = new St.Label({ text: '  File        Edit        View        Go        Window        Help', 
    y_align: Clutter.ActorAlign.CENTER, 
    style_class: 'panel-button', 
    track_hover: false, 
    reactive: false, 
    style_class: 'panel-button my-class'});
    Main.panel._leftBox.insert_child_at_index(_myText, 10)
    }

    disable() {
    _myText.destroy();
    }
}

function init() {
    return new Extension();
}

I am on Ubuntu 21.04 with GNOME 40.4 installed.

br flag
Hi, Change your disable() function as below and see `disable() { Main.panel._leftBox.remove_child(_myText); }`
Zany_Zachary1 avatar
ru flag
I would replace my current disable() function with this, correct?
Zany_Zachary1 avatar
ru flag
it has no effect, after suspend, it is still to the left of the application button. Maybe if there was an alignment option to align first or last in relation to the left box?
Zany_Zachary1 avatar
ru flag
Oops, I should've mentioned, I'm on Ubuntu 21.04. I'll edit the question.
Zany_Zachary1 avatar
ru flag
When I disable, I get an error: `Expected an object of type ClutterActor for argument 'child' but got type undefined`.
Zany_Zachary1 avatar
ru flag
yes, I understand that the one on the extensions website is fully functional. The error occurs when you wake from suspend. The extension is then to the left of the application menu.
Score:0
br flag

from the code you have provided, it seems the disable function like below will do what you are looking for

disable() { 
Main.panel._leftBox.remove_child(_myText);
}

also remove the text "const" from your enable code 2nd line

enable() {
    const _myText = new St.Label({ text: '  File        Edit        View .....
Zany_Zachary1 avatar
ru flag
I also had to disable `const` before `_myText`
br flag
yes, thats correct.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.