updates
This commit is contained in:
27 files changed
+2725
-221
No files matched your search
@@ -2,8 +2,9 @@ import os
|
||||
import json
|
||||
import config.data as data
|
||||
from fabric.widgets.box import Box
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.widgets.datetime import DateTime
|
||||
from fabric.widgets.label import Label
|
||||
from fabric.widgets.button import Button
|
||||
from fabric.system_tray.widgets import SystemTray
|
||||
from .battery import Battery
|
||||
from .metrics import Metrics
|
||||
@@ -11,6 +12,10 @@ from .controls import Controls
|
||||
from .workspaces import workspace
|
||||
from .indicators import Indicators
|
||||
from .applications import Applications
|
||||
from .music_player import MusicPlayer
|
||||
from fabric.hyprland.widgets import get_hyprland_connection, Language
|
||||
import utils.icons as icons
|
||||
from fabric.hyprland.service import HyprlandEvent
|
||||
|
||||
|
||||
class DockComponents(Box):
|
||||
@@ -26,11 +31,19 @@ class DockComponents(Box):
|
||||
orientation_val=orientation_val, dock_instance=dock_instance
|
||||
)
|
||||
|
||||
self.connection = get_hyprland_connection()
|
||||
self.lang_label = Label(name="lang-label")
|
||||
self.language = Button(
|
||||
name="language", h_align="center", v_align="center", child=self.lang_label
|
||||
)
|
||||
self.on_language_switch()
|
||||
self.connection.connect("event::activelayout", self.on_language_switch)
|
||||
|
||||
# Initialize component visibility from data
|
||||
self.component_visibility = data.DOCK_COMPONENTS_VISIBILITY
|
||||
|
||||
# Create components
|
||||
self.workspaces = workspace # Use the workspace instance directly
|
||||
self.workspaces = workspace
|
||||
self.metrics = Metrics()
|
||||
self.battery = Battery()
|
||||
self.date_time = DateTime(
|
||||
@@ -43,6 +56,7 @@ class DockComponents(Box):
|
||||
)
|
||||
self.controls = Controls()
|
||||
self.indicators = Indicators()
|
||||
self.music_player = MusicPlayer()
|
||||
self.systray = SystemTray(
|
||||
icon_size=18,
|
||||
spacing=4,
|
||||
@@ -58,7 +72,9 @@ class DockComponents(Box):
|
||||
self.applications,
|
||||
self.indicators,
|
||||
self.battery,
|
||||
self.music_player,
|
||||
self.date_time,
|
||||
self.language,
|
||||
self.systray,
|
||||
]
|
||||
|
||||
@@ -70,9 +86,8 @@ class DockComponents(Box):
|
||||
self.apply_component_props()
|
||||
|
||||
# Apply invert style for specific themes and positions
|
||||
should_invert = (
|
||||
data.DOCK_THEME in ["Dense", "Edge"] or
|
||||
(data.DOCK_THEME == "Pills" and data.DOCK_POSITION in ["Left", "Right"])
|
||||
should_invert = data.DOCK_THEME in ["Dense", "Edge"] or (
|
||||
data.DOCK_THEME == "Pills" and data.DOCK_POSITION in ["Left", "Right"]
|
||||
)
|
||||
|
||||
if should_invert:
|
||||
@@ -88,8 +103,10 @@ class DockComponents(Box):
|
||||
"date_time": self.date_time,
|
||||
"controls": self.controls,
|
||||
"indicators": self.indicators,
|
||||
"music_player": self.music_player,
|
||||
"systray": self.systray,
|
||||
"applications": self.applications,
|
||||
"language": self.language,
|
||||
}
|
||||
|
||||
for component_name, widget in components.items():
|
||||
@@ -104,8 +121,10 @@ class DockComponents(Box):
|
||||
"date_time": self.date_time,
|
||||
"controls": self.controls,
|
||||
"indicators": self.indicators,
|
||||
"music_player": self.music_player,
|
||||
"systray": self.systray,
|
||||
"applications": self.applications,
|
||||
"language": self.language,
|
||||
}
|
||||
|
||||
if component_name in components and component_name in self.component_visibility:
|
||||
@@ -136,3 +155,16 @@ class DockComponents(Box):
|
||||
return self.component_visibility[component_name]
|
||||
|
||||
return None
|
||||
|
||||
def on_language_switch(self, _=None, event: HyprlandEvent = None):
|
||||
lang_data = (
|
||||
event.data[1]
|
||||
if event and event.data and len(event.data) > 1
|
||||
else Language().get_label()
|
||||
)
|
||||
self.language.set_tooltip_text(lang_data)
|
||||
if not data.VERTICAL:
|
||||
self.lang_label.set_label(lang_data[:2].lower())
|
||||
else:
|
||||
self.lang_label.add_style_class("icon")
|
||||
self.lang_label.set_markup(icons.keyboard)
|
||||
Reference in new issue
Block a user