Enhancements: - Add optimized night‑variant detection for weather icons using a predefined list - Replace `Svg` usage with direct `svg_file` calls throughout the todo widget, removing redundant relative‑path logic - Update dock and battery modules to load assets via direct paths, eliminating unnecessary `get_relative_path` calls- Introduce `WEATHER_CACHE_TIMEOUT` constant and tidy up unused imports (`WEATHER_EMOJI_MAP` removed) - Minor formatting and structural clean‑ups that improve code readability Bug Fixes: - Remove dead import of `WEATHER_EMOJI_MAP` and unused constant `WEATHER_EMOJI_MAP` - Correct syntax of `condition_em` initialization to avoid potential rendering issues New Features: - None.
48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
from fabric.widgets.label import Label
|
|
from utils.utils import svg_file
|
|
from .base import BaseOSDContainer
|
|
from services.capslock import CapsLock
|
|
|
|
|
|
class CapsLockOSDContainer(BaseOSDContainer):
|
|
def __init__(self, window, **kwargs):
|
|
super().__init__(window, **kwargs)
|
|
self.capslock = CapsLock.get_initial()
|
|
self._setup_specific_components()
|
|
self._connect_specific_signals()
|
|
|
|
def _setup_specific_components(self):
|
|
self.osd_image = svg_file(
|
|
"misc/caps-lock.svg",
|
|
size=(100, 100),
|
|
name="osd-image",
|
|
h_align="center",
|
|
v_align="center",
|
|
h_expand=True,
|
|
v_expand=True,
|
|
)
|
|
self.label = Label(name="osd-label")
|
|
self.add(self.osd_image)
|
|
self._update_display(self.capslock.is_on)
|
|
|
|
def _connect_specific_signals(self):
|
|
self.capslock.connect("state_changed", self._on_caps_lock_state_changed)
|
|
|
|
def _on_caps_lock_state_changed(self, _, is_on: bool):
|
|
self._update_display(is_on)
|
|
self.update()
|
|
|
|
def _update_display(self, is_on: bool):
|
|
icon_path = "caps-lock.svg" if is_on else "caps-lock-off.svg"
|
|
self.osd_image.set_from_file(f"misc/{icon_path}")
|
|
if is_on:
|
|
self.add_style_class("capslock-on")
|
|
self.remove_style_class("capslock-off")
|
|
else:
|
|
self.add_style_class("capslock-off")
|
|
self.remove_style_class("capslock-on")
|
|
|
|
def update(self, *_):
|
|
# We don't need a separate display update here as it's handled in the signal
|
|
super().update()
|