summaryrefslogtreecommitdiffstats
path: root/iw/network_gui.py
blob: 7cea2a5430253eb51438a5cfcfa81c9b18bfd057 (plain)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
#
# network_gui.py: Network configuration dialog
#
# Michael Fulbright <msf@redhat.com>
#
# Copyright 2000-2002 Red Hat, Inc.
#
# This software may be freely redistributed under the terms of the GNU
# library public license.
#
# You should have received a copy of the GNU Library Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#

import string
import gtk
import gobject
from iw_gui import *
import isys
import gui
from rhpl.translate import _, N_
import network
import checklist
import ipwidget

global_options = [_("Gateway"), _("Primary DNS"),
		  _("Secondary DNS"), _("Tertiary DNS")]

global_option_labels = [_("_Gateway"), _("_Primary DNS"),
		  _("_Secondary DNS"), _("_Tertiary DNS")]

class NetworkWindow(InstallWindow):		

    windowTitle = N_("Network Configuration")
    htmlTag = "netconf"

    def __init__(self, ics):
	InstallWindow.__init__(self, ics)

    def getNext(self):

	if self.getNumberActiveDevices() == 0:
	    rc = self.handleNoActiveDevices()
	    if not rc:
		raise gui.StayOnScreen

	override = 0
	if self.hostnameManual.get_active():
	    hname = string.strip(self.hostnameEntry.get_text())
	    neterrors =  network.sanityCheckHostname(hname)
	    if neterrors is not None:
		self.handleBadHostname(hname, neterrors) 
		raise gui.StayOnScreen
            elif len(hname) == 0:
                hname = "localhost.localdomain" # ...better than empty
		if ((self.getNumberActiveDevices() > 0) and
                    self.handleMissingHostname()):
		    raise gui.StayOnScreen

	    newHostname = hname
            override = 1
	else:
	    newHostname = "localhost.localdomain"
	    override = 0

	# If we're not using DHCP, skip setting up the network config
	# boxes.  Otherwise, don't clear the values out if we are doing
	# kickstart since we could be in interactive mode.  Don't want to
	# write out a broken resolv.conf later on, after all.
	if not self.anyUsingDHCP():
	    tmpvals = {}
	    for t in range(len(global_options)):
		try:
		    tmpvals[t] = self.globals[global_options[t]].dehydrate()
		except ipwidget.IPMissing, msg:
                    if t < 2 and self.getNumberActiveDevices() > 0:
			if self.handleMissingOptionalIP(global_options[t]):
			    raise gui.StayOnScreen
			else:
			    tmpvals[t] = None
		    else:
			    tmpvals[t] = None
			
		except ipwidget.IPError, msg:
		    self.handleIPError(global_options[t], msg[0])
		    raise gui.StayOnScreen

	    self.network.gateway = tmpvals[0]
	    self.network.primaryNS = tmpvals[1]
	    self.network.secondaryNS = tmpvals[2]
	    self.network.ternaryNS = tmpvals[3]
	elif self.id.instClass.name != "kickstart":
	    self.network.gateway = None
	    self.network.primaryNS = None
	    self.network.secondaryNS = None
	    self.network.ternaryNS = None

        iter = self.ethdevices.store.get_iter_first()
	while iter:
	    model = self.ethdevices.store
	    dev = model.get_value(iter, 1)
	    bootproto = model.get_value(iter, 2)
	    onboot = model.get_value(iter, 0)

	    if onboot:
		onboot = "yes"
	    else:
		onboot = "no"
		
	    if bootproto == "DHCP":
		bootproto = 'dhcp'
	    else:
		bootproto = 'static'
		
	    self.devices[dev].set(("ONBOOT", onboot))
	    self.devices[dev].set(("bootproto", bootproto))
            iter = self.ethdevices.store.iter_next(iter)

	self.network.hostname = newHostname
	self.network.overrideDHCPhostname = override

        return None
        
    def DHCPtoggled(self, widget, (dev, table)):
	active = widget.get_active()
        table.set_sensitive(not active)
	
	bootproto = "dhcp"
	if not active:
            bootproto = "static"

    def onBootToggled(self, widget, dev):
	if widget.get_active():
	    onboot = "yes"
	else:
	    onboot = "no"
	dev.set(("ONBOOT", onboot))

    def setHostOptionsSensitivity(self):
        # figure out if they have overridden using dhcp for hostname
	if self.anyUsingDHCP():
	    self.hostnameUseDHCP.set_sensitive(1)

	    if self.hostname != "localhost.localdomain" and self.network.overrideDHCPhostname:
		self.hostnameManual.set_active(1)
		self.hostnameManual.set_sensitive(1)
	    else:
		self.hostnameUseDHCP.set_active(1)
	else:
	    self.hostnameManual.set_active(1)
	    self.hostnameUseDHCP.set_sensitive(0)

    def setIPTableSensitivity(self):
	numactive = self.getNumberActiveDevices()
	if numactive == 0:
	    state = False
	else:
	    state = not self.anyUsingDHCP()

	self.ipTable.set_sensitive(state)

    def handleMissingHostname(self):
	return not self.intf.messageWindow(_("Error With Data"),
				_("You have not specified a hostname.  Depending on your network environment this may cause problems later."), type="custom", custom_buttons=["gtk-cancel", _("C_ontinue")])

    def handleMissingOptionalIP(self, field):
	return not self.intf.messageWindow(_("Error With Data"),
				_("You have not specified the field \"%s\".  Depending on your network environment this may cause problems later.") % (field,), type="custom", custom_buttons=["gtk-cancel", _("C_ontinue")])

    def handleBadHostname(self, hostname, error):
	self.intf.messageWindow(_("Error With Data"),
				_("The hostname \"%s\" is not valid for the following reason:\n\n%s") % (hostname, error))

    def handleIPError(self, field, errmsg):
	newfield = string.replace(field, "_", "")
	self.intf.messageWindow(_("Error With Data"),
				_("An error occurred converting "
				  "the value entered for \"%s\":\n%s") % (newfield, errmsg))

    def handleIPMissing(self, field):
	newfield = string.replace(field, "_", "")
	self.intf.messageWindow(_("Error With Data"),
				_("A value is required for the field \"%s\".") % (newfield,))

    def handleBroadCastError(self):
	self.intf.messageWindow(_("Error With Data"),
				_("The IP information you have entered is "
				  "invalid."))

    def handleNoActiveDevices(self):
	return self.intf.messageWindow(_("Error With Data"), _("You have no active network devices.  Your system will not be able to communicate over a network by default without at least one device active.\n\nNOTE: If you have a PCMCIA-based network adapter you should leave it inactive at this point. When you reboot your system the adapter will be activated automatically."), type="custom", custom_buttons=["gtk-cancel", _("C_ontinue")])
    
    def setHostnameRadioState(self):
	pass

    def editDevice(self, data):
	if self.ignoreEvents:
	    return
	
	selection = self.ethdevices.get_selection()
        (model, iter) = selection.get_selected()
        if not iter:
            return None

        dev = model.get_value(iter, 1)
	bootproto = model.get_value(iter, 2)
	onboot = model.get_value(iter, 0)

	# create dialog box
        editWin = gtk.Dialog(_("Edit Interface %s") % (dev,),
			     flags=gtk.DIALOG_MODAL)
        gui.addFrame(editWin)
        editWin.set_modal(True)
