# HG changeset patch # User Tuomo Valkonen # Date 1516574281 0 # Node ID 00accd11978b4bd6cf78553d8c588771801b0a7f # Parent e2641cb9ca6de3ecbf8fc32561a73472a535fdc2 Moved logwindow dispay out of BorgendTray, and made notification_center display it (if it would work) diff -r e2641cb9ca6d -r 00accd11978b ui.py --- a/ui.py Sun Jan 21 22:01:57 2018 +0000 +++ b/ui.py Sun Jan 21 22:38:01 2018 +0000 @@ -142,7 +142,6 @@ menu, state=self.__rebuild_menu() self.refresh_timer=None - self.logwindow=None super().__init__(traynames[state], menu=menu, quit_button=None) @@ -164,7 +163,7 @@ menu.append(item) state=combine_state(state, this_state) - menu_log=rumps.MenuItem("Show log", callback=self.showlog) + menu_log=rumps.MenuItem("Show log", callback=lambda _: showlog()) menu.append(menu_log) if not settings['no_quit_menu_entry']: @@ -217,22 +216,38 @@ notification_workaround(borgend.appname_stylised, err.__class__.__name__, str(err)) - @rumps.notifications - def notification_center(data): - pass +# +# Log window +# - def showlog(self, _): - try: - if not self.logwindow: +logwindow=[None] +logwindow_lock=Lock() + +def showlog(): + try: + w=None + with logwindow_lock: + if not logwindow[0]: lines=borgend.fifolog.formatAll() msg="\n".join(lines[0:]) - self.logwindow=rumps.Window(title=borgend.appname_stylised+' log', - default_text=msg, - ok='Close', - dimensions=(640,320)) - self.logwindow.run() - # Does not return until closed - self.logwindow=None - except Exception as err: - utils.log_exception(logger, err) + w=rumps.Window(title=borgend.appname_stylised+' log', + default_text=msg, + ok='Close', + dimensions=(640,320)) + logwindow[0]=w + if w: + try: + w.run() + finally: + with logwindow_lock: + logwindow[0]=None + except Exception as err: + utils.log_exception(logger, err) +# +# Notification click response => show log window +# + +@rumps.notifications +def notification_center(_): + showlog()