- add "ok" to the configMenu's actionlist again
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sat, 12 Nov 2005 18:24:07 +0000 (18:24 +0000)
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>
Sat, 12 Nov 2005 18:24:07 +0000 (18:24 +0000)
- timer edit is now functional (not for repeated timers) but we have a redraw-problem again

data/skin.xml
lib/python/Components/TimerList.py
lib/python/Screens/ConfigMenu.py
lib/python/Screens/TimerEdit.py
lib/python/Screens/TimerEntry.py

index ef5bbd1..b632b6c 100644 (file)
@@ -85,7 +85,6 @@
                </screen>
                <screen name="TimerEntry" position="100,100" size="500,400" title="Timer entry">
                        <widget name="config" position="5,10" size="480,350" />
-                       <widget name="introduction" position="20,360" size="250,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" />
index dbc0cfc..b976969 100644 (file)
@@ -29,11 +29,11 @@ def TimerEntryComponent(timer, processed):
        res.append((0, 0, 400, 30, 0, RT_HALIGN_LEFT, timer.service_ref.getServiceName()))
        res.append((0, 30, 200, 20, 1, RT_HALIGN_LEFT, "%s, %s" % FuzzyTime(timer.begin)))
 
-       res.append((200, 0, 200, 20, 1, RT_HALIGN_RIGHT, timer.description))    
+       res.append((300, 0, 200, 20, 1, RT_HALIGN_RIGHT, timer.description))    
        if processed:
-               res.append((200, 30, 200, 20, 1, RT_HALIGN_RIGHT, FuzzyTime(timer.end)[1]))
+               res.append((300, 30, 200, 20, 1, RT_HALIGN_RIGHT, FuzzyTime(timer.end)[1]))
        else:
-               res.append((200, 30, 200, 20, 1, RT_HALIGN_RIGHT, "done"))
+               res.append((300, 30, 200, 20, 1, RT_HALIGN_RIGHT, "done"))
        return res
 
 class TimerList(HTMLComponent, GUIComponent):
index 8827175..57bdda5 100644 (file)
@@ -13,7 +13,7 @@ class ConfigMenu(Screen):
 
                self["actions"] = ActionMap(["OkCancelActions"], 
                        {
-                               #"ok": self.okbuttonClick,
+                               "ok": self.okbuttonClick,
                                "cancel": self.close
                        })
 
index 233bfe2..ec8b11c 100644 (file)
@@ -9,50 +9,8 @@ from TimerEntry import TimerEntry
 from RecordTimer import RecordTimerEntry
 from time import *
 from ServiceReference import ServiceReference
+from Components.config import *
 
-class TimerEdit(Screen):
-       def __init__(self, session, entry):
-               Screen.__init__(self, session)
-
-               self["actions"] = ActionMap(["OkCancelActions"], 
-                       {
-                               "ok": self.apply,
-                               "cancel": self.close
-                       })
-               
-               self["shortcuts"] = ActionMap(["ShortcutActions"],
-                       {
-                               "red": self.beginFocus,
-                               "yellow": self.endFocus,
-                               "green": self.descFocus
-                       })
-               
-               self.entry = entry
-               # begin, end, description, service
-               self["begin"] = TimeInput()
-               self["end"] = TimeInput()
-               
-               self["lbegin"] = Label("Begin")
-               self["lend"] = Label("End")
-               
-               self["description"] = TextInput()
-               self["apply"] = Button("Apply")
-               self["service"] = Button()
-               
-               self["description"].setText(entry.description);
-       
-       def beginFocus(self):
-               self.setFocus(self["begin"])
-       
-       def endFocus(self):
-               self.setFocus(self["end"])
-       
-       def descFocus(self):
-               self.setFocus(self["description"])
-       
-       def apply(self):
-               print "applied!"
-       
 class TimerEditList(Screen):
        def __init__(self, session):
                Screen.__init__(self, session)
@@ -76,17 +34,18 @@ class TimerEditList(Screen):
                                "ok": self.openEdit,
                                "cancel": self.close,
                                "red": self.removeTimer,
-                               "green": self.addTimer
+                               "green": self.addCurrentTimer
                        })
 
        def openEdit(self):
-               self.session.open(TimerEntry, self["timerlist"].getCurrent()[0])
+               self.session.openWithCallback(self.finishedEdit, TimerEntry, self["timerlist"].getCurrent()[0])
                #self.session.open(TimerEdit, self["timerlist"].getCurrent()[0])
                
        def removeTimer(self):
+               # FIXME doesn't work...
                self.session.nav.RecordTimer.removeEntry(self["timerlist"].getCurrent()[0])
        
-       def addTimer(self):
+       def addCurrentTimer(self):
                begin = time()
                end = time() + 60
                
@@ -114,6 +73,20 @@ class TimerEditList(Screen):
                # FIXME only works if already playing a service
                serviceref = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference())
                
+               self.addTimer(begin, end, serviceref, epg, description)
+               
+       def addTimer(self, begin, end, serviceref, epg, description):
                newEntry = RecordTimerEntry(begin, end, serviceref, epg, description)
