define movepaths for MovingPixmaps and proof of concept in the start-wizard
[enigma2.git] / lib / python / Screens / EpgSelection.py
1 from Screen import Screen
2 from Components.Button import Button
3 from Components.EpgList import EPGList
4 from Components.ActionMap import ActionMap
5 from Screens.EventView import EventView
6 from enigma import eServiceReference, eServiceEventPtr
7 from Screens.FixedMenu import FixedMenu
8 from RecordTimer import RecordTimerEntry
9 from TimerEdit import TimerEditList
10 from TimerEntry import TimerEntry
11 from ServiceReference import ServiceReference
12
13 import xml.dom.minidom
14
15 class EPGSelection(Screen):
16         def __init__(self, session, root):
17                 Screen.__init__(self, session)
18
19                 self["list"] = EPGList()
20
21                 class ChannelActionMap(ActionMap):
22                         def action(self, contexts, action):
23                                         ActionMap.action(self, contexts, action)
24                                         
25                 self["key_red"] = Button("")
26                 self["key_green"] = Button(_("Add timer"))
27                 self["key_yellow"] = Button("")
28                 self["key_blue"] = Button("")
29
30                 self["actions"] = ChannelActionMap(["EPGSelectActions", "OkCancelActions"], 
31                         {
32                                 "cancel": self.close,
33                                 "ok": self.eventSelected,
34                                 "timerAdd": self.timerAdd
35                         })
36                 self["actions"].csel = self
37                 self.setRoot(root)
38
39         def eventViewCallback(self, setEvent, val):
40                 if val == -1:
41                         self.moveUp()
42                         setEvent(self["list"].getCurrent())
43                 elif val == +1:
44                         self.moveDown()
45                         setEvent(self["list"].getCurrent())
46
47         def eventSelected(self):
48                 event = self["list"].getCurrent()
49                 self.session.open(EventView, event, self.currentService, self.eventViewCallback)
50         
51         def timerAdd(self):
52                 epg = self["list"].getCurrent()
53                 
54                 if (epg == None):
55                         description = "unknown event"
56                 else:
57                         description = epg.getEventName()
58                         # FIXME we need a timestamp here:
59                         begin = epg.getBeginTime()
60                         
61                         print begin
62                         print epg.getDuration()
63                         end = begin + epg.getDuration()
64
65
66                 # FIXME only works if already playing a service
67                 serviceref = ServiceReference(self.session.nav.getCurrentlyPlayingServiceReference())
68                 
69                 newEntry = RecordTimerEntry(begin, end, serviceref, epg, description)
70                 self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)
71         
72         def timerEditFinished(self, answer):
73                 if (answer[0]):
74                         self.session.nav.RecordTimer.record(answer[1])
75                 else:
76                         print "Timeredit aborted"       
77
78         def setRoot(self, root):
79                 self.currentService=ServiceReference(root)
80                 self["list"].setRoot(root)
81
82         def moveUp(self):
83                 self["list"].moveUp()
84
85         def moveDown(self):
86                 self["list"].moveDown()