tweaks
This commit is contained in:
20
cht/app.py
20
cht/app.py
@@ -1,5 +1,6 @@
|
||||
import logging
|
||||
import os
|
||||
import signal
|
||||
import sys
|
||||
import threading
|
||||
import gi
|
||||
@@ -19,13 +20,30 @@ class ChtApp(Adw.Application):
|
||||
application_id=APP_ID,
|
||||
flags=Gio.ApplicationFlags.DEFAULT_FLAGS,
|
||||
)
|
||||
# Let GLib handle SIGINT/SIGTERM so Ctrl+C triggers graceful shutdown
|
||||
GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGINT, self._on_signal)
|
||||
GLib.unix_signal_add(GLib.PRIORITY_HIGH, signal.SIGTERM, self._on_signal)
|
||||
|
||||
def _on_signal(self):
|
||||
log = logging.getLogger("cht")
|
||||
log.info("Signal received — shutting down gracefully")
|
||||
self.quit()
|
||||
return GLib.SOURCE_REMOVE
|
||||
|
||||
def do_shutdown(self):
|
||||
# Ensure all windows tear down before the process exits
|
||||
for win in self.get_windows():
|
||||
if hasattr(win, "teardown"):
|
||||
win.teardown()
|
||||
Adw.Application.do_shutdown(self)
|
||||
|
||||
def do_activate(self):
|
||||
win = self.props.active_window
|
||||
if not win:
|
||||
css = Gtk.CssProvider()
|
||||
css.load_from_string(
|
||||
".frame-selected { border: 3px solid @accent_color; border-radius: 6px; }"
|
||||
".frame-selected { border: 3px solid @accent_color; border-radius: 6px; }\n"
|
||||
"row.frame-selected { background: alpha(@accent_color, 0.25); border: none; border-radius: 0; }"
|
||||
)
|
||||
Gtk.StyleContext.add_provider_for_display(
|
||||
Gdk.Display.get_default(),
|
||||
|
||||
Reference in New Issue
Block a user