borgend/ui.py

changeset 141
a1c97bc1789e
parent 133
ec8014a2ee7a
child 144
31227feaa05a
equal deleted inserted replaced
140:a70ba964f455 141:a1c97bc1789e
322 self.refresh_timer.interval=delay 322 self.refresh_timer.interval=delay
323 self.refresh_timer.start() 323 self.refresh_timer.start()
324 324
325 return itemlist, title 325 return itemlist, title
326 326
327 # Callbacks -- exception-protected to get any indications of errors 327 def __schedule_refresh(self):
328
329 @protect_noreturn
330 def __refresh_callback(self, timer):
331 with self.lock:
332 self.build_menu_and_timer(True)
333
334 @protect_noreturn
335 def __status_callback(self, index, status, errorlog=None):
336 logger.debug("Tray status callback")
337 with self.lock:
338 self.statuses[index]=status
339 self.updated_recently=True 328 self.updated_recently=True
340 # Time the refresh if it has not been timed, or if the timer 329 # Time the refresh if it has not been timed, or if the timer
341 # is timing for the "long-term" (refresh_timer_time set) 330 # is timing for the "long-term" (refresh_timer_time set)
342 if self.refresh_timer.interval>refresh_interval: 331 if self.refresh_timer.interval>refresh_interval:
343 self.refresh_timer.stop() 332 self.refresh_timer.stop()
344 self.refresh_timer.interval=refresh_interval 333 self.refresh_timer.interval=refresh_interval
345 self.refresh_timer.start() 334 self.refresh_timer.start()
335
336 # Callbacks -- exception-protected to get any indications of errors
337 @protect_noreturn
338 def __refresh_callback(self, timer):
339 with self.lock:
340 self.build_menu_and_timer(True)
341
342 @protect_noreturn
343 def __status_callback(self, index, status, errorlog=None):
344 logger.debug("Tray status callback")
345 with self.lock:
346 self.statuses[index]=status
347 self.__schedule_refresh()
346 348
347 # if errorlog: 349 # if errorlog:
348 # if 'msgid' not in errorlog or not isinstance(errorlog['msgid'], str): 350 # if 'msgid' not in errorlog or not isinstance(errorlog['msgid'], str):
349 # msgid='UnknownError' 351 # msgid='UnknownError'
350 # else: 352 # else:
375 logger.exception("Pause/resume error") 377 logger.exception("Pause/resume error")
376 378
377 @protect_noreturn 379 @protect_noreturn
378 def __sleepwake_callback(self, woke): 380 def __sleepwake_callback(self, woke):
379 if woke: 381 if woke:
380 self.refresh_ui() 382 with self.lock:
383 self.__schedule_refresh()
381 384
382 @protect_noreturn 385 @protect_noreturn
383 def quit(self): 386 def quit(self):
384 rumps.quit_application() 387 rumps.quit_application()
385 388

mercurial