#        editWin.set_size_request(350, 200)
        editWin.set_position (gtk.WIN_POS_CENTER)
	
	# create contents
	devbox = gtk.VBox()

	align = gtk.Alignment()
	DHCPcb = gtk.CheckButton(_("Configure using _DHCP"))

	align.add(DHCPcb)
	devbox.pack_start(align, False)

	align = gtk.Alignment()
	bootcb = gtk.CheckButton(_("_Activate on boot"))

	bootcb.connect("toggled", self.onBootToggled, self.devices[dev])
	bootcb.set_active(onboot)
	align.add(bootcb)

	devbox.pack_start(align, False, padding=6)
#	devbox.pack_start(gtk.HSeparator(), False, padding=3)

	options = [(_("_IP Address"), "ipaddr"),
		   (_("Net_mask"),    "netmask")]

        devopts = []

        if (network.isPtpDev(dev)):
	    newopt = (_("_Point to Point (IP)"), "remip")
	    options.append(newopt)

        if (isys.isWireless(dev)):
            newopt = [(_("_ESSID"), "essid"),
                      (_("Encryption _Key"), "key")]
            devopts.extend(newopt)
            
        ipTable = gtk.Table(len(options) + 1, 2)
	DHCPcb.connect("toggled", self.DHCPtoggled, (self.devices[dev], ipTable))
	# go ahead and set up DHCP on the first device
	DHCPcb.set_active(bootproto == 'DHCP')
	entrys = {}

        hwaddr = self.devices[dev].get("hwaddr")
        if hwaddr is not None and len(hwaddr) > 0:
            label = gui.MnemonicLabel(_("Hardware address:"), (0.0, 0.5))
            ipTable.attach(label, 0, 1, 0, 1, gtk.FILL, 0, 10, 5)
            hwlabel = gtk.Label("%s" %(hwaddr,))
            ipTable.attach(hwlabel, 1, 2, 0, 1)
        
	for t in range(len(options)):
	    label = gtk.Label("%s:" %(options[t][0],))
	    label.set_alignment(0.0, 0.5)
	    label.set_property("use-underline", True)
	    ipTable.attach(label, 0, 1, t+1, t+2, gtk.FILL, 0, 10)

	    entry = ipwidget.IPEditor()
	    entry.hydrate(self.devices[dev].get(options[t][1]))
	    entrys[t] = entry
	    label.set_mnemonic_widget(entry.getFocusableWidget())
	    ipTable.attach(entry.getWidget(), 1, 2, t+1, t+2, 0, gtk.FILL|gtk.EXPAND)

	devbox.pack_start(ipTable, False, False, 6)
        devbox.set_border_width(6)

        deventrys = {}
        if len(devopts) > 0:
            devTable = gtk.Table(len(devopts), 2)

            for t in range(len(devopts)):
                label = gtk.Label("%s:" %(devopts[t][0],))
                label.set_alignment(0.0, 0.5)
                label.set_property("use-underline", True)
                devTable.attach(label, 0, 1, t, t+1, gtk.FILL, 0, 10)

                entry = gtk.Entry()
                entry.set_text(self.devices[dev].get(devopts[t][1]))
                deventrys[t] = entry
                label.set_mnemonic_widget(entry)
                devTable.attach(entry, 1, 2, t, t+1, 0, gtk.FILL|gtk.EXPAND)


            devbox.pack_start(devTable, False, False, 6)

	framelab = _("Configure %s") % (dev,)
	descr = self.devices[dev].get("desc")
	if descr is not None and len(descr) > 0:
	    framelab += " - " + descr[:70]
        
        l = gtk.Label()
        l.set_markup("<b>%s</b>" %(framelab,))
	
	frame = gtk.Frame()
        frame.set_label_widget(l)
	frame.set_border_width(12)
	frame.add(devbox)
        frame.set_shadow_type(gtk.SHADOW_NONE)
	editWin.vbox.pack_start(frame, padding=6)
        editWin.set_position(gtk.WIN_POS_CENTER)
	editWin.show_all()
        editWin.add_button('gtk-cancel', 2)
	editWin.add_button('gtk-ok', 1)

	while 1:
	    rc = editWin.run()

	    if rc == 2:
                editWin.destroy()
                return

	    if DHCPcb.get_active():
		bootproto = 'dhcp'
	    else:
		bootproto = 'static'


	    if bootcb.get_active():
		onboot = 'yes'
	    else:
		onboot = 'no'

	    if bootproto != 'dhcp':
		valsgood = 1
		tmpvals = {}
		for t in range(len(options)):
		    try:
			tmpvals[t] = entrys[t].dehydrate()
		    except ipwidget.IPMissing, msg:
			self.handleIPMissing(options[t][0])
			valsgood = 0
			break
		    except ipwidget.IPError, msg:
			self.handleIPError(options[t][0], msg[0])
			valsgood = 0
			break

		if valsgood == 0:
		    continue

		try:
                    (net, bc) = isys.inet_calcNetBroad (tmpvals[0], tmpvals[1])
		except:
		    self.handleBroadCastError()
		    valsgood = 0

		if not valsgood:
		    continue

		for t in range(len(options)):
		    self.devices[dev].set((options[t][1], tmpvals[t]))

		self.devices[dev].set(('network', net), ('broadcast', bc))

	    self.devices[dev].set(('bootproto', bootproto))
	    self.devices[dev].set(('ONBOOT', onboot))
	    model.set_value(iter, 0, onboot == 'yes')
	    model.set_value(iter, 2, self.createIPRepr(self.devices[dev]))

            for t in range(len(devopts)):
                self.devices[dev].set((devopts[t][1], deventrys[t].get_text()))

	    editWin.destroy()

	    self.setIPTableSensitivity()
	    self.setHostOptionsSensitivity()

	    return

    def createIPRepr(self, device):
	bootproto = device.get("bootproto")
	if bootproto == "dhcp":
	    ip = "DHCP"
	else:
	    ip = "%s/%s" % (device.get("ipaddr"), device.get("netmask"))

	return ip

    def getNumberActiveDevices(self):
        iter = self.ethdevices.store.get_iter_first()
	numactive = 0
	while iter:
	    model = self.ethdevices.store
	    if model.get_value(iter, 0):
		numactive = numactive + 1
		break
            iter = self.ethdevices.store.iter_next(iter)

	return numactive

    def anyUsingDHCP(self):
	for device in self.devices.keys():
	    bootproto = self.devices[device].get("bootproto")

	    if bootproto and bootproto == 'dhcp':
		onboot = self.devices[device].get("ONBOOT")
		if onboot != "no":
		    return 1

	return 0
	
    def onbootToggleCB(self, row, data):
	model = self.ethdevices.get_model()
	iter = model.get_iter((string.atoi(data),))
	val = model.get_value(iter, 0)
	dev = model.get_value(iter, 1)
	if val:
	    onboot = "yes"
	else:
	    onboot = "no"
	    
	self.devices[dev].set(("ONBOOT", onboot))
	
	self.setIPTableSensitivity()
	self.setHostOptionsSensitivity()
	
	return
    
	
    def setupDevices(self):
	devnames = self.devices.keys()
	devnames.sort()

	store = gtk.TreeStore(gobject.TYPE_BOOLEAN,
			  gobject.TYPE_STRING,
			  gobject.TYPE_STRING)
	
	self.ethdevices = NetworkDeviceCheckList(2, store, clickCB=self.onbootToggleCB)
        num = 0
        for device in devnames:
	    onboot = self.devices[device].get("ONBOOT")
	    if ((num == 0 and not onboot) or onboot == "yes"):
		active = True
	    else:
		active = False

	    bootproto = self.devices[device].get("bootproto")
	    if not bootproto:
		bootproto = 'dhcp'
		self.devices[device].set(("bootproto", bootproto))
		
	    ip = self.createIPRepr(self.devices[device])

