diff options
author | kotontrion <[email protected]> | 2025-01-10 09:25:08 +0100 |
---|---|---|
committer | kotontrion <[email protected]> | 2025-01-10 09:25:08 +0100 |
commit | ef4f95608481414053ecdbe4de29bd86fb452813 (patch) | |
tree | 666a28eb2977a39f8fa49b70692bc443df74eb41 | |
parent | c5b219171cbab489b01087a372e24e3a719f6299 (diff) |
tray: add a way to call the menus AboutToShow
-rw-r--r-- | lib/tray/trayItem.vala | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/tray/trayItem.vala b/lib/tray/trayItem.vala index 991abce..6da51cb 100644 --- a/lib/tray/trayItem.vala +++ b/lib/tray/trayItem.vala @@ -165,14 +165,14 @@ public class TrayItem : Object { private DBusMenu.Importer menu_importer; - public MenuModel menu_model { + public MenuModel? menu_model { owned get { if (menu_importer == null) return null; return menu_importer.model; } } - public ActionGroup action_group { + public ActionGroup? action_group { owned get { if (menu_importer == null) return null; return menu_importer.action_group; @@ -299,6 +299,31 @@ public class TrayItem : Object { } /** + * tells the tray app that its menu is about to be opened, + * so it can update the menu if needed. You should call this method + * before openening the menu. + */ + public void about_to_show() { + if(proxy.Menu == null) return; + try { + Bus.get_sync(BusType.SESSION).call_sync( + this.proxy.g_name_owner, + this.proxy.Menu, + "com.canonical.dbusmenu", + "AboutToShow", + new Variant("(i)", 0), + null, + DBusCallFlags.NONE, + -1, + null + ); + } + catch (Error r) { + //silently ignore + } + } + + /** * Send an activate request to the tray app. */ public void activate(int x, int y) { |