Added log to ui toggle

This commit is contained in:
itdominator 2024-09-26 21:24:31 -05:00
parent ffcad8a139
commit 135304cedc
2 changed files with 18 additions and 7 deletions

View File

@ -16,6 +16,8 @@ class LogList(Gtk.ListBox):
def __init__(self): def __init__(self):
super(LogList, self).__init__() super(LogList, self).__init__()
self.display_logging = False
self._setup_styling() self._setup_styling()
self._setup_signals() self._setup_signals()
self._subscribe_to_events() self._subscribe_to_events()
@ -52,7 +54,12 @@ class LogList(Gtk.ListBox):
def _load_widgets(self): def _load_widgets(self):
... ...
def toggle_logging(self, state: bool):
self.display_logging = state
def add_log_entry(self, m_type: str, data: MessageTypes): def add_log_entry(self, m_type: str, data: MessageTypes):
if not self.display_logging: return
message = get_message_str(data) message = get_message_str(data)
frame = Gtk.Frame() frame = Gtk.Frame()

View File

@ -51,14 +51,15 @@ class LSPUI(Gtk.Grid):
def _load_widgets(self): def _load_widgets(self):
scrolled_win1 = Gtk.ScrolledWindow() scrolled_win1 = Gtk.ScrolledWindow()
scrolled_win2 = Gtk.ScrolledWindow() scrolled_win2 = Gtk.ScrolledWindow()
log_chk_btn = Gtk.CheckButton(label = "Log to UI")
self.log_list = LogList() self.log_list = LogList()
alt_command_lbl = Gtk.Label(label="Alt Command:") alt_command_lbl = Gtk.Label(label = "Alt Command:")
command_lbl = Gtk.Label(label="Command:") command_lbl = Gtk.Label(label = "Command:")
socket_lbl = Gtk.Label(label="Socket:") socket_lbl = Gtk.Label(label = "Socket:")
init_options_lbl = Gtk.Label(label="Initialization Options") init_options_lbl = Gtk.Label(label = "Initialization Options")
message_box_lbl = Gtk.Label(label="Message Box") message_box_lbl = Gtk.Label(label = "Message Box")
log_list_lbl = Gtk.Label(label="Logs") log_list_lbl = Gtk.Label(label = "Logs")
self.link_btn = InfoLinkButton(self._language.title(), self._data["info"]) self.link_btn = InfoLinkButton(self._language.title(), self._data["info"])
self.alt_command_entry = AltCommandEntry( self._data["alt-command"] ) 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"] ) self.init_ops_src_vw = InitOptionsSourceView( self._data["initialization-options"] )
message_box = LSPMessageBox() 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) init_options_lbl.set_margin_top(10)
message_box_lbl.set_margin_top(10) message_box_lbl.set_margin_top(10)
log_list_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(message_box, 0, 7, 3, 1)
self.attach(log_list_lbl, 3, 0, 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(): for child in self.get_children():
child.show() child.show()