# only if we want descriptions in the master device list
# currently too wide, but might be able to do it with a tooltip on
# each row once I figure out how (can't be done: b.g.o #80980)
# would require adding extra text field to end of store above as well
#
#	    descr = self.devices[device].get("desc")
#	    if descr is None:
#		descr = ""
#		
#	    self.ethdevices.append_row((device, ip, descr), active)
#
# use this for now
            self.ethdevices.append_row((device, ip), active)

            num += 1

	self.ethdevices.set_column_title(0, (_("Active on Boot")))
        self.ethdevices.set_column_sizing (0, gtk.TREE_VIEW_COLUMN_GROW_ONLY)
	self.ethdevices.set_column_title(1, (_("Device")))
        self.ethdevices.set_column_sizing (1, gtk.TREE_VIEW_COLUMN_GROW_ONLY)
	self.ethdevices.set_column_title(2, (_("IP/Netmask")))
        self.ethdevices.set_column_sizing (2, gtk.TREE_VIEW_COLUMN_GROW_ONLY)
#	self.ethdevices.set_column_title(3, (_("Description")))
#        self.ethdevices.set_column_sizing (3, gtk.TREE_VIEW_COLUMN_GROW_ONLY)
        self.ethdevices.set_headers_visible(True)

	self.ignoreEvents = 1
	iter = self.ethdevices.store.get_iter_first()
	selection = self.ethdevices.get_selection()
	selection.set_mode(gtk.SELECTION_BROWSE)
	selection.select_iter(iter)
	self.ignoreEvents = 0

	return self.ethdevices

    def hostnameUseDHCPCB(self, widget, data):
	self.network.overrideDHCPhostname = 0
	self.hostnameEntry.set_sensitive(not widget.get_active())

    def hostnameManualCB(self, widget, data):
	self.network.overrideDHCPhostname = 1
	if widget.get_active():
	    self.hostnameEntry.grab_focus()

    # NetworkWindow tag="netconf"
    def getScreen(self, network, dir, intf, id):
	self.intf = intf
	self.id = id
        box = gtk.VBox(False)
        box.set_spacing(6)
	self.network = network
        
        self.devices = self.network.available()
	
        if not self.devices:
	    return None

	self.numdevices = len(self.devices.keys())

	self.hostname = self.network.hostname

	devhbox = gtk.HBox(False)
	devhbox.set_spacing(12)

	self.devlist = self.setupDevices()

	devlistSW = gtk.ScrolledWindow()
        devlistSW.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        devlistSW.set_shadow_type(gtk.SHADOW_IN)
        devlistSW.add(self.devlist)
	devlistSW.set_size_request(-1, 100)
	devhbox.pack_start(devlistSW, False)

        buttonbar = gtk.VButtonBox()
        buttonbar.set_layout(gtk.BUTTONBOX_START)
	edit = gtk.Button(_("_Edit"))
        edit.connect("clicked", self.editDevice)
	buttonbar.pack_start(edit, False)
	devhbox.pack_start(buttonbar, False)
        devhbox.set_border_width(6)

        l = gtk.Label()
        l.set_markup("<b>%s</b>" %(_("Network Devices"),))
	frame=gtk.Frame()
        frame.set_label_widget(l)
	frame.add(devhbox)
        frame.set_shadow_type(gtk.SHADOW_NONE)
	box.pack_start(frame, False)
	
	# show hostname and dns/misc network info and offer chance to modify
	hostbox=gtk.VBox()
	hostbox.set_spacing(6)

	label=gtk.Label(_("Set the hostname:"))
	label.set_alignment(0.0, 0.0)
	hostbox.pack_start(label, False, False)

	tmphbox=gtk.HBox()
        self.hostnameUseDHCP = gtk.RadioButton(label=_("_automatically via DHCP"))
	self.hostnameUseDHCP.connect("toggled", self.hostnameUseDHCPCB, None)
	tmphbox.pack_start (self.hostnameUseDHCP, False, False)
	hostbox.pack_start(tmphbox, False, False)

	tmphbox=gtk.HBox()
	tmphbox.set_spacing(6)
	self.hostnameManual = gtk.RadioButton(group=self.hostnameUseDHCP, label=_("_manually"))
	tmphbox.pack_start(self.hostnameManual, False, False)
	self.hostnameEntry = gtk.Entry()
	tmphbox.pack_start(self.hostnameEntry, False, False)
	tmphbox.pack_start(gtk.Label(_('(ex. "host.domain.com")')), False, False)
	self.hostnameManual.connect("toggled", self.hostnameManualCB, None)
	hostbox.pack_start(tmphbox, False, False)

	hostbox.set_border_width(6)
        l = gtk.Label()
        l.set_markup("<b>%s</b>" %(_("Hostname"),))
	frame=gtk.Frame()
        frame.set_label_widget(l)
	frame.add(hostbox)
        frame.set_shadow_type(gtk.SHADOW_NONE)
	box.pack_start(frame, False, False)


        self.setHostOptionsSensitivity()
        
        #
	# this is the iptable used for DNS, et. al
	self.ipTable = gtk.Table(len(global_options), 2)
