feat(src): add recursive CSS file monitoring and streamline stylesheet setting
Monitor CSS files and their subdirectories for changes by walking the styles directory and connecting change events to each monitor. Simplify the `set_css` function by removing the unnecessary empty line and directly passing the path to `set_stylesheet_from_file`. This enhances file change detection and reduces redundant code.
This commit is contained in:
1 file changed
+7
-6
+7
-6
@@ -62,9 +62,12 @@ def main():
|
||||
dock = Dock()
|
||||
osd = OSDWindow()
|
||||
|
||||
# Monitor CSS files for changes
|
||||
css_file = monitor_file(get_relative_path("styles"))
|
||||
_ = css_file.connect("changed", lambda *_: set_css())
|
||||
# Monitor CSS files and subdirectories for changes
|
||||
css_monitors = []
|
||||
for root, dirs, files in os.walk(get_relative_path("styles/")):
|
||||
monitor = monitor_file(root)
|
||||
monitor.connect("changed", lambda *_: set_css())
|
||||
css_monitors.append(monitor)
|
||||
|
||||
app = Application(
|
||||
f"{APP_NAME}",
|
||||
@@ -78,9 +81,7 @@ def main():
|
||||
)
|
||||
|
||||
def set_css():
|
||||
app.set_stylesheet_from_file(
|
||||
get_relative_path("styles/main.css"),
|
||||
)
|
||||
app.set_stylesheet_from_file(get_relative_path("styles/main.css"))
|
||||
|
||||
app.set_css = set_css
|
||||
app.set_css()
|
||||
|
||||
Reference in new issue
Block a user