From 7834372acbaad177c6f0649fa9f328186e22b8eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 30 Jul 2022 02:24:17 +0200 Subject: [PATCH] panel: Add closeQuickSettings() method Like the aggregate menu currently, the quick settings menu will eventually contain some items that should dismiss the menu. And as those items may appear in child menus or otherwise be nested, a public method on a global object is more convenient than handing the main menu down the hierarchy. Part-of: --- js/ui/panel.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index 850d4f06c..d259fcbb2 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -643,6 +643,16 @@ class Panel extends St.Widget { menu.actor.navigate_focus(null, St.DirectionType.TAB_FORWARD, false); } + _closeMenu(indicator) { + if (!indicator || !indicator.mapped) + return; // menu not supported by current session mode + + if (!indicator.reactive) + return; + + indicator.menu.close(); + } + toggleAppMenu() { this._toggleMenu(this.statusArea.appMenu); } @@ -652,15 +662,11 @@ class Panel extends St.Widget { } closeCalendar() { - let indicator = this.statusArea.dateMenu; - if (!indicator) // calendar not supported by current session mode - return; + this._closeMenu(this.statusArea.dateMenu); + } - let menu = indicator.menu; - if (!indicator.reactive) - return; - - menu.close(); + closeQuickSettings() { + this._closeMenu(this.statusArea.quickSettings); } set boxOpacity(value) {