cleanup some imports
[enigma2.git] / lib / python / Plugins / Extensions / FileManager / plugin.py
1 from Screens.Screen import Screen
2 from Components.ActionMap import NumberActionMap
3 from Components.Pixmap import Pixmap
4 from Components.FileList import FileList
5 from Plugins.Plugin import PluginDescriptor
6
7 class FileManager(Screen):
8         skin = """
9                 <screen position="100,100" size="550,400" title="Test" >
10                         <!--widget name="text" position="0,0" size="550,25" font="Regular;20" /-->
11                         <widget name="list" position="10,0" size="190,250" scrollbarMode="showOnDemand" />
12                         <widget name="pixmap" position="200,0" size="190,250" alphatest="on" />
13                 </screen>"""
14         def __init__(self, session, args = None):
15                 self.skin = FileManager.skin
16                 Screen.__init__(self, session)
17
18                 self["list"] = FileList("/", matchingPattern = "^.*\.(png|avi|mp3|mpeg|ts)", useServiceRef = True)
19                 self["pixmap"] = Pixmap()
20                 
21                 #self["text"] = Input("1234", maxSize=True, type=Input.NUMBER)
22                                 
23                 self["actions"] = NumberActionMap(["WizardActions", "InputActions"],
24                 {
25                         "ok": self.ok,
26                         "back": self.close,
27 #                       "left": self.keyLeft,
28 #                       "right": self.keyRight,
29                         "1": self.keyNumberGlobal,
30                         "2": self.keyNumberGlobal,
31                         "3": self.keyNumberGlobal,
32                         "4": self.keyNumberGlobal,
33                         "5": self.keyNumberGlobal,
34                         "6": self.keyNumberGlobal,
35                         "7": self.keyNumberGlobal,
36                         "8": self.keyNumberGlobal,
37                         "9": self.keyNumberGlobal,
38                         "0": self.keyNumberGlobal
39                 }, -1)
40                 
41         def keyLeft(self):
42                 self["text"].left()
43         
44         def keyRight(self):
45                 self["text"].right()
46         
47         def ok(self):
48         
49                 if self["list"].canDescent(): # isDir
50                         self["list"].descent()
51                 else:
52                         self["pixmap"].instance.setPixmapFromFile(self["list"].getFilename())
53         
54         def keyNumberGlobal(self, number):
55                 print "pressed", number
56                 self["text"].number(number)
57
58 def main(session, **kwargs):
59         session.open(FileManager)
60
61 def Plugins(**kwargs):
62         return [PluginDescriptor(name="File-Manager", description="Let's you view/edit files in your Dreambox", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
63                         PluginDescriptor(name="File-Manager", description="Let's you view/edit files in your Dreambox", where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main)]