Logo Search packages:      
Sourcecode: wicd version File versions

def wicd::gui::appGui::settings_dialog (   self,
  widget,
  event = None 
)

Displays a general settings dialog. 

Definition at line 1332 of file gui.py.

01332                                                  :
        """ Displays a general settings dialog. """
        dialog = self.wTree.get_widget("pref_dialog")
        dialog.set_title(language['preferences'])
        size = config.ReadWindowSize("pref")
        width = size[0]
        height = size[1]
        if width > -1 and height > -1:
            dialog.resize(int(width), int(height))
        wiredcheckbox = self.wTree.get_widget("pref_always_check")
        wiredcheckbox.set_label(language['wired_always_on'])
        wiredcheckbox.set_active(wired.GetAlwaysShowWiredInterface())
        
        reconnectcheckbox = self.wTree.get_widget("pref_auto_check")
        reconnectcheckbox.set_label(language['auto_reconnect'])
        reconnectcheckbox.set_active(daemon.GetAutoReconnect())

        debugmodecheckbox = self.wTree.get_widget("pref_debug_check")
        debugmodecheckbox.set_label(language['use_debug_mode'])
        debugmodecheckbox.set_active(daemon.GetDebugMode())

        displaytypecheckbox = self.wTree.get_widget("pref_dbm_check")
        displaytypecheckbox.set_label(language['display_type_dialog'])
        displaytypecheckbox.set_active(daemon.GetSignalDisplayType())

        entryWiredAutoMethod = self.wTree.get_widget("pref_wired_auto_label")
        entryWiredAutoMethod.set_label('Wired Autoconnect Setting:')
        usedefaultradiobutton = self.wTree.get_widget("pref_use_def_radio")
        usedefaultradiobutton.set_label(language['use_default_profile'])
        showlistradiobutton = self.wTree.get_widget("pref_prompt_radio")
        showlistradiobutton.set_label(language['show_wired_list'])
        lastusedradiobutton = self.wTree.get_widget("pref_use_last_radio")
        lastusedradiobutton.set_label(language['use_last_used_profile'])

        ## External Programs tab
        self.wTree.get_widget("gen_settings_label").set_label(language["gen_settings"])
        self.wTree.get_widget("ext_prog_label").set_label(language["ext_programs"])
        self.wTree.get_widget("dhcp_client_label").set_label(language["dhcp_client"])
        self.wTree.get_widget("wired_detect_label").set_label(language["wired_detect"])
        self.wTree.get_widget("route_flush_label").set_label(language["route_flush"])
        
        # DHCP Clients
        dhcpautoradio = self.wTree.get_widget("dhcp_auto_radio")
        dhcpautoradio.set_label(language["wicd_auto_config"])
        dhclientradio = self.wTree.get_widget("dhclient_radio")
        pumpradio = self.wTree.get_widget("pump_radio")
        dhcpcdradio = self.wTree.get_widget("dhcpcd_radio")
        dhcp_list = [dhcpautoradio, dhclientradio, dhcpcdradio, pumpradio]
        
        dhcp_method = daemon.GetDHCPClient()
        dhcp_list[dhcp_method].set_active(True)
        
        # Wired Link Detection Apps
        linkautoradio = self.wTree.get_widget("link_auto_radio")
        linkautoradio.set_label(language['wicd_auto_config'])
        linkautoradio = self.wTree.get_widget("link_auto_radio")
        ethtoolradio = self.wTree.get_widget("ethtool_radio")
        miitoolradio = self.wTree.get_widget("miitool_radio")
        wired_link_list = [linkautoradio, ethtoolradio, miitoolradio]
        wired_link_method = daemon.GetLinkDetectionTool()
        wired_link_list[wired_link_method].set_active(True)
        
        # Route Flushing Apps
        flushautoradio = self.wTree.get_widget("flush_auto_radio")
        flushautoradio.set_label(language['wicd_auto_config'])
        ipflushradio = self.wTree.get_widget("ip_flush_radio")
        routeflushradio = self.wTree.get_widget("route_flush_radio")
        flush_list = [flushautoradio, ipflushradio, routeflushradio]
        flush_method = daemon.GetFlushTool()
        flush_list[flush_method].set_active(True)
        
        if wired.GetWiredAutoConnectMethod() == 1:
            usedefaultradiobutton.set_active(True)
        elif wired.GetWiredAutoConnectMethod() == 2:
            showlistradiobutton.set_active(True)
        elif wired.GetWiredAutoConnectMethod() == 3:
            lastusedradiobutton.set_active(True)

        self.set_label("pref_driver_label", language['wpa_supplicant_driver'] +
                       ':')

        # Hack to get the combo box we need, which you can't do with glade.
        wpa_hbox = self.wTree.get_widget("hbox_wpa")
        if not self.first_dialog_load:
            wpa_hbox.remove(self.wpadrivercombo)
        else:
            self.first_dialog_load = False
        self.wpadrivercombo = gtk.combo_box_new_text()
        wpadrivercombo = self.wpadrivercombo  # Just to make my life easier
        wpa_hbox.pack_end(wpadrivercombo)
            
        wpadrivers = ["wext", "hostap", "madwifi", "atmel", "ndiswrapper", 
                      "ipw", "ralink legacy"]
        found = False
        def_driver = daemon.GetWPADriver()
        for i, x in enumerate(wpadrivers):
            if x == def_driver: #and not found:
                found = True
                user_driver_index = i
            wpadrivercombo.append_text(x)

        # Set the active choice here.  Doing it before all the items are
        # added the combobox causes the choice to be reset.
        if found:
            wpadrivercombo.set_active(user_driver_index)
        else:
            # Use wext as default, since normally it is the correct driver.
            wpadrivercombo.set_active(0)

        self.set_label("pref_wifi_label", language['wireless_interface'] + ':')
        self.set_label("pref_wired_label", language['wired_interface'] + ':')

        entryWirelessInterface = self.wTree.get_widget("pref_wifi_entry")
        entryWirelessInterface.set_text(daemon.GetWirelessInterface())

        entryWiredInterface = self.wTree.get_widget("pref_wired_entry")
        entryWiredInterface.set_text(daemon.GetWiredInterface())

        # Set up global DNS stuff
        useGlobalDNSCheckbox = self.wTree.get_widget("pref_global_check")
        useGlobalDNSCheckbox.set_label(language['use_global_dns'])
        
        dns1Entry = self.wTree.get_widget("pref_dns1_entry")
        dns2Entry = self.wTree.get_widget("pref_dns2_entry")
        dns3Entry = self.wTree.get_widget("pref_dns3_entry")
        self.set_label("pref_dns1_label", language['dns'] + ' ' + language['1'])
        self.set_label("pref_dns2_label", language['dns'] + ' ' + language['2'])
        self.set_label("pref_dns3_label", language['dns'] + ' ' + language['3'])

        useGlobalDNSCheckbox.connect("toggled", checkboxTextboxToggle,
                                     (dns1Entry, dns2Entry, dns3Entry))

        dns_addresses = daemon.GetGlobalDNSAddresses()
        useGlobalDNSCheckbox.set_active(daemon.GetUseGlobalDNS())
        dns1Entry.set_text(noneToBlankString(dns_addresses[0]))
        dns2Entry.set_text(noneToBlankString(dns_addresses[1]))
        dns3Entry.set_text(noneToBlankString(dns_addresses[2]))

        if not daemon.GetUseGlobalDNS():
            dns1Entry.set_sensitive(False)
            dns2Entry.set_sensitive(False)
            dns3Entry.set_sensitive(False)

        # Bold/Align the Wired Autoconnect label.
        entryWiredAutoMethod.set_alignment(0, 0)
        atrlist = pango.AttrList()
        atrlist.insert(pango.AttrWeight(pango.WEIGHT_BOLD, 0, 50))
        entryWiredAutoMethod.set_attributes(atrlist)
        
        self.wTree.get_widget("notebook2").set_current_page(0)
        dialog.show_all()

        invalid = True
        response = -1
        while invalid:
            response = dialog.run()
            invalid = False
            if response == 1:
                # would do this, but we should make sure
                # that all IPs are valid
                # if useGlobalDNSCheckbox.get_active():
                if not misc.IsValidIP(dns1Entry.get_text()):
                    invalid = True
                if not misc.IsValidIP(dns2Entry.get_text()):
                    invalid = True
                if dns3Entry.get_text() != "" and \
                         not misc.IsValidIP(dns3Entry.get_text()):
                    invalid = True
                
                # if they are all blank, and the global DNS box is disabled
                # then we can let it pass
                if useGlobalDNSCheckbox.get_active() == False and \
                        dns1Entry.get_text() == "" and \
                        dns2Entry.get_text() == "" and \
                        dns3Entry.get_text() == "":
                    invalid = False
                if invalid: error(dialog, "One or more of your global DNS servers are invalid.")
                
        if response == 1:
            daemon.SetUseGlobalDNS(useGlobalDNSCheckbox.get_active())
            daemon.SetGlobalDNS(dns1Entry.get_text(), dns2Entry.get_text(),
                                dns3Entry.get_text())
            daemon.SetWirelessInterface(entryWirelessInterface.get_text())
            daemon.SetWiredInterface(entryWiredInterface.get_text())
            daemon.SetWPADriver(wpadrivers[wpadrivercombo.get_active()])
            wired.SetAlwaysShowWiredInterface(wiredcheckbox.get_active())
            daemon.SetAutoReconnect(reconnectcheckbox.get_active())
            daemon.SetDebugMode(debugmodecheckbox.get_active())
            daemon.SetSignalDisplayType(displaytypecheckbox.get_active())
            if showlistradiobutton.get_active():
                wired.SetWiredAutoConnectMethod(2)
            elif lastusedradiobutton.get_active():
                wired.SetWiredAutoConnectMethod(3)
            else:
                wired.SetWiredAutoConnectMethod(1)
                
            # External Programs Tab
            if dhcpautoradio.get_active():
                dhcp_client = misc.AUTO
            elif dhclientradio.get_active():
                dhcp_client = misc.DHCLIENT
            elif dhcpcdradio.get_active():
                dhcp_client = misc.DHCPCD
            else:
                dhcp_client = misc.PUMP
            daemon.SetDHCPClient(dhcp_client)
            
            if linkautoradio.get_active():
                link_tool = misc.AUTO
            elif ethtoolradio.get_active():
                link_tool = misc.ETHTOOL
            else:
                link_tool = misc.MIITOOL
            daemon.SetLinkDetectionTool(link_tool)
            
            if flushautoradio.get_active():
                flush_tool = misc.AUTO
            elif ipflushradio.get_active():
                flush_tool = misc.IP
            else:
                flush_tool = misc.ROUTE
            daemon.SetFlushTool(flush_tool)
    
        dialog.hide()
        [width, height] = dialog.get_size()
        config.WriteWindowSize(width, height, "pref")

    def set_label(self, glade_str, label):


Generated by  Doxygen 1.6.0   Back to index