revert local change (just for testing)
[enigma2.git] / lib / python / Screens / NetworkSetup.py
1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.ConfigList import ConfigList, ConfigListScreen
4 from Components.config import config, getConfigListEntry
5 from Components.Network import iNetwork
6 from Components.Label import Label
7
8 class NetworkSetup(Screen, ConfigListScreen):
9         def __init__(self, session):
10                 Screen.__init__(self, session)
11         
12                 self["actions"] = ActionMap(["SetupActions"],
13                 {
14                         "ok": self.ok,
15                         "cancel": self.cancel,
16                 }, -2)
17
18                 self.list = []
19                 ConfigListScreen.__init__(self, self.list)
20                 self.createSetup()
21
22                 self["introduction"] = Label(_("Press OK to activate the settings."))
23
24         def createSetup(self):
25                 self.list = []
26
27                 self.dhcpEntry = getConfigListEntry(_("Use DHCP"), config.network.dhcp)
28                 self.list.append(self.dhcpEntry)
29                 self.list.append(getConfigListEntry(_('IP Address'), config.network.ip))
30                 if not config.network.dhcp.value:
31                         self.list.append(getConfigListEntry(_('Netmask'), config.network.netmask))
32                         self.list.append(getConfigListEntry(_('Gateway'), config.network.gateway))
33                         self.list.append(getConfigListEntry(_('Nameserver'), config.network.dns))
34
35                 self["config"].list = self.list
36                 self["config"].l.setList(self.list)
37
38         def newConfig(self):
39                 print self["config"].getCurrent()
40                 if self["config"].getCurrent() == self.dhcpEntry:
41                         self.createSetup()
42
43         def keyLeft(self):
44                 ConfigListScreen.keyLeft(self)
45                 self.createSetup()
46
47         def keyRight(self):
48                 ConfigListScreen.keyRight(self)
49                 self.createSetup()
50
51         def ok(self):
52                 #for x in self["config"].list:
53                         #x[1].save()
54                 
55                 iNetwork.deactivateNetworkConfig()
56                 iNetwork.writeNetworkConfig()    
57                 iNetwork.activateNetworkConfig()
58                 self.close()
59
60         def cancel(self):
61                 for x in self["config"].list:
62                         x[1].cancel()
63                 iNetwork.loadNetworkConfig()
64                 self.close()