Skip to content

Commit

Permalink
fix popup timer close KlipperScreen#946
Browse files Browse the repository at this point in the history
  • Loading branch information
alfrix committed May 9, 2023
1 parent ebaedea commit 49d910a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class KlipperScreen(Gtk.Window):
reinit_count = 0
max_retries = 4
initialized = False
popup_timeout = None

def __init__(self, args, version):
try:
Expand Down Expand Up @@ -336,15 +337,18 @@ def show_popup_message(self, message, level=3):
self.popup_message.show_all()

if self._config.get_main_config().getboolean('autoclose_popups', True):
GLib.timeout_add_seconds(10, self.close_popup_message)
if self.popup_timeout:
GLib.source_remove(self.popup_timeout)
self.popup_timeout = GLib.timeout_add_seconds(10, self.close_popup_message)

return False

def close_popup_message(self, widget=None):
if self.popup_message is None:
return
self.popup_message.popdown()
self.popup_message = None
GLib.source_remove(self.popup_timeout)
self.popup_message = self.popup_timeout = None

def show_error_modal(self, err, e=""):
logging.error(f"Showing error modal: {err} {e}")
Expand Down

0 comments on commit 49d910a

Please sign in to comment.