1 from Screen import Screen
2 from Components.Button import Button
3 from Components.ServiceList import ServiceList
4 from Components.ActionMap import ActionMap
5 from Components.MovieList import MovieList
6 from Components.DiskInfo import DiskInfo
7 from Components.Label import Label
8 from Components.PluginComponent import plugins
9 from Plugins.Plugin import PluginDescriptor
11 from Screens.MessageBox import MessageBox
12 from Screens.FixedMenu import FixedMenu
14 from Tools.Directories import *
15 from Tools.BoundFunction import boundFunction
17 from enigma import eServiceReference, eServiceCenter, eTimer
19 class ChannelContextMenu(FixedMenu):
20 def __init__(self, session, csel, service):
22 self.service = service
24 menu = [(_("back"), self.close), (_("delete..."), self.delete)]
26 for p in plugins.getPlugins(PluginDescriptor.WHERE_MOVIELIST):
27 menu.append((p.description, boundFunction(self.execPlugin, p)))
29 FixedMenu.__init__(self, session, _("Movie Menu"), menu)
30 self.skinName = "Menu"
32 def execPlugin(self, plugin):
33 plugin(session=self.session, service=self.service)
36 serviceHandler = eServiceCenter.getInstance()
37 offline = serviceHandler.offlineOperations(self.service)
38 info = serviceHandler.info(self.service)
39 name = info and info.getName(self.service) or _("this recording")
41 if offline is not None:
43 if not offline.deleteFromDisk(1):
47 self.session.openWithCallback(self.deleteConfirmed, MessageBox, _("Do you really want to delete %s?") % (name))
49 self.session.openWithCallback(self.close, MessageBox, _("You cannot delete this!"), MessageBox.TYPE_ERROR)
51 def deleteConfirmed(self, confirmed):
55 serviceHandler = eServiceCenter.getInstance()
56 offline = serviceHandler.offlineOperations(self.service)
58 if offline is not None:
60 if not offline.deleteFromDisk(0):
64 self.session.openWithCallback(self.close, MessageBox, _("Delete failed!"), MessageBox.TYPE_ERROR)
66 list = self.csel["list"].removeService(self.service)
69 class MovieSelection(Screen):
70 def __init__(self, session, selectedmovie = None):
71 Screen.__init__(self, session)
74 self.bouquet_mark_edit = False
76 self.delayTimer = eTimer()
77 self.delayTimer.timeout.get().append(self.updateHDDData)
79 self["waitingtext"] = Label(_("Please wait... Loading list..."))
81 self["list"] = MovieList(None)
82 self.list = self["list"]
83 self.selectedmovie = selectedmovie
85 #self["okbutton"] = Button("ok", [self.channelSelected])
86 self["freeDiskSpace"] = DiskInfo(resolveFilename(SCOPE_HDD), DiskInfo.FREE, update=False)
88 self["actions"] = ActionMap(["OkCancelActions", "MovieSelectionActions"],
91 "ok": self.movieSelected,
92 "showEventInfo": self.showEventInformation,
93 "contextMenu": self.doContext,
95 self["actions"].csel = self
96 self.onShown.append(self.go)
98 self.lengthTimer = eTimer()
99 self.lengthTimer.timeout.get().append(self.updateLengthData)
102 def showEventInformation(self):
103 from Screens.EventView import EventViewSimple
104 from ServiceReference import ServiceReference
105 evt = self["list"].getCurrentEvent()
107 self.session.open(EventViewSimple, evt, ServiceReference(self.getCurrent()))
111 # ouch. this should redraw our "Please wait..."-text.
112 # this is of course not the right way to do this.
113 self.delayTimer.start(10, 1)
116 def updateHDDData(self):
117 self["list"].reload(eServiceReference("2:0:1:0:0:0:0:0:0:0:" + resolveFilename(SCOPE_HDD)))
118 if (self.selectedmovie is not None):
120 self["waitingtext"].instance.hide()
122 self["freeDiskSpace"].update()
124 self.lengthTimer.start(10, 1)
125 self.lengthPosition = 0
126 self.lengthLength = len(self["list"])
128 def updateLengthData(self):
129 self.list.updateLengthOfIndex(self.lengthPosition)
130 self.lengthPosition += 1
131 if self.lengthPosition < self.lengthLength:
132 self.lengthTimer.start(10, 1)
135 self["list"].moveTo(self.selectedmovie)
137 def getCurrent(self):
138 return self["list"].getCurrent()
140 def movieSelected(self):
141 self.lengthTimer.stop()
142 current = self.getCurrent()
143 if current is not None:
147 current = self.getCurrent()
148 if current is not None:
149 self.session.open(ChannelContextMenu, self, current)