new Version 0.5: Question if KiddyTimer should be enabled on each start
[enigma2-plugins.git] / kiddytimer / src / KTglob.py
1 import time
2
3 PLUGIN_BASE = "KiddyTimer"
4 PLUGIN_VERSION = "0.5"
5
6 DAYNAMES= (_("Sunday"),
7           _("Monday"),
8           _("Tuesday"),
9           _("Wednesday"),
10           _("Thursday"),
11           _("Friday"),
12           _("Saturday"),
13           )
14
15 ONEHOUR=3600
16 ONEMINUTE=60
17
18 MOVEPOSITIONSTEP = 10
19
20
21 #This is a hack to get the times in the current timezone to feed as default value for the ConfigClock
22 ONEOCLOCK=time.mktime([2000,1,1,1,0,0,5,1,time.timezone])
23 EIGHTOCLOCK=time.mktime([2000,1,1,8,0,0,5,1,time.timezone])
24 EIGHTOCLOCKNOON=time.mktime([2000,1,1,20,0,0,5,1,time.timezone])
25
26 oKiddyTimer = None
27 plugin_path = ""
28
29 ##############################################################################
30
31 SKIN = """
32     <screen flags="wfNoBorder" position="0,0" size="82,104" title="Kiddy Timer" backgroundColor="#ff000000">
33         <ePixmap pixmap="~/img/Smiley-Background.png" position="0,0" zPosition="1" size="82,82" alphatest="on" transparent="1"/>
34         <widget name="TimerSlider" pixmap="~/img/Smiley-Slider.png" zPosition="2" position="0,0" size="82,82" transparent="1" orientation="orBottomToTop" />
35         <widget name="TimerSliderText" zPosition="3" position="0,75" size="82,21" font="Regular;18" halign="center" valign="center" foregroundColor="#000000" backgroundColor="#aaffffff" />
36         <widget name="TimerGraph" pixmaps="~/img/Timer1000.png,~/img/Timer0950.png,~/img/Timer0900.png,~/img/Timer0850.png,~/img/Timer0800.png,~/img/Timer0750.png,~/img/Timer0700.png,~/img/Timer0650.png,~/img/Timer0600.png,~/img/Timer0550.png,~/img/Timer0500.png,~/img/Timer0450.png,~/img/Timer0400.png,~/img/Timer0350.png,~/img/Timer0300.png,~/img/Timer0250.png,~/img/Timer0200.png,~/img/Timer0150.png,~/img/Timer0100.png,~/img/Timer0050.png,~/img/Timer0000.png" position="0,0" zPosition="2" size="82,82" transparent="1" alphatest="on" />
37         <widget name="TimerText" zPosition="3" position="0,30" size="82,21" font="Regular;18" halign="center" valign="center" foregroundColor="#000000" transparent = "1" />
38     </screen>"""
39
40 ##############################################################################
41
42 def getSecondsFromClock(aClock):
43     iSeconds = 60*(int(aClock[0])*60 + int(aClock[1]))
44     return iSeconds
45
46 def getTimeFromSeconds(iSecondsLeft,bReturnSeconds):
47         iHours = int( iSecondsLeft // 3600 )
48         iHourRest = iSecondsLeft - ( iHours * 3600 )
49         iMinutes = int( iHourRest // 60 )
50         if bReturnSeconds == False:
51             return( ("00"+str(iHours))[-2:] + ":" + ("00"+str(iMinutes))[-2:] )
52         else:
53             iSeconds = int( iHourRest - ( iMinutes * 60) )
54             return( ("00"+str(iHours))[-2:] + ":" + ("00"+str(iMinutes))[-2:] + ":" + ("00"+str(iSeconds))[-2:] )
55
56