diff options
author | Aylur <[email protected]> | 2024-12-19 23:44:18 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2024-12-19 23:44:18 +0100 |
commit | c34349ca44c4e43bf2c58b3e2e4f1f9e39358b53 (patch) | |
tree | 604bdece8e3fe3bd2a286ab1e8ef07dd8d90c37c /examples/vala/simple-bar/widget/Bar.vala | |
parent | 4f47b69946dd7127ba66e6333af4945afaba15de (diff) | |
parent | c5664e2941b33609de0743a8475a40b24522a3dc (diff) |
Merge pull request #68 from Aylur/feat/tray-gtk4
tray: gtk4 compatibility
Diffstat (limited to 'examples/vala/simple-bar/widget/Bar.vala')
-rw-r--r-- | examples/vala/simple-bar/widget/Bar.vala | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/examples/vala/simple-bar/widget/Bar.vala b/examples/vala/simple-bar/widget/Bar.vala index ba4062c..ba9f06c 100644 --- a/examples/vala/simple-bar/widget/Bar.vala +++ b/examples/vala/simple-bar/widget/Bar.vala @@ -103,6 +103,7 @@ class SysTray : Gtk.Box { AstalTray.Tray tray = AstalTray.get_default(); public SysTray() { + Astal.widget_set_class_names(this, { "SysTray" }); tray.item_added.connect(add_item); tray.item_removed.connect(remove_item); } @@ -112,26 +113,19 @@ class SysTray : Gtk.Box { return; var item = tray.get_item(id); - - var menu = item.create_menu(); - var btn = new Astal.Button(); - 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(); - }); + var btn = new Gtk.MenuButton() { use_popover = false, visible = true }; + var icon = new Astal.Icon() { visible = true }; 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); + }); + btn.add(icon); add(btn); - btn.show_all(); items.set(id, btn); } |