diff --git a/ks_includes/defaults.conf b/ks_includes/defaults.conf
index ba0fa1d2..bbb270cf 100644
--- a/ks_includes/defaults.conf
+++ b/ks_includes/defaults.conf
@@ -191,6 +191,16 @@ name: {{ gettext('Network') }}
icon: network
panel: network
+[menu __main more notifications]
+name: {{ gettext('Notifications') }}
+icon: notifications
+panel: notifications
+
+[menu __print notifications]
+name: {{ gettext('Notifications') }}
+icon: notifications
+panel: notifications
+
[menu __print]
name: {{ gettext('Print Control') }}
diff --git a/panels/notifications.py b/panels/notifications.py
new file mode 100644
index 00000000..64d33880
--- /dev/null
+++ b/panels/notifications.py
@@ -0,0 +1,67 @@
+import gi
+
+gi.require_version("Gtk", "3.0")
+from gi.repository import Gtk
+from ks_includes.screen_panel import ScreenPanel
+
+
+COLORS = {
+ "time": "DarkGrey",
+ "info": "Silver",
+ "warning": "DarkOrange",
+ "error": "FireBrick",
+}
+
+
+def remove_newlines(msg: str) -> str:
+ return msg.replace('\n', ' ')
+
+
+class Panel(ScreenPanel):
+ def __init__(self, screen, title):
+ super().__init__(screen, title)
+ self.empty = _("Notification log empty")
+ self.tb = Gtk.TextBuffer(text=self.empty)
+ tv = Gtk.TextView()
+ tv.set_buffer(self.tb)
+ tv.set_editable(False)
+ tv.set_cursor_visible(False)
+ tv.connect("size-allocate", self._autoscroll)
+
+ scroll = Gtk.ScrolledWindow()
+ scroll.set_hexpand(True)
+ scroll.set_vexpand(True)
+ scroll.add(tv)
+ self.content.add(scroll)
+
+ def activate(self):
+ self.clear()
+ for log in self._screen.notification_log:
+ self.add_notification(log)
+
+ def add_notification(self, log):
+ if log["level"] == 0:
+ if "error" in log["message"].lower() or "cannot" in log["message"].lower():
+ color = COLORS["error"]
+ else:
+ color = COLORS["info"]
+ elif log["level"] == 1:
+ color = COLORS["info"]
+ elif log["level"] == 2:
+ color = COLORS["warning"]
+ else:
+ color = COLORS["error"]
+ self.tb.insert_markup(
+ self.tb.get_end_iter(),
+ f'\n{log["time"]} '
+ f'{remove_newlines(log["message"])}',
+ -1
+ )
+
+ def clear(self):
+ self.tb.set_text("")
+
+ def process_update(self, action, data):
+ if action != "notify_log":
+ return
+ self.add_notification(data)
diff --git a/screen.py b/screen.py
index 4e51eac9..35d7e490 100755
--- a/screen.py
+++ b/screen.py
@@ -16,6 +16,7 @@ from gi.repository import Gtk, Gdk, GLib, Pango
from importlib import import_module
from jinja2 import Environment
from signal import SIGTERM
+from datetime import datetime
from ks_includes import functions
from ks_includes.KlippyWebsocket import KlippyWebsocket
@@ -93,6 +94,7 @@ class KlipperScreen(Gtk.Window):
popup_timeout = None
wayland = False
windowed = False
+ notification_log = []
def __init__(self, args):
try:
@@ -162,7 +164,7 @@ class KlipperScreen(Gtk.Window):
# Prevent this dialog from being destroyed
self.dialogs = []
self.set_screenblanking_timeout(self._config.get_main_config().get('screen_blanking'))
-
+ self.log_notification("KlipperScreen Started", 1)
self.initial_connection()
def initial_connection(self):
@@ -312,11 +314,21 @@ class KlipperScreen(Gtk.Window):
self.panels[panel].activate()
self.show_all()
+ def log_notification(self, message, level=0):
+ time = datetime.now().strftime("%H:%M:%S")
+ log_entry = {"message": message, "level": level, "time": time}
+ if len(self.notification_log) > 999:
+ del self.notification_log[0]
+ self.notification_log.append(log_entry)
+ self.process_update("notify_log", log_entry)
+
def show_popup_message(self, message, level=3):
self.close_screensaver()
if self.popup_message is not None:
self.close_popup_message()
+ self.log_notification(message, level)
+
msg = Gtk.Button(label=f"{message}")
msg.set_hexpand(True)
msg.set_vexpand(True)
@@ -827,6 +839,7 @@ class KlipperScreen(Gtk.Window):
if 'splash_screen' not in self.panels or remove:
self.show_panel("splash_screen", None, remove_all=True)
self.panels['splash_screen'].update_text(msg)
+ self.log_notification(msg, 0)
def search_power_devices(self, devices):
found_devices = []
@@ -945,6 +958,7 @@ class KlipperScreen(Gtk.Window):
self.reinit_count = 0
self.initializing = False
self.printer.process_update(data['result']['status'])
+ self.log_notification("Printer Initialized", 1)
return False
def init_tempstore(self):
diff --git a/styles/colorized/images/notification_important.svg b/styles/colorized/images/notification_important.svg
new file mode 100644
index 00000000..d1c637b4
--- /dev/null
+++ b/styles/colorized/images/notification_important.svg
@@ -0,0 +1,87 @@
+
+
diff --git a/styles/colorized/images/notifications.svg b/styles/colorized/images/notifications.svg
new file mode 100644
index 00000000..b5a66dc9
--- /dev/null
+++ b/styles/colorized/images/notifications.svg
@@ -0,0 +1,73 @@
+
+
diff --git a/styles/colorized/images/notifications_active.svg b/styles/colorized/images/notifications_active.svg
new file mode 100644
index 00000000..077f5119
--- /dev/null
+++ b/styles/colorized/images/notifications_active.svg
@@ -0,0 +1,78 @@
+
+
diff --git a/styles/material-dark/images/notification_important.svg b/styles/material-dark/images/notification_important.svg
new file mode 100644
index 00000000..095f8d79
--- /dev/null
+++ b/styles/material-dark/images/notification_important.svg
@@ -0,0 +1,43 @@
+
+
diff --git a/styles/material-dark/images/notifications.svg b/styles/material-dark/images/notifications.svg
new file mode 100644
index 00000000..2537c85b
--- /dev/null
+++ b/styles/material-dark/images/notifications.svg
@@ -0,0 +1,39 @@
+
+
diff --git a/styles/material-dark/images/notifications_active.svg b/styles/material-dark/images/notifications_active.svg
new file mode 100644
index 00000000..9eafcee1
--- /dev/null
+++ b/styles/material-dark/images/notifications_active.svg
@@ -0,0 +1,43 @@
+
+
diff --git a/styles/material-darker/images/notification_important.svg b/styles/material-darker/images/notification_important.svg
new file mode 100644
index 00000000..095f8d79
--- /dev/null
+++ b/styles/material-darker/images/notification_important.svg
@@ -0,0 +1,43 @@
+
+
diff --git a/styles/material-darker/images/notifications.svg b/styles/material-darker/images/notifications.svg
new file mode 100644
index 00000000..2537c85b
--- /dev/null
+++ b/styles/material-darker/images/notifications.svg
@@ -0,0 +1,39 @@
+
+
diff --git a/styles/material-darker/images/notifications_active.svg b/styles/material-darker/images/notifications_active.svg
new file mode 100644
index 00000000..9eafcee1
--- /dev/null
+++ b/styles/material-darker/images/notifications_active.svg
@@ -0,0 +1,43 @@
+
+
diff --git a/styles/material-light/images/notification_important.svg b/styles/material-light/images/notification_important.svg
new file mode 100644
index 00000000..2efd0435
--- /dev/null
+++ b/styles/material-light/images/notification_important.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/styles/material-light/images/notifications.svg b/styles/material-light/images/notifications.svg
new file mode 100644
index 00000000..6d5dfe6a
--- /dev/null
+++ b/styles/material-light/images/notifications.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/styles/material-light/images/notifications_active.svg b/styles/material-light/images/notifications_active.svg
new file mode 100644
index 00000000..0de3cca2
--- /dev/null
+++ b/styles/material-light/images/notifications_active.svg
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/styles/z-bolt/images/notification_important.svg b/styles/z-bolt/images/notification_important.svg
new file mode 100644
index 00000000..b6b426e0
--- /dev/null
+++ b/styles/z-bolt/images/notification_important.svg
@@ -0,0 +1,82 @@
+
+
diff --git a/styles/z-bolt/images/notifications.svg b/styles/z-bolt/images/notifications.svg
new file mode 100644
index 00000000..ee73493f
--- /dev/null
+++ b/styles/z-bolt/images/notifications.svg
@@ -0,0 +1,72 @@
+
+
diff --git a/styles/z-bolt/images/notifications_active.svg b/styles/z-bolt/images/notifications_active.svg
new file mode 100644
index 00000000..d2c7d983
--- /dev/null
+++ b/styles/z-bolt/images/notifications_active.svg
@@ -0,0 +1,77 @@
+
+