From 135304cedccb6330f953af3cf418f23ed9b33dcb Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Thu, 26 Sep 2024 21:24:31 -0500 Subject: [PATCH] Added log to ui toggle --- src/core/widgets/log_list.py | 7 +++++++ src/core/widgets/lsp_ui.py | 18 +++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/core/widgets/log_list.py b/src/core/widgets/log_list.py index 93fe8dc..acf64d9 100644 --- a/src/core/widgets/log_list.py +++ b/src/core/widgets/log_list.py @@ -16,6 +16,8 @@ class LogList(Gtk.ListBox): def __init__(self): super(LogList, self).__init__() + self.display_logging = False + self._setup_styling() self._setup_signals() self._subscribe_to_events() @@ -52,7 +54,12 @@ class LogList(Gtk.ListBox): def _load_widgets(self): ... + def toggle_logging(self, state: bool): + self.display_logging = state + def add_log_entry(self, m_type: str, data: MessageTypes): + if not self.display_logging: return + message = get_message_str(data) frame = Gtk.Frame() diff --git a/src/core/widgets/lsp_ui.py b/src/core/widgets/lsp_ui.py index e2fef46..c6eb4a3 100644 --- a/src/core/widgets/lsp_ui.py +++ b/src/core/widgets/lsp_ui.py @@ -51,14 +51,15 @@ class LSPUI(Gtk.Grid): def _load_widgets(self): scrolled_win1 = Gtk.ScrolledWindow() scrolled_win2 = Gtk.ScrolledWindow() + log_chk_btn = Gtk.CheckButton(label = "Log to UI") self.log_list = LogList() - alt_command_lbl = Gtk.Label(label="Alt Command:") - command_lbl = Gtk.Label(label="Command:") - socket_lbl = Gtk.Label(label="Socket:") - init_options_lbl = Gtk.Label(label="Initialization Options") - message_box_lbl = Gtk.Label(label="Message Box") - log_list_lbl = Gtk.Label(label="Logs") + alt_command_lbl = Gtk.Label(label = "Alt Command:") + command_lbl = Gtk.Label(label = "Command:") + socket_lbl = Gtk.Label(label = "Socket:") + init_options_lbl = Gtk.Label(label = "Initialization Options") + message_box_lbl = Gtk.Label(label = "Message Box") + log_list_lbl = Gtk.Label(label = "Logs") self.link_btn = InfoLinkButton(self._language.title(), self._data["info"]) self.alt_command_entry = AltCommandEntry( self._data["alt-command"] ) @@ -67,6 +68,8 @@ class LSPUI(Gtk.Grid): self.init_ops_src_vw = InitOptionsSourceView( self._data["initialization-options"] ) message_box = LSPMessageBox() + log_chk_btn.connect("toggled", lambda button: self.log_list.toggle_logging( button.get_active() ) ) + init_options_lbl.set_margin_top(10) message_box_lbl.set_margin_top(10) log_list_lbl.set_margin_top(10) @@ -96,7 +99,8 @@ class LSPUI(Gtk.Grid): self.attach(message_box, 0, 7, 3, 1) self.attach(log_list_lbl, 3, 0, 3, 1) - self.attach(scrolled_win2, 3, 1, 3, 11) + self.attach(log_chk_btn, 3, 1, 3, 1) + self.attach(scrolled_win2, 3, 2, 3, 10) for child in self.get_children(): child.show() \ No newline at end of file