fix: rearrange preferences box elements

This commit is contained in:
aclist committed 2026-05-17 22:54:03 +09:00
1 parent 25e2e7e20e
commit 13bd36cec6
4 files changed
+31 -26

No files matched your search

+1 -1
View File
@@ -109,7 +109,7 @@ def main() -> None:
migrate_cols_file(XDG.columns) migrate_cols_file(XDG.columns)
copy_state_files(xdg_paths["XDG_STATE_HOME"]) copy_state_files(xdg_paths["XDG_STATE_HOME"])
# TODO: add logging inside wizard # TODO: add logging inside wizard
SetupWizard(version, _is_steam_deck, XDG.config) SetupWizard(_is_steam_deck, XDG.config)
return return
setup_logger(XDG.debug) setup_logger(XDG.debug)
+1 -1
View File
@@ -1,7 +1,7 @@
### IntroductionPage ### IntroductionPage
title_intro = "Welcome" title_intro = "Welcome"
blurb_intro = """ blurb_intro = """
This wizard is going to help you set up some common config options before launching the application. This wizard will help you set up some common config options before launching the application.
""" """
### SteamPathPage ### SteamPathPage
+28 -23
View File
@@ -236,10 +236,10 @@ class SteamValidationPage(APIValidationPage):
class IntroductionPage(ScrolledWizardPage): class IntroductionPage(ScrolledWizardPage):
def __init__(self, version: str): def __init__(self):
super().__init__( super().__init__(
enum=PageNum.INTRO, enum=PageNum.INTRO,
heading=f"Welcome to {APP_NAME} {version}!", heading=f"Welcome to {APP_NAME}!",
description=wizard.blurb_intro, description=wizard.blurb_intro,
) )
self.page_type = Gtk.AssistantPageType.INTRO self.page_type = Gtk.AssistantPageType.INTRO
@@ -359,37 +359,39 @@ class PreferencesPage(ScrolledWizardPage):
self.page_type = Gtk.AssistantPageType.INTRO self.page_type = Gtk.AssistantPageType.INTRO
# TODO: widgets and strings are largely a reimplementation of options page, consolidate # TODO: widgets and strings are largely a reimplementation of options page, consolidate
name_label = Gtk.Label(label=wizard.label_player) name_label = Gtk.Label(label=wizard.label_player, halign=Gtk.Align.START)
self.name_box = Gtk.Box( self.name_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
orientation=Gtk.Orientation.HORIZONTAL, spacing=10, halign=Gtk.Align.CENTER self.name_entry = Gtk.Entry(
placeholder_text=wizard.placeholder_player,
halign=Gtk.Align.END,
width_chars=40,
) )
self.name_entry = Gtk.Entry(placeholder_text=wizard.placeholder_player)
self.name_entry.connect("changed", self._on_entry_changed) self.name_entry.connect("changed", self._on_entry_changed)
self.name_box.add(name_label) self.name_box.add(name_label)
self.name_box.add(self.name_entry) self.name_box.add(self.name_entry)
self.dist_box = Gtk.Box( self.dist_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
orientation=Gtk.Orientation.HORIZONTAL, spacing=10, halign=Gtk.Align.CENTER
)
self.radio_km = Gtk.RadioButton.new_with_label(None, wizard.radio_km) self.radio_km = Gtk.RadioButton.new_with_label(None, wizard.radio_km)
self.radio_miles = Gtk.RadioButton.new_with_label_from_widget( self.radio_miles = Gtk.RadioButton.new_with_label_from_widget(
self.radio_km, wizard.radio_mi self.radio_km, wizard.radio_mi
) )
dist_label = Gtk.Label(label=wizard.label_dist) dist_label = Gtk.Label(label=wizard.label_dist, halign=Gtk.Align.START)
self.dist_box.add(dist_label) self.dist_box.add(dist_label)
self.dist_box.add(self.radio_km) self.dist_box.add(self.radio_km)
self.dist_box.add(self.radio_miles) self.dist_box.add(self.radio_miles)
client_label = Gtk.Label(label=wizard.label_client) client_label = Gtk.Label(label=wizard.label_client, halign=Gtk.Align.START)
self.client_box = Gtk.Box( self.client_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=10)
orientation=Gtk.Orientation.HORIZONTAL, spacing=10, halign=Gtk.Align.CENTER
)
self.client_combo = ClientCombo() self.client_combo = ClientCombo()
self.client_box.add(client_label) self.client_box.add(client_label)
self.client_box.add(self.client_combo) self.client_box.add(self.client_combo)
for el in self.name_box, self.dist_box, self.client_box: outer_box = Gtk.Box(
self.add_start(el) orientation=Gtk.Orientation.VERTICAL, halign=Gtk.Align.CENTER, spacing=10
)
for el in self.name_box, self.client_box, self.dist_box:
outer_box.add(el)
self.add_start(outer_box)
def get_prefs(self) -> tuple[str, bool, str]: def get_prefs(self) -> tuple[str, bool, str]:
name = self.name_entry.get_text().strip() name = self.name_entry.get_text().strip()
@@ -420,7 +422,7 @@ class CompletionPage(ScrolledWizardPage):
class Assistant(Gtk.Assistant): class Assistant(Gtk.Assistant):
def __init__(self, version: str, is_deck: bool, config: Path): def __init__(self, is_deck: bool, config: Path):
super().__init__() super().__init__()
if is_deck: if is_deck:
self.fullscreen() self.fullscreen()
@@ -431,7 +433,7 @@ class Assistant(Gtk.Assistant):
self.config_values: dict[str, Any] = config_boilerplate self.config_values: dict[str, Any] = config_boilerplate
self.page1 = IntroductionPage(version) self.page1 = IntroductionPage()
self.page2 = ConfigMigrationPage(config) self.page2 = ConfigMigrationPage(config)
self.page3 = SteamPathPage() self.page3 = SteamPathPage()
self.page4 = SteamValidationPage() self.page4 = SteamValidationPage()
@@ -565,7 +567,7 @@ class SteamPathPage(ScrolledWizardPage):
) )
total = len(paths) total = len(paths)
if total == 0: if total == 0:
self.err_box.set_visible(True) show_errors = 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):
@@ -577,8 +579,11 @@ class SteamPathPage(ScrolledWizardPage):
frame = RadioFrame(self.first_button, button_path) frame = RadioFrame(self.first_button, button_path)
button_box.add(frame) button_box.add(frame)
self.add_start(button_box) self.add_start(button_box)
show_errors = False
EMITTER.emit("step_complete") EMITTER.emit("step_complete")
self.show_all() self.show_all()
# TODO: more robust approach
self.err_box.set_visible(show_errors)
def get_path_from_radio(self) -> str: def get_path_from_radio(self) -> str:
active = next(r for r in self.first_button.get_group() if r.get_active()) active = next(r for r in self.first_button.get_group() if r.get_active())
@@ -589,17 +594,17 @@ class SteamPathPage(ScrolledWizardPage):
class SetupWizard(Gtk.Application): class SetupWizard(Gtk.Application):
def __init__(self, version: str, is_deck: bool, config: Path) -> None: def __init__(self, is_deck: bool, config: Path) -> None:
super().__init__() super().__init__()
GLib.set_prgname(APP_NAME) GLib.set_prgname(APP_NAME)
Window(version, is_deck, config) Window(is_deck, config)
Gtk.main() Gtk.main()
class Window(Gtk.Window): class Window(Gtk.Window):
def __init__(self, version: str, is_deck: bool, config: Path) -> None: def __init__(self, is_deck: bool, config: Path) -> None:
super().__init__(title=APP_NAME, icon_name=APP_NAME) super().__init__(title=APP_NAME, icon_name=APP_NAME)
Assistant(version, is_deck, config) Assistant(is_deck, config)
class Emitter(GObject.GObject): class Emitter(GObject.GObject):