-               self.session.open(TimerEntry, newEntry)
+               self.session.openWithCallback(self.finishedAdd, TimerEntry, newEntry)
                
+       def finishedEdit(self, answer):
+               if (answer[0]):
+                       print "Edited timer"
+               else:
+                       print "Timeredit aborted"
+
+       def finishedAdd(self, answer):
+               if (answer[0]):
+                       print "Added timer"
+               else:
+                       print "Timeredit aborted"               
\ No newline at end of file
index c7ea0cf..50df93d 100644 (file)
@@ -5,12 +5,14 @@ from Components.ConfigList import ConfigList
 from Components.NimManager import nimmanager
 from Components.Label import Label
 from time import *
+from datetime import *
 
 class TimerEntry(Screen):
     def __init__(self, session, timer):
         Screen.__init__(self, session)
-        
-        self.createConfig(timer)
+        self.timer = timer;
+                
+        self.createConfig()
         
         self["actions"] = NumberActionMap(["SetupActions"],
         {
@@ -34,21 +36,19 @@ class TimerEntry(Screen):
         self["config"] = ConfigList(self.list)
         self.createSetup()
 
-        self["introduction"] = Label("Press OK to start the scan")
-
-    def createConfig(self, timer):
+    def createConfig(self):
             config.timerentry = ConfigSubsection()
 
             config.timerentry.type = configElement_nonSave("config.timerentry.type", configSelection, 0, ("once", "repeated"))
-            config.timerentry.description = configElement_nonSave("config.timerentry.description", configText, timer.description, (configText.extendableSize,))
+            config.timerentry.description = configElement_nonSave("config.timerentry.description", configText, self.timer.description, (configText.extendableSize,))
 
             config.timerentry.repeated = configElement_nonSave("config.timerentry.repeated", configSelection, 0, ("daily", "weekly", "Mon-Fri", "user-defined"))
 
-            config.timerentry.startdate = configElement_nonSave("config.timerentry.startdate", configDateTime, timer.begin, ("%d.%B %Y", 86400))
-            config.timerentry.starttime = configElement_nonSave("config.timerentry.starttime", configSequence, [int(strftime("%H", localtime(timer.begin))), int(strftime("%M", localtime(timer.begin)))], configsequencearg.get("CLOCK"))
+            config.timerentry.startdate = configElement_nonSave("config.timerentry.startdate", configDateTime, self.timer.begin, ("%d.%B %Y", 86400))
+            config.timerentry.starttime = configElement_nonSave("config.timerentry.starttime", configSequence, [int(strftime("%H", localtime(self.timer.begin))), int(strftime("%M", localtime(self.timer.begin)))], configsequencearg.get("CLOCK"))
 
-            config.timerentry.enddate = configElement_nonSave("config.timerentry.enddate", configDateTime, timer.end, ("%d.%B %Y", 86400))
-            config.timerentry.endtime = configElement_nonSave("config.timerentry.endtime", configSequence, [int(strftime("%H", localtime(timer.end))), int(strftime("%M", localtime(timer.end)))], configsequencearg.get("CLOCK"))
+            config.timerentry.enddate = configElement_nonSave("config.timerentry.enddate", configDateTime, self.timer.end, ("%d.%B %Y", 86400))
+            config.timerentry.endtime = configElement_nonSave("config.timerentry.endtime", configSequence, [int(strftime("%H", localtime(self.timer.end))), int(strftime("%M", localtime(self.timer.end)))], configsequencearg.get("CLOCK"))
             
             config.timerentry.weekday = configElement_nonSave("config.timerentry.weekday", configDateTime, time(), ("%A", 86400))
             
@@ -61,7 +61,7 @@ class TimerEntry(Screen):
             config.timerentry.sunday = configElement_nonSave("config.timerentry.sunday", configSelection, 0, ("yes", "no"))
             
             # FIXME some service-chooser needed here
-            config.timerentry.service = configElement_nonSave("config.timerentry.service", configSelection, 0, ((str(timer.service_ref.getServiceName())),))
+            config.timerentry.service = configElement_nonSave("config.timerentry.service", configSelection, 0, ((str(self.timer.service_ref.getServiceName())),))
             
     def createSetup(self):
         self.list = []
@@ -123,14 +123,17 @@ class TimerEntry(Screen):
         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)        
+    def getTimestamp(self, date, time):
+        d = localtime(date) # for gettin indexes 0(year), 1(month) and 2(day)
+        dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, time[0], time[1])
+        print dt
+        return int(mktime(dt.timetuple()))
 
-        #self.close()
+    def keyGo(self):        
+        if (config.timerentry.type.value == 0): # once
+            self.timer.begin = self.getTimestamp(config.timerentry.startdate.value, config.timerentry.starttime.value)
+            self.timer.end = self.getTimestamp(config.timerentry.enddate.value, config.timerentry.endtime.value)
+        self.close((True, self.timer))
 
     def keyCancel(self):
-        for x in self["config"].list:
-            x[1].cancel()
-        self.close()
\ No newline at end of file
+        self.close((False,))
\ No newline at end of file