activate language when used in standalone screen
[enigma2.git] / lib / python / Screens / MovieSelection.py
index f5f2652..ce3a973 100644 (file)
@@ -3,9 +3,56 @@ from Components.Button import Button
 from Components.ServiceList import ServiceList
 from Components.ActionMap import ActionMap
 from Components.MovieList import MovieList
+from Components.DiskInfo import DiskInfo
 
-from enigma import eServiceReference
+from Screens.MessageBox import MessageBox
+from Screens.FixedMenu import FixedMenu
 
+from enigma import eServiceReference, eServiceCenter
+
+class ChannelContextMenu(FixedMenu):
+       def __init__(self, session, csel, service):
+               self.csel = csel
+               self.service = service
+               
+               menu = [("back", self.close), ("delete...", self.delete)]
+               
+               FixedMenu.__init__(self, session, "Movie Menu", menu)
+               self.skinName = "Menu"
+
+       def delete(self):
+               serviceHandler = eServiceCenter.getInstance()
+               offline = serviceHandler.offlineOperations(self.service)
+               result = False
+               if offline is not None:
+                       # simulate first
+                       if not offline.deleteFromDisk(1):
+                               result = True
+               
+               if result == True:
+                       self.session.openWithCallback(self.deleteConfirmed, MessageBox, "Do you really want to delete this recording?")
+               else:
+                       self.session.openWithCallback(self.close, MessageBox, "You cannot delete this!")
+
+       def deleteConfirmed(self, confirmed):
+               if not confirmed:
+                       return self.close()
+                       
+               serviceHandler = eServiceCenter.getInstance()
+               offline = serviceHandler.offlineOperations(self.service)
+               result = False
+               if offline is not None:
+                       # really delete!
+                       if not offline.deleteFromDisk(0):
+                               result = True
+               
+               if result == False:
+                       self.session.openWithCallback(self.close, MessageBox, "Delete failed!")
+               else:
+                       self.csel["list"].reload()
+                       self.close()
+               
 class MovieSelection(Screen):
        def __init__(self, session):
                Screen.__init__(self, session)
@@ -13,17 +60,27 @@ 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:/"))
+               self["list"] = MovieList(eServiceReference("2:0:1:0:0:0:0:0:0:0:/hdd/movies/"))
                
                #self["okbutton"] = Button("ok", [self.channelSelected])
+               self["freeDiskSpace"] = DiskInfo("/hdd/movies", DiskInfo.FREE)
                
-               self["actions"] = ActionMap(["OkCancelActions"], 
+               self["actions"] = ActionMap(["OkCancelActions", "ContextMenuActions"],
                        {
-                               "cancel": self.close,
+                               "cancel": self.abort,
                                "ok": self.movieSelected,
+                               "contextMenu": self.doContext,
                        })
                self["actions"].csel = self
 
+       def getCurrent(self):
+               return self["list"].getCurrent()[0]
+
        def movieSelected(self):
-#              self.session.nav.playService(self["list"].getCurrent())
-               self.close()
+               self.close(self.getCurrent())
+
+       def doContext(self):
+               self.session.open(ChannelContextMenu, self, self.getCurrent())
+
+       def abort(self):
+               self.close(None)