Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing actor member on PopupMenu #30

Merged
merged 3 commits into from
Apr 1, 2024

Conversation

jp-vernooy
Copy link
Contributor

@jp-vernooy jp-vernooy commented Apr 1, 2024

The PopupMenu class has an actor member of type BoxPointer that's used when setting up a menu for a panel indicator. It's defined here: https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/ui/popupMenu.js?#L879

An example of this member being accessed from outside the class can be found here: https://gitlab.gnome.org/GNOME/gnome-shell/-/blob/main/js/gdm/loginDialog.js#L337

When implementing a menu for an indicator, you would do something like this:

class MyIndicatorMenu extends PopupMenu.PopupMenu {
  constructor(sourceActor: St.Widget, arrowAlignment: number, arrowSide: St.Side) {
    super(sourceActor, arrowAlignment, arrowSide);

    Main.uiGroup.add_child(this.actor);
    this.actor.hide();

    this.addAction("Some action", () => { });
  }
}

Without this addition you have to resort to (this as any).actor in order to add the menu to uiGroup and hide it appropriately without type errors.

From the shell code, it doesn't seem like it's ever modified from the outside, so I've made it readonly.

EDIT: I've added the missing actor member to PopupDummyMenu and PopupMenuSection as well.

@jp-vernooy
Copy link
Contributor Author

I see similar references being made to the actor member in PopupDummyMenu and PopupMenuSection. I suppose I could add those as well.

@Totto16 Totto16 self-assigned this Apr 1, 2024
@Totto16 Totto16 added the enhancement New feature or request label Apr 1, 2024
@Totto16
Copy link
Collaborator

Totto16 commented Apr 1, 2024

Thank you for your contribution ❤️

@Totto16 Totto16 merged commit b8b4a00 into gjsify:main Apr 1, 2024
1 check passed
@jp-vernooy jp-vernooy deleted the popupmenu-actor branch April 1, 2024 16:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants