feat: set start tab

This commit is contained in:
aclist committed 2026-05-05 18:31:50 +09:00
1 parent ce44d67bf6
commit 73d131a64b
9 files changed
+75 -31

No files matched your search

+41 -14
View File
@@ -4,17 +4,6 @@ from typing import TYPE_CHECKING
from dzgui.api import pefile as PeFile
from dzgui.api.steam import find_user_id
from dzgui.config import query
from dzgui.util import strings, css, open_links
from dzgui.views.components.labels import LeftLabel
from dzgui.views.components.eventbox import InfoEventBox
from dzgui.views.components.buttons import WebButton
from dzgui.views.components.frame import HeadingFrame
from dzgui.views.dialogs.generic import ExceptionDialog
from dzgui.views.dialogs.link_dialog import WorkshopLinkDialog
from dzgui.const.enum import Preferences
from dzgui.const.endpoints import STEAM_API_SETUP, BM_API_SETUP
from dzgui.const.constants import (
APPID_DAYZ,
APPID_DAYZ_EXP,
@@ -29,6 +18,16 @@ from dzgui.const.constants import (
VIEW_CONCEAL,
VIEW_REVEAL,
)
from dzgui.const.endpoints import STEAM_API_SETUP, BM_API_SETUP
from dzgui.const.enum import Preferences, ServerTab
from dzgui.util import strings, css, open_links
from dzgui.views.components.labels import LeftLabel
from dzgui.views.components.eventbox import InfoEventBox
from dzgui.views.components.buttons import WebButton
from dzgui.views.components.frame import HeadingFrame
from dzgui.views.dialogs.generic import ExceptionDialog
from dzgui.views.dialogs.link_dialog import WorkshopLinkDialog
import gi
@@ -96,17 +95,36 @@ class Options(Gtk.Box):
self.client_combo.append_text("Flatpak (container)")
self.client_combo.set_active(0)
self.client_combo.connect("changed", self._on_client_changed)
hbox = Gtk.Box(spacing=5, halign=Gtk.Align.START)
hbox.pack_start(self.client_combo, NO_EXPAND, NO_FILL, NO_PADDING)
client_hbox = Gtk.Box(spacing=5, halign=Gtk.Align.START)
client_hbox.pack_start(self.client_combo, NO_EXPAND, NO_FILL, NO_PADDING)
self.distance_toggle = self.make_binary_radio(
strings.options.km, strings.options.mi, Preferences.DIST
)
combo_store = Gtk.ListStore(str, object)
tabs = (
("Server browser", ServerTab.BROWSER),
("Saved servers", ServerTab.SAVED),
("Recent", ServerTab.RECENT),
("LAN", ServerTab.LAN),
)
for tab in tabs:
combo_store.append(tab)
self.start_tab_combo = Gtk.ComboBox.new_with_model(combo_store)
renderer_text = Gtk.CellRendererText()
self.start_tab_combo.pack_start(renderer_text, True)
self.start_tab_combo.add_attribute(renderer_text, "text", 0)
self.start_tab_combo.set_active(0)
start_tab_hbox = Gtk.Box(spacing=5, halign=Gtk.Align.START)
start_tab_hbox.pack_start(self.start_tab_combo, NO_EXPAND, NO_FILL, NO_PADDING)
self.start_tab_combo.connect("changed", self._on_start_tab_changed)
pref_rows = [
[LeftLabel(strings.options.client), hbox],
[LeftLabel(strings.options.client), client_hbox],
[LeftLabel(strings.options.window_size), self.fullscreen_toggle],
[LeftLabel(strings.options.distance), self.distance_toggle],
[LeftLabel("Start tab"), start_tab_hbox],
[LeftLabel(strings.options.name), self.player_box],
]
@@ -295,6 +313,12 @@ class Options(Gtk.Box):
# TODO: unimplemented
print("UNIMPLEMENTED")
def _on_start_tab_changed(self, combo: Gtk.ComboBoxText) -> None:
_iter = combo.get_active_iter()
enum = combo.get_model()[_iter][1]
index = enum.value
self.controller.update_config(Preferences.START_TAB, index)
def _on_client_changed(self, combo: Gtk.ComboBoxText) -> None:
# TODO: use two columns or constants here, not strings
client = combo.get_active_text()
@@ -457,6 +481,9 @@ class Options(Gtk.Box):
self.client_combo.set_active(active_combo)
# active_combo = 0
start_tab = self.controller.query_config(Preferences.START_TAB)
self.start_tab_combo.set_active(start_tab)
def _suppress_toggles(self, state: bool) -> None:
for toggle in [
self.mod_install_toggle,