From 41a4598d354c2140b57856a2298e39a6237d5634 Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Sun, 25 Jan 2009 12:02:10 +0800 Subject: [PATCH 1/5] Removed vertical space between the DNS entriesw --- data/wicd.glade | 1109 ++++++++++++++++++++++++----------------------- 1 file changed, 555 insertions(+), 554 deletions(-) diff --git a/data/wicd.glade b/data/wicd.glade index e5a9d7f..a199fa1 100644 --- a/data/wicd.glade +++ b/data/wicd.glade @@ -1,6 +1,6 @@ - + 450 @@ -429,112 +429,271 @@ 4 4 - + True 24 - + True - 0 - DNS domain: + True + If enabled, the wired network interface will always be displayed in the main window. This can be useful if your wired network card does not detect when the interface is connected to a cable. + Always show wired interface + 0 + True - 6 - 7 + 2 + 3 + 4 - + True True 1 2 - 6 - 7 - - - - - True - 12 - - - True - True - Automatically reconnect on network connection loss - 0 - True - - - - - 2 - 16 - 17 + 7 + 8 - + + True + True + + + 1 + 2 + 8 + 9 + + + + + + True + True + + + 1 + 2 + 9 + 10 + + + + + True 0 - <b>Automatic Reconnection</b> + <b>Global DNS Servers</b> True 2 - 15 - 16 + 4 + 5 - + True 12 - + True True - Use last wired network profile + Use global DNS servers 0 - True True 2 - 14 - 15 + 5 + 6 - + True - 12 + 24 - + True - True - Prompt for wired network profile - 0 - True - True - pref_use_last_radio + 0 + Search domain: + 7 + 8 + + + + + + True + 24 + + + True + 0 + DNS server 1: + + + + + 8 + 9 + + + + + + True + 24 + + + True + 0 + DNS server 2: + + + + + 9 + 10 + + + + + + True + True + + + 1 2 - 13 - 14 + 10 + 11 + + + + + + True + 24 + + + True + 0 + DNS server 3: + + + + + 10 + 11 + + + + + + True + 0 + <b>Network Interfaces</b> + True + + + 2 + + + + + + True + True + + + 1 + 2 + 1 + 2 + + + + + + True + True + + + 1 + 2 + 2 + 3 + + + + + + True + 12 + + + True + 0 + Wireless interface: + + + + + 1 + 2 + + + + + + True + 12 + + + True + 0 + Wired interface: + + + + + 2 + 3 + + + + + + True + 0 + <b>Wired automatic connection</b> + True + + + 2 + 11 + 12 @@ -562,187 +721,73 @@ - - True - 0 - <b>Wired automatic connection</b> - True - - - 2 - 11 - 12 - - - - - + True 12 - - True - 0 - Wired interface: - - - - - 2 - 3 - - - - - - True - 12 - - - True - 0 - Wireless interface: - - - - - 1 - 2 - - - - - - True - True - - - 1 - 2 - 2 - 3 - - - - - - True - True - - - 1 - 2 - 1 - 2 - - - - - - True - 0 - <b>Network Interfaces</b> - True - - - 2 - - - - - - True - 24 - - - True - 0 - DNS server 3: - - - - - 10 - 11 - - - - - - True - True - - - 1 - 2 - 10 - 11 - - - - - - True - 24 - - - True - 0 - DNS server 2: - - - - - 9 - 10 - - - - - - True - 24 - - - True - 0 - DNS server 1: - - - - - 8 - 9 - - - - - - True - 24 - - - True - 0 - Search domain: - - - - - 7 - 8 - - - - - - True - 12 - - + True True - Use global DNS servers + Prompt for wired network profile + 0 + True + True + pref_use_last_radio + + + + + 2 + 13 + 14 + + + + + + True + 12 + + + True + True + Use last wired network profile + 0 + True + True + + + + + 2 + 14 + 15 + + + + + + True + 0 + <b>Automatic Reconnection</b> + True + + + 2 + 15 + 16 + + + + + + True + 12 + + + True + True + Automatically reconnect on network connection loss 0 True @@ -750,83 +795,39 @@ 2 - 5 - 6 + 16 + 17 - - True - 0 - <b>Global DNS Servers</b> - True - - - 2 - 4 - 5 - - - - - + True True 1 2 - 9 - 10 - + 6 + 7 + GTK_FILL - - True - True - - - 1 - 2 - 8 - 9 - - - - - - True - True - - - 1 - 2 - 7 - 8 - - - - - + True 24 - + True - True - If enabled, the wired network interface will always be displayed in the main window. This can be useful if your wired network card does not detect when the interface is connected to a cable. - Always show wired interface - 0 - True + 0 + DNS domain: - 2 - 3 - 4 + 6 + 7 @@ -871,146 +872,13 @@ True 6 - + True 0 - <b>Route Table Flushing</b> + <b>DHCP Client</b> True - 4 - 5 - - - - - - True - 0 - <b>Wired Link Detection</b> - True - - - 2 - 3 - - - - - - True - 12 - - - True - - - True - True - Automatic (recommended) - 0 - True - True - - - False - - - - - True - True - ip - 0 - True - True - flush_auto_radio - - - False - 1 - - - - - True - True - route - 0 - True - True - flush_auto_radio - - - False - 2 - - - - - - - 5 - 6 - - - - - - True - 12 - - - True - - - True - True - Automatic (recommended) - 0 - True - True - - - False - - - - - True - True - ethtool - 0 - True - True - link_auto_radio - - - False - 1 - - - - - True - True - mii-tool - 0 - True - True - link_auto_radio - - - False - 2 - - - - - - - 3 - 4 @@ -1089,13 +957,146 @@ - + + True + 12 + + + True + + + True + True + Automatic (recommended) + 0 + True + True + + + False + + + + + True + True + ethtool + 0 + True + True + link_auto_radio + + + False + 1 + + + + + True + True + mii-tool + 0 + True + True + link_auto_radio + + + False + 2 + + + + + + + 3 + 4 + + + + + + True + 12 + + + True + + + True + True + Automatic (recommended) + 0 + True + True + + + False + + + + + True + True + ip + 0 + True + True + flush_auto_radio + + + False + 1 + + + + + True + True + route + 0 + True + True + flush_auto_radio + + + False + 2 + + + + + + + 5 + 6 + + + + + True 0 - <b>DHCP Client</b> + <b>Wired Link Detection</b> True + 2 + 3 + + + + + + True + 0 + <b>Route Table Flushing</b> + True + + + 4 + 5 @@ -1134,88 +1135,114 @@ 10 2 - + True - 0 - Hover your mouse over the selected backend -to read its description. - True - 1 - 2 5 6 - - - - - - True - - - True - - - False - - - - - 1 - 2 - 1 - 2 - - - - - - True - - - 2 - 3 GTK_FILL - + True - 12 - - - True - 0 - Driver: - - + 0 + You should almost always use wext as the +WPA supplicant driver. + True - 1 - 2 + 1 + 2 + 2 + 3 - + + True + 0 + <b>Backend</b> + True + + + 2 + 3 + 4 + + + + + + True + True + + + 1 + 2 + 4 + 5 + + + + + True 12 - + True - True - Use dBm to measure signal strength - 0 - True + 0 + Backend: + + 4 + 5 + + + + + + True + 0 + <b>Debugging</b> + True + 2 - 9 - 10 + 6 + 7 + + + + + + True + 0 + <b>WPA Supplicant</b> + True + + + 2 + + + + + + True + 0 + <b>Wireless Interface</b> + True + + + 2 + 8 + 9 @@ -1241,114 +1268,88 @@ to read its description. - - True - 0 - <b>Wireless Interface</b> - True - - - 2 - 8 - 9 - - - - - - True - 0 - <b>WPA Supplicant</b> - True - - - 2 - - - - - - True - 0 - <b>Debugging</b> - True - - - 2 - 6 - 7 - - - - - + True 12 - + True - 0 - Backend: + True + Use dBm to measure signal strength + 0 + True - 4 - 5 + 2 + 9 + 10 - + True - True + 12 + + + True + 0 + Driver: + + + + + 1 + 2 + + + + + + True + + + 2 + 3 + GTK_FILL + + + + + + True + + + True + + + False + + 1 2 - 4 - 5 + 1 + 2 - + True 0 - <b>Backend</b> - True - - - 2 - 3 - 4 - - - - - - True - 0 - You should almost always use wext as the -WPA supplicant driver. + Hover your mouse over the selected backend +to read its description. True 1 2 - 2 - 3 - - - - - - True - - 5 6 - GTK_FILL From e53581f9dda715396caf905ce6a8e7dcaf369606 Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Sun, 25 Jan 2009 12:03:01 +0800 Subject: [PATCH 2/5] Updated the wired profile Add/Delete system as per https://bugs.launchpad.net/wicd/+bug/318645 --- wicd/guiutil.py | 39 +++++++++++++++++++++++++++++++++++++++ wicd/netentry.py | 37 ++++++++++++++++++++++++------------- 2 files changed, 63 insertions(+), 13 deletions(-) diff --git a/wicd/guiutil.py b/wicd/guiutil.py index e84c753..8eea489 100644 --- a/wicd/guiutil.py +++ b/wicd/guiutil.py @@ -46,6 +46,45 @@ def alert(parent, message, block=True): dialog.run() dialog.destroy() +def string_input(prompt, secondary, textbox_label): + # based on a version of a PyGTK text entry from + # http://ardoris.wordpress.com/2008/07/05/pygtk-text-entry-dialog/ + + def dialog_response(entry, dialog, response): + dialog.response(response) + + dialog = gtk.MessageDialog( + None, + gtk.DIALOG_MODAL, + gtk.MESSAGE_QUESTION, + gtk.BUTTONS_OK_CANCEL, + None) + + # set the text + dialog.set_markup("" + prompt + "") + # add the secondary text + dialog.format_secondary_markup(secondary) + + entry = gtk.Entry() + # allow the user to press enter instead of clicking OK + entry.connect("activate", dialog_response, dialog, gtk.RESPONSE_OK) + + # create an hbox and pack the label and entry in + hbox = gtk.HBox() + hbox.pack_start(gtk.Label(textbox_label), False, 4, 4) + hbox.pack_start(entry) + + # pack the boxes and show the dialog + dialog.vbox.pack_end(hbox, True, True, 0) + dialog.show_all() + + if dialog.run() == gtk.RESPONSE_OK: + text = entry.get_text() + dialog.destroy() + return text + else: + dialog.destroy() + return None class SmallLabel(gtk.Label): def __init__(self, text=''): diff --git a/wicd/netentry.py b/wicd/netentry.py index 4474b99..302b04d 100644 --- a/wicd/netentry.py +++ b/wicd/netentry.py @@ -21,7 +21,7 @@ import os import misc import wpath from misc import noneToString, stringToNone, noneToBlankString, to_bool -from guiutil import error, SmallLabel, LabelEntry, GreyLabel, LeftAlignedLabel +from guiutil import error, SmallLabel, LabelEntry, GreyLabel, LeftAlignedLabel, string_input language = misc.get_language_list_gui() @@ -553,7 +553,7 @@ class WiredNetworkEntry(NetworkEntry): self.chkbox_default_profile = gtk.CheckButton(language['default_wired']) # Build the profile list. - self.combo_profile_names = gtk.combo_box_entry_new_text() + self.combo_profile_names = gtk.combo_box_new_text() self.profile_list = wired.GetWiredProfileList() if self.profile_list: for x in self.profile_list: @@ -642,21 +642,32 @@ class WiredNetworkEntry(NetworkEntry): def add_profile(self, widget): """ Add a profile to the profile list. """ print "adding profile" - profile_name = self.combo_profile_names.get_active_text() + + response = string_input("Enter a profile name", "The profile name " + + "will not be used by the computer. It " + + "allows you to " + + "easily distinguish between different network " + + "profiles.", "Profile name:") + + # if response is "" or None + if not response: + return + + profile_name = response profile_list = wired.GetWiredProfileList() if profile_list: if profile_name in profile_list: return False - if profile_name != "": - self.profile_help.hide() - wired.CreateWiredNetworkProfile(profile_name, False) - self.combo_profile_names.prepend_text(profile_name) - self.combo_profile_names.set_active(0) - self.advanced_dialog.prof_name = profile_name - if self.is_full_gui: - self.button_delete.set_sensitive(True) - self.connect_button.set_sensitive(True) - self.advanced_button.set_sensitive(True) + + self.profile_help.hide() + wired.CreateWiredNetworkProfile(profile_name, False) + self.combo_profile_names.prepend_text(profile_name) + self.combo_profile_names.set_active(0) + self.advanced_dialog.prof_name = profile_name + if self.is_full_gui: + self.button_delete.set_sensitive(True) + self.connect_button.set_sensitive(True) + self.advanced_button.set_sensitive(True) def remove_profile(self, widget): """ Remove a profile from the profile list. """ From ec3720690575f3bb2d98ba96d3cf398e635d1fd2 Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Sat, 24 Jan 2009 23:31:24 -0500 Subject: [PATCH 3/5] Initial work on automatic switchover to wired networks (no UI work yet) actually use "write=True" instead of just "True" everywhere we do config writes explicitly. Fix the scripts dialog not working for wired connections. Force the monitor to update state after triggering a disconnect or connect. Remove an unneeded Scan call from autoconnect.py --- wicd/autoconnect.py | 1 - wicd/backends/be-ioctl.py | 7 +++---- wicd/configmanager.py | 6 +++--- wicd/gui.py | 5 ++--- wicd/monitor.py | 37 ++++++++++++++++++++++++++++-------- wicd/netentry.py | 3 ++- wicd/networking.py | 12 ++++++++---- wicd/wicd-daemon.py | 40 ++++++++++++++++++++++----------------- 8 files changed, 70 insertions(+), 41 deletions(-) diff --git a/wicd/autoconnect.py b/wicd/autoconnect.py index 310de8b..b21672d 100755 --- a/wicd/autoconnect.py +++ b/wicd/autoconnect.py @@ -49,7 +49,6 @@ def error_handler(*args): if __name__ == '__main__': try: time.sleep(2) - wireless.Scan(True) daemon.SetSuspend(False) if not daemon.CheckIfConnecting(): daemon.AutoConnect(True, reply_handler=handler, error_handler=handler) diff --git a/wicd/backends/be-ioctl.py b/wicd/backends/be-ioctl.py index b261449..08a6a79 100644 --- a/wicd/backends/be-ioctl.py +++ b/wicd/backends/be-ioctl.py @@ -376,9 +376,8 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface): False otherwise. """ - def error(): - print "Unable to find ctrl_interface for wpa_supplicant. " + \ - "Could not validate authentication." + error= "Unable to find ctrl_interface for wpa_supplicant. " + \ + "Could not validate authentication." # Right now there's no way to do this for ralink drivers if self.wpa_driver == RALINK_DRIVER: @@ -389,7 +388,7 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface): socket = [os.path.join(ctrl_iface, s) \ for s in os.listdir(ctrl_iface) if s == self.iface][0] except OSError: - error() + print error return True wpa = wpactrl.WPACtrl(socket) diff --git a/wicd/configmanager.py b/wicd/configmanager.py index 29d4320..b2755cc 100644 --- a/wicd/configmanager.py +++ b/wicd/configmanager.py @@ -48,7 +48,7 @@ class ConfigManager(RawConfigParser): """ Returns the path to the loaded config file. """ return self.config_file - def set_option(self, section, option, value, save=False): + def set_option(self, section, option, value, write=False): """ Wrapper around ConfigParser.set Adds the option to write the config file change right away. @@ -65,7 +65,7 @@ class ConfigManager(RawConfigParser): value = "%(ws)s%(value)s%(ws)s" % {"value" : value, "ws" : self.mrk_ws} RawConfigParser.set(self, section, str(option), value) - if save: + if write: self.write() def set(self, *args, **kargs): @@ -98,7 +98,7 @@ class ConfigManager(RawConfigParser): else: if default != "__None__": print 'did not find %s in configuration, setting default %s' % (option, str(default)) - self.set(section, option, str(default), save=True) + self.set(section, option, str(default), write=True) ret = default else: ret = None diff --git a/wicd/gui.py b/wicd/gui.py index 55f0eda..597e781 100644 --- a/wicd/gui.py +++ b/wicd/gui.py @@ -706,15 +706,14 @@ class appGui(object): [width, height] = self.window.get_size() try: daemon.WriteWindowSize(width, height, "main") - except: + daemon.SetGUIOpen(False) + except dbusmanager.DBusException: pass if self.standalone: sys.exit(0) self.is_visible = False - daemon.SetGUIOpen(False) - self.wait_for_events() return True def show_win(self): diff --git a/wicd/monitor.py b/wicd/monitor.py index 47fe3b5..0566b9b 100755 --- a/wicd/monitor.py +++ b/wicd/monitor.py @@ -63,20 +63,29 @@ class ConnectionStatus(object): self.last_reconnect_time = time.time() self.signal_changed = False self.iwconfig = "" + self.trigger_reconnect = False bus = dbusmanager.get_bus() bus.add_signal_receiver(self._force_update_connection_status, "UpdateState", "org.wicd.daemon") def check_for_wired_connection(self, wired_ip): - """ Checks for an active wired connection. + """ Checks for a wired connection. - Checks for and updates the tray icon for an active wired connection - Returns True if wired connection is active, false if inactive. + Checks for two states: + 1) A wired connection is not in use, but a cable is plugged + in, and the user has chosen to switch to a wired connection + whenever its available, even if already connected to a + wireless network + + 2) A wired connection is currently active. """ + if not wired_ip and daemon.GetPreferWiredNetwork(): + if not daemon.GetForcedDisconnect() and wired.CheckPluggedIn(): + self.trigger_reconnect = True - if wired_ip and wired.CheckPluggedIn(): + elif wired_ip and wired.CheckPluggedIn(): # Only change the interface if it's not already set for wired if not self.still_wired: daemon.SetCurrentInterface(daemon.GetWiredInterface()) @@ -89,14 +98,17 @@ class ConnectionStatus(object): def check_for_wireless_connection(self, wireless_ip): """ Checks for an active wireless connection. - Checks for and updates the tray icon for an active - wireless connection. Returns True if wireless connection - is active, and False otherwise. + Checks for an active wireless connection. Also notes + if the signal strength is 0, and if it remains there + for too long, triggers a wireless disconnect. + + Returns True if wireless connection is active, and + False otherwise. """ # Make sure we have an IP before we do anything else. - if wireless_ip is None: + if not wireless_ip: return False if daemon.NeedsExternalCalls(): @@ -158,6 +170,15 @@ class ConnectionStatus(object): # Check for wired. wired_ip = wired.GetWiredIP("") wired_found = self.check_for_wired_connection(wired_ip) + # Trigger an AutoConnect if we're plugged in, not connected + # to a wired network, and the "autoswitch to wired" option + # is on. + if self.trigger_reconnect: + self.trigger_reconnect = False + wireless.DisconnectWireless() + daemon.AutoConnect(False, reply_handler=lambda:None, + error_handler=lambda:None) + return True if wired_found: self.update_state(misc.WIRED, wired_ip=wired_ip) return True diff --git a/wicd/netentry.py b/wicd/netentry.py index 4474b99..e2a6500 100644 --- a/wicd/netentry.py +++ b/wicd/netentry.py @@ -234,7 +234,7 @@ class WiredSettingsDialog(AdvancedSettingsDialog): def edit_scripts(self, widget=None, event=None): """ Launch the script editting dialog. """ - profile = self.combo_profile_names.get_active_text() + profile = self.prof_name cmdend = [os.path.join(wpath.lib, "configscript.py"), profile, "wired"] if os.getuid() != 0: cmdbase = misc.get_sudo_cmd(language['scripts_need_pass']) @@ -695,6 +695,7 @@ class WiredNetworkEntry(NetworkEntry): return profile_name = self.combo_profile_names.get_active_text() + self.advanced_dialog.prof_name = profile_name wired.ReadWiredNetworkProfile(profile_name) self.advanced_dialog.txt_ip.set_text(self.format_entry("ip")) diff --git a/wicd/networking.py b/wicd/networking.py index dcecce8..e1a99f7 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -741,7 +741,8 @@ class WirelessConnectThread(ConnectThread): self.is_connecting = True # Run pre-connection script. - self.run_script_if_needed(self.before_script, 'pre-connection', self.network['bssid'], self.network['essid']) + self.run_script_if_needed(self.before_script, 'pre-connection', + self.network['bssid'], self.network['essid']) # Take down interface and clean up previous connections. @@ -783,7 +784,8 @@ class WirelessConnectThread(ConnectThread): self.set_dns_addresses() # Run post-connection script. - self.run_script_if_needed(self.after_script, 'post-connection', self.network['bssid'], self.network['essid']) + self.run_script_if_needed(self.after_script, 'post-connection', + self.network['bssid'], self.network['essid']) self.SetStatus('done') print 'Connecting thread exiting.' @@ -947,7 +949,8 @@ class WiredConnectThread(ConnectThread): self.is_connecting = True # Run pre-connection script. - self.run_script_if_needed(self.before_script, 'pre-connection', 'wired', 'wired') + self.run_script_if_needed(self.before_script, 'pre-connection', 'wired', + 'wired') # Take down interface and clean up previous connections. self.put_iface_down(liface) @@ -965,7 +968,8 @@ class WiredConnectThread(ConnectThread): self.set_dns_addresses() # Run post-connection script. - self.run_script_if_needed(self.after_script, 'post-connection', 'wired', 'wired') + self.run_script_if_needed(self.after_script, 'post-connection', 'wired', + 'wired') self.SetStatus('done') print 'Connecting thread exiting.' diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index 53c9ad2..40e80ea 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -141,28 +141,28 @@ class WicdDaemon(dbus.service.Object): """ Sets the wired interface for the daemon to use. """ print "setting wired interface %s" % (str(interface)) self.wired.wired_interface = noneToBlankString(interface) - self.config.set("Settings", "wired_interface", interface, True) + self.config.set("Settings", "wired_interface", interface, write=True) @dbus.service.method('org.wicd.daemon') def SetWirelessInterface(self, interface): """ Sets the wireless interface the daemon will use. """ print "setting wireless interface %s" % (str(interface)) self.wifi.wireless_interface = noneToBlankString(interface) - self.config.set("Settings", "wireless_interface", interface, True) + self.config.set("Settings", "wireless_interface", interface, write=True) @dbus.service.method('org.wicd.daemon') def SetWPADriver(self, driver): """ Sets the wpa driver the wpa_supplicant will use. """ print "setting wpa driver", str(driver) self.wifi.wpa_driver = driver - self.config.set("Settings", "wpa_driver", driver, True) + self.config.set("Settings", "wpa_driver", driver, write=True) @dbus.service.method('org.wicd.daemon') def SetUseGlobalDNS(self, use): """ Sets a boolean which determines if global DNS is enabled. """ print 'setting use global dns to', use use = misc.to_bool(use) - self.config.set("Settings", "use_global_dns", use, True) + self.config.set("Settings", "use_global_dns", use, write=True) self.use_global_dns = use self.wifi.use_global_dns = use self.wired.use_global_dns = use @@ -197,12 +197,11 @@ class WicdDaemon(dbus.service.Object): print 'search domain is %s' % search_dom self.config.write() - @dbus.service.method('org.wicd.daemon') def SetBackend(self, backend): """ Sets a new backend. """ print "setting backend to %s" % backend - self.config.set("Settings", "backend", backend, True) + self.config.set("Settings", "backend", backend, write=True) if backend != self.GetCurrentBackend(): self.suspended = True self.wifi.LoadBackend(backend) @@ -272,7 +271,7 @@ class WicdDaemon(dbus.service.Object): @dbus.service.method('org.wicd.daemon') def SetDebugMode(self, debug): """ Sets if debugging mode is on or off. """ - self.config.set("Settings", "debug_mode", debug, True) + self.config.set("Settings", "debug_mode", debug, write=True) self.debug_mode = misc.to_bool(debug) self.wifi.debug = self.debug_mode self.wired.debug = self.debug_mode @@ -352,7 +351,8 @@ class WicdDaemon(dbus.service.Object): """ print 'setting automatically reconnect when connection drops %s' % value - self.config.set("Settings", "auto_reconnect", misc.to_bool(value), True) + self.config.set("Settings", "auto_reconnect", misc.to_bool(value), + write=True) self.auto_reconnect = misc.to_bool(value) @dbus.service.method('org.wicd.daemon') @@ -453,7 +453,7 @@ class WicdDaemon(dbus.service.Object): @dbus.service.method('org.wicd.daemon') def SetSignalDisplayType(self, value): """ Sets the signal display type and writes it the wicd config file. """ - self.config.set("Settings", "signal_display_type", value, True) + self.config.set("Settings", "signal_display_type", value, write=True) self.signal_display_type = int(value) @dbus.service.method('org.wicd.daemon') @@ -483,7 +483,7 @@ class WicdDaemon(dbus.service.Object): def SetAlwaysShowWiredInterface(self, value): """ Sets always_show_wired_interface to the given value. """ self.config.set("Settings", "always_show_wired_interface", - misc.to_bool(value), True) + misc.to_bool(value), write=True) self.always_show_wired_interface = misc.to_bool(value) @dbus.service.method('org.wicd.daemon') @@ -497,7 +497,8 @@ class WicdDaemon(dbus.service.Object): # 1 = default profile # 2 = show list # 3 = last used profile - self.config.set("Settings","wired_connect_mode", int(method), True) + self.config.set("Settings","wired_connect_mode", int(method), + write=True) self.wired_connect_mode = int(method) self.wired_bus.connect_mode = int(method) @@ -505,9 +506,8 @@ class WicdDaemon(dbus.service.Object): def GetWiredAutoConnectMethod(self): """ Returns the wired autoconnect method. """ return int(self.wired_connect_mode) - - - @dbus.service.method('org.wicd.dameon') + + @dbus.service.method('org.wicd.daemon') def GetPreferWiredNetwork(self): """ Returns True if wired network preference is set. @@ -520,6 +520,7 @@ class WicdDaemon(dbus.service.Object): @dbus.service.method('org.wicd.daemon') def SetPreferWiredNetwork(self, value): """ Sets the prefer_wired state. """ + self.config.set("Settings", "prefer_wired", bool(value), write=True) self.prefer_wired = bool(value) @dbus.service.method('org.wicd.daemon') @@ -589,7 +590,7 @@ class WicdDaemon(dbus.service.Object): self.dhcp_client = int(client) self.wifi.dhcp_client = int(client) self.wired.dhcp_client = int(client) - self.config.set("Settings", "dhcp_client", client, True) + self.config.set("Settings", "dhcp_client", client, write=True) @dbus.service.method('org.wicd.daemon') def GetLinkDetectionTool(self): @@ -609,7 +610,7 @@ class WicdDaemon(dbus.service.Object): """ self.link_detect_tool = int(link_tool) self.wired.link_tool = int(link_tool) - self.config.set("Settings", "link_detect_tool", link_tool, True) + self.config.set("Settings", "link_detect_tool", link_tool, write=True) @dbus.service.method('org.wicd.daemon') def GetFlushTool(self): @@ -628,7 +629,7 @@ class WicdDaemon(dbus.service.Object): self.flush_tool = int(flush_tool) self.wired.flush_tool = int(flush_tool) self.wifi.flush_tool = int(flush_tool) - self.config.set("Settings", "flush_tool", flush_tool, True) + self.config.set("Settings", "flush_tool", flush_tool, write=True) @dbus.service.method('org.wicd.daemon') def WriteWindowSize(self, width, height, win_name): @@ -1018,6 +1019,7 @@ class WirelessDaemon(dbus.service.Object): """ Disconnects the wireless network. """ self.SetForcedDisconnect(True) self.wifi.Disconnect() + self.daemon.UpdateState() @dbus.service.method('org.wicd.daemon.wireless') def GetForcedDisconnect(self): @@ -1100,6 +1102,7 @@ class WirelessDaemon(dbus.service.Object): 'disconnectscript') print 'Connecting to wireless network ' + self.LastScan[id]['essid'] conthread = self.wifi.Connect(self.LastScan[id], debug=self.debug_mode) + self.daemon.UpdateState() @dbus.service.method('org.wicd.daemon.wireless') def CheckIfWirelessConnecting(self): @@ -1354,6 +1357,7 @@ class WiredDaemon(dbus.service.Object): """ Disconnects the wired network. """ self.SetForcedDisconnect(True) self.wired.Disconnect() + self.daemon.UpdateState() @dbus.service.method('org.wicd.daemon.wired') def CheckPluggedIn(self): @@ -1402,6 +1406,7 @@ class WiredDaemon(dbus.service.Object): self.wired.after_script = self.GetWiredProperty("afterscript") self.wired.disconnect_script = self.GetWiredProperty("disconnectscript") self.wired.Connect(self.WiredNetwork, debug=self.debug_mode) + self.daemon.UpdateState() @dbus.service.method('org.wicd.daemon.wired') def CreateWiredNetworkProfile(self, profilename, default=False): @@ -1474,6 +1479,7 @@ class WiredDaemon(dbus.service.Object): self.config.set(prof, script, None) if profilename == "": + self.config.write() return "500: Bad Profile name" profilename = misc.to_unicode(profilename) self.config.remove_section(profilename) From a2e757a64d31a23eb8ddf65977af1f02320f8827 Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Sun, 25 Jan 2009 00:44:51 -0500 Subject: [PATCH 4/5] Add new wired GUI icon. --- images/wired-gui.svg | 682 +++++++++++++++++++++++++++++++++++++++++++ wicd/netentry.py | 7 +- 2 files changed, 685 insertions(+), 4 deletions(-) create mode 100644 images/wired-gui.svg diff --git a/images/wired-gui.svg b/images/wired-gui.svg new file mode 100644 index 0000000..437efcd --- /dev/null +++ b/images/wired-gui.svg @@ -0,0 +1,682 @@ + + + + + + + image/svg+xml + + + + Lapo Calamandrei + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/wicd/netentry.py b/wicd/netentry.py index 88e9ca4..8f36f13 100644 --- a/wicd/netentry.py +++ b/wicd/netentry.py @@ -535,10 +535,10 @@ class WiredNetworkEntry(NetworkEntry): """ Load the wired network entry. """ NetworkEntry.__init__(self, dbus_ifaces) # Center the picture and pad it a bit - self.image.set_alignment(.5, 0) + self.image.set_padding(0, 0) + self.image.set_alignment(.5, .5) self.image.set_size_request(60, -1) - #self.image.set_from_icon_name("network-wired", 6) - self.image.set_from_file(wpath.images + "wired.png") + self.image.set_from_file(wpath.images + "wired-gui.svg") self.image.show() self.connect_button.show() @@ -729,7 +729,6 @@ class WirelessNetworkEntry(NetworkEntry): self.image.set_alignment(.5, .5) self.image.set_size_request(60, -1) self.image.show() - #self.image.set_from_icon_name("network-wired", 6) self.essid = noneToBlankString(wireless.GetWirelessProperty(networkID, "essid")) self.lbl_strength = GreyLabel() From 7a375db45301eb103c2d6d94f30c5cde08f749df Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Sun, 25 Jan 2009 15:15:49 -0500 Subject: [PATCH 5/5] Add UI portion of wired switch feature. --- data/wicd.glade | 116 +++++++++++++++++++++++++++++------------------- wicd/prefs.py | 4 ++ 2 files changed, 74 insertions(+), 46 deletions(-) diff --git a/data/wicd.glade b/data/wicd.glade index a199fa1..4a5cf77 100644 --- a/data/wicd.glade +++ b/data/wicd.glade @@ -1,6 +1,6 @@ - + 450 @@ -424,7 +424,7 @@ True - 17 + 18 2 4 4 @@ -455,19 +455,6 @@ True True - - 1 - 2 - 7 - 8 - - - - - - True - True - 1 2 @@ -477,7 +464,7 @@ - + True True @@ -489,6 +476,19 @@ + + + True + True + + + 1 + 2 + 10 + 11 + + + True @@ -498,8 +498,8 @@ 2 - 4 - 5 + 5 + 6 @@ -519,8 +519,8 @@ 2 - 5 - 6 + 6 + 7 @@ -537,8 +537,8 @@ - 7 - 8 + 8 + 9 @@ -555,8 +555,8 @@ - 8 - 9 + 9 + 10 @@ -573,8 +573,8 @@ - 9 - 10 + 10 + 11 @@ -586,8 +586,8 @@ 1 2 - 10 - 11 + 11 + 12 @@ -604,8 +604,8 @@ - 10 - 11 + 11 + 12 @@ -692,8 +692,8 @@ 2 - 11 - 12 + 12 + 13 @@ -715,8 +715,8 @@ 2 - 12 - 13 + 13 + 14 @@ -738,8 +738,8 @@ 2 - 13 - 14 + 14 + 15 @@ -760,8 +760,8 @@ 2 - 14 - 15 + 15 + 16 @@ -774,8 +774,8 @@ 2 - 15 - 16 + 16 + 17 @@ -795,8 +795,8 @@ 2 - 16 - 17 + 17 + 18 @@ -808,8 +808,8 @@ 1 2 - 6 - 7 + 7 + 8 GTK_FILL @@ -826,11 +826,35 @@ - 6 - 7 + 7 + 8 + + + True + + + True + True + True + If selected, wicd will automatically connect to a wired network +as soon as a cable is plugged in, even if a wireless connection +is already active. + Always switch to a wired connection when available + 0 + True + + + + + 2 + 4 + 5 + 24 + + diff --git a/wicd/prefs.py b/wicd/prefs.py index b5779fb..bff88bb 100644 --- a/wicd/prefs.py +++ b/wicd/prefs.py @@ -58,6 +58,7 @@ class PreferencesDialog(object): self.reconnectcheckbox.set_active(daemon.GetAutoReconnect()) self.debugmodecheckbox.set_active(daemon.GetDebugMode()) self.displaytypecheckbox.set_active(daemon.GetSignalDisplayType()) + self.preferwiredcheckbox.set_active(daemon.GetPreferWiredNetwork()) dhcp_list = [self.dhcpautoradio, self.dhclientradio, self.dhcpcdradio, self.pumpradio] @@ -148,6 +149,7 @@ class PreferencesDialog(object): daemon.SetAutoReconnect(self.reconnectcheckbox.get_active()) daemon.SetDebugMode(self.debugmodecheckbox.get_active()) daemon.SetSignalDisplayType(int(self.displaytypecheckbox.get_active())) + daemon.SetPreferWiredNetwork(bool(self.preferwiredcheckbox.get_active())) if self.showlistradiobutton.get_active(): daemon.SetWiredAutoConnectMethod(2) elif self.lastusedradiobutton.get_active(): @@ -253,6 +255,8 @@ class PreferencesDialog(object): self.wiredcheckbox = setup_label("pref_always_check", 'wired_always_on') + self.preferwiredcheckbox = setup_label("pref_prefer_wired_check", + "prefer_wired") self.reconnectcheckbox = setup_label("pref_auto_check", 'auto_reconnect')