summaryrefslogtreecommitdiff
path: root/examples/py/simple-bar/widget/Bar.py
diff options
context:
space:
mode:
authorkotontrion <[email protected]>2024-12-20 09:49:58 +0100
committerkotontrion <[email protected]>2024-12-20 09:49:58 +0100
commitfcef5cea5ca84fa06a74e69de34e84b4d0842fcc (patch)
tree798de065ecce20a6f5892bc729ef73455abe209c /examples/py/simple-bar/widget/Bar.py
parent5ed7a1416c2532188a7e01fead3842602fdb670f (diff)
parentd7d11b341db85ce9768fa06b6f225d713621ec56 (diff)
Merge branch 'main' into feat/wayland-glib
Diffstat (limited to 'examples/py/simple-bar/widget/Bar.py')
-rw-r--r--examples/py/simple-bar/widget/Bar.py33
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: