add language selection to the start-wizard
[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                 result = self.hdd.initialize()
13                 self.close(result)
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, result):
45                 print "Result: " + str(result)
46                 if (result != 0):
47                         self.session.open(MessageBox, _("Unable to initialize harddisk.\nPlease refer to the user-manual.\nError: ") + str(self.hdd.errorList[0 - result]))
48                 else:
49                         self.close()
50                         
51         def hddInitialize(self):
52                 print "this will start the initialize now!"
53                 self.session.openWithCallback(self.hddReady, HarddiskWait, self.hdd)
54
55 class HarddiskSelection(Screen):
56         def __init__(self, session):
57                 Screen.__init__(self, session)
58                 
59                 if harddiskmanager.HDDCount() == 0:
60                         tlist = []
61                         tlist.append((_("no HDD found"), 0))
62                         self["hddlist"] = MenuList(tlist)
63                 else:                   
64                         self["hddlist"] = MenuList(harddiskmanager.HDDList())
65                 
66                 self["actions"] = ActionMap(["OkCancelActions"],
67                 {
68                         "ok": self.okbuttonClick ,
69                         "cancel": self.close
70                 })
71
72         def okbuttonClick(self):
73                 selection = self["hddlist"].getCurrent()
74                 if selection[1] != 0:
75                         self.session.open(HarddiskSetup, selection[1])