fix: handle zero mods

This commit is contained in:
aclist 2026-04-30 01:06:20 +09:00
parent 0fad9155e2
commit 34d8545c94
4 changed files with 18 additions and 5 deletions

View File

@ -124,8 +124,14 @@ class Emitter(GObject.GObject):
def load_maps(self, store: ListStore) -> None:
pass
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=(str,))
def mods_updated(self, msg: str) -> None:
@GObject.Signal(
flags=GObject.SignalFlags.RUN_LAST,
arg_types=(
str,
int,
),
)
def mods_updated(self, msg: str, mods: int) -> None:
pass
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=())

View File

@ -31,6 +31,7 @@ class ModSelectionPanel(Gtk.Box):
emitter = controller.get_emitter()
emitter.connect("mod_page_toggled", self._on_mod_page_toggled)
emitter.connect("mods_highlighted", self._on_mods_highlighted)
emitter.connect("mods_updated", self._on_mods_updated)
header = BoldLabel(mod_panel.header)
@ -72,6 +73,11 @@ class ModSelectionPanel(Gtk.Box):
else:
child.set_sensitive(True)
def _on_mods_updated(self, emitter: "Emitter", msg: str, mods: int) -> None:
if mods < 1:
self.main_panel.set_sensitive(False)
self.stale_panel.set_sensitive(False)
def _on_mods_highlighted(self, emitter: "Emitter") -> None:
self.swap_sensitive(True)

View File

@ -70,7 +70,7 @@ class Statusbar(Gtk.Grid):
# FIXME: fails if button was not previously drawn
self.alert_button.hide()
def _on_mods_updated(self, emitter: "Emitter", msg: str) -> None:
def _on_mods_updated(self, emitter: "Emitter", msg: str, mods: int) -> None:
self.set_by_context(NotebookPage.MODS, msg)
def _on_notebook_page_changed(

View File

@ -61,8 +61,9 @@ class ModTreeView(ModsMixin, ContextMixin, TreeView):
def _on_mods_highlighted(self, emitter: "Emitter") -> None:
self.get_selection().unselect_all()
# TODO: test loading with no mods
def _on_mods_updated(self, emitter: "Emitter", msg: str) -> None:
def _on_mods_updated(self, emitter: "Emitter", msg: str, mods: int) -> None:
if mods < 1:
return
self.set_cursor(0)
def get_selected_mod(self) -> str: