Compare commits

...

6 Commits

Author SHA1 Message Date
aclist
c4cc9f04c4
Merge pull request #347 from aclist/chore/clean-statusbar
Some checks are pending
Mirror to Codeberg / mirror-to-codeberg (push) Waiting to run
chore: drop unused code from statusbar
2026-06-06 17:56:03 +09:00
aclist
bcd59162b1 chore: drop unused code from statusbar 2026-06-06 17:55:05 +09:00
aclist
2f0bac75ac
Merge pull request #346 from aclist/fix/permit-filters
fix: permit legacy filters
2026-06-06 17:53:19 +09:00
aclist
9191f43c8e chore: drop comment 2026-06-06 17:50:53 +09:00
aclist
2419fedd19 chore: format exceptions with type 2026-06-06 17:50:32 +09:00
aclist
83a7996189 The filter panel previously did not pack filter labels homogeneously, so
the width of the "Unofficial" label was being manually constrained by
abbreviating it. Labels auto ellipsize and adjust now, so the full name
is used. The filter file check is also allowed to fail if the user's
filter preferences file contains old key names.
2026-06-06 17:39:49 +09:00
7 changed files with 21 additions and 31 deletions

View File

@ -14,6 +14,7 @@ from typing import Any, Optional, TYPE_CHECKING, Union
from dzgui.api.bm import map_id_to_record
from dzgui.const.constants import APP_NAME, REQUEST_TIMEOUT
from dzgui.const.endpoints import STEAM_SERVERS
from dzgui.util.format import format_exception
from dzgui.util import strings
import a2s
@ -272,8 +273,9 @@ def source_info_to_dict(ip: str, qport: int, info: "SourceInfo") -> dict[str, An
res["ping"] = ping
return res
except Exception as e:
# TODO: generalized function
logger.critical(f"{type(e).__name__}: {e} ({ip}:{qport})")
msg = format_exception(e)
msg += f" ({ip}:{qport})"
logger.critical(msg)
raise e

View File

@ -238,8 +238,7 @@ class ConnectionManager:
def query_modlist_and_present(self, record: Servers.Record) -> None:
try:
mods = self._query_modlist(record)
except Exception as e:
print(f"{type(e).__name__}: {e}")
except Exception:
self.thread_man.set_cleanup_func(
StoredFunc(self._server_timeout), destroy_first=True
)

View File

@ -83,3 +83,7 @@ def format_player_count(model: Gtk.TreeModel | None, control: list) -> str:
def embolden(text: str) -> str:
return f"<b>{text}</b>"
def format_exception(e: Exception) -> str:
return f"{type(e).__name__}: {e}"

View File

@ -181,7 +181,7 @@ filter_lowpop = "Low pop"
filter_nonascii = "Non-ASCII"
filter_duplicate = "Duplicate"
filter_official = "Official"
filter_unofficial = "Unoffic."
filter_unofficial = "Unofficial"
filter_modded = "Modded"
# maps

View File

@ -11,6 +11,7 @@ from dzgui.const.constants import (
)
from dzgui.const.enum import FilterMode
from dzgui.model.servers import ServerModelManager
from dzgui.util.format import format_exception
from dzgui.util.strings import all_maps
from dzgui.views.components.maps_combo import MapsCombo
from dzgui.views.components.labels import BoldLabel
@ -333,6 +334,10 @@ class FilterPanel(Gtk.Box):
self.emitter.emit("map_selection_changed", name)
def set_filters(self, filters: dict[str, bool]) -> None:
for check in self.button_grid.checks:
label = check.get_label()
check.set_active(filters[label])
try:
for check in self.button_grid.checks:
label = check.get_label()
check.set_active(filters[label])
except Exception as e:
msg = format_exception(e)
logger.warning(msg)

View File

@ -8,7 +8,7 @@ from dzgui.views.components.buttons import LoggerAlertsButton
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk, GObject # noqa E402
from gi.repository import Gtk # noqa E402
if TYPE_CHECKING:
from dzgui.const.enum import ServerTab
@ -34,14 +34,6 @@ class Statusbar(Gtk.Grid):
self.attach(self.statusbar, 0, 0, 3, 1)
self.attach_next_to(self.spinner, self.statusbar, Gtk.PositionType.RIGHT, 3, 1)
# TODO: pack version event box in right panel into hbox with update button
# TODO: spawns a modal or just jumps right to install page
# from dzgui.views.components.buttons import IconTextButton
# b = IconTextButton("dialog-information-symbolic", label="Updates available")
# b.set_halign(Gtk.Align.END)
# b.set_hexpand(True)
# self.attach_next_to(b, self.spinner, Gtk.PositionType.RIGHT, 3, 1)
self.players = ""
controller.get_menu().connect("generic_treesel_changed", self._help_row_changed)
@ -92,12 +84,6 @@ class Statusbar(Gtk.Grid):
self.set_by_context(enum, bar)
# TODO: unused
def _on_notebook_page_returned(
self, statusbar: Self, prior_context: NotebookPage
) -> None:
self.pop(prior_context)
def _on_server_row_changed(self, statusbar: Self) -> None:
self.spinner.start()
@ -132,12 +118,6 @@ class Statusbar(Gtk.Grid):
cid = self.statusbar.get_context_id(str(context))
self.statusbar.pop(cid)
@deprecated("currently unused")
# def get_text(self) -> str:
# area = self.statusbar.get_message_area()
# label = area.get_children()[0]
# return str(label.get_text())
def set_by_context(
self, context: Union[NotebookPage, "ServerTab"], string: str
) -> None:

View File

@ -14,6 +14,7 @@ from dzgui.init.update import check_updates
from dzgui.const.constants import EXPAND, FILL
from dzgui.managers.threading import call_on_thread, StoredFunc, ThreadingManager
from dzgui.strings import preboot
from dzgui.util.format import format_exception
from dzgui.util.strings import dialog_header
from dzgui.util.symlink import rebuild_symlinks
from dzgui.views.components.buttons import ClipboardButton
@ -175,8 +176,7 @@ class BootDialog(Gtk.Dialog):
self.thread_man.set_cleanup_func(callback)
except Exception as e:
self.failed = True
# TODO: generic exception wrapper
self.exception = f"{type(e).__name__}: {e}"
self.exception = format_exception(e)
callback = StoredFunc(self.update_status, Success.FAIL)
self.thread_man.set_cleanup_func(callback)