diff --git a/panels/notifications.py b/panels/notifications.py index 7785e2f71..eb0c30325 100644 --- a/panels/notifications.py +++ b/panels/notifications.py @@ -29,12 +29,19 @@ def __init__(self, screen, title): 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 @@ def add_notification(self, log): -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": diff --git a/screen.py b/screen.py index a9ea56abc..82f632c88 100755 --- a/screen.py +++ b/screen.py @@ -362,6 +362,9 @@ def log_notification(self, message, level=0): 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: