diff options
author | Aylur <[email protected]> | 2024-12-20 22:27:25 +0100 |
---|---|---|
committer | Aylur <[email protected]> | 2024-12-20 22:27:25 +0100 |
commit | 53bfc0929d62263547c1282b388040b9616a377e (patch) | |
tree | 2b2c776ecc57209179203eb7b8638ee7502a286e /examples/py/simple-bar/widget/Bar.py | |
parent | 2f09ed83386b334f0dfb7f376b99739b15e49fc9 (diff) | |
parent | d7d11b341db85ce9768fa06b6f225d713621ec56 (diff) |
Merge branch 'main' into feat/jsx-gtk4
Diffstat (limited to 'examples/py/simple-bar/widget/Bar.py')
-rw-r--r-- | examples/py/simple-bar/widget/Bar.py | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/examples/py/simple-bar/widget/Bar.py b/examples/py/simple-bar/widget/Bar.py index 3b09dce..3c5c3f8 100644 --- a/examples/py/simple-bar/widget/Bar.py +++ b/examples/py/simple-bar/widget/Bar.py @@ -32,7 +32,8 @@ class Workspaces(Gtk.Box): child.destroy() for ws in hypr.get_workspaces(): - self.add(self.button(ws)) + if not (ws.id >= -99 and ws.id <= -2): # filter out special workspaces + self.add(self.button(ws)) def button(self, ws): hypr = Hyprland.get_default() @@ -108,6 +109,7 @@ class Media(Gtk.Box): class SysTray(Gtk.Box): def __init__(self) -> None: super().__init__() + Astal.widget_set_class_names(self, ["SysTray"]) self.items = {} tray = Tray.get_default() tray.connect("item_added", self.add_item) @@ -118,33 +120,22 @@ class SysTray(Gtk.Box): return item = Tray.get_default().get_item(id) - theme = item.get_icon_theme_path() - - if theme is not None: - from app import app - - app.add_icons(theme) - - menu = item.create_menu() - btn = Astal.Button(visible=True) + btn = Gtk.MenuButton(use_popover=False, visible=True) icon = Astal.Icon(visible=True) - def on_clicked(btn): - if menu: - menu.popup_at_widget(btn, Gdk.Gravity.SOUTH, Gdk.Gravity.NORTH, None) + item.bind_property("tooltip-markup", btn, "tooltip-markup", SYNC) + item.bind_property("gicon", icon, "g-icon", SYNC) + item.bind_property("menu-model", btn, "menu-model", SYNC) + btn.insert_action_group("dbusmenu", item.get_action_group()) - def on_destroy(btn): - if menu: - menu.destroy() + def on_action_group(*args): + btn.insert_action_group("dbusmenu", item.get_action_group()) - btn.connect("clicked", on_clicked) - btn.connect("destroy", on_destroy) + item.connect("notify::action-group", on_action_group) - item.bind_property("tooltip-markup", btn, "tooltip-markup", SYNC) - item.bind_property("gicon", icon, "gicon", SYNC) + btn.add(icon) self.add(btn) self.items[id] = btn - self.show_all() def remove_item(self, _: Tray.Tray, id: str): if id in self.items: |