screen: reduce the complexity of the status changes close #792

This commit is contained in:
alfrix
2022-11-14 13:22:27 -03:00
parent 9020d0b0ea
commit 6b1fd23e35
2 changed files with 21 additions and 68 deletions

View File

@@ -165,15 +165,13 @@ class Printer:
if state not in list(self.state_callbacks): # disconnected, startup, ready, shutdown, error, paused, printing
return
logging.debug(f"Changing state from '{self.state}' to '{state}'")
prev_state = self.state
self.state = state
if self.state_callbacks[state] is not None:
logging.debug(f"Adding callback for state: {state}")
Gdk.threads_add_idle(
GLib.PRIORITY_HIGH_IDLE,
self.state_cb,
self.state_callbacks[state],
prev_state
self.state_callbacks[state]
)
def configure_power_devices(self, data):