X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/bb59fd202b257cce05684912216678d9872ff0cc..d5dbdb94223dad7deac17ff66759980911cae6b2:/lib/python/Screens/NetworkSetup.py diff --git a/lib/python/Screens/NetworkSetup.py b/lib/python/Screens/NetworkSetup.py index 5637d88d..278c6606 100644 --- a/lib/python/Screens/NetworkSetup.py +++ b/lib/python/Screens/NetworkSetup.py @@ -1,80 +1,64 @@ from Screen import Screen -from Components.ActionMap import NumberActionMap -from Components.ConfigList import ConfigList -from Components.config import config -from Components.config import getConfigListEntry +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): - def __init__(self, session): - Screen.__init__(self, session) +class NetworkSetup(Screen, ConfigListScreen): + def __init__(self, session): + Screen.__init__(self, session) - self["actions"] = NumberActionMap(["SetupActions"], - { - "ok": self.keySave, - "cancel": self.keyCancel, - "left": self.keyLeft, - "right": self.keyRight, - "1": self.keyNumberGlobal, - "2": self.keyNumberGlobal, - "3": self.keyNumberGlobal, - "4": self.keyNumberGlobal, - "5": self.keyNumberGlobal, - "6": self.keyNumberGlobal, - "7": self.keyNumberGlobal, - "8": self.keyNumberGlobal, - "9": self.keyNumberGlobal, - "0": self.keyNumberGlobal - }, -1) + self["actions"] = ActionMap(["SetupActions"], + { + "ok": self.ok, + "cancel": self.cancel, + }, -2) - self.list = [] - self["config"] = ConfigList(self.list) - self.createSetup() - - self["introduction"] = Label("Press OK to activate the settings.") - - def createSetup(self): - self.list = [] - - self.list.append(getConfigListEntry("Use DHCP", config.network.dhcp)) - if (config.network.dhcp.value == 0): - self.list.append(getConfigListEntry(_('IP Address'), config.network.ip)) - 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()[0] == "Use DHCP": - self.createSetup() + self.list = [] + ConfigListScreen.__init__(self, self.list) + self.createSetup() - def keyLeft(self): - self["config"].handleKey(config.key["prevElement"]) - self.newConfig() + self["introduction"] = Label(_("Press OK to activate the settings.")) - def keyRight(self): - self["config"].handleKey(config.key["nextElement"]) - self.newConfig() - - def keyNumberGlobal(self, number): - print "You pressed number " + str(number) - if (self["config"].getCurrent()[1].parent.enabled == True): - self["config"].handleKey(config.key[str(number)]) - - def keySave(self): - #for x in self["config"].list: - #x[1].save() - - iNetwork.writeNetworkConfig() - iNetwork.activateNetworkConfig() - self.close() + 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 keyCancel(self): - for x in self["config"].list: - x[1].cancel() - iNetwork.loadNetworkConfig() - self.close() \ No newline at end of file + def cancel(self): + for x in self["config"].list: + x[1].cancel() + iNetwork.loadNetworkConfig() + self.close()