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(self.session, 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.selectedmovie = selectedmovie
82 #self["okbutton"] = Button("ok", [self.channelSelected])
83 self["freeDiskSpace"] = DiskInfo(resolveFilename(SCOPE_HDD), DiskInfo.FREE, update=False)
85 self["actions"] = ActionMap(["OkCancelActions", "MovieSelectionActions"],
88 "ok": self.movieSelected,
89 "contextMenu": self.doContext,
91 self["actions"].csel = self
92 self.onShown.append(self.go)
95 # ouch. this should redraw our "Please wait..."-text.
96 # this is of course not the right way to do this.
97 self.delayTimer.start(10, 1)
99 def updateHDDData(self):
100 self["list"].reload(eServiceReference("2:0:1:0:0:0:0:0:0:0:" + resolveFilename(SCOPE_HDD)))
101 if (self.selectedmovie is not None):
103 self["waitingtext"].instance.hide()
105 self["freeDiskSpace"].update()
108 self["list"].moveTo(self.selectedmovie)
110 def getCurrent(self):
111 l = self["list"].getCurrent()
114 def movieSelected(self):
115 current = self.getCurrent()
116 if current is not None:
120 current = self.getCurrent()
121 if current is not None:
122 self.session.open(ChannelContextMenu, self, current)