chore: additional error handling

This commit is contained in:
aclist 2026-05-17 04:21:50 +09:00
parent 5e2d3d1a88
commit 59a84e9e3a
3 changed files with 18 additions and 26 deletions

View File

@ -35,3 +35,6 @@
.masked-tree { .masked-tree {
background-color: transparent; background-color: transparent;
} }
.error-frame border {
border: 2px solid red;
}

View File

@ -6,7 +6,6 @@ This wizard is going to help you set up some common config options before launch
### SteamPathPage ### SteamPathPage
# TODO # TODO
error_steam_path = "ERROR TEXT HERE"
heading_steam_path = "Steam path" heading_steam_path = "Steam path"
blurb_steam_path = """ blurb_steam_path = """
DZGUI needs to find the location to your default Steam installation. DZGUI needs to find the location to your default Steam installation.
@ -36,6 +35,7 @@ config_import_box = (
) )
config_new_button = "Create new DZGUI 7 config from scratch" config_new_button = "Create new DZGUI 7 config from scratch"
config_new_box = "A new config file will be created. Proceed to the next step." config_new_box = "A new config file will be created. Proceed to the next step."
config_error_box = "Something went wrong while writing a new config file to the system."
### APIValidationPage ### APIValidationPage
entry_placeholder = "Enter API key here" entry_placeholder = "Enter API key here"

View File

@ -20,7 +20,7 @@ from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManage
from dzgui.strings import wizard from dzgui.strings import wizard
from dzgui.util._json import write_json from dzgui.util._json import write_json
from dzgui.util.open_links import open_link_by_url from dzgui.util.open_links import open_link_by_url
from dzgui.util.css import add_class from dzgui.util.css import add_class, load_css
from dzgui.views.components.buttons import WebButton from dzgui.views.components.buttons import WebButton
from dzgui.views.components.entry import APIEntry from dzgui.views.components.entry import APIEntry
from dzgui.views.components.misc import ClientCombo from dzgui.views.components.misc import ClientCombo
@ -138,7 +138,6 @@ class NotificationFrame(Gtk.Frame):
self.add(self.box) self.add(self.box)
if error: if error:
# TODO: custom css file only for wizard
add_class(self, "error-frame") add_class(self, "error-frame")
@ -250,11 +249,7 @@ class IntroductionPage(ScrolledWizardPage):
class Heading(Gtk.Label): class Heading(Gtk.Label):
def __init__(self, label: str): def __init__(self, label: str):
super().__init__(label=label) super().__init__(label=label)
add_class(self, "settings-subheading")
# add_class(self, "heading")
# font weight
# TODO: set css em size
# TODO: bold text
class ChunkyButton(Gtk.Button): class ChunkyButton(Gtk.Button):
@ -317,17 +312,18 @@ class ConfigMigrationPage(ScrolledWizardPage):
self.add_start(self.grid) self.add_start(self.grid)
self.err_box = NotificationFrame(wizard.config_error_box, error=True)
self.success_box = NotificationFrame(wizard.config_import_box) self.success_box = NotificationFrame(wizard.config_import_box)
self.from_scratch_box = NotificationFrame(wizard.config_new_box) self.from_scratch_box = NotificationFrame(wizard.config_new_box)
self.add_start(self.success_box) for box in self.err_box, self.success_box, self.from_scratch_box:
self.add_start(self.from_scratch_box) self.add_start(box)
self.connect("map", self._hide_boxes) self.connect("map", self._hide_boxes)
self.import_button.connect("clicked", self._on_import_clicked) self.import_button.connect("clicked", self._on_import_clicked)
self.new_button.connect("clicked", self._on_new_clicked) self.new_button.connect("clicked", self._on_new_clicked)
def _hide_boxes(self, page: Self) -> None: def _hide_boxes(self, page: Self) -> None:
for box in self.success_box, self.from_scratch_box: for box in self.success_box, self.from_scratch_box, self.err_box:
box.set_visible(False) box.set_visible(False)
def _on_new_clicked(self, button: Gtk.Button) -> None: def _on_new_clicked(self, button: Gtk.Button) -> None:
@ -346,7 +342,9 @@ class ConfigMigrationPage(ScrolledWizardPage):
self.migrated = True self.migrated = True
self.success_box.set_visible(True) self.success_box.set_visible(True)
except Exception: except Exception:
pass self.err_box.set_visible(True)
EMITTER.emit("step_pending")
return
EMITTER.emit("step_complete") EMITTER.emit("step_complete")
EMITTER.emit("config", True) EMITTER.emit("config", True)
@ -467,6 +465,7 @@ class Assistant(Gtk.Assistant):
self.connect("cancel", self.destroy_and_quit) self.connect("cancel", self.destroy_and_quit)
self.connect("close", self.destroy_and_quit) self.connect("close", self.destroy_and_quit)
self.show_all() self.show_all()
load_css()
def write_config(self) -> None: def write_config(self) -> None:
write_json(self.config_values, self.config_path) write_json(self.config_values, self.config_path)
@ -546,15 +545,13 @@ class SteamPathPage(ScrolledWizardPage):
) )
self.page_type = Gtk.AssistantPageType.INTRO self.page_type = Gtk.AssistantPageType.INTRO
self.err_box = NotificationFrame(wizard.no_valid_paths, error=True)
# TODO: add custom CSS class to Gtk.Frame so that only this one is styled
err_box = NotificationFrame(wizard.error_steam_path, error=True)
self.err = err_box
self.scan_button = Gtk.Button(label=wizard.button_scan, halign=Gtk.Align.CENTER) self.scan_button = Gtk.Button(label=wizard.button_scan, halign=Gtk.Align.CENTER)
self.scan_button.connect("clicked", self._on_scan_clicked) self.scan_button.connect("clicked", self._on_scan_clicked)
self.add_start(self.scan_button) self.add_start(self.scan_button)
self.add_start(self.err_box)
self.connect("map", self._start_incomplete) self.connect("map", self._start_incomplete)
def _on_scan_clicked(self, button: Gtk.Button) -> None: def _on_scan_clicked(self, button: Gtk.Button) -> None:
@ -567,9 +564,8 @@ class SteamPathPage(ScrolledWizardPage):
spacing=10, spacing=10,
) )
total = len(paths) total = len(paths)
err_box = NotificationFrame(wizard.no_valid_paths)
if total == 0: if total == 0:
self.add_start(err_box) self.err_box.set_visible(True)
else: else:
button_box.add(Gtk.Label(label=f"Steam paths found: {total} total.")) button_box.add(Gtk.Label(label=f"Steam paths found: {total} total."))
for i, button_path in enumerate(paths): for i, button_path in enumerate(paths):
@ -589,11 +585,7 @@ class SteamPathPage(ScrolledWizardPage):
return active.get_label() return active.get_label()
def _start_incomplete(self, page: Self) -> None: def _start_incomplete(self, page: Self) -> None:
self.err.set_visible(False) self.err_box.set_visible(False)
def _test_error_func(self, button: Gtk.CheckButton) -> None:
self.err.set_visible(True)
EMITTER.emit("step_incomplete")
class SetupWizard(Gtk.Application): class SetupWizard(Gtk.Application):
@ -628,6 +620,3 @@ class Emitter(GObject.GObject):
EMITTER = Emitter() EMITTER = Emitter()
# TODO: Ctrl-q
# TODO: change behavior of global emitter