MCPcopy Create free account
hub / github.com/debuggyo/Exo / __init__

Method __init__

ignis/modules/bar/widgets/workspaces.py:41–95  ·  view source on GitHub ↗
(self, workspace)

Source from the content-addressed store, hash-verified

39
40class WorkspaceButton(widgets.Button):
41 def __init__(self, workspace) -> None:
42 bar = (
43 user_settings.interface.bar
44 if user_settings.interface.modules.bar_id.workspaces == 0
45 else user_settings.interface.bar2
46 )
47 style = user_settings.interface.modules.options.workspaces_style
48
49 if isinstance(workspace, NiriWorkspace):
50 label_text = str(workspace.idx)
51 else:
52 label_text = str(workspace.id)
53
54 self.workspace = workspace
55 self._label = widgets.Label(label=label_text, halign="center", valign="center")
56
57 children = [self._label]
58 self._icons_box = None
59
60 if style == "windows":
61 self._icons_box = widgets.Box(spacing=5, css_classes=["workspace-icons"])
62 children.append(self._icons_box)
63
64 self._main_content_box = widgets.Box(
65 halign="center", valign="center", spacing=4, child=children
66 )
67
68 super().__init__(
69 css_classes=["workspace"],
70 on_click=lambda x: self.workspace.switch_to(),
71 child=self._main_content_box,
72 )
73
74 def update_css_classes(*args):
75 active_workspace = get_active_workspace()
76 if active_workspace and self.workspace.id == active_workspace.id:
77 self.add_css_class("active")
78 else:
79 self.remove_css_class("active")
80 if not self._get_windows_for_workspace():
81 self.add_css_class("empty")
82 else:
83 self.remove_css_class("empty")
84
85 if SERVICE:
86 SERVICE.connect("notify::workspaces", update_css_classes)
87 if isinstance(SERVICE, HyprlandService):
88 SERVICE.connect("notify::active-workspace", update_css_classes)
89 update_css_classes()
90
91 self.update_layout()
92 if style == "windows":
93 self._update_icons()
94 if SERVICE:
95 SERVICE.connect("notify::windows", lambda *args: self._update_icons())
96
97 def _get_windows_for_workspace(self):
98 if isinstance(SERVICE, NiriService):

Callers

nothing calls this directly

Calls 4

update_layoutMethod · 0.95
_update_iconsMethod · 0.95
switch_toMethod · 0.80
__init__Method · 0.45

Tested by

no test coverage detected