#	self.ipTable.set_row_spacing(0, 5)
	options = {}
	for i in range(len(global_options)):
	    label = gtk.Label("%s:" %(global_option_labels[i],))
	    label.set_property("use-underline", True)
	    label.set_alignment(0.0, 0.0)
	    self.ipTable.attach(label, 0, 1, i, i+1, gtk.FILL, 0)
	    align = gtk.Alignment(0, 0.5)
	    options[i] = ipwidget.IPEditor()
	    align.add(options[i].getWidget())
	    label.set_mnemonic_widget(options[i].getFocusableWidget())

	    self.ipTable.attach(align, 1, 2, i, i+1, gtk.FILL, 0)


	self.globals = {}
	for t in range(len(global_options)):
	    self.globals[global_options[t]] = options[t]

	# bring over the value from the loader
	self.hostnameEntry.set_text(self.network.hostname)

	if not self.anyUsingDHCP():
	    if self.network.gateway:
		self.globals[_("Gateway")].hydrate(self.network.gateway)
	    if self.network.primaryNS:
		self.globals[_("Primary DNS")].hydrate(self.network.primaryNS)
	    if self.network.secondaryNS:
		self.globals[_("Secondary DNS")].hydrate(self.network.secondaryNS)
	    if self.network.ternaryNS:
		self.globals[_("Tertiary DNS")].hydrate(self.network.ternaryNS)

	self.ipTable.set_border_width(6)

        l = gtk.Label()
        l.set_markup("<b>%s</b>" %(_("Miscellaneous Settings"),))
	frame=gtk.Frame()
        frame.set_label_widget(l)
	frame.add(self.ipTable)
        frame.set_shadow_type(gtk.SHADOW_NONE)
	box.pack_start(frame, False, False)
	box.set_border_width(6)

	self.hostnameEntry.set_sensitive(not self.hostnameUseDHCP.get_active())
	self.setIPTableSensitivity()

        self.hostnameUseDHCP.set_sensitive(self.anyUsingDHCP())

	return box


class NetworkDeviceCheckList(checklist.CheckList):
    def toggled_item(self, data, row):
	checklist.CheckList.toggled_item(self, data, row)

	if self.clickCB:
	    rc = self.clickCB(data, row)
    
    def __init__(self, columns, store, clickCB=None):
	checklist.CheckList.__init__(self, columns=columns,
				     custom_store=store)

	self.clickCB = clickCB