mirror of
https://github.com/aclist/dztui.git
synced 2026-10-30 22:52:42 +01:00
feat: capture escape signal in BootDialog
This commit is contained in:
1 parent
401c8625ad
commit
687b1a915e
2 files changed
+13
-6
No files matched your search
@@ -11,3 +11,7 @@ deleting_mods = "Deleting mods"
|
|||||||
scanning_mods = "Scanning mods"
|
scanning_mods = "Scanning mods"
|
||||||
|
|
||||||
checking_api = "Checking API key"
|
checking_api = "Checking API key"
|
||||||
|
|
||||||
|
running = "Running"
|
||||||
|
failed = "FAILED"
|
||||||
|
ok = "OK"
|
||||||
@@ -14,7 +14,7 @@ from dzgui.init.dayz import is_dayz_installed
|
|||||||
from dzgui.init.update import check_updates
|
from dzgui.init.update import check_updates
|
||||||
from dzgui.const.constants import EXPAND, FILL
|
from dzgui.const.constants import EXPAND, FILL
|
||||||
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
|
||||||
from dzgui.strings import preboot
|
from dzgui.strings import preboot, dialogs
|
||||||
from dzgui.util.format import format_exception
|
from dzgui.util.format import format_exception
|
||||||
from dzgui.util.strings import dialog_header
|
from dzgui.util.strings import dialog_header
|
||||||
from dzgui.util.symlink import rebuild_symlinks
|
from dzgui.util.symlink import rebuild_symlinks
|
||||||
@@ -59,6 +59,9 @@ class BootDialog(Gtk.Dialog):
|
|||||||
self.view = Gtk.TreeView(enable_search=False, headers_visible=False)
|
self.view = Gtk.TreeView(enable_search=False, headers_visible=False)
|
||||||
self.view.set_model(self.store)
|
self.view.set_model(self.store)
|
||||||
|
|
||||||
|
# TODO: capture sigint in early dialogs
|
||||||
|
self.connect("key-press-event", lambda _, __: self.exit_button.emit("clicked"))
|
||||||
|
|
||||||
for i, column_title in enumerate(["Task", "State"]):
|
for i, column_title in enumerate(["Task", "State"]):
|
||||||
renderer = Gtk.CellRendererText()
|
renderer = Gtk.CellRendererText()
|
||||||
column = Gtk.TreeViewColumn(column_title, renderer, text=i)
|
column = Gtk.TreeViewColumn(column_title, renderer, text=i)
|
||||||
@@ -184,10 +187,10 @@ class BootDialog(Gtk.Dialog):
|
|||||||
self.thread_man.set_cleanup_func(callback)
|
self.thread_man.set_cleanup_func(callback)
|
||||||
|
|
||||||
def update_task(self, task: str) -> None:
|
def update_task(self, task: str) -> None:
|
||||||
self.store.append((task, "Running", True, 0))
|
self.store.append((task, dialogs.running, True, 0))
|
||||||
|
|
||||||
def update_status(self, state: Success) -> None:
|
def update_status(self, state: Success) -> None:
|
||||||
d = {Success.OK: "OK", Success.FAIL: "FAILED"}
|
d = {Success.OK: dialogs.ok, Success.FAIL: dialogs.failed}
|
||||||
msg = d[state]
|
msg = d[state]
|
||||||
self.store[len(self.store) - 1][1] = msg
|
self.store[len(self.store) - 1][1] = msg
|
||||||
self.iter_step()
|
self.iter_step()
|
||||||
@@ -200,7 +203,7 @@ class BootDialog(Gtk.Dialog):
|
|||||||
it: Gtk.TreeIter,
|
it: Gtk.TreeIter,
|
||||||
data: Any,
|
data: Any,
|
||||||
) -> None:
|
) -> None:
|
||||||
if model[it][1] == "Running":
|
if model[it][1] == dialogs.running:
|
||||||
cell.set_property("visible", True)
|
cell.set_property("visible", True)
|
||||||
else:
|
else:
|
||||||
cell.set_property("visible", False)
|
cell.set_property("visible", False)
|
||||||
@@ -217,9 +220,9 @@ class BootDialog(Gtk.Dialog):
|
|||||||
state = model[it][1]
|
state = model[it][1]
|
||||||
if column.get_sort_column_id() != 1:
|
if column.get_sort_column_id() != 1:
|
||||||
return
|
return
|
||||||
if state == "OK":
|
if state == dialogs.ok:
|
||||||
cell.set_property(prop, HEX_GREEN)
|
cell.set_property(prop, HEX_GREEN)
|
||||||
elif state == "FAILED":
|
elif state == dialogs.running:
|
||||||
cell.set_property(prop, HEX_RED)
|
cell.set_property(prop, HEX_RED)
|
||||||
else:
|
else:
|
||||||
cell.set_property(prop, None)
|
cell.set_property(prop, None)
|
||||||
|
|||||||
Reference in new issue
Block a user