* Remove triple dot "..." from main menu entries and main menu plugin names.
[enigma2.git] / lib / python / Screens / TimeDateInput.py
index 6cdc6217f3303e0dba47ca17700aa4b6c81e4ef7..56ccae901b2088dc39cc2040566de18d68c9bbf1 100644 (file)
@@ -1,23 +1,21 @@
 from Screen import Screen
-from Components.config import *
-from Components.ActionMap import ActionMap, NumberActionMap
-from Components.ConfigList import ConfigList, ConfigListScreen
-from Components.Button import Button
+from Components.config import ConfigClock, ConfigDateTime, getConfigListEntry
+from Components.ActionMap import NumberActionMap
+from Components.ConfigList import ConfigListScreen
 from Components.Label import Label
 from Components.Pixmap import Pixmap
 import time
 import datetime
 
 class TimeDateInput(Screen, ConfigListScreen):
-       def __init__(self, session):
+       def __init__(self, session, config_time=None, config_date=None):
                Screen.__init__(self, session)
-
                self["oktext"] = Label(_("OK"))
                self["canceltext"] = Label(_("Cancel"))
                self["ok"] = Pixmap()
                self["cancel"] = Pixmap()
 
-               self.createConfig()
+               self.createConfig(config_date, config_time)
 
                self["actions"] = NumberActionMap(["SetupActions"],
                {
@@ -30,15 +28,24 @@ class TimeDateInput(Screen, ConfigListScreen):
                ConfigListScreen.__init__(self, self.list)
                self.createSetup(self["config"])
 
-       def createConfig(self):
-               nowtime = time.time()
-               self.timeinput_date = ConfigDateTime(default = nowtime, formatstring = _("%d.%B %Y"), increment = 86400)
-               self.timeinput_time = ConfigClock(default = nowtime)
+       def createConfig(self, conf_date, conf_time):
+               self.save_mask = 0
+               if conf_time:
+                       self.save_mask |= 1
+               else:
+                       conf_time = ConfigClock(default = time.time()),
+               if conf_date:
+                       self.save_mask |= 2
+               else:
+                       conf_date = ConfigDateTime(default = time.time(), formatstring = _("%d.%B %Y"), increment = 86400)
+               self.timeinput_date = conf_date
+               self.timeinput_time = conf_time
 
        def createSetup(self, configlist):
-               self.list = []
-               self.list.append(getConfigListEntry(_("Date"), self.timeinput_date))
-               self.list.append(getConfigListEntry(_("Time"), self.timeinput_time))
+               self.list = [
+                       getConfigListEntry(_("Date"), self.timeinput_date),
+                       getConfigListEntry(_("Time"), self.timeinput_time)
+               ]
                configlist.list = self.list
                configlist.l.setList(self.list)
 
@@ -52,7 +59,15 @@ class TimeDateInput(Screen, ConfigListScreen):
 
        def keyGo(self):
                time = self.getTimestamp(self.timeinput_date.value, self.timeinput_time.value)
+               if self.save_mask & 1:
+                       self.timeinput_time.save()
+               if self.save_mask & 2:
+                       self.timeinput_date.save()
                self.close((True, time))
 
        def keyCancel(self):
+               if self.save_mask & 1:
+                       self.timeinput_time.cancel()
+               if self.save_mask & 2:
+                       self.timeinput_date.cancel()
                self.close((False,))