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 "contextMenu": self.doContext,
94 self["actions"].csel = self
95 self.onShown.append(self.go)
97 self.lengthTimer = eTimer()
98 self.lengthTimer.timeout.get().append(self.updateLengthData)
101 # ouch. this should redraw our "Please wait..."-text.
102 # this is of course not the right way to do this.
103 self.delayTimer.start(10, 1)
105 def updateHDDData(self):
106 self["list"].reload(eServiceReference("2:0:1:0:0:0:0:0:0:0:" + resolveFilename(SCOPE_HDD)))
107 if (self.selectedmovie is not None):
109 self["waitingtext"].instance.hide()
111 self["freeDiskSpace"].update()
113 self.lengthTimer.start(10, 1)
114 self.lengthPosition = 0
115 self.lengthLength = len(self["list"])
117 def updateLengthData(self):
118 self.list.updateLengthOfIndex(self.lengthPosition)
119 self.lengthPosition += 1
120 if self.lengthPosition < self.lengthLength:
121 self.lengthTimer.start(10, 1)
124 self["list"].moveTo(self.selectedmovie)
126 def getCurrent(self):
127 return self["list"].getCurrent()
129 def movieSelected(self):
130 self.lengthTimer.stop()
131 current = self.getCurrent()
132 if current is not None:
136 current = self.getCurrent()
137 if current is not None:
138 self.session.open(ChannelContextMenu, self, current)