feat: wrap callback function

This commit is contained in:
aclist committed 2026-02-14 20:16:28 +09:00
1 parent 2c8e722d8a
commit 96244a4560
8 files changed
+150 -108

No files matched your search

+10 -9
View File
@@ -16,7 +16,7 @@ if TYPE_CHECKING:
class EnumeratedModButton(Gtk.Button):
def __init__(self, enum: ModButton) -> None:
super().__init__(margin_start=10, margin_end=10)
super().__init__(margin_start=10, margin_end=10, focus_on_click=False)
self.enum = enum
self.set_label(enum.dict["label"])
@@ -30,6 +30,7 @@ class ModSelectionPanel(Gtk.Box):
self.controller = controller
emitter = controller.get_emitter()
emitter.connect("mod_page_toggled", self._on_mod_page_toggled)
emitter.connect("mods_highlighted", self._on_mods_highlighted)
header = BoldLabel(mod_panel.header)
@@ -60,14 +61,17 @@ class ModSelectionPanel(Gtk.Box):
for el in header, self.main_panel, self.stale_panel:
self.pack_start(el, NO_EXPAND, FILL, NO_PADDING)
def _on_mods_highlighted(self, emitter: "Emitter") -> None:
self.swap_sensitive(True)
def _on_mod_page_toggled(self, emitter: "Emitter", state: bool) -> None:
self.set_visible(state)
def after_colorize(self) -> None:
# TODO: split into signal that touches two widgets,
# modtreeview and this widget
self.controller.unselect_all_mods()
self.swap_sensitive(True)
#def after_colorize(self) -> None:
# # TODO: split into signal that touches two widgets,
# # modtreeview and this widget
# #self.controller.unselect_all_mods()
# self.swap_sensitive(True)
def swap_sensitive(self, state: bool) -> None:
for child in self.stale_panel.get_children():
@@ -79,15 +83,12 @@ class ModSelectionPanel(Gtk.Box):
def _on_button_clicked(self, button: EnumeratedModButton) -> None:
match button.enum:
case ModButton.SELECT_ALL:
# TODO: signals
self.controller.toggle_mod_selection(True)
case ModButton.UNSELECT_ALL:
self.controller.toggle_mod_selection(False)
case ModButton.DELETE_SELECTED:
self.controller.delete_multiple_mods()
case ModButton.HIGHLIGHT_STALE:
self.controller.set_callback(self.after_colorize)
self.controller.highlight_stale()
case ModButton.UNHIGHLIGHT_STALE:
self.controller.uncolorize_mods()
+1
View File
@@ -44,6 +44,7 @@ class RightPanel(Gtk.Box):
state = self.controller.has_server_model()
for widget in (self.refresh_button, self.filters_vbox):
widget.set_sensitive(state)
# FIXME: may wish to reload these in place to show new data
if context in (ServerTab.RECENT, ServerTab.SAVED):
self.refresh_button.set_sensitive(False)
+10 -2
View File
@@ -51,6 +51,11 @@ class Statusbar(Gtk.Grid):
self.emitter.connect("distcalc_started", self._on_distcalc_started)
self.emitter.connect("distcalc_ended", self._on_distcalc_ended)
self.emitter.connect("servers_loaded", self._on_servers_loaded)
self.emitter.connect("mod_page_loaded", self._on_mod_page_loaded)
def _on_mod_page_loaded(self, emitter: "Emitter") -> None:
msg = self.controller.format_mod_statusbar()
self.set_by_context(NotebookPage.MODS, msg)
def _on_notebook_page_changed(
self, notebook: "Notebook", child: Gtk.Widget, index: int
@@ -75,12 +80,15 @@ class Statusbar(Gtk.Grid):
match enum:
case NotebookPage.MODS:
bar = self.controller.format_mod_statusbar()
return
# FIXME: format on callback after mods load
#bar = self.controller.format_mod_statusbar()
case NotebookPage.HELP:
bar = self.controller.get_help_row()
case NotebookPage.SERVERS:
context = self.controller.get_active_context()
self.emitter.emit("servers_loaded", context)
# FIXME: may be superfluous
#self.emitter.emit("servers_loaded", context)
return
case NotebookPage.KEYS:
bar = question_to_return