add TimerEntry for later use in TimerEdit
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Mon, 7 Nov 2005 23:07:53 +0000 (23:07 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Mon, 7 Nov 2005 23:07:53 +0000 (23:07 +0000)
add configDateTime as a config entry to select time, date, weekday or whatever is wanted... flexible as always :)

data/menu.xml
data/skin.xml
lib/python/Components/__init__.py
lib/python/Components/config.py
lib/python/Screens/Makefile.am
lib/python/Screens/TimerEntry.py [new file with mode: 0644]

index f023a2adc6e253469c3ac6dde95d225098b26c3f..ecc9b4af1c44f7e93d971ea157e96a27c4439a6f 100644 (file)
@@ -18,6 +18,7 @@
                <item text="CI"><screen module="Ci" screen="CiSelection" /></item>
                <item text="Satelliteconfig"><screen module="Satconfig" screen="NimSelection" /></item>
                <item text="Scanconfiguration"><screen module="ScanSetup" screen="ScanSetup" /></item>
+               <item text="Timerentry"><screen module="TimerEntry" screen="TimerEntry" /></item>
                <item text="Radio"><code>print "radio mode"</code></item>
                <item text="Timer"><screen module="TimerEdit" screen="TimerEditList" /></item>
                <item text="Information"><screen module="About" /></item>
index 82c48d8a0338b3699025b5e5f5c245f14527e03d..16908a3b4ae334ecb224a6c7170d405d4ec946b5 100644 (file)
                        <widget name="config" position="20,10" size="460,350" />
                        <widget name="introduction" position="20,360" size="280,30" font="Arial;23" />
                </screen>
+               <screen name="TimerEntry" position="100,100" size="500,400" title="Timer entry">
+                       <widget name="config" position="20,10" size="460,350" />
+                       <widget name="introduction" position="20,360" size="280,30" font="Arial;23" />
+               </screen>
                <screen name="NetworkSetup" position="140,125" size="460,280" title="Network Setup">
                        <widget name="config" position="10,50" size="420,175" />
                        <widget name="introduction" position="10,230" size="400,30" font="Arial;23" />
index be75d13fa7b79b327d1ce79c04ab6a1c118c1cff..f697b95661e8f5b8cd0931a32f43f932ba5d3663 100644 (file)
@@ -5,4 +5,4 @@ __all__ = ["ActionMap", "Button", "Clock", "ConfigList", "EventInfo",
        "ServiceName", "ServiceScan", "VariableText", "VariableValue", "VolumeBar",
        "components", "config", "TimerList", "TimeInput", "MovieList", 
        "InputDevice",  "ServicePosition", "IPAddress", "VariableIP", "IPGateway",
-       "IPNameserver", "Network", "RFmon", "DiskInfo", "NimManager" ]
+       "IPNameserver", "Network", "RFmon", "DiskInfo", "NimManager", "TimerEntry" ]
index 7e7978619e3a703a780a2afaef665e256d0ec14c..a28c40ca6500d9b51ea426af35598fbafe974985 100644 (file)
@@ -1,3 +1,5 @@
+from time import *
+
 class configFile:
        def __init__(self):
                self.changed = 0
@@ -80,6 +82,38 @@ class configSelection:
                self.checkValues()
                return ("text", self.parent.vals[self.parent.value])
 
+class configDateTime:
+       def __init__(self, parent):
+               self.parent = parent
+               
+       def checkValues(self):
+               pass
+#              if self.parent.value < 0:
+                       #self.parent.value = 0  
+
+               #if(self.parent.value >= (len(self.parent.vals) - 1)):
+                       #self.parent.value = len(self.parent.vals) - 1
+
+       def cancel(self):
+               self.parent.reload()
+
+       def save(self):
+               self.parent.save()
+
+       def handleKey(self, key):
+               if key == config.key["prevElement"]:
+                       self.parent.value = self.parent.value - self.parent.vals[1]
+               if key == config.key["nextElement"]:
+                       self.parent.value = self.parent.value + self.parent.vals[1]
+               
+               self.checkValues()                      
+
+               self.parent.change()    
+
+       def __call__(self, selected):                   #needed by configlist
+               self.checkValues()
+               return ("text", strftime(self.parent.vals[0], localtime(self.parent.value)))
+       
 class configSatlist:
        def __init__(self, parent):
                self.parent = parent
@@ -308,6 +342,8 @@ class configElement:
                        return int(data);
                elif control == configSelection:
                        return int(data);
