panel: Add PanelMenu.Button menu when menu-set is emitted

When a `PanelMenu.Button` is added to the `statusArea`, its menu is
added to the `PopupMenuManager` if it has one at the time. If a menu is
added later or a new one set, the new menu is never added.

Move the call to `PopupMenuManager.addMenu()` from `_addToPanelBox()`
to `_onMenuSet()`, which is called when the `PanelMenu.Button` is added
and whenever it emits the `menu-set` signal.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2470>
This commit is contained in:
Andy Holmes 2022-09-04 17:21:29 -07:00 committed by Marge Bot
parent 0bd73b79a6
commit 990eb92bd9

View File

@ -707,8 +707,6 @@ class Panel extends St.Widget {
box.insert_child_at_index(container, position); box.insert_child_at_index(container, position);
if (indicator.menu)
this.menuManager.addMenu(indicator.menu);
this.statusArea[role] = indicator; this.statusArea[role] = indicator;
let destroyId = indicator.connect('destroy', emitter => { let destroyId = indicator.connect('destroy', emitter => {
delete this.statusArea[role]; delete this.statusArea[role];
@ -741,6 +739,8 @@ class Panel extends St.Widget {
if (!indicator.menu || indicator.menu._openChangedId) if (!indicator.menu || indicator.menu._openChangedId)
return; return;
this.menuManager.addMenu(indicator.menu);
indicator.menu._openChangedId = indicator.menu.connect('open-state-changed', indicator.menu._openChangedId = indicator.menu.connect('open-state-changed',
(menu, isOpen) => { (menu, isOpen) => {
let boxAlignment; let boxAlignment;