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