diff options
author | kotontrion <[email protected]> | 2024-11-16 12:30:21 +0100 |
---|---|---|
committer | kotontrion <[email protected]> | 2024-11-16 12:30:21 +0100 |
commit | e674e8f6e49e74edde795e012adbfe0fcfd8d729 (patch) | |
tree | 71ed72165458080f74a6d0269a834fd519603383 /examples | |
parent | 3c33226dc7c1636194491842c43dd3dd8945d3d0 (diff) |
examples(vala): update tray
Diffstat (limited to 'examples')
-rw-r--r-- | examples/vala/simple-bar/widget/Bar.vala | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/examples/vala/simple-bar/widget/Bar.vala b/examples/vala/simple-bar/widget/Bar.vala index 17db831..3893ec5 100644 --- a/examples/vala/simple-bar/widget/Bar.vala +++ b/examples/vala/simple-bar/widget/Bar.vala @@ -113,26 +113,22 @@ class SysTray : Gtk.Box { var item = tray.get_item(id); - if (item.icon_theme_path != null) - App.instance.add_icons(item.icon_theme_path); - - var menu = item.create_menu(); - var btn = new Astal.Button(); + var btn = new Gtk.MenuButton() { + use_popover = false + }; var icon = new Astal.Icon(); - btn.clicked.connect(() => { - if (menu != null) - menu.popup_at_widget(this, Gdk.Gravity.SOUTH, Gdk.Gravity.NORTH, null); - }); - - btn.destroy.connect(() => { - if (menu != null) - menu.destroy(); + item.bind_property("tooltip-markup", btn, "tooltip-markup", BindingFlags.SYNC_CREATE); + item.bind_property("gicon", icon, "g-icon", BindingFlags.SYNC_CREATE); + item.bind_property("menu-model", btn, "menu-model", BindingFlags.SYNC_CREATE); + btn.insert_action_group("dbusmenu", item.action_group); + item.notify["action-group"].connect(() => { + btn.insert_action_group("dbusmenu", item.action_group); }); - item.bind_property("tooltip-markup", btn, "tooltip-markup", BindingFlags.SYNC_CREATE); - item.bind_property("gicon", icon, "gicon", BindingFlags.SYNC_CREATE); + btn.add(icon); add(btn); + btn.show_all(); items.set(id, btn); } |