+               elif control == configDateTime:
+                       return int(data);
                elif control == configSequence:
                        list = [ ]
                        part = data.split(self.vals[0])
@@ -324,6 +360,8 @@ class configElement:
                        return str(data);
                elif control == configSelection:
                        return str(data);
+               elif control == configDateTime:
+                       return str(data);
                elif control == configSequence:
                        value = ((len(data) * ("%d" + self.vals[0]))[0:-1]) % tuple(data)
 #                      just in case you don't understand the above, here an equivalent:
index 14c397c6da82eba127ea14ff8ddb79871bdc2b55..ecd2da55ee98b688186a5c65d56c69148f7970a3 100644 (file)
@@ -4,4 +4,4 @@ install_PYTHON = \
        ChannelSelection.py ClockDisplay.py ConfigMenu.py InfoBar.py Menu.py    \
        MessageBox.py ScartLoopThrough.py Screen.py ServiceScan.py TimerEdit.py \
        MovieSelection.py Setup.py About.py HarddiskSetup.py FixedMenu.py \
-       Satconfig.py ScanSetup.py NetworkSetup.py Ci.py __init__.py
+       Satconfig.py ScanSetup.py NetworkSetup.py Ci.py TimerEntry.py __init__.py
diff --git a/lib/python/Screens/TimerEntry.py b/lib/python/Screens/TimerEntry.py
new file mode 100644 (file)
index 0000000..f09a16b
--- /dev/null
@@ -0,0 +1,84 @@
+from Screen import Screen
+from Components.config import *
+from Components.ActionMap import NumberActionMap
+from Components.ConfigList import ConfigList
+from Components.NimManager import nimmanager
+from Components.Label import Label
+from time import *
+
+class TimerEntry(Screen):
+    def __init__(self, session):
+        Screen.__init__(self, session)
+        
+        self.createConfig()
+        
+        self["actions"] = NumberActionMap(["SetupActions"],
+        {
+            "ok": self.keyGo,
+            "cancel": self.keyCancel,
+            "left": self.keyLeft,
+            "right": self.keyRight,
+            "1": self.keyNumberGlobal,
+            "2": self.keyNumberGlobal,
+            "3": self.keyNumberGlobal,
+            "4": self.keyNumberGlobal,
+            "5": self.keyNumberGlobal,
+            "6": self.keyNumberGlobal,
+            "7": self.keyNumberGlobal,
+            "8": self.keyNumberGlobal,
+            "9": self.keyNumberGlobal,
+            "0": self.keyNumberGlobal
+        }, -1)
+                
+        self.list = []
+        self["config"] = ConfigList(self.list)
+        self.createSetup()
+
+        self["introduction"] = Label("Press OK to start the scan")
+
+    def createConfig(self):
+            config.timerentry = ConfigSubsection()
+
+            config.timerentry.date = configElement_nonSave("config.timerentry.date", configDateTime, time(), ("%d.%B %Y", 86400))
+            config.timerentry.time = configElement_nonSave("config.timerentry.time", configDateTime, time(), ("%H:%M", 60))
+
+    def createSetup(self):
+        self.list = []
+        
+        self.list.append(getConfigListEntry("Date", config.timerentry.date))
+        self.list.append(getConfigListEntry("Time", config.timerentry.time))        
+        
+        self["config"].list = self.list
+        self["config"].l.setList(self.list)
+        
+    def newConfig(self):
+        print self["config"].getCurrent()
+        if self["config"].getCurrent()[0] == "Type of scan":
+            self.createSetup()
+        if self["config"].getCurrent()[0] == "Tuner":
+            self.createSetup()
+                    
+    def keyLeft(self):
+        self["config"].handleKey(config.key["prevElement"])
+        self.newConfig()
+
+    def keyRight(self):
+        self["config"].handleKey(config.key["nextElement"])
+        self.newConfig()
+
+    def keyNumberGlobal(self, number):
+        print "You pressed number " + str(number)
+        if (self["config"].getCurrent()[1].parent.enabled == True):
+            self["config"].handleKey(config.key[str(number)])
+
+    def keyGo(self):
+        for x in self["config"].list:
+            x[1].save()
+        self.session.openWithCallback(self.keyCancel, ServiceScan)        
+
+        #self.close()
+
+    def keyCancel(self):
+        for x in self["config"].list:
+            x[1].cancel()
+        self.close()
\ No newline at end of file