From d9a361cacc65850e59eff3c554802573073ef2c7 Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Sun, 18 Feb 2024 17:26:08 -0300 Subject: [PATCH] ws: fix issue that made buttons busy forever fixes #1087 (#1266) * ws: fix issue that made buttons busy forever fixes #1087 * ws: reduce to high_idle due to touch not as responsive * ws: make string translatable * less animation steps for the spinner the slower spinning gear icon is actually more pleasant to look --- ks_includes/KlippyWebsocket.py | 12 +++++++----- styles/base.css | 4 ++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ks_includes/KlippyWebsocket.py b/ks_includes/KlippyWebsocket.py index c9e5851f..ce9ad11c 100644 --- a/ks_includes/KlippyWebsocket.py +++ b/ks_includes/KlippyWebsocket.py @@ -111,13 +111,13 @@ class KlippyWebsocket(threading.Thread): self.callback_table[response['id']][1], self.callback_table[response['id']][2], *self.callback_table[response['id']][3]) - GLib.idle_add(self.callback_table[response['id']][0], *args) + GLib.idle_add(self.callback_table[response['id']][0], *args, priority=GLib.PRIORITY_HIGH_IDLE) self.callback_table.pop(response['id']) return if "method" in response and "on_message" in self._callback: - args = response['method'], response['params'][0] if "params" in response else {} - GLib.idle_add(self._callback['on_message'], *args) + args = (response['method'], response['params'][0] if "params" in response else {}) + GLib.idle_add(self._callback['on_message'], *args, priority=GLib.PRIORITY_HIGH_IDLE) return def send_method(self, method, params=None, callback=None, *args): @@ -146,7 +146,7 @@ class KlippyWebsocket(threading.Thread): self._screen.reinit_count = 0 self.reconnect_count = 0 if "on_connect" in self._callback: - GLib.idle_add(self._callback['on_connect']) + GLib.idle_add(self._callback['on_connect'], priority=GLib.PRIORITY_HIGH_IDLE) def on_close(self, *args): # args: ws, status, message @@ -164,7 +164,9 @@ class KlippyWebsocket(threading.Thread): self.closing = False return if "on_close" in self._callback: - GLib.idle_add(self._callback['on_close'], "Lost Connection to Moonraker") + GLib.idle_add(self._callback['on_close'], + _("Lost Connection to Moonraker"), + priority=GLib.PRIORITY_HIGH_IDLE) logging.info("Moonraker Websocket Closed") self.connected = False diff --git a/styles/base.css b/styles/base.css index 4970de4a..943d5c73 100644 --- a/styles/base.css +++ b/styles/base.css @@ -247,6 +247,10 @@ undershoot.bottom { background-image: none; } +spinner { + animation-timing-function: steps(10); +} + separator { margin: 1em 2em; background-color: rgba(255, 255, 255, 0.5);