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 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 e2a6500..88e9ca4 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,11 +553,19 @@ 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() + default_prof = wired.GetDefaultWiredNetwork() if self.profile_list: - for x in self.profile_list: - self.combo_profile_names.append_text(x) + starting_index = 0 + for x, prof in enumerate(self.profile_list): + self.combo_profile_names.append_text(prof) + if default_prof == prof: + starting_index = x + self.combo_profile_names.set_active(starting_index) + else: + print "no wired profiles found" + self.profile_help.show() # Format the profile help label. self.profile_help.set_justify(gtk.JUSTIFY_LEFT) @@ -580,6 +588,11 @@ class WiredNetworkEntry(NetworkEntry): self.chkbox_default_profile.connect("toggled", self.toggle_default_profile) self.combo_profile_names.connect("changed", self.change_profile) + + # Show everything, but hide the profile help label. + self.show_all() + self.profile_help.hide() + self.advanced_dialog = WiredSettingsDialog(self.combo_profile_names.get_active_text()) # Toggle the default profile checkbox to the correct state. if to_bool(wired.GetWiredProperty("default")): @@ -587,25 +600,6 @@ class WiredNetworkEntry(NetworkEntry): else: self.chkbox_default_profile.set_active(False) - # Show everything, but hide the profile help label. - self.show_all() - self.profile_help.hide() - self.advanced_dialog = WiredSettingsDialog(self.combo_profile_names.get_active_text()) - - # Display the default profile if it exists. - if self.profile_list is not None: - prof = wired.GetDefaultWiredNetwork() - if prof != None: # Make sure the default profile gets displayed. - i = 0 - while self.combo_profile_names.get_active_text() != prof: - self.combo_profile_names.set_active(i) - i += 1 - else: - self.combo_profile_names.set_active(0) - print "wired profiles found" - else: - print "no wired profiles found" - self.profile_help.show() self.check_enable() self.wireddis = self.connect("destroy", self.destroy_called) @@ -642,21 +636,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. """