chore: move client to separate file
This commit is contained in:
6 files changed
+69
-66
No files matched your search
+1
-63
@@ -18,6 +18,7 @@ from utils.functions import (
|
||||
read_json_file,
|
||||
write_json_file,
|
||||
)
|
||||
from utils.hyprland import NativeClient
|
||||
from utils.icon_resolver import IconResolver
|
||||
from utils.widget_settings import BarConfig
|
||||
|
||||
@@ -26,69 +27,6 @@ DOCK_DND_TARGET = [Gtk.TargetEntry.new("dock-app", Gtk.TargetFlags.SAME_APP, 0)]
|
||||
DOCK_SYNC_DEBOUNCE_MS = 60
|
||||
|
||||
|
||||
class NativeClient:
|
||||
"""Lightweight Hyprland client adapter matching dock expectations."""
|
||||
|
||||
__slots__ = ("_active", "_data", "_hyprland_connection")
|
||||
|
||||
def __init__(self, data: dict, hyprland_connection, active_address: str | None):
|
||||
self._data = data
|
||||
self._hyprland_connection = hyprland_connection
|
||||
self._active = normalize_address(data.get("address")) == active_address
|
||||
|
||||
def get_app_id(self) -> str:
|
||||
return self._data.get("initialClass") or self._data.get("class") or ""
|
||||
|
||||
def get_title(self) -> str:
|
||||
return self._data.get("title") or self.get_app_id()
|
||||
|
||||
def get_hyprland_address(self) -> int:
|
||||
addr = normalize_address(self._data.get("address"))
|
||||
return int(addr, 16) if addr else 0
|
||||
|
||||
def get_address_str(self) -> str | None:
|
||||
return normalize_address(self._data.get("address"))
|
||||
|
||||
def get_fullscreen(self) -> bool:
|
||||
return bool(self._data.get("fullscreen", False))
|
||||
|
||||
def get_activated(self) -> bool:
|
||||
return self._active
|
||||
|
||||
def set_activated(self, active: bool):
|
||||
self._active = active
|
||||
|
||||
def activate(self):
|
||||
addr = self.get_address_str()
|
||||
if addr:
|
||||
self._hyprland_connection.send_command_async(
|
||||
f"dispatch focuswindow address:{addr}",
|
||||
lambda *_: None,
|
||||
)
|
||||
|
||||
def close(self):
|
||||
addr = self.get_address_str()
|
||||
if addr:
|
||||
self._hyprland_connection.send_command_async(
|
||||
f"dispatch closewindow address:{addr}",
|
||||
lambda *_: None,
|
||||
)
|
||||
|
||||
def fullscreen(self):
|
||||
self.activate()
|
||||
self._hyprland_connection.send_command_async(
|
||||
"dispatch fullscreen 1",
|
||||
lambda *_: None,
|
||||
)
|
||||
|
||||
def unfullscreen(self):
|
||||
self.activate()
|
||||
self._hyprland_connection.send_command_async(
|
||||
"dispatch fullscreen 0",
|
||||
lambda *_: None,
|
||||
)
|
||||
|
||||
|
||||
class MultiDotIndicator(Gtk.DrawingArea):
|
||||
"""A dot indicator widget that can show multiple dots for grouped apps."""
|
||||
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ class ScanButton(HoverButton):
|
||||
|
||||
self.scan_image = CircularImage(
|
||||
image_file=f"{ASSETS_DIR}icons/svg/refresh.svg",
|
||||
size=kwargs.get("size",20),
|
||||
size=kwargs.get("size", 20),
|
||||
)
|
||||
self.scan_animator = None
|
||||
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
from utils.functions import normalize_address
|
||||
|
||||
|
||||
class NativeClient:
|
||||
"""Lightweight Hyprland client adapter matching dock expectations."""
|
||||
|
||||
__slots__ = ("_active", "_data", "_hyprland_connection")
|
||||
|
||||
def __init__(self, data: dict, hyprland_connection, active_address: str | None):
|
||||
self._data = data
|
||||
self._hyprland_connection = hyprland_connection
|
||||
self._active = normalize_address(data.get("address")) == active_address
|
||||
|
||||
def get_app_id(self) -> str:
|
||||
return self._data.get("initialClass") or self._data.get("class") or ""
|
||||
|
||||
def get_title(self) -> str:
|
||||
return self._data.get("title") or self.get_app_id()
|
||||
|
||||
def get_hyprland_address(self) -> int:
|
||||
addr = normalize_address(self._data.get("address"))
|
||||
return int(addr, 16) if addr else 0
|
||||
|
||||
def get_address_str(self) -> str | None:
|
||||
return normalize_address(self._data.get("address"))
|
||||
|
||||
def get_fullscreen(self) -> bool:
|
||||
return bool(self._data.get("fullscreen", False))
|
||||
|
||||
def get_activated(self) -> bool:
|
||||
return self._active
|
||||
|
||||
def set_activated(self, active: bool):
|
||||
self._active = active
|
||||
|
||||
def activate(self):
|
||||
addr = self.get_address_str()
|
||||
if addr:
|
||||
self._hyprland_connection.send_command_async(
|
||||
f"dispatch focuswindow address:{addr}",
|
||||
lambda *_: None,
|
||||
)
|
||||
|
||||
def close(self):
|
||||
addr = self.get_address_str()
|
||||
if addr:
|
||||
self._hyprland_connection.send_command_async(
|
||||
f"dispatch closewindow address:{addr}",
|
||||
lambda *_: None,
|
||||
)
|
||||
|
||||
def fullscreen(self):
|
||||
self.activate()
|
||||
self._hyprland_connection.send_command_async(
|
||||
"dispatch fullscreen 1",
|
||||
lambda *_: None,
|
||||
)
|
||||
|
||||
def unfullscreen(self):
|
||||
self.activate()
|
||||
self._hyprland_connection.send_command_async(
|
||||
"dispatch fullscreen 0",
|
||||
lambda *_: None,
|
||||
)
|
||||
@@ -253,7 +253,7 @@ class SystemTrayWidget(ButtonWidget, PopoverMixin, BaseSystemTray):
|
||||
# Widget is visible if there are any items (visible or hidden)
|
||||
self.set_visible(has_visible_items or has_hidden_items)
|
||||
|
||||
def not_empty(self,item):
|
||||
def not_empty(self, item):
|
||||
return len(item) > 0
|
||||
|
||||
def on_item_removed(self, _, item_identifier):
|
||||
|
||||
@@ -16,6 +16,7 @@ class TaskBarWidget(BoxWidget):
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
# TODO: remove glace, use hyprland
|
||||
self.icon_resolver = IconResolver()
|
||||
self._manager = Glace.Manager()
|
||||
self._manager.connect("client-added", self.on_client_added)
|
||||
|
||||
@@ -51,7 +51,7 @@ class USBManagerMenu(Box):
|
||||
on_clicked=self._on_refresh_clicked,
|
||||
sensitive=False,
|
||||
tooltip_text="Refresh",
|
||||
size = 17
|
||||
size=17,
|
||||
)
|
||||
|
||||
header = CenterBox(
|
||||
|
||||
Reference in new issue
Block a user