mirror of
https://github.com/aclist/dztui.git
synced 2026-08-26 09:47:36 +02:00
change: drop statusbar alerts button
This commit is contained in:
parent
8ec9e5abff
commit
63d85b03c1
@ -150,8 +150,4 @@ class Emitter(GObject.GObject):
|
||||
def keyword_set(self, keyword: str) -> None:
|
||||
pass
|
||||
|
||||
@GObject.Signal(flags=GObject.SignalFlags.RUN_LAST, arg_types=())
|
||||
def log_page_loaded(self) -> None:
|
||||
pass
|
||||
|
||||
# TODO: if servers fail to load, may leave dangling widgets waiting for a signal
|
||||
|
||||
@ -483,13 +483,5 @@ class Controller(GObject.GObject):
|
||||
def set_active_keyword(self, keyword: str) -> None:
|
||||
self.get_filter_man().set_active_keyword(keyword)
|
||||
|
||||
def set_alerts(self, count: tuple[int]) -> None:
|
||||
self.alerts = count
|
||||
|
||||
def get_alerts(self) -> tuple[int]:
|
||||
log_man = LogManager()
|
||||
alerts = log_man.get_alerts(self.prefs.paths.debug)
|
||||
return alerts
|
||||
|
||||
def get_modtreeview(self) -> "ModTreeView":
|
||||
return self.mediator.modtreeview
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
import logging
|
||||
from pathlib import Path
|
||||
|
||||
from dzgui.const.constants import APP_NAME
|
||||
from dzgui.util.strings import delimiter
|
||||
|
||||
logger = logging.getLogger(APP_NAME)
|
||||
|
||||
|
||||
class LogManager:
|
||||
def __init__(self) -> None:
|
||||
self.CRITICAL = "CRITICAL"
|
||||
self.WARNING = "WARNING"
|
||||
|
||||
# TODO: more of a static method
|
||||
def get_alerts(self, log_path: Path) -> tuple[int]:
|
||||
try:
|
||||
with open(log_path, "r") as f:
|
||||
lines = f.read().splitlines()
|
||||
errors = [
|
||||
line for line in lines if line.split(delimiter)[1] == self.CRITICAL
|
||||
]
|
||||
warnings = [
|
||||
line for line in lines if line.split(delimiter)[1] == self.WARNING
|
||||
]
|
||||
return len(warnings), len(errors)
|
||||
except Exception as e:
|
||||
logger.critical(e)
|
||||
return 0, 0
|
||||
@ -33,15 +33,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)
|
||||
|
||||
warnings, errors = self.controller.get_alerts()
|
||||
|
||||
if warnings + errors > 0:
|
||||
self.alert_button = LoggerAlertsButton(warnings, errors)
|
||||
self.attach_next_to(
|
||||
self.alert_button, self.spinner, Gtk.PositionType.RIGHT, 3, 1
|
||||
)
|
||||
self.alert_button.connect("clicked", self._on_alerts_clicked)
|
||||
|
||||
# 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
|
||||
@ -61,15 +52,10 @@ class Statusbar(Gtk.Grid):
|
||||
self.emitter.connect("distcalc_ended", self._on_distcalc_ended)
|
||||
self.emitter.connect("servers_loaded", self._on_servers_loaded)
|
||||
self.emitter.connect("mods_updated", self._on_mods_updated)
|
||||
self.emitter.connect("log_page_loaded", self._on_log_page_loaded)
|
||||
|
||||
def _on_alerts_clicked(self, button: LoggerAlertsButton) -> None:
|
||||
self.controller.populate_log()
|
||||
|
||||
def _on_log_page_loaded(self, emitter: "Emitter") -> None:
|
||||
# FIXME: fails if button was not previously drawn
|
||||
self.alert_button.hide()
|
||||
|
||||
def _on_mods_updated(self, emitter: "Emitter", msg: str, mods: int) -> None:
|
||||
self.set_by_context(NotebookPage.MODS, msg)
|
||||
|
||||
|
||||
@ -42,7 +42,6 @@ class Log(CursorMixin, HelpMenuMixin, Gtk.Box): # type: ignore
|
||||
self.emitter = controller.get_emitter()
|
||||
|
||||
self.connect("key-press-event", self._on_esc_keypress)
|
||||
self.connect("map", lambda _: self.emitter.emit("log_page_loaded"))
|
||||
|
||||
def _on_checkbox_clicked(self, checkbox: Gtk.CheckButton) -> None:
|
||||
label = checkbox.get_label()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user