Gnome extension : Integrate aggregateMenu in another button

I all !

I’m trying to code a Gnome extension to change the Main.panel.statusArea.aggregateMenu button.

So I created a custom button and added the following line in the button object extending PanelMenu.Button

this.setMenu(Main.panel.statusArea.aggregateMenu.menu);

It indeed associates the aggregateMenu to my button, but it is displayed at the top left of the screen whilst button is at the top right ; and worst than that, the menu diseapears as soon as I release the click of the mouse !

So I did

this.setMenu(Main.panel.statusArea.aggregateMenu.menu);
this.menu.sourceActor = this

This brings the menu to the right position… but it still disappears when I release the click of the mouse.
I tryed to set the focusActor variable as well, it doesn’t change anything.

After hours of source code seeking I don’t find anything. Any help whould be appreciable :slight_smile:

You may have to remove the aggregate menu actor from its original container before moving it. I’m not sure if setMenu() or Clutter will do that for you.

Another option is just creating a new instance of the AggregateMenu class and hiding the original, rather than trying to manipulate the existing one and hoping another extension or part of the shell doesn’t mess with it.

Hi and thank you for the answer !

Actualy, I’d like to keep the original one, because it happens that other extensions add or remove items there, and that’s basically what I want to preserve.
If I create a new instance, the other extensions will change something invisible.

Or maybe I could instead override all the functions of the Main.panel.statusArea.aggregateMenu.menu to redirect them to my new instance ?

Also, I’ve seen a lot of actor in the source code, but I don’t understant what it is. Could you propose a code portion to explain you answer ? Or a brief explanation of what an actor is ?

In principle you could probably do that, but I would expect it to be extremely fragile if it worked at all. I’d not recommend that approach.

An actor is just a widget; a visual object. In GNOME Shell and Clutter “stage” and “actor” are just the terms used to refer to the same thing as “top-level window” and “widget” in applications.

I’m not sure I can offer you a code sample since I’m not sure what exactly you’re trying to achieve. If you just want to change the way the aggregate menu and button works, you should just do that rather than trying to “steal” its menu and stuff it in a different PanelMenu.Button.

There’s the Big-Sur-StatusArea extension that put out of the aggregate menu some items like the audio settings, night mode, and so on.
And then recreates a system menu to shutdown, restard and so on.

What I actually want is to preserve the original system menu. But I was blocked because I couldn’t figre how to set it an icon, so I was looking for alternative solution.

But I figured it out, the icon needed to go in Main.panel.statusArea.aggregateMenu._indicators !

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.