enigma2 (20120327 rel32 -> 20120430 master)
[enigma2.git] / usr / lib / enigma2 / python / Screens / TimerEntry.py
1 from Screen import Screen
2 import ChannelSelection
3 from ServiceReference import ServiceReference
4 from Components.config import config, ConfigSelection, ConfigText, ConfigSubList, ConfigDateTime, ConfigClock, ConfigYesNo, getConfigListEntry
5 from Components.ActionMap import NumberActionMap
6 from Components.ConfigList import ConfigListScreen
7 from Components.MenuList import MenuList
8 from Components.Button import Button
9 from Components.Label import Label
10 from Components.Pixmap import Pixmap
11 from Components.SystemInfo import SystemInfo
12 from Components.UsageConfig import defaultMoviePath, defaultStorageDevice
13 from Components.Harddisk import harddiskmanager
14 from Screens.MovieSelection import getPreferredTagEditor
15 from Screens.LocationBox import MovieLocationBox
16 from Screens.ChoiceBox import ChoiceBox
17 from Screens.MessageBox import MessageBox
18 from Tools.BoundFunction import boundFunction
19 from RecordTimer import AFTEREVENT
20 from enigma import eEPGCache
21 from time import localtime, mktime, time, strftime
22 from datetime import datetime
23
24 class TimerEntry(Screen, ConfigListScreen):
25         def __init__(self, session, timer):
26                 Screen.__init__(self, session)
27                 self.timer = timer
28
29                 self.entryDate = None
30                 self.entryService = None
31
32                 self["oktext"] = Label(_("OK"))
33                 self["canceltext"] = Label(_("Cancel"))
34                 self["ok"] = Pixmap()
35                 self["cancel"] = Pixmap()
36
37                 self.createConfig()
38
39                 self["actions"] = NumberActionMap(["SetupActions", "GlobalActions", "PiPSetupActions"],
40                 {
41                         "ok": self.keySelect,
42                         "save": self.keyGo,
43                         "cancel": self.keyCancel,
44                         "volumeUp": self.incrementStart,
45                         "volumeDown": self.decrementStart,
46                         "size+": self.incrementEnd,
47                         "size-": self.decrementEnd
48                 }, -2)
49
50                 self.list = []
51                 ConfigListScreen.__init__(self, self.list, session = session)
52                 self.createSetup("config")
53
54         def createConfig(self):
55                         justplay = self.timer.justplay
56
57                         afterevent = {
58                                 AFTEREVENT.NONE: "nothing",
59                                 AFTEREVENT.DEEPSTANDBY: "deepstandby",
60                                 AFTEREVENT.STANDBY: "standby",
61                                 AFTEREVENT.AUTO: "auto"
62                                 }[self.timer.afterEvent]
63
64                         weekday_table = ("mon", "tue", "wed", "thu", "fri", "sat", "sun")
65
66                         # calculate default values
67                         day = []
68                         weekday = 0
69                         for x in (0, 1, 2, 3, 4, 5, 6):
70                                 day.append(0)
71                         if self.timer.repeated: # repeated
72                                 type = "repeated"
73                                 if (self.timer.repeated == 31): # Mon-Fri
74                                         repeated = "weekdays"
75                                 elif (self.timer.repeated == 127): # daily
76                                         repeated = "daily"
77                                 else:
78                                         flags = self.timer.repeated
79                                         repeated = "user"
80                                         count = 0
81                                         for x in (0, 1, 2, 3, 4, 5, 6):
82                                                 if flags == 1: # weekly
83                                                         print "Set to weekday " + str(x)
84                                                         weekday = x
85                                                 if flags & 1 == 1: # set user defined flags
86                                                         day[x] = 1
87                                                         count += 1
88                                                 else:
89                                                         day[x] = 0
90                                                 flags = flags >> 1
91                                         if count == 1:
92                                                 repeated = "weekly"
93                         else: # once
94                                 type = "once"
95                                 repeated = None
96                                 weekday = (int(strftime("%w", localtime(self.timer.begin))) - 1) % 7
97                                 day[weekday] = 1
98
99                         justplay_default = {0: "record", 1: "zap"}[justplay]
100                         tmp_dir = self.timer.dirname or defaultMoviePath()
101                         if not harddiskmanager.inside_mountpoint(tmp_dir):
102                                 justplay_default = {0: "record", 1: "zap"}[True]
103                         self.timerentry_justplay = ConfigSelection(choices = [("zap", _("zap")), ("record", _("record"))], default = justplay_default)
104
105                         if SystemInfo["DeepstandbySupport"]:
106                                 shutdownString = _("go to deep standby")
107                         else:
108                                 shutdownString = _("shut down")
109                         self.timerentry_afterevent = ConfigSelection(choices = [("nothing", _("do nothing")), ("standby", _("go to standby")), ("deepstandby", shutdownString), ("auto", _("auto"))], default = afterevent)
110                         self.timerentry_type = ConfigSelection(choices = [("once",_("once")), ("repeated", _("repeated"))], default = type)
111                         self.timerentry_name = ConfigText(default = self.timer.name, visible_width = 50, fixed_size = False)
112                         self.timerentry_description = ConfigText(default = self.timer.description, visible_width = 50, fixed_size = False)
113                         self.timerentry_tags = self.timer.tags[:]
114                         self.timerentry_tagsset = ConfigSelection(choices = [not self.timerentry_tags and "None" or " ".join(self.timerentry_tags)])
115
116                         self.timerentry_repeated = ConfigSelection(default = repeated, choices = [("daily", _("daily")), ("weekly", _("weekly")), ("weekdays", _("Mon-Fri")), ("user", _("user defined"))])
117                         
118                         self.timerentry_date = ConfigDateTime(default = self.timer.begin, formatstring = _("%d.%B %Y"), increment = 86400)
119                         self.timerentry_starttime = ConfigClock(default = self.timer.begin)
120                         self.timerentry_endtime = ConfigClock(default = self.timer.end)
121                         self.timerentry_showendtime = ConfigSelection(default = ((self.timer.end - self.timer.begin) > 4), choices = [(True, _("yes")), (False, _("no"))])
122
123                         default = self.timer.dirname or defaultMoviePath()
124                         tmp = config.movielist.videodirs.value
125                         if default not in tmp:
126                                 tmp.append(default)
127                         self.timerentry_dirname = ConfigSelection(default = default, choices = tmp)
128
129                         self.timerentry_repeatedbegindate = ConfigDateTime(default = self.timer.repeatedbegindate, formatstring = _("%d.%B %Y"), increment = 86400)
130
131                         self.timerentry_weekday = ConfigSelection(default = weekday_table[weekday], choices = [("mon",_("Monday")), ("tue", _("Tuesday")), ("wed",_("Wednesday")), ("thu", _("Thursday")), ("fri", _("Friday")), ("sat", _("Saturday")), ("sun", _("Sunday"))])
132
133                         self.timerentry_day = ConfigSubList()
134                         for x in (0, 1, 2, 3, 4, 5, 6):
135                                 self.timerentry_day.append(ConfigYesNo(default = day[x]))
136
137                         # FIXME some service-chooser needed here
138                         servicename = "N/A"
139                         try: # no current service available?
140                                 servicename = str(self.timer.service_ref.getServiceName())
141                         except:
142                                 pass
143                         self.timerentry_service_ref = self.timer.service_ref
144                         self.timerentry_service = ConfigSelection([servicename])
145
146                         self.timerentry_plugins = {}
147                         if config.usage.setup_level.index >= 2:
148                                 from Plugins.Plugin import PluginDescriptor
149                                 from Components.PluginComponent import plugins
150                                 missing = self.timer.plugins.keys()
151                                 for p in plugins.getPlugins(PluginDescriptor.WHERE_TIMEREDIT):
152                                         if p.__call__.has_key("setupFnc"):
153                                                 setupFnc = p.__call__["setupFnc"]
154                                                 if setupFnc is not None:
155                                                         if p.__call__.has_key("configListEntry"):
156                                                                 entry = p.__call__["configListEntry"]
157                                                                 pdata = None
158                                                                 if p.name in self.timer.plugins:
159                                                                         pval = self.timer.plugins[p.name][0]
160                                                                         pdata = self.timer.plugins[p.name][1]
161                                                                         try:
162                                                                                 if isinstance(entry[1].value, bool):
163                                                                                         entry[1].value = (pval == "True")
164                                                                                 elif isinstance(entry[1].value, str):
165                                                                                         entry[1].value = str(pval)
166                                                                                 elif isinstance(entry[1].value, int):
167                                                                                         entry[1].value = int(pval)
168                                                                         except ValueError:
169                                                                                 print "could not get config_val", pval, type(pval), "for WHERE_TIMEREDIT plugin:", p.name
170                                                                                 break
171
172                                                                 self.timerentry_plugins[entry] = [p.name, setupFnc, pdata] # [plugin name, function call for plugin setup, plugin private data]
173                                                                 if p.name in missing:
174                                                                         missing.remove(p.name)
175                                 if len(missing):
176                                         print "could not setup WHERE_TIMEREDIT plugin(s):", missing
177
178         def createSetup(self, widget):
179                 self.list = []
180                 self.list.append(getConfigListEntry(_("Name"), self.timerentry_name))
181                 self.list.append(getConfigListEntry(_("Description"), self.timerentry_description))
182                 self.timerJustplayEntry = getConfigListEntry(_("Timer Type"), self.timerentry_justplay)
183                 self.list.append(self.timerJustplayEntry)
184                 self.timerTypeEntry = getConfigListEntry(_("Repeat Type"), self.timerentry_type)
185                 self.list.append(self.timerTypeEntry)
186
187                 if self.timerentry_type.value == "once":
188                         self.frequencyEntry = None
189                 else: # repeated
190                         self.frequencyEntry = getConfigListEntry(_("Repeats"), self.timerentry_repeated)
191                         self.list.append(self.frequencyEntry)
192                         self.repeatedbegindateEntry = getConfigListEntry(_("Starting on"), self.timerentry_repeatedbegindate)
193                         self.list.append(self.repeatedbegindateEntry)
194                         if self.timerentry_repeated.value == "daily":
195                                 pass
196                         if self.timerentry_repeated.value == "weekdays":
197                                 pass
198                         if self.timerentry_repeated.value == "weekly":
199                                 self.list.append(getConfigListEntry(_("Weekday"), self.timerentry_weekday))
200
201                         if self.timerentry_repeated.value == "user":
202                                 self.list.append(getConfigListEntry(_("Monday"), self.timerentry_day[0]))
203                                 self.list.append(getConfigListEntry(_("Tuesday"), self.timerentry_day[1]))
204                                 self.list.append(getConfigListEntry(_("Wednesday"), self.timerentry_day[2]))
205                                 self.list.append(getConfigListEntry(_("Thursday"), self.timerentry_day[3]))
206                                 self.list.append(getConfigListEntry(_("Friday"), self.timerentry_day[4]))
207                                 self.list.append(getConfigListEntry(_("Saturday"), self.timerentry_day[5]))
208                                 self.list.append(getConfigListEntry(_("Sunday"), self.timerentry_day[6]))
209
210                 self.entryDate = getConfigListEntry(_("Date"), self.timerentry_date)
211                 if self.timerentry_type.value == "once":
212                         self.list.append(self.entryDate)
213                 
214                 self.entryStartTime = getConfigListEntry(_("StartTime"), self.timerentry_starttime)
215                 self.list.append(self.entryStartTime)
216                 
217                 self.entryShowEndTime = getConfigListEntry(_("Set End Time"), self.timerentry_showendtime)
218                 if self.timerentry_justplay.value == "zap":
219                         self.list.append(self.entryShowEndTime)
220                 self.entryEndTime = getConfigListEntry(_("EndTime"), self.timerentry_endtime)
221                 if self.timerentry_justplay.value != "zap" or self.timerentry_showendtime.value:
222                         self.list.append(self.entryEndTime)
223
224                 self.channelEntry = getConfigListEntry(_("Channel"), self.timerentry_service)
225                 self.list.append(self.channelEntry)
226
227                 self.dirname = getConfigListEntry(_("Location"), self.timerentry_dirname)
228                 self.tagsSet = getConfigListEntry(_("Tags"), self.timerentry_tagsset)
229                 if self.timerentry_justplay.value != "zap":
230                         if config.usage.setup_level.index >= 2: # expert+
231                                 self.list.append(self.dirname)
232                         if getPreferredTagEditor():
233                                 self.list.append(self.tagsSet)
234                         self.list.append(getConfigListEntry(_("After event"), self.timerentry_afterevent))
235
236                 for entry in self.timerentry_plugins.keys():
237                         self.list.append(entry)
238
239                 self[widget].list = self.list
240                 self[widget].l.setList(self.list)
241
242         def newConfig(self):
243                 print "newConfig", self["config"].getCurrent()
244                 if self["config"].getCurrent() in (self.timerTypeEntry, self.timerJustplayEntry, self.frequencyEntry, self.entryShowEndTime):
245                         self.createSetup("config")
246
247         def keyLeft(self):
248                 if self["config"].getCurrent() in (self.channelEntry, self.tagsSet):
249                         self.keySelect()
250                 else:
251                         ConfigListScreen.keyLeft(self)
252                         self.newConfig()
253
254         def keyRight(self):
255                 if self["config"].getCurrent() in (self.channelEntry, self.tagsSet):
256                         self.keySelect()
257                 else:
258                         ConfigListScreen.keyRight(self)
259                         self.newConfig()
260
261         def keySelect(self):
262                 cur = self["config"].getCurrent()
263                 if cur == self.channelEntry:
264                         self.session.openWithCallback(
265                                 self.finishedChannelSelection,
266                                 ChannelSelection.SimpleChannelSelection,
267                                 _("Select channel to record from")
268                         )
269                 elif config.usage.setup_level.index >= 2 and cur == self.dirname:
270                         self.session.openWithCallback(
271                                 self.pathSelected,
272                                 MovieLocationBox,
273                                 _("Choose target folder"),
274                                 self.timerentry_dirname.value,
275                                 minFree = 100 # We require at least 100MB free space
276                         )
277                 elif getPreferredTagEditor() and cur == self.tagsSet:
278                         self.session.openWithCallback(
279                                 self.tagEditFinished,
280                                 getPreferredTagEditor(),
281                                 self.timerentry_tags
282                         )
283                 elif config.usage.setup_level.index >= 2 and cur in self.timerentry_plugins.keys():
284                         self.getConfigListValues()
285                         setupFnc = self.timerentry_plugins[cur][1]
286                         configentry = cur[1]
287                         private_data = self.timerentry_plugins[cur][2]
288                         print "calling setupFnc of WHERE_TIMEREDIT plugin:", cur[0], setupFnc, configentry, private_data, self.timer.name
289                         self.session.openWithCallback(boundFunction(self.pluginFinished, cur), setupFnc , configentry, private_data, self.timer)
290                 else:
291                         self.keyGo()
292
293         def pluginFinished(self, entry, ret=""):
294                 print "[pluginFinished]", entry, ret
295                 self.timerentry_plugins[entry][2] = ret
296                 self["config"].invalidate(entry)
297                 print "plugin private data", self.timerentry_plugins[entry][2]
298
299         def finishedChannelSelection(self, *args):
300                 if args:
301                         self.timerentry_service_ref = ServiceReference(args[0])
302                         self.timerentry_service.setCurrentText(self.timerentry_service_ref.getServiceName())
303                         self["config"].invalidate(self.channelEntry)
304                         
305         def getTimestamp(self, date, mytime):
306                 d = localtime(date)
307                 dt = datetime(d.tm_year, d.tm_mon, d.tm_mday, mytime[0], mytime[1])
308                 return int(mktime(dt.timetuple()))
309
310         def getBeginEnd(self):
311                 date = self.timerentry_date.value
312                 endtime = self.timerentry_endtime.value
313                 starttime = self.timerentry_starttime.value
314
315                 begin = self.getTimestamp(date, starttime)
316                 end = self.getTimestamp(date, endtime)
317
318                 # if the endtime is less than the starttime, add 1 day.
319                 if end < begin:
320                         end += 86400
321                 return begin, end
322
323         def selectChannelSelector(self, *args):
324                 self.session.openWithCallback(
325                                 self.finishedChannelSelectionCorrection,
326                                 ChannelSelection.SimpleChannelSelection,
327                                 _("Select channel to record from")
328                         )
329
330         def finishedChannelSelectionCorrection(self, *args):
331                 if args:
332                         self.finishedChannelSelection(*args)
333                         self.keyGo()
334
335         def getConfigListValues(self):
336                 if not self.timerentry_service_ref.isRecordable():
337                         self.session.openWithCallback(self.selectChannelSelector, MessageBox, _("You didn't select a channel to record from."), MessageBox.TYPE_ERROR)
338                         return
339                 if self.timerentry_justplay.value == 'record':
340                         if not harddiskmanager.inside_mountpoint(self.timerentry_dirname.value):
341                                 if harddiskmanager.HDDCount() and not harddiskmanager.HDDEnabledCount():
342                                         self.session.open(MessageBox, _("Unconfigured storage devices found!") + "\n" \
343                                                 + _("Please make sure to set up your storage devices with the improved storage management in menu -> setup -> system -> storage devices."), MessageBox.TYPE_ERROR)
344                                         return
345                                 elif harddiskmanager.HDDEnabledCount() and defaultStorageDevice() == "<undefined>":
346                                         self.session.open(MessageBox, _("No default storage device found!") + "\n" \
347                                                 + _("Please make sure to set up your default storage device in menu -> setup -> system -> recording paths."), MessageBox.TYPE_ERROR)
348                                         return
349                                 elif harddiskmanager.HDDEnabledCount() and defaultStorageDevice() != "<undefined>":
350                                         part = harddiskmanager.getDefaultStorageDevicebyUUID(defaultStorageDevice())
351                                         if part is None:
352                                                 self.session.open(MessageBox, _("Default storage device is not available!") + "\n" \
353                                                         + _("Please verify if your default storage device is attached or set up your default storage device in menu -> setup -> system -> recording paths."), MessageBox.TYPE_ERROR)
354                                                 return
355                                 else:
356                                         self.session.open(MessageBox, _("Recording destination for this timer does not exists."), MessageBox.TYPE_ERROR)
357                                         return
358
359                 self.timer.name = self.timerentry_name.value
360                 self.timer.description = self.timerentry_description.value
361                 self.timer.justplay = self.timerentry_justplay.value == "zap"
362                 if self.timerentry_justplay.value == "zap":
363                         if not self.timerentry_showendtime.value:
364                                 self.timerentry_endtime.value = self.timerentry_starttime.value
365
366                 self.timer.resetRepeated()
367                 self.timer.afterEvent = {
368                         "nothing": AFTEREVENT.NONE,
369                         "deepstandby": AFTEREVENT.DEEPSTANDBY,
370                         "standby": AFTEREVENT.STANDBY,
371                         "auto": AFTEREVENT.AUTO
372                         }[self.timerentry_afterevent.value]
373                 self.timer.service_ref = self.timerentry_service_ref
374                 self.timer.tags = self.timerentry_tags
375
376                 if self.timer.dirname or self.timerentry_dirname.value != defaultMoviePath():
377                         self.timer.dirname = self.timerentry_dirname.value
378                         config.movielist.last_timer_videodir.value = self.timer.dirname
379                         config.movielist.last_timer_videodir.save()
380
381                 if self.timerentry_type.value == "once":
382                         self.timer.begin, self.timer.end = self.getBeginEnd()
383                 if self.timerentry_type.value == "repeated":
384                         if self.timerentry_repeated.value == "daily":
385                                 for x in (0, 1, 2, 3, 4, 5, 6):
386                                         self.timer.setRepeated(x)
387
388                         if self.timerentry_repeated.value == "weekly":
389                                 self.timer.setRepeated(self.timerentry_weekday.index)
390
391                         if self.timerentry_repeated.value == "weekdays":
392                                 for x in (0, 1, 2, 3, 4):
393                                         self.timer.setRepeated(x)
394
395                         if self.timerentry_repeated.value == "user":
396                                 for x in (0, 1, 2, 3, 4, 5, 6):
397                                         if self.timerentry_day[x].value:
398                                                 self.timer.setRepeated(x)
399
400                         self.timer.repeatedbegindate = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value)
401                         if self.timer.repeated:
402                                 self.timer.begin = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_starttime.value)
403                                 self.timer.end = self.getTimestamp(self.timerentry_repeatedbegindate.value, self.timerentry_endtime.value)
404                         else:
405                                 self.timer.begin = self.getTimestamp(time.time(), self.timerentry_starttime.value)
406                                 self.timer.end = self.getTimestamp(time.time(), self.timerentry_endtime.value)
407
408                         # when a timer end is set before the start, add 1 day
409                         if self.timer.end < self.timer.begin:
410                                 self.timer.end += 86400
411
412         def keyGo(self, result = None):
413                 self.getConfigListValues()
414                 if self.timer.eit is not None:
415                         event = eEPGCache.getInstance().lookupEventId(self.timer.service_ref.ref, self.timer.eit)
416                         if event:
417                                 n = event.getNumOfLinkageServices()
418                                 if n > 1:
419                                         tlist = []
420                                         ref = self.session.nav.getCurrentlyPlayingServiceReference()
421                                         parent = self.timer.service_ref.ref
422                                         selection = 0
423                                         for x in range(n):
424                                                 i = event.getLinkageService(parent, x)
425                                                 if i.toString() == ref.toString():
426                                                         selection = x
427                                                 tlist.append((i.getName(), i))
428                                         self.session.openWithCallback(self.subserviceSelected, ChoiceBox, title=_("Please select a subservice to record..."), list = tlist, selection = selection)
429                                         return
430                                 elif n > 0:
431                                         parent = self.timer.service_ref.ref
432                                         self.timer.service_ref = ServiceReference(event.getLinkageService(parent, 0))
433                 
434                 if self.timerentry_plugins:
435                         self.timer.plugins = {}
436                         for key, val in self.timerentry_plugins.iteritems():
437                                 self.timer.plugins[val[0]] = (str(key[1].value),str(val[2]))
438                                 print "timerentry self.timer.plugins", self.timer.plugins
439                 
440                 self.saveTimer()
441                 self.close((True, self.timer))
442
443         def incrementStart(self):
444                 self.timerentry_starttime.increment()
445                 self["config"].invalidate(self.entryStartTime)
446
447         def decrementStart(self):
448                 self.timerentry_starttime.decrement()
449                 self["config"].invalidate(self.entryStartTime)
450
451         def incrementEnd(self):
452                 if self.entryEndTime is not None:
453                         self.timerentry_endtime.increment()
454                         self["config"].invalidate(self.entryEndTime)
455
456         def decrementEnd(self):
457                 if self.entryEndTime is not None:
458                         self.timerentry_endtime.decrement()
459                         self["config"].invalidate(self.entryEndTime)
460
461         def subserviceSelected(self, service):
462                 if not service is None:
463                         self.timer.service_ref = ServiceReference(service[1])
464                 self.saveTimer()
465                 self.close((True, self.timer))
466
467         def saveTimer(self):
468                 self.session.nav.RecordTimer.saveTimer()
469
470         def keyCancel(self):
471                 self.close((False,))
472
473         def pathSelected(self, res):
474                 if res is not None:
475                         if config.movielist.videodirs.value != self.timerentry_dirname.choices:
476                                 self.timerentry_dirname.setChoices(config.movielist.videodirs.value, default=res)
477                         self.timerentry_dirname.value = res
478
479         def tagEditFinished(self, ret):
480                 if ret is not None:
481                         self.timerentry_tags = ret
482                         self.timerentry_tagsset.setChoices([not ret and "None" or " ".join(ret)])
483                         self["config"].invalidate(self.tagsSet)
484
485 class TimerLog(Screen):
486         def __init__(self, session, timer):
487                 Screen.__init__(self, session)
488                 self.timer = timer;
489                 self.log_entries = self.timer.log_entries[:]
490
491                 self.fillLogList()
492
493                 self["loglist"] = MenuList(self.list)
494                 self["logentry"] = Label()
495
496                 self["key_red"] = Button(_("Delete entry"))
497                 self["key_green"] = Button()
498                 self["key_yellow"] = Button("")
499                 self["key_blue"] = Button(_("Clear log"))
500
501                 self.onShown.append(self.updateText)
502
503                 self["actions"] = NumberActionMap(["OkCancelActions", "DirectionActions", "ColorActions"],
504                 {
505                         "ok": self.keyClose,
506                         "cancel": self.keyClose,
507                         "up": self.up,
508                         "down": self.down,
509                         "left": self.left,
510                         "right": self.right,
511                         "red": self.deleteEntry,
512                         "blue": self.clearLog
513                 }, -1)
514
515         def deleteEntry(self):
516                 cur = self["loglist"].getCurrent()
517                 if cur is None:
518                         return 
519                 self.log_entries.remove(cur[1])
520                 self.fillLogList()
521                 self["loglist"].l.setList(self.list)
522                 self.updateText()
523
524         def fillLogList(self):
525                 self.list = [(str(strftime("%Y-%m-%d %H-%M", localtime(x[0])) + " - " + x[2]), x) for x in self.log_entries]
526
527         def clearLog(self):
528                 self.log_entries = []
529                 self.fillLogList()
530                 self["loglist"].l.setList(self.list)
531                 self.updateText()
532
533         def keyClose(self):
534                 if self.timer.log_entries != self.log_entries:
535                         self.timer.log_entries = self.log_entries
536                         self.close((True, self.timer))
537                 else:
538                         self.close((False,))
539
540         def up(self):
541                 self["loglist"].instance.moveSelection(self["loglist"].instance.moveUp)
542                 self.updateText()
543
544         def down(self):
545                 self["loglist"].instance.moveSelection(self["loglist"].instance.moveDown)
546                 self.updateText()
547
548         def left(self):
549                 self["loglist"].instance.moveSelection(self["loglist"].instance.pageUp)
550                 self.updateText()
551
552         def right(self):
553                 self["loglist"].instance.moveSelection(self["loglist"].instance.pageDown)
554                 self.updateText()
555
556         def updateText(self):
557                 if self.list:
558                         self["logentry"].setText(str(self["loglist"].getCurrent()[1][2]))
559                 else:
560                         self["logentry"].setText("")