From c65d90065549079111918934ce6ffa1c8ae04015 Mon Sep 17 00:00:00 2001 From: pnfisher Date: Wed, 4 Aug 1999 05:06:43 +0000 Subject: Remove XPM file dependancies and fixup the network config. --- iw/network.py | 75 +++++++++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 15 deletions(-) (limited to 'iw/network.py') diff --git a/iw/network.py b/iw/network.py index 75b9f858f..7ec9371f7 100644 --- a/iw/network.py +++ b/iw/network.py @@ -12,6 +12,11 @@ class NetworkWindow (InstallWindow): self.todo = ics.getToDo () self.calcNMHandler = None + + def getNext (self): + self.setupTODO () + return None + def focusInIP (self, *args): if self.nm.get_text() == "": self.calcNetmask () @@ -23,6 +28,25 @@ class NetworkWindow (InstallWindow): self.calcNMHandler = None + def setupTODO (self): + if self.DHCPcb.get_active (): + self.dev.set (("bootproto", "dhcp")) + self.dev.unset ("ipaddr", "netmask", "network", "broadcast") + else: + try: + network, broadcast = inet_calcNetBroad (self.ip.get_text (), self.nm.get_text ()) + self.dev.set (("bootproto", "static")) + self.dev.set (("ipaddr", self.ip.get_text ()), ("netmask", self.nm.get_text ()), + ("network", network), ("broadcast", broadcast)) + self.todo.network.gateway = self.gw.get_text () + self.todo.network.primaryNS = self.dns1.get_text () + self.todo.network.guessHostnames () + except: + pass + + self.dev.set (("onboot", "yes")) + + def calcNetmask (self, *args): ip = self.ip.get_text () dots = 0 @@ -35,6 +59,18 @@ class NetworkWindow (InstallWindow): if (new_nm != self.nm.get_text ()): self.nm.set_text (new_nm) + def devSelected (self, widget, key): + self.setupTODO () + self.dev = self.devs[key] + if self.dev.get ("bootproto") == "dhcp": + self.DHCPcb.set_active (TRUE) + self.ip.set_text ("") + self.nm.set_text ("") + else: + self.DHCPcb.set_active (FALSE) + self.ip.set_text (self.dev.get ("ipaddr")) + self.nm.set_text (self.dev.get ("netmask")) + def getScreen (self): box = GtkVBox () @@ -43,17 +79,22 @@ class NetworkWindow (InstallWindow): devLabel.set_alignment (0, 0) devLine.pack_start (devLabel) menu = GtkMenu () - for i in self.todo.network.available ().keys (): - menu.append (GtkMenuItem (i)) + self.devs = self.todo.network.available () + self.devs.keys ().sort () + self.dev = self.devs[self.devs.keys()[0]] + for i in self.devs.keys (): + menu_item = GtkMenuItem (i) + menu_item.connect ("activate", self.devSelected, i) + menu.append (menu_item) devMenu = GtkOptionMenu () devMenu.set_menu (menu) devLine.pack_start (devMenu) box.pack_start (devLine, FALSE) - isDHCP = GtkCheckButton ("Configure using DHCP") - isDHCP.set_active (TRUE) + self.DHCPcb = GtkCheckButton ("Configure using DHCP") + self.DHCPcb.set_active (TRUE) - box.pack_start (isDHCP, FALSE) + box.pack_start (self.DHCPcb, FALSE) box.pack_start (GtkHSeparator (), FALSE, padding=3) ipTable = GtkTable (2, 2) @@ -63,8 +104,9 @@ class NetworkWindow (InstallWindow): self.ip = GtkEntry (15) self.ip.connect ("focus_in_event", self.focusInIP) self.ip.connect ("focus_out_event", self.focusOutIP) - self.ip.connect ("activate", lambda widget, self=self: self.ipTable.focus (DIR_TAB_FORWARD)) + self.ip.connect ("activate", lambda widget, box=box: box.focus (DIR_TAB_FORWARD)) self.nm = GtkEntry (15) + self.nm.connect ("activate", lambda widget, box=box: box.focus (DIR_TAB_FORWARD)) ipTable.attach (self.ip, 1, 2, 0, 1) ipTable.attach (self.nm, 1, 2, 1, 2) box.pack_start (ipTable, FALSE) @@ -75,15 +117,18 @@ class NetworkWindow (InstallWindow): ipTable.attach (GtkLabel ("Gateway: "), 0, 1, 0, 1) ipTable.attach (GtkLabel ("Primary DNS: "), 0, 1, 2, 3) ipTable.attach (GtkLabel ("Secondary DNS: "), 0, 1, 3, 4) - ipTable.attach (GtkLabel ("Trinary DNS: "), 0, 1, 4, 5) - gw = GtkEntry (15) - dns1 = GtkEntry (15) - dns2 = GtkEntry (15) - dns3 = GtkEntry (15) - ipTable.attach (gw, 1, 2, 0, 1) - ipTable.attach (dns1, 1, 2, 2, 3) - ipTable.attach (dns2, 1, 2, 3, 4) - ipTable.attach (dns3, 1, 2, 4, 5) + ipTable.attach (GtkLabel ("Ternary DNS: "), 0, 1, 4, 5) + self.gw = GtkEntry (15) + self.gw.connect ("activate", lambda widget, box=box: box.focus (DIR_TAB_FORWARD)) + self.dns1 = GtkEntry (15) + self.dns1.connect ("activate", lambda widget, box=box: box.focus (DIR_TAB_FORWARD)) + self.dns2 = GtkEntry (15) + self.dns2.connect ("activate", lambda widget, box=box: box.focus (DIR_TAB_FORWARD)) + self.dns3 = GtkEntry (15) + ipTable.attach (self.gw, 1, 2, 0, 1) + ipTable.attach (self.dns1, 1, 2, 2, 3) + ipTable.attach (self.dns2, 1, 2, 3, 4) + ipTable.attach (self.dns3, 1, 2, 4, 5) box.pack_start (ipTable, FALSE) -- cgit