add simple summary
[enigma2.git] / lib / python / Screens / MovieSelection.py
index 6bb187213f1e4702aa1f07fe5c1520b57dd222b7..c70627bb253856be412126166a150c9aafd4d673 100644 (file)
@@ -4,13 +4,17 @@ from Components.ServiceList import ServiceList
 from Components.ActionMap import ActionMap
 from Components.MovieList import MovieList
 from Components.DiskInfo import DiskInfo
+from Components.Label import Label
+from Components.PluginComponent import plugins
+from Plugins.Plugin import PluginDescriptor
 
 from Screens.MessageBox import MessageBox
 from Screens.FixedMenu import FixedMenu
 
 from Tools.Directories import *
+from Tools.BoundFunction import boundFunction
 
-from enigma import eServiceReference, eServiceCenter
+from enigma import eServiceReference, eServiceCenter, eTimer
 
 class ChannelContextMenu(FixedMenu):
        def __init__(self, session, csel, service):
@@ -19,8 +23,14 @@ class ChannelContextMenu(FixedMenu):
                
                menu = [(_("back"), self.close), (_("delete..."), self.delete)]
                
+               for p in plugins.getPlugins(PluginDescriptor.WHERE_MOVIELIST):
+                       menu.append((p.description, boundFunction(self.execPlugin, p)))
+               
                FixedMenu.__init__(self, session, _("Movie Menu"), menu)
                self.skinName = "Menu"
+       
+       def execPlugin(self, plugin):
+               plugin(self.session, self.service)
 
        def delete(self):
                serviceHandler = eServiceCenter.getInstance()
@@ -51,13 +61,7 @@ class ChannelContextMenu(FixedMenu):
                if result == False:
                        self.session.openWithCallback(self.close, MessageBox, _("Delete failed!"), MessageBox.TYPE_ERROR)
                else:
-                       list = self.csel["list"]
-                       currentIndex = list.getCurrentIndex()
-                       list.moveDown()
-                       if list.getCurrentIndex() == currentIndex:
-                               currentIndex -= 1
-                       list.reload()
-                       list.moveToIndex(currentIndex)
+                       list = self.csel["list"].removeService(self.service)
                        self.close()
  
 class MovieSelection(Screen):
@@ -67,33 +71,55 @@ class MovieSelection(Screen):
                self.movemode = False
                self.bouquet_mark_edit = False
                
-               self["list"] = MovieList(eServiceReference("2:0:1:0:0:0:0:0:0:0:" + resolveFilename(SCOPE_HDD)))
-               if (selectedmovie is not None):
-                       self.onShown.append(self.moveTo)
-                       self.selectedmovie = selectedmovie
+               self.delayTimer = eTimer()
+               self.delayTimer.timeout.get().append(self.updateHDDData)
+               
+               self["waitingtext"] = Label(_("Please wait... Loading list..."))
+               
+               self["list"] = MovieList(None)
+               self.selectedmovie = selectedmovie
                
                #self["okbutton"] = Button("ok", [self.channelSelected])
-               self["freeDiskSpace"] = DiskInfo(resolveFilename(SCOPE_HDD), DiskInfo.FREE)
+               self["freeDiskSpace"] = DiskInfo(resolveFilename(SCOPE_HDD), DiskInfo.FREE, update=False)
                
-               self["actions"] = ActionMap(["OkCancelActions", "ContextMenuActions"],
+               self["actions"] = ActionMap(["OkCancelActions", "MovieSelectionActions"],
                        {
                                "cancel": self.abort,
                                "ok": self.movieSelected,
                                "contextMenu": self.doContext,
                        })
                self["actions"].csel = self
+               self.onShown.append(self.go)
+               
+       def go(self):
+               # ouch. this should redraw our "Please wait..."-text.
+               # this is of course not the right way to do this.
+               self.delayTimer.start(10, 1)
+
+       def updateHDDData(self):
+               self["list"].reload(eServiceReference("2:0:1:0:0:0:0:0:0:0:" + resolveFilename(SCOPE_HDD)))
+               if (self.selectedmovie is not None):
+                       self.moveTo()
+               self["waitingtext"].instance.hide()
+                                               
+               self["freeDiskSpace"].update()
 
        def moveTo(self):
                self["list"].moveTo(self.selectedmovie)
 
        def getCurrent(self):
-               return self["list"].getCurrent()[0]
+               l = self["list"].getCurrent()
+               return l and l[0]
 
        def movieSelected(self):
-               self.close(self.getCurrent())
+               current = self.getCurrent()
+               if current is not None:
+                       self.close(current)
 
        def doContext(self):
-               self.session.open(ChannelContextMenu, self, self.getCurrent())
+               current = self.getCurrent()
+               if current is not None:
+                       self.session.open(ChannelContextMenu, self, current)
 
        def abort(self):
                self.close(None)