ask to resume on playback
[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 Components.Pixmap import Pixmap
7 from Screens.MessageBox import MessageBox
8 from enigma import eTimer
9
10 class HarddiskWait(Screen):
11         def doInit(self):
12                 self.timer.stop()
13                 result = self.hdd.initialize()
14                 self.close(result)
15
16         def __init__(self, session, hdd):
17                 Screen.__init__(self, session)
18                 self.hdd = hdd
19                 self["wait"] = Label(_("Initializing Harddisk..."));
20                 self.timer = eTimer()
21                 self.timer.timeout.get().append(self.doInit)
22                 self.timer.start(100)
23
24 class HarddiskSetup(Screen):
25         def __init__(self, session, hdd):
26                 Screen.__init__(self, session)
27                 self.hdd = hdd
28                 
29                 self["model"] = Label(_("Model: ") + hdd.model())
30                 self["capacity"] = Label(_("Capacity: ") + hdd.capacity())
31                 self["bus"] = Label(_("Bus: ") + hdd.bus())
32                 self["initialize"] = Pixmap()
33                 self["initializetext"] = Label(_("Initialize"))
34
35                 self["actions"] = ActionMap(["OkCancelActions"],
36                 {
37                         "ok": self.close,
38                         "cancel": self.close
39                 })
40                 
41                 self["shortcuts"] = ActionMap(["ShortcutActions"],
42                 {
43                         "red": self.hddInitialize
44                 })
45
46         def hddReady(self, result):
47                 print "Result: " + str(result)
48                 if (result != 0):
49                         self.session.open(MessageBox, _("Unable to initialize harddisk.\nPlease refer to the user manual.\nError: ") + str(self.hdd.errorList[0 - result]), MessageBox.TYPE_ERROR)
50                 else:
51                         self.close()
52
53         def hddInitialize(self):
54                 self.session.openWithCallback(self.hddInitConfirmed, MessageBox, _("Do you really want to initialize the harddisk?\nAll data on the disk will be lost!"))
55
56         def hddInitConfirmed(self, confirmed):
57                 if not confirmed:
58                         return
59
60                 print "this will start the initialize now!"
61                 self.session.openWithCallback(self.hddReady, HarddiskWait, self.hdd)
62                         
63 class HarddiskSelection(Screen):
64         def __init__(self, session):
65                 Screen.__init__(self, session)
66                 
67                 if harddiskmanager.HDDCount() == 0:
68                         tlist = []
69                         tlist.append((_("no HDD found"), 0))
70                         self["hddlist"] = MenuList(tlist)
71                 else:                   
72                         self["hddlist"] = MenuList(harddiskmanager.HDDList())
73                 
74                 self["actions"] = ActionMap(["OkCancelActions"],
75                 {
76                         "ok": self.okbuttonClick ,
77                         "cancel": self.close
78                 })
79
80         def okbuttonClick(self):
81                 selection = self["hddlist"].getCurrent()
82                 if selection[1] != 0:
83                         self.session.open(HarddiskSetup, selection[1])