Пример #1
0
 def initialize_applet(self):
     # Set flags and GUI elements
     self.initializing = True
     self.log('Initializing', '...')
     self.icon = 'updating'
     self.tooltip = 'Initializing...'
     # Call applet's initialize method
     self.initialize_id = id()
     try:
         self.appletting = True
         self.success = self.initialize()
     except:
         self.success = None
         self.initialize_id = 0
         self.debug()
     finally:
         self.appletting = False
     # Determine success
     if self.success:
         self.initialized = True
         self.log('Initialization', 'DONE')
         self.update_id = id()
         thread(self.run, self.update_id)
     else:
         self.log('Initialization', 'ERROR')
         self.icon = 'error'
         self.context = []
         threadTimeout(self.interval, self.run)
     self.tooltip = None
     # Final
     self.initializing = False
Пример #2
0
 def notifications(self, value):
     if not self.settings['notify']:
         return
     if not self.was_set(self.id['notifications']):
         self.id['notifications'] = id()
         self.value['notifications'] = value
         gui.IdleAdd(self.notifications_setter, tolist(value))
Пример #3
0
 def enable_disable(self):
     self.enabled = not self.enabled
     self.log('Enabled', 'TRUE' if self.enabled else 'FALSE')
     if self.enabled:
         self.icon = 'idle'
     self.context = []
     self.update_id = id()
     self.run(self.update_id)
Пример #4
0
 def tooltip(self, value):
     if self.appletting:                
         self.value['tooltip-applet'] = value
     elif value == None:
         value = self.value['tooltip-applet']
     if not self.was_set(self.id['tooltip']):
         self.id['tooltip'] = id()
         self.value['tooltip'] = value
     gui.IdleAdd(self.tooltip_setter, value)
Пример #5
0
 def update_applet(self):
     # Set flags and GUI elements
     self.updating = True
     self.log('Updating', '...')
     self.icon = 'updating'
     self.tooltip = 'Updating...'
     # Call applet's update method
     self.update_id = id()
     try:
         self.appletting = True
         self.success = self.update()
     except:
         self.success = None
         self.update_id = 0
         self.debug()
     finally:
         self.appletting = False
     # Determine success
     if self.success == True:
         self.log('Update', 'NEW')
         self.icon = 'new'
     elif self.success == False:
         self.log('Update', 'OLD')
         self.icon = 'idle'
     else:
         self.log('Update', 'ERROR')
         self.icon = 'error'
     self.tooltip = None    
     self.context = []
     # Add next update interval
     self.update_id = id()
     threadTimeout(self.interval, self.run, self.update_id)
     # Final
     self.updating = False
     if self.success and self.settings['notify']:
         self.notify_applet()
Пример #6
0
 def context(self, value):
     value = tolist(value)
     
     if self.appletting:
         self.value['context-applet'] = value
         value += ['-']
     else:
         time = timestamp(id() + self.interval)
         if self.updating:
             if self.success == None:
                 self.value['context-time'] = ['Error while updating. Next try at '+time,'-']
             else:
                 self.value['context-time'] = ['Next update at '+time,'-']
         elif self.initializing and self.success == None:
             self.value['context-time'] = ['Error while initializing. Next try at '+time,'-']
     
     self.value['context-default'] = self.context_default()
     value += self.value['context-time'] + self.value['context-default']
     gui.IdleAdd(self.context_setter, value)
Пример #7
0
 def data(self, value):
     if not self.was_set(self.id['data']):
         value = tolist(value)
         self.id['data'] = id()
         self.value['data'] = value
         gui.IdleAdd(self.data_setter, value)
Пример #8
0
 def visible(self, value):
     self.id['visible'] = id()
     self.value['visible'] = value
     gui.IdleAdd(self.visible_setter, value)
Пример #9
0
 def icon(self, value):
     if not self.was_set(self.id['icon']):
         self.id['icon'] = id()
         self.value['icon'] = value
         gui.IdleAdd(self.icon_setter, value)
Пример #10
0
 def run_manual(self):
     self.update_id = id()
     self.run(self.update_id)