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)
39 if offline is not None:
41 if not offline.deleteFromDisk(1):
45 self.session.openWithCallback(self.deleteConfirmed, MessageBox, _("Do you really want to delete this recording?"))
47 self.session.openWithCallback(self.close, MessageBox, _("You cannot delete this!"), MessageBox.TYPE_ERROR)
49 def deleteConfirmed(self, confirmed):
53 serviceHandler = eServiceCenter.getInstance()
54 offline = serviceHandler.offlineOperations(self.service)
56 if offline is not None:
58 if not offline.deleteFromDisk(0):
62 self.session.openWithCallback(self.close, MessageBox, _("Delete failed!"), MessageBox.TYPE_ERROR)
64 list = self.csel["list"].removeService(self.service)
67 class MovieSelection(Screen):
68 def __init__(self, session, selectedmovie = None):
69 Screen.__init__(self, session)
72 self.bouquet_mark_edit = False
74 self.delayTimer = eTimer()
75 self.delayTimer.timeout.get().append(self.updateHDDData)
77 self["waitingtext"] = Label(_("Please wait... Loading list..."))
79 self["list"] = MovieList(None)
80 self.list = self["list"]
81 self.selectedmovie = selectedmovie
83 #self["okbutton"] = Button("ok", [self.channelSelected])
84 self["freeDiskSpace"] = DiskInfo(resolveFilename(SCOPE_HDD), DiskInfo.FREE, update=False)
86 self["actions"] = ActionMap(["OkCancelActions", "MovieSelectionActions"],
89 "ok": self.movieSelected,
90 "contextMenu": self.doContext,
92 self["actions"].csel = self
93 self.onShown.append(self.go)
95 self.lengthTimer = eTimer()
96 self.lengthTimer.timeout.get().append(self.updateLengthData)
99 # ouch. this should redraw our "Please wait..."-text.
100 # this is of course not the right way to do this.
101 self.delayTimer.start(10, 1)
103 def updateHDDData(self):
104 self["list"].reload(eServiceReference("2:0:1:0:0:0:0:0:0:0:" + resolveFilename(SCOPE_HDD)))
105 if (self.selectedmovie is not None):
107 self["waitingtext"].instance.hide()
109 self["freeDiskSpace"].update()
111 self.lengthTimer.start(10, 1)
112 self.lengthPosition = 0
113 self.lengthLength = len(self["list"])
115 def updateLengthData(self):
116 self.list.updateLengthOfIndex(self.lengthPosition)
117 self.lengthPosition += 1
118 if self.lengthPosition < self.lengthLength:
119 self.lengthTimer.start(10, 1)
122 self["list"].moveTo(self.selectedmovie)
124 def getCurrent(self):
125 return self["list"].getCurrent()
127 def movieSelected(self):
128 self.lengthTimer.stop()
129 current = self.getCurrent()
130 if current is not None:
134 current = self.getCurrent()
135 if current is not None:
136 self.session.open(ChannelContextMenu, self, current)