| 144 return menu, state |
146 return menu, state |
| 145 |
147 |
| 146 def refresh_ui(self): |
148 def refresh_ui(self): |
| 147 with self.lock: |
149 with self.lock: |
| 148 self.refresh_timer=None |
150 self.refresh_timer=None |
| 149 logging.debug('Rebuilding menu') |
151 logger.debug('Rebuilding menu') |
| 150 menu, active=self.__rebuild_menu() |
152 menu, active=self.__rebuild_menu() |
| 151 self.menu.clear() |
153 self.menu.clear() |
| 152 self.menu.update(menu) |
154 self.menu.update(menu) |
| 153 self.title=traynames[active] |
155 self.title=traynames[active] |
| 154 |
156 |
| 155 def __status_callback(self, obj, index, status, errorlog): |
157 def __status_callback(self, obj, index, status, errorlog): |
| 156 logging.debug('Status callbackup %s' % str(status)) |
158 logger.debug('Status callbackup %s' % str(status)) |
| 157 |
159 |
| 158 with self.lock: |
160 with self.lock: |
| 159 self.statuses[index]=status |
161 self.statuses[index]=status |
| 160 if self.refresh_timer==None: |
162 if self.refresh_timer==None: |
| 161 self.refresh_timer=Timer(refresh_interval, self.refresh_ui) |
163 self.refresh_timer=Timer(refresh_interval, self.refresh_ui) |
| 165 if 'msgid' not in errorlog or not isinstance(errorlog['msgid'], str): |
167 if 'msgid' not in errorlog or not isinstance(errorlog['msgid'], str): |
| 166 msgid='UnknownError' |
168 msgid='UnknownError' |
| 167 else: |
169 else: |
| 168 msgid=errorlog['msgid'] |
170 msgid=errorlog['msgid'] |
| 169 |
171 |
| 170 logging.debug('Opening notification for error') |
172 logger.debug('Opening notification for error') |
| 171 |
173 |
| 172 # Workaround to rumps brokenness |
174 # Workaround to rumps brokenness |
| 173 # See https://github.com/jaredks/rumps/issues/59 |
175 # See https://github.com/jaredks/rumps/issues/59 |
| 174 NSDictionary = objc.lookUpClass("NSDictionary") |
176 NSDictionary = objc.lookUpClass("NSDictionary") |
| 175 d=NSDictionary() |
177 d=NSDictionary() |
| 179 def my_quit(self, _): |
181 def my_quit(self, _): |
| 180 rumps.quit_application() |
182 rumps.quit_application() |
| 181 |
183 |
| 182 def __menu_select_backup(self, sender, b): |
184 def __menu_select_backup(self, sender, b): |
| 183 #sender.state=not sender.state |
185 #sender.state=not sender.state |
| 184 logging.debug("Manually backup '%s'", b.name) |
186 logger.debug("Manually backup '%s'", b.name) |
| 185 b.create(None) |
187 b.create(None) |
| 186 |
188 |
| 187 @rumps.notifications |
189 @rumps.notifications |
| 188 def notification_center(data): |
190 def notification_center(data): |
| 189 pass |
191 pass |