aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Screens/EventView.py
blob: d96be6d604c61255bb0b6a6c1cdc393617daea14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from Screen import Screen
from Components.ActionMap import ActionMap
from Components.Label import Label
from Components.ScrollLabel import ScrollLabel
from enigma import eServiceEventPtr
from ServiceReference import ServiceReference
from RecordTimer import RecordTimerEntry, parseEvent
from TimerEntry import TimerEntry

class EventView(Screen):
	def __init__(self, session, Event, Ref, callback=None):
		Screen.__init__(self, session)
		self.cbFunc = callback
		self.currentService=Ref
		self.event = Event
		self["epg_description"] = ScrollLabel()
		self["datetime"] = Label()
		self["channel"] = Label()
		self["duration"] = Label()
		self["actions"] = ActionMap(["OkCancelActions", "EventViewActions"],
			{
				"cancel": self.close,
				"ok": self.close,
				"pageUp": self.pageUp,
				"pageDown": self.pageDown,
				"prevEvent": self.prevEvent,
				"nextEvent": self.nextEvent,
				"timerAdd": self.timerAdd
			})
		self.onShown.append(self.onCreate)

	def onCreate(self):
		self.setEvent(self.event)
		self.setService(self.currentService)

	def prevEvent(self):
		if self.cbFunc is not None:
			self.cbFunc(self.setEvent, self.setService, -1)

	def nextEvent(self):
		if self.cbFunc is not None:
			self.cbFunc(self.setEvent, self.setService, +1)

	def timerAdd(self):
		newEntry = RecordTimerEntry(self.currentService, *parseEvent(self.event))
		self.session.openWithCallback(self.timerEditFinished, TimerEntry, newEntry)

	def timerEditFinished(self, answer):
		if (answer[0]):
			self.session.nav.RecordTimer.record(answer[1])
		else:
			print "Timeredit aborted"	

	def setService(self, service):
		self.currentService=service
		name = self.currentService.getServiceName()
		if name is not None:
			self["channel"].setText(name)
		else:
			self["channel"].setText(_("unknown service"))

	def setEvent(self, event):
		self.event = event
		text = event.getEventName()
		short = event.getShortDescription()
		ext = event.getExtendedDescription()
		if len(short) > 0 and short != text:
			text = text + '\n\n' + short
		if len(ext) > 0:
			if len(text) > 0:
				text = text + '\n\n'
			text = text + ext
		self.session.currentDialog.instance.setTitle(event.getEventName())
		self["epg_description"].setText(text)
		self["datetime"].setText(event.getBeginTimeString())
		self["duration"].setText(_("%d min")%(event.getDuration()/60))

	def pageUp(self):
		self["epg_description"].pageUp()
	
	def pageDown(self):
		self["epg_description"].pageDown()