mirror of
https://github.com/aclist/dztui.git
synced 2026-08-28 02:37:20 +02:00
chore: store filter levels as constant
This commit is contained in:
parent
0aafe44b4e
commit
7139686d9b
@ -61,3 +61,5 @@ LEGACY_IPS_PATH = ".local/share/dzgui/helpers/ips.csv"
|
||||
DEBUG_LOG = f"{APP_NAME}_DEBUG.LOG"
|
||||
SYSTEM_LOG = f"{APP_NAME}_SYSTEM.LOG"
|
||||
CHANGELOG_PATH = "data/CHANGELOG.md"
|
||||
|
||||
LOG_FILTERS = ("CRITICAL", "WARNING", "INFO", "DEBUG")
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
from typing import TYPE_CHECKING
|
||||
from dzgui.const.constants import LOG_FILTERS
|
||||
from dzgui.views.mixins.cursor_mixin import CursorMixin
|
||||
from dzgui.views.mixins.help_menu_mixin import HelpMenuMixin
|
||||
from dzgui.views.trees.tree_log import LogTreeView
|
||||
@ -16,23 +17,20 @@ if TYPE_CHECKING:
|
||||
class Log(CursorMixin, HelpMenuMixin, Gtk.Box): # type: ignore
|
||||
def __init__(self, controller: "Controller") -> None:
|
||||
super().__init__(orientation=Gtk.Orientation.VERTICAL)
|
||||
# NOTE: LogTreeView is kept in a separate ScrolledWindow so that
|
||||
# checkboxes will be flush on bottom
|
||||
"""
|
||||
NOTE: LogTreeView is kept in a separate ScrolledWindow so that
|
||||
checkboxes will be flush on bottom
|
||||
"""
|
||||
self.scrolled = Gtk.ScrolledWindow()
|
||||
self.treeview = LogTreeView(controller)
|
||||
self.scrolled.add(self.treeview)
|
||||
|
||||
self.check_bar = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
# TODO: strings
|
||||
active = (
|
||||
"WARN",
|
||||
"CRITICAL",
|
||||
)
|
||||
for check in ("WARN", "CRITICAL", "INFO", "DEBUG"):
|
||||
|
||||
for check in LOG_FILTERS:
|
||||
c = Gtk.CheckButton(label=check)
|
||||
self.check_bar.pack_start(c, False, False, 0)
|
||||
if check in active:
|
||||
c.set_active(True)
|
||||
c.set_active(True)
|
||||
c.connect("clicked", self._on_checkbox_clicked)
|
||||
self.add(self.scrolled)
|
||||
self.add(self.check_bar)
|
||||
|
||||
@ -2,7 +2,7 @@ import logging
|
||||
|
||||
from typing import Any, TYPE_CHECKING
|
||||
|
||||
from dzgui.const.constants import APP_NAME
|
||||
from dzgui.const.constants import APP_NAME, LOG_FILTERS
|
||||
from dzgui.const.enum import ContextMenuGroup
|
||||
from dzgui.model.model_factory import ModelFactory
|
||||
from dzgui.util import strings
|
||||
@ -35,9 +35,7 @@ class LogTreeView(ContextMixin, TreeView):
|
||||
|
||||
self.set_model(None)
|
||||
|
||||
# TODO: strings
|
||||
# NOTE: default filters that should be shown on startup
|
||||
self.filters = ["CRITICAL", "WARNING"]
|
||||
self.filters = list(LOG_FILTERS)
|
||||
for i, column_title in enumerate(strings.log_cols):
|
||||
renderer = Gtk.CellRendererText()
|
||||
column = Gtk.TreeViewColumn(column_title, renderer, text=i)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user