feat(notifications): add clear close #1178

This commit is contained in:
Alfredo Monclus committed 2024-07-06 11:15:50 -03:00
1 parent 115dba8c88
commit fde41e85dd
2 files changed
+21 -5

No files matched your search

+18 -5
View File
@@ -29,12 +29,19 @@ class Panel(ScreenPanel):
scroll = Gtk.ScrolledWindow(hexpand=True, vexpand=True)
scroll.add(tv)
self.content.add(scroll)
clear_button = self._gtk.Button("refresh", _('Clear') + " ", None, self.bts, Gtk.PositionType.RIGHT, 1)
clear_button.get_style_context().add_class("buttons_slim")
clear_button.set_vexpand(False)
clear_button.connect("clicked", self.clear)
content_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
content_box.add(clear_button)
content_box.add(scroll)
self.content.add(content_box)
def activate(self):
self.clear()
for log in self._screen.notification_log:
self.add_notification(log)
self.refresh()
def add_notification(self, log):
if log["level"] == 0:
@@ -55,8 +62,14 @@ class Panel(ScreenPanel):
-1
)
def clear(self):
def clear(self, widget):
self.tb.set_text("")
self._screen.notification_log_clear()
def refresh(self):
self.tb.set_text("")
for log in self._screen.notification_log:
self.add_notification(log)
def process_update(self, action, data):
if action != "notify_log":
+3
View File
@@ -362,6 +362,9 @@ class KlipperScreen(Gtk.Window):
self.notification_log.append(log_entry)
self.process_update("notify_log", log_entry)
def notification_log_clear(self):
self.notification_log.clear()
def show_popup_message(self, message, level=3, from_ws=False):
if from_ws:
if (datetime.now() - self.last_popup_time).seconds < 1: