def update_time(self): options = Option(self.settings['servername'],self.settings['folder'],self.settings['username'],self.settings['password'],int(self.settings['connectiontimeout']),int(self.settings['mailinfo'])) emailinfo = EmailInfo(options) mail=emailinfo.writeOutput() if mail == None: icon = 'mail-mark-important' self.can_show_icon = True self.set_size_request(self.cfg['icon_size'], self.cfg['icon_size']) if self.cfg['tooltips']: self.gmail.plugin.tooltip = _('Error loading mail') elif mail == {}: icon = 'mail-read' if self.settings['hide_icon'] == 0: self.can_show_icon = True self.set_size_request(self.cfg['icon_size'], self.cfg['icon_size']) else: self.can_show_icon = False self.set_size_request(-1, -1) if self.cfg['tooltips']: self.gmail.plugin.tooltip = _('No unread mail') else: #icon = 'stock_mail-unread' #icon = 'mail-mark-unread' icon = 'mail-unread' self.can_show_icon = True self.set_size_request(self.cfg['icon_size'], self.cfg['icon_size']) if self.cfg['tooltips']: self.gmail.plugin.tooltip = _('Unread mail : ')+str(len(mail)) if int(self.settings['play_sound']) == 1: if self.settings['file_sound'] != '': if Core.isfile('/usr/bin/mplayer') | \ Core.isfile('/usr/local/bin/mplayer'): Core.launch_command('mplayer -quiet "'+self.settings['file_sound']+'"&') self.gmail.update_icon_status(icon) self.gmail.restart() return True
def update_time(self): if self.locked: return True now = time.localtime() time_current = time.strftime( '<span color="%s">%s</span>' % (self.settings['time_color'], self.settings['time']), now) if self.lb_date: date_current = time.strftime( '<span color="%s">%s</span>' % (self.settings['date_color'], self.settings['date']), now) if not time_current == self.time_txt: self.lb_time.set_markup(time_current) self.time_txt = time_current if self.lb_date: self.lb_date.set_markup(date_current) self.date_txt = date_current if self.cfg['tooltips'] & (self.settings['tooltip'] != ''): self.calendarplugin.plugin.tooltip = time.strftime( self.settings['tooltip'], now) min_for_alarm_current = str(time.strftime('%M', now)) if not min_for_alarm_current == self.min_for_alarm: self.min_for_alarm = min_for_alarm_current if self.alarmlist != []: plus5min = time.localtime(time.time() + 300) #5 minutes *60 for alarm in self.alarmlist: if alarm != {}: if ( ( (alarm['date_d'] != '') & \ (str(alarm['date_m']) == str(time.strftime('%m', now))) ) & \ ((str(alarm['date_d']) == str(time.strftime('%d', now)) ) & \ (str(alarm['date_y']) == str(time.strftime('%Y', now)) ) & \ (str(alarm['time_h']) == str(time.strftime('%H', now)) ) & \ (str(alarm['time_m']) == str(time.strftime('%M', now)) ) ) ) | \ \ ( ( (alarm['date_d'] == '') & \ (str(alarm['time_m']) == str(time.strftime('%M', now)) ) & \ (str(alarm['time_h']) == str(time.strftime('%H', now)) ) ) & \ (( (str(time.strftime('%w', now)) == '1') & (str(alarm['day1']) == '1') ) | \ ( (str(time.strftime('%w', now)) == '2') & (str(alarm['day2']) == '1') ) | \ ( (str(time.strftime('%w', now)) == '3') & (str(alarm['day3']) == '1') ) | \ ( (str(time.strftime('%w', now)) == '4') & (str(alarm['day4']) == '1') ) | \ ( (str(time.strftime('%w', now)) == '5') & (str(alarm['day5']) == '1') ) | \ ( (str(time.strftime('%w', now)) == '6') & (str(alarm['day6']) == '1') ) | \ ( (str(time.strftime('%w', now)) == '0') & (str(alarm['day7']) == '1') ) ) ): if (alarm['notify'] == '1') & (alarm['text'] != ''): if Core.isfile('/usr/bin/notify-send') | \ Core.isfile('/usr/local/bin/notify-send'): Core.launch_command( 'notify-send "' + alarm['text'] + '" -i task-due -t ' + str(144000) + '&') # 2 min elif Core.isfile('/usr/bin/notify-osd') | \ Core.isfile('/usr/local/bin/notify-osd'): Core.launch_command( 'notify-osd "' + alarm['text'] + '" -i task-due -t ' + str(144000) + '&') # 2 min else: try: import pynotify pynotify.init("Alamclock notification") n = pynotify.Notification( alarm['text'], "", "task-due") n.set_urgency( pynotify.URGENCY_CRITICAL) n.set_timeout(144000) n.show() except: print "Error: need notify-osd or libnotify-bin or notify-send or python-notify" if alarm['soundfile'] != '': # /usr/bin/aplay -q if Core.isfile('/usr/bin/mplayer') | \ Core.isfile('/usr/local/bin/mplayer'): Core.launch_command('mplayer -quiet "' + alarm['soundfile'] + '"&') if alarm['cmd'] != '': Core.launch_command('"' + alarm['cmd'] + '"&') elif (alarm['remind'] == '1') & (alarm['text'] != '') & \ ( ( (alarm['date_d'] != '') & \ (str(alarm['date_m']) == str(time.strftime('%m', plus5min))) ) & \ ((str(alarm['date_d']) == str(time.strftime('%d', plus5min)) ) & \ (str(alarm['date_y']) == str(time.strftime('%Y', plus5min)) ) & \ (str(alarm['time_h']) == str(time.strftime('%H', plus5min)) ) & \ (str(alarm['time_m']) == str(time.strftime('%M', plus5min)) ) ) ) | \ \ ( ( (alarm['date_d'] == '') & \ (str(alarm['time_m']) == str(time.strftime('%M', plus5min)) ) & \ (str(alarm['time_h']) == str(time.strftime('%H', plus5min)) ) ) & \ (( (str(time.strftime('%w', plus5min)) == '1') & (str(alarm['day1']) == '1') ) | \ ( (str(time.strftime('%w', plus5min)) == '2') & (str(alarm['day2']) == '1') ) | \ ( (str(time.strftime('%w', plus5min)) == '3') & (str(alarm['day3']) == '1') ) | \ ( (str(time.strftime('%w', plus5min)) == '4') & (str(alarm['day4']) == '1') ) | \ ( (str(time.strftime('%w', plus5min)) == '5') & (str(alarm['day5']) == '1') ) | \ ( (str(time.strftime('%w', plus5min)) == '6') & (str(alarm['day6']) == '1') ) | \ ( (str(time.strftime('%w', plus5min)) == '0') & (str(alarm['day7']) == '1') ) ) ): if Core.isfile('/usr/bin/notify-send') | \ Core.isfile('/usr/local/bin/notify-send'): Core.launch_command('notify-send "' + _( "Remind you that after about 5 minutes to do " ) + alarm['text'] + '" -i task-due -t ' + str(144000) + '&') # 2 min elif Core.isfile('/usr/bin/notify-osd') | \ Core.isfile('/usr/local/bin/notify-osd'): Core.launch_command('notify-osd "' + _( "Remind you that after about 5 minutes to do " ) + alarm['text'] + '" -i task-due -t ' + str(144000) + '&') # 2 min else: try: import pynotify pynotify.init("Alamclock notification") n = pynotify.Notification( _("Remind you that after about 5 minutes to do " ) + alarm['text'], "", "task-due") n.set_urgency(pynotify.URGENCY_CRITICAL) n.set_timeout(144000) n.show() except: print "Error: need notify-osd or libnotify-bin or notify-send or python-notify" return True
self.can_show_icon = False self.set_size_request(-1, -1) if self.cfg['tooltips']: self.gmail.plugin.tooltip = _('No unread mail') else: #icon = 'stock_mail-unread' #icon = 'mail-mark-unread' icon = 'mail-unread' self.can_show_icon = True self.set_size_request(self.cfg['icon_size'], self.cfg['icon_size']) if self.cfg['tooltips']: self.gmail.plugin.tooltip = _('Unread mail : ') + str( len(mail)) if int(self.settings['play_sound']) == 1: if self.settings['file_sound'] != '': if Core.isfile('/usr/bin/mplayer') | \ Core.isfile('/usr/local/bin/mplayer'): Core.launch_command('mplayer -quiet "' + self.settings['file_sound'] + '"&') self.gmail.update_icon_status(icon) self.gmail.restart() return True def resize(self): self.gmail.restart() def on_init(self): if self.settings['hide_icon'] == 0: self.can_show_icon = True
def update_time(self): if self.locked: return True now = time.localtime() time_current = time.strftime('<span color="%s">%s</span>' % (self.settings['time_color'], self.settings['time']), now) if self.lb_date: date_current = time.strftime('<span color="%s">%s</span>' % (self.settings['date_color'], self.settings['date']), now) if not time_current == self.time_txt: self.lb_time.set_markup(time_current) self.time_txt = time_current if self.lb_date: self.lb_date.set_markup(date_current) self.date_txt = date_current if self.cfg['tooltips'] & (self.settings['tooltip'] != ''): self.calendarplugin.plugin.tooltip = time.strftime(self.settings['tooltip'], now) min_for_alarm_current = str(time.strftime('%M', now)) if not min_for_alarm_current == self.min_for_alarm: self.min_for_alarm = min_for_alarm_current if self.alarmlist != []: plus5min = time.localtime( time.time() + 300 ) #5 minutes *60 for alarm in self.alarmlist: if alarm != {}: if ( ( (alarm['date_d'] != '') & \ (str(alarm['date_m']) == str(time.strftime('%m', now))) ) & \ ((str(alarm['date_d']) == str(time.strftime('%d', now)) ) & \ (str(alarm['date_y']) == str(time.strftime('%Y', now)) ) & \ (str(alarm['time_h']) == str(time.strftime('%H', now)) ) & \ (str(alarm['time_m']) == str(time.strftime('%M', now)) ) ) ) | \ \ ( ( (alarm['date_d'] == '') & \ (str(alarm['time_m']) == str(time.strftime('%M', now)) ) & \ (str(alarm['time_h']) == str(time.strftime('%H', now)) ) ) & \ (( (str(time.strftime('%w', now)) == '1') & (str(alarm['day1']) == '1') ) | \ ( (str(time.strftime('%w', now)) == '2') & (str(alarm['day2']) == '1') ) | \ ( (str(time.strftime('%w', now)) == '3') & (str(alarm['day3']) == '1') ) | \ ( (str(time.strftime('%w', now)) == '4') & (str(alarm['day4']) == '1') ) | \ ( (str(time.strftime('%w', now)) == '5') & (str(alarm['day5']) == '1') ) | \ ( (str(time.strftime('%w', now)) == '6') & (str(alarm['day6']) == '1') ) | \ ( (str(time.strftime('%w', now)) == '0') & (str(alarm['day7']) == '1') ) ) ): if (alarm['notify'] == '1') & (alarm['text'] != ''): if Core.isfile('/usr/bin/notify-send') | \ Core.isfile('/usr/local/bin/notify-send'): Core.launch_command('notify-send "'+alarm['text']+'" -i task-due -t '+str(144000)+'&') # 2 min elif Core.isfile('/usr/bin/notify-osd') | \ Core.isfile('/usr/local/bin/notify-osd'): Core.launch_command('notify-osd "'+alarm['text']+'" -i task-due -t '+str(144000)+'&') # 2 min else: try: import pynotify pynotify.init("Alamclock notification") n = pynotify.Notification(alarm['text'], "", "task-due") n.set_urgency(pynotify.URGENCY_CRITICAL) n.set_timeout(144000) n.show() except: print "Error: need notify-osd or libnotify-bin or notify-send or python-notify" if alarm['soundfile'] != '': # /usr/bin/aplay -q if Core.isfile('/usr/bin/mplayer') | \ Core.isfile('/usr/local/bin/mplayer'): Core.launch_command('mplayer -quiet "'+alarm['soundfile']+'"&') if alarm['cmd'] != '': Core.launch_command('"'+alarm['cmd']+'"&') elif (alarm['remind'] == '1') & (alarm['text'] != '') & \ ( ( (alarm['date_d'] != '') & \ (str(alarm['date_m']) == str(time.strftime('%m', plus5min))) ) & \ ((str(alarm['date_d']) == str(time.strftime('%d', plus5min)) ) & \ (str(alarm['date_y']) == str(time.strftime('%Y', plus5min)) ) & \ (str(alarm['time_h']) == str(time.strftime('%H', plus5min)) ) & \ (str(alarm['time_m']) == str(time.strftime('%M', plus5min)) ) ) ) | \ \ ( ( (alarm['date_d'] == '') & \ (str(alarm['time_m']) == str(time.strftime('%M', plus5min)) ) & \ (str(alarm['time_h']) == str(time.strftime('%H', plus5min)) ) ) & \ (( (str(time.strftime('%w', plus5min)) == '1') & (str(alarm['day1']) == '1') ) | \ ( (str(time.strftime('%w', plus5min)) == '2') & (str(alarm['day2']) == '1') ) | \ ( (str(time.strftime('%w', plus5min)) == '3') & (str(alarm['day3']) == '1') ) | \ ( (str(time.strftime('%w', plus5min)) == '4') & (str(alarm['day4']) == '1') ) | \ ( (str(time.strftime('%w', plus5min)) == '5') & (str(alarm['day5']) == '1') ) | \ ( (str(time.strftime('%w', plus5min)) == '6') & (str(alarm['day6']) == '1') ) | \ ( (str(time.strftime('%w', plus5min)) == '0') & (str(alarm['day7']) == '1') ) ) ): if Core.isfile('/usr/bin/notify-send') | \ Core.isfile('/usr/local/bin/notify-send'): Core.launch_command('notify-send "'+_("Remind you that after about 5 minutes to do ")+alarm['text']+'" -i task-due -t '+str(144000)+'&') # 2 min elif Core.isfile('/usr/bin/notify-osd') | \ Core.isfile('/usr/local/bin/notify-osd'): Core.launch_command('notify-osd "'+_("Remind you that after about 5 minutes to do ")+alarm['text']+'" -i task-due -t '+str(144000)+'&') # 2 min else: try: import pynotify pynotify.init("Alamclock notification") n = pynotify.Notification(_("Remind you that after about 5 minutes to do ")+alarm['text'], "", "task-due") n.set_urgency(pynotify.URGENCY_CRITICAL) n.set_timeout(144000) n.show() except: print "Error: need notify-osd or libnotify-bin or notify-send or python-notify" return True