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