mirror of
https://github.com/aclist/dztui.git
synced 2026-08-26 17:57:06 +02:00
fix: restore mod statusbar when returning from other pages
This commit is contained in:
parent
3af53775cd
commit
8ee3b36816
@ -1,5 +1,4 @@
|
||||
from typing import Self, Union, TYPE_CHECKING
|
||||
from warnings import deprecated
|
||||
|
||||
from dzgui.const.enum import NotebookPage, ServerTab
|
||||
from dzgui.util.strings import esc_to_return, question_to_return
|
||||
@ -26,6 +25,8 @@ class Statusbar(Gtk.Grid):
|
||||
self.controller.register_widget("statusbar", self)
|
||||
self.emitter = controller.get_emitter()
|
||||
|
||||
self.prior_enum: NotebookPage
|
||||
self.prior_status: str
|
||||
self.playercount = ""
|
||||
self.statusbar = Gtk.Statusbar()
|
||||
|
||||
@ -71,6 +72,7 @@ class Statusbar(Gtk.Grid):
|
||||
NotebookPage.LOG,
|
||||
NotebookPage.CONNECTION,
|
||||
):
|
||||
self.prior_enum = enum
|
||||
self.set_by_context(enum, esc_to_return)
|
||||
return
|
||||
|
||||
@ -80,8 +82,9 @@ class Statusbar(Gtk.Grid):
|
||||
case NotebookPage.KEYS:
|
||||
bar = question_to_return
|
||||
case _:
|
||||
return
|
||||
bar = self.prior_status
|
||||
|
||||
self.prior_enum = enum
|
||||
self.set_by_context(enum, bar)
|
||||
|
||||
def _on_server_row_changed(self, statusbar: Self) -> None:
|
||||
@ -97,6 +100,10 @@ class Statusbar(Gtk.Grid):
|
||||
context: Union["ServerTab", NotebookPage],
|
||||
) -> None:
|
||||
self.spinner.stop()
|
||||
|
||||
if type(context) is NotebookPage:
|
||||
self.prior_enum = context
|
||||
self.prior_status = ""
|
||||
# FIXME: CalcDist is being called when table is not loaded
|
||||
if dist is None:
|
||||
return
|
||||
@ -121,6 +128,8 @@ class Statusbar(Gtk.Grid):
|
||||
def set_by_context(
|
||||
self, context: Union[NotebookPage, "ServerTab"], string: str
|
||||
) -> None:
|
||||
if context != NotebookPage.KEYS:
|
||||
self.prior_status = string
|
||||
meta = self.statusbar.get_context_id(str(context))
|
||||
self.statusbar.push(meta, string)
|
||||
self.set_cache(string)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user