fix(??) repeated timer... i really don't know, if this will ever work
[enigma2.git] / lib / python / Screens / HarddiskSetup.py
1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.Harddisk import harddiskmanager                 #global harddiskmanager
4 from Components.MenuList import MenuList
5 from Components.Label import Label
6 from Screens.MessageBox import MessageBox
7 from enigma import eTimer
8
9 class HarddiskWait(Screen):
10         def doInit(self):
11                 self.timer.stop()
12                 self.hdd.initialize()
13                 self.close()
14
15         def __init__(self, session, hdd):
16                 Screen.__init__(self, session)
17                 self.hdd = hdd
18                 self["wait"] = Label("Initializing Harddisk...");
19                 self.timer = eTimer()
20                 self.timer.timeout.get().append(self.doInit)
21                 self.timer.start(100)
22
23 class HarddiskSetup(Screen):
24         def __init__(self, session, hdd):
25                 Screen.__init__(self, session)
26                 self.hdd = hdd
27                 
28                 self["model"] = Label("Model: " + hdd.model())
29                 self["capacity"] = Label("Capacity: " + hdd.capacity())
30                 self["bus"] = Label("Bus: " + hdd.bus())
31                 self["initialize"] = Label("Initialize")
32
33                 self["actions"] = ActionMap(["OkCancelActions"],
34                 {
35                         "ok": self.close,
36                         "cancel": self.close
37                 })
38                 
39                 self["shortcuts"] = ActionMap(["ShortcutActions"],
40                 {
41                         "red": self.hddInitialize
42                 })
43
44         def hddReady(self):
45                 self.close()
46
47         def hddInitialize(self):
48                 print "this will start the initialize now!"
49                 self.session.openWithCallback(self.hddReady, HarddiskWait, self.hdd)
50
51 class HarddiskSelection(Screen):
52         def __init__(self, session):
53                 Screen.__init__(self, session)
54                 
55                 if harddiskmanager.HDDCount() == 0:
56                         tlist = []
57                         tlist.append(("no HDD found", 0))
58                         self["hddlist"] = MenuList(tlist)
59                 else:                   
60                         self["hddlist"] = MenuList(harddiskmanager.HDDList())
61                 
62                 self["actions"] = ActionMap(["OkCancelActions"],
63                 {
64                         "ok": self.okbuttonClick ,
65                         "cancel": self.close
66                 })
67
68         def okbuttonClick(self):
69                 selection = self["hddlist"].getCurrent()
70                 if selection[1] != 0:
71                         self.session.open(HarddiskSetup, selection[1])