1
0
mirror of https://github.com/gryf/wicd.git synced 2026-01-05 21:34:16 +01:00

Merged with mainline 1.6 branch, r241, adding in the noexpander stuff

This commit is contained in:
Andrew Psaltis
2009-01-16 12:09:20 -05:00
8 changed files with 255 additions and 128 deletions

View File

@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd"> <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
<!--Generated with glade3 3.4.5 on Sat Jan 10 08:53:20 2009 --> <!--Generated with glade3 3.4.5 on Sat Jan 10 10:47:27 2009 -->
<glade-interface> <glade-interface>
<widget class="GtkWindow" id="window1"> <widget class="GtkWindow" id="window1">
<property name="width_request">450</property> <property name="width_request">450</property>
<property name="height_request">400</property> <property name="height_request">400</property>
<property name="visible">True</property> <property name="visible">True</property>
<property name="title" translatable="yes">Wicd Manager</property> <property name="title" translatable="yes">Wicd Network Manager</property>
<property name="window_position">GTK_WIN_POS_CENTER</property> <property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="default_width">550</property> <property name="default_width">550</property>
<property name="gravity">GDK_GRAVITY_CENTER</property> <property name="gravity">GDK_GRAVITY_CENTER</property>
@@ -456,7 +456,6 @@
<property name="right_attach">2</property> <property name="right_attach">2</property>
<property name="top_attach">6</property> <property name="top_attach">6</property>
<property name="bottom_attach">7</property> <property name="bottom_attach">7</property>
<property name="y_options"></property>
</packing> </packing>
</child> </child>
<child> <child>

View File

@@ -17,6 +17,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
# #
from wicd import dbusmanager
import dbus import dbus
import time import time
import gobject import gobject
@@ -29,9 +31,9 @@ else:
DBusGMainLoop(set_as_default=True) DBusGMainLoop(set_as_default=True)
try: try:
bus = dbus.SystemBus() dbusmanager.connect_to_dbus()
proxy_obj = bus.get_object('org.wicd.daemon', '/org/wicd/daemon') daemon = dbusmanager.get_interface('daemon')
daemon = dbus.Interface(proxy_obj, 'org.wicd.daemon') wireless = dbusmanager.get_interface('wireless')
except Exception, e: except Exception, e:
print>>sys.stderr, "Exception caught: %s" % str(e) print>>sys.stderr, "Exception caught: %s" % str(e)
print>>sys.stderr, 'Could not connect to daemon.' print>>sys.stderr, 'Could not connect to daemon.'
@@ -46,10 +48,10 @@ def error_handler(*args):
if __name__ == '__main__': if __name__ == '__main__':
try: try:
time.sleep(3) time.sleep(2)
wireless.Scan()
daemon.SetSuspend(False) daemon.SetSuspend(False)
if not daemon.CheckIfConnecting(): if not daemon.CheckIfConnecting():
daemon.SetForcedDisconnect(False)
daemon.AutoConnect(True, reply_handler=handler, error_handler=handler) daemon.AutoConnect(True, reply_handler=handler, error_handler=handler)
except Exception, e: except Exception, e:
print>>sys.stderr, "Exception caught: %s" % str(e) print>>sys.stderr, "Exception caught: %s" % str(e)

View File

@@ -316,7 +316,7 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
ap['hidden'] = False ap['hidden'] = False
if cell["channel"]: if cell["channel"]:
ap["channel"] = True ap["channel"] = cell["channel"]
else: else:
ap["channel"] = self._FreqToChannel(cell["frequency"]) ap["channel"] = self._FreqToChannel(cell["frequency"])

View File

@@ -241,8 +241,10 @@ class appGui(object):
if width > -1 and height > -1: if width > -1 and height > -1:
self.window.resize(int(width), int(height)) self.window.resize(int(width), int(height))
else: else:
self.window.resize(gtk.gdk.screen_width() / 3, width = int(gtk.gdk.screen_width() / 2)
gtk.gdk.screen_height() / 2) if width > 530:
width = 530
self.window.resize(width, int(gtk.gdk.screen_height() / 1.7))
dic = { "refresh_clicked" : self.refresh_clicked, dic = { "refresh_clicked" : self.refresh_clicked,
"quit_clicked" : self.exit, "quit_clicked" : self.exit,

View File

@@ -435,7 +435,7 @@ def get_language_list_gui():
language['use_static_ip'] = _('Use Static IPs') language['use_static_ip'] = _('Use Static IPs')
language['use_static_dns'] = _('Use Static DNS') language['use_static_dns'] = _('Use Static DNS')
language['use_encryption'] = _('Use Encryption') language['use_encryption'] = _('Use Encryption')
language['advanced_settings'] = _('Advanced Settings') language['advanced_settings'] = _('Properties')
language['wired_network'] = _('Wired Network') language['wired_network'] = _('Wired Network')
language['wired_network_instructions'] = _('To connect to a wired network,' language['wired_network_instructions'] = _('To connect to a wired network,'
' you must create a network profile. To create a network profile, type a' ' you must create a network profile. To create a network profile, type a'

View File

@@ -42,6 +42,11 @@ class SmallLabel(gtk.Label):
gtk.Label.__init__(self, text) gtk.Label.__init__(self, text)
self.set_size_request(50, -1) self.set_size_request(50, -1)
class LeftAlignedLabel(gtk.Label):
def __init__(self, label=None):
gtk.Label.__init__(self, label)
self.set_alignment(0.0, 0.5)
class LabelEntry(gtk.HBox): class LabelEntry(gtk.HBox):
""" A label on the left with a textbox on the right. """ """ A label on the left with a textbox on the right. """
def __init__(self, text): def __init__(self, text):
@@ -126,6 +131,19 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.hbox_dns.pack_start(self.chkbox_static_dns) self.hbox_dns.pack_start(self.chkbox_static_dns)
self.hbox_dns.pack_start(self.chkbox_global_dns) self.hbox_dns.pack_start(self.chkbox_global_dns)
# Set up the script settings button
self.script_button = gtk.Button()
script_image = gtk.Image()
script_image.set_from_stock(gtk.STOCK_EXECUTE, 4)
script_image.set_padding(4, 0)
#self.script_button.set_alignment(.5, .5)
self.script_button.set_image(script_image)
self.script_button.set_label(language['scripts'])
self.button_hbox = gtk.HBox(False, 2)
self.button_hbox.pack_start(self.script_button, fill=False, expand=False)
self.button_hbox.show()
assert(isinstance(self.vbox, gtk.VBox)) assert(isinstance(self.vbox, gtk.VBox))
self.vbox.pack_start(self.chkbox_static_ip, fill=False, expand=False) self.vbox.pack_start(self.chkbox_static_ip, fill=False, expand=False)
self.vbox.pack_start(self.txt_ip, fill=False, expand=False) self.vbox.pack_start(self.txt_ip, fill=False, expand=False)
@@ -137,6 +155,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.vbox.pack_start(self.txt_dns_1, fill=False, expand=False) self.vbox.pack_start(self.txt_dns_1, fill=False, expand=False)
self.vbox.pack_start(self.txt_dns_2, fill=False, expand=False) self.vbox.pack_start(self.txt_dns_2, fill=False, expand=False)
self.vbox.pack_start(self.txt_dns_3, fill=False, expand=False) self.vbox.pack_start(self.txt_dns_3, fill=False, expand=False)
self.vbox.pack_end(self.button_hbox, fill=False, expand=False, padding=5)
# Connect the events to the actions # Connect the events to the actions
@@ -277,12 +296,27 @@ class WiredSettingsDialog(AdvancedSettingsDialog):
""" Build the wired settings dialog. """ """ Build the wired settings dialog. """
AdvancedSettingsDialog.__init__(self) AdvancedSettingsDialog.__init__(self)
self.des = self.connect("destroy", self.destroy_called) self.des = self.connect("destroy", self.destroy_called)
self.script_button.connect("button-press-event", self.edit_scripts)
self.prof_name = name self.prof_name = name
def set_net_prop(self, option, value): def set_net_prop(self, option, value):
""" Sets the given option to the given value for this network. """ """ Sets the given option to the given value for this network. """
wired.SetWiredProperty(option, value) wired.SetWiredProperty(option, value)
def edit_scripts(self, widget=None, event=None):
""" Launch the script editting dialog. """
profile = self.combo_profile_names.get_active_text()
cmdend = [os.path.join(wpath.lib, "configscript.py"), profile, "wired"]
if os.getuid() != 0:
cmdbase = misc.get_sudo_cmd(language['scripts_need_pass'])
if not cmdbase:
error(None, language["no_sudo_prog"])
return
cmdbase.extend(cmdend)
misc.LaunchAndWait(cmdbase)
else:
misc.LaunchAndWait(cmdend)
def set_values(self): def set_values(self):
""" Fill in the Gtk.Entry objects with the correct values. """ """ Fill in the Gtk.Entry objects with the correct values. """
self.txt_ip.set_text(self.format_entry("ip")) self.txt_ip.set_text(self.format_entry("ip"))
@@ -330,12 +364,16 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
self.combo_encryption.set_sensitive(False) self.combo_encryption.set_sensitive(False)
self.encrypt_types = misc.LoadEncryptionMethods() self.encrypt_types = misc.LoadEncryptionMethods()
information_button = gtk.Button(stock=gtk.STOCK_INFO)
self.button_hbox.pack_start(information_button, False, False)
information_button.connect('clicked', lambda *a, **k: WirelessInformationDialog(networkID))
information_button.show()
# Build the encryption menu # Build the encryption menu
activeID = -1 # Set the menu to this item when we are done activeID = -1 # Set the menu to this item when we are done
for x, enc_type in enumerate(self.encrypt_types): for x, enc_type in enumerate(self.encrypt_types):
self.combo_encryption.append_text(enc_type[0]) self.combo_encryption.append_text(enc_type[0])
if enc_type[1] == wireless.GetWirelessProperty(networkID, if enc_type[1] == wireless.GetWirelessProperty(networkID, "enctype"):
"enctype"):
activeID = x activeID = x
self.combo_encryption.set_active(activeID) self.combo_encryption.set_active(activeID)
if activeID != -1: if activeID != -1:
@@ -354,6 +392,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
# Connect signals. # Connect signals.
self.chkbox_encryption.connect("toggled", self.toggle_encryption) self.chkbox_encryption.connect("toggled", self.toggle_encryption)
self.combo_encryption.connect("changed", self.change_encrypt_method) self.combo_encryption.connect("changed", self.change_encrypt_method)
self.script_button.connect("button-press-event", self.edit_scripts)
self.des = self.connect("destroy", self.destroy_called) self.des = self.connect("destroy", self.destroy_called)
def destroy_called(self, *args): def destroy_called(self, *args):
@@ -363,6 +402,20 @@ class WirelessSettingsDialog(AdvancedSettingsDialog):
self.destroy() self.destroy()
del self del self
def edit_scripts(self, widget=None, event=None):
""" Launch the script editting dialog. """
cmdend = [os.path.join(wpath.lib, "configscript.py"),
str(self.networkID), "wireless"]
if os.getuid() != 0:
cmdbase = misc.get_sudo_cmd(language['scripts_need_pass'])
if not cmdbase:
error(None, language["no_sudo_prog"])
return
cmdbase.extend(cmdend)
misc.LaunchAndWait(cmdbase)
else:
misc.LaunchAndWait(cmdend)
def set_net_prop(self, option, value): def set_net_prop(self, option, value):
""" Sets the given option to the given value for this network. """ """ Sets the given option to the given value for this network. """
wireless.SetWirelessProperty(self.networkID, option, value) wireless.SetWirelessProperty(self.networkID, option, value)
@@ -495,10 +548,12 @@ class NetworkEntry(gtk.HBox):
wired = dbus_ifaces["wired"] wired = dbus_ifaces["wired"]
wireless = dbus_ifaces["wireless"] wireless = dbus_ifaces["wireless"]
gtk.HBox.__init__(self, False, 2) gtk.HBox.__init__(self, False, 2)
self.expander = gtk.Expander()
self.image = gtk.Image() self.image = gtk.Image()
self.pack_start(self.image, False, False) self.pack_start(self.image, False, False)
# Create an HBox to hold the buttons
self.buttons_hbox = gtk.HBox(False, 6)
# Set up the Connect button # Set up the Connect button
self.connect_button = gtk.Button(stock=gtk.STOCK_CONNECT) self.connect_button = gtk.Button(stock=gtk.STOCK_CONNECT)
self.connect_hbox = gtk.HBox(False, 2) self.connect_hbox = gtk.HBox(False, 2)
@@ -509,11 +564,13 @@ class NetworkEntry(gtk.HBox):
self.disconnect_button = gtk.Button(stock=gtk.STOCK_DISCONNECT) self.disconnect_button = gtk.Button(stock=gtk.STOCK_DISCONNECT)
self.connect_hbox.pack_start(self.disconnect_button, False, False) self.connect_hbox.pack_start(self.disconnect_button, False, False)
# Create a label to hold the name of the entry
self.name_label = gtk.Label()
self.name_label.set_alignment(0, 0.5)
# Set up the VBox that goes in the gtk.Expander # Set up the VBox that goes in the gtk.Expander
self.expander_vbox = gtk.VBox(False, 1) self.expander_vbox = gtk.VBox(False, 1)
self.expander_vbox.show() self.expander_vbox.show()
self.expander_vbox.pack_start(self.expander)
self.expander_vbox.pack_start(self.connect_hbox, False, False)
self.pack_end(self.expander_vbox) self.pack_end(self.expander_vbox)
# Set up the advanced settings button # Set up the advanced settings button
@@ -525,27 +582,18 @@ class NetworkEntry(gtk.HBox):
self.advanced_button.set_label(language['advanced_settings']) self.advanced_button.set_label(language['advanced_settings'])
self.advanced_button.set_image(self.advanced_image) self.advanced_button.set_image(self.advanced_image)
# Set up the script settings button #self.buttons_hbox.pack_start(self.script_button, False, False)
self.script_button = gtk.Button() self.buttons_hbox.pack_start(self.connect_hbox, False, False)
self.script_image = gtk.Image() self.buttons_hbox.pack_start(self.advanced_button, False, False)
self.script_image.set_from_stock(gtk.STOCK_EXECUTE, 4)
self.script_image.set_padding(4, 0)
self.script_button.set_alignment(.5, .5)
self.script_button.set_image(self.script_image)
self.script_button.set_label(language['scripts'])
self.settings_hbox = gtk.HBox(False, 3)
self.settings_hbox.set_border_width(5)
self.settings_hbox.pack_start(self.script_button, False, False)
self.settings_hbox.pack_start(self.advanced_button, False, False)
self.vbox_top = gtk.VBox(False, 0) self.vbox_top = gtk.VBox(False, 0)
self.vbox_top.pack_end(self.settings_hbox, False, False) #self.vbox_top.pack_end(self.buttons_hbox, False, False)
#self.vbox_top.pack_end(self.connect_hbox, False, False)
aligner = gtk.Alignment(xscale=1.0)
aligner.add(self.vbox_top) self.expander_vbox.pack_start(self.name_label)
aligner.set_padding(0, 0, 15, 0) self.expander_vbox.pack_start(self.vbox_top)
self.expander.add(aligner) self.expander_vbox.pack_start(self.buttons_hbox)
def destroy_called(self, *args): def destroy_called(self, *args):
""" Clean up everything. """ """ Clean up everything. """
@@ -564,10 +612,10 @@ class WiredNetworkEntry(NetworkEntry):
#self.image.set_from_icon_name("network-wired", 6) #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.png")
self.image.show() self.image.show()
self.expander.show()
self.connect_button.show() self.connect_button.show()
self.expander.set_label(language['wired_network']) self.name_label.set_label(language['wired_network'])
#self.reset_static_checkboxes() #self.reset_static_checkboxes()
self.is_full_gui = True self.is_full_gui = True
@@ -628,11 +676,8 @@ class WiredNetworkEntry(NetworkEntry):
else: else:
self.combo_profile_names.set_active(0) self.combo_profile_names.set_active(0)
print "wired profiles found" print "wired profiles found"
self.expander.set_expanded(False)
else: else:
print "no wired profiles found" print "no wired profiles found"
if not wired.GetAlwaysShowWiredInterface():
self.expander.set_expanded(True)
self.profile_help.show() self.profile_help.show()
self.check_enable() self.check_enable()
self.wireddis = self.connect("destroy", self.destroy_called) self.wireddis = self.connect("destroy", self.destroy_called)
@@ -650,20 +695,6 @@ class WiredNetworkEntry(NetworkEntry):
""" Save wired network settings. """ """ Save wired network settings. """
return self.advanced_dialog.save_settings() return self.advanced_dialog.save_settings()
def edit_scripts(self, widget=None, event=None):
""" Launch the script editting dialog. """
profile = self.combo_profile_names.get_active_text()
cmdend = [os.path.join(wpath.lib, "configscript.py"), profile, "wired"]
if os.getuid() != 0:
cmdbase = misc.get_sudo_cmd(language['scripts_need_pass'])
if not cmdbase:
error(None, language["no_sudo_prog"])
return
cmdbase.extend(cmdend)
misc.LaunchAndWait(cmdbase)
else:
misc.LaunchAndWait(cmdend)
def check_enable(self): def check_enable(self):
""" Disable objects if the profile list is empty. """ """ Disable objects if the profile list is empty. """
profile_list = wired.GetWiredProfileList() profile_list = wired.GetWiredProfileList()
@@ -765,53 +796,39 @@ class WirelessNetworkEntry(NetworkEntry):
self.networkID = networkID self.networkID = networkID
self.image.set_padding(0, 0) self.image.set_padding(0, 0)
self.image.set_alignment(.5, 0) self.image.set_alignment(.5, .5)
self.image.set_size_request(60, -1) self.image.set_size_request(60, -1)
self.image.show()
#self.image.set_from_icon_name("network-wired", 6) #self.image.set_from_icon_name("network-wired", 6)
self.essid = noneToBlankString(wireless.GetWirelessProperty(networkID, self.essid = noneToBlankString(wireless.GetWirelessProperty(networkID,
"essid")) "essid"))
print "ESSID : " + self.essid
# Make the combo box.
self.lbl_strength = GreyLabel() self.lbl_strength = GreyLabel()
self.lbl_encryption = GreyLabel() self.lbl_encryption = GreyLabel()
self.lbl_mac = GreyLabel()
self.lbl_channel = GreyLabel() self.lbl_channel = GreyLabel()
self.lbl_mode = GreyLabel()
self.hbox_status = gtk.HBox(False, 5) print "ESSID : " + self.essid
self.chkbox_autoconnect = gtk.CheckButton(language['automatic_connect']) self.chkbox_autoconnect = gtk.CheckButton(language['automatic_connect'])
# Set the values of the network info labels.
self.set_signal_strength(wireless.GetWirelessProperty(networkID, self.set_signal_strength(wireless.GetWirelessProperty(networkID,
'quality'), 'quality'),
wireless.GetWirelessProperty(networkID, wireless.GetWirelessProperty(networkID,
'strength')) 'strength'))
self.set_mac_address(wireless.GetWirelessProperty(networkID, 'bssid'))
self.set_mode(wireless.GetWirelessProperty(networkID, 'mode'))
self.set_channel(wireless.GetWirelessProperty(networkID, 'channel'))
self.set_encryption(wireless.GetWirelessProperty(networkID, self.set_encryption(wireless.GetWirelessProperty(networkID,
'encryption'), 'encryption'),
wireless.GetWirelessProperty(networkID, wireless.GetWirelessProperty(networkID,
'encryption_method')) 'encryption_method'))
self.set_channel(wireless.GetWirelessProperty(networkID, 'channel'))
# The the expander label. self.name_label.set_use_markup(True)
self.expander.set_use_markup(True) self.name_label.set_label("%s %s %s %s" % (self._escape(self.essid),
self.lbl_strength.get_label(),
self.expander.set_label(self._escape(self.essid) + " " + self.lbl_encryption.get_label(),
self.lbl_strength.get_label() + " " + self.lbl_channel.get_label(),
self.lbl_encryption.get_label() + " " + )
self.lbl_mac.get_label()) )
# Pack the network status HBox.
self.hbox_status.pack_start(self.lbl_strength, True, True)
self.hbox_status.pack_start(self.lbl_encryption, True, True)
self.hbox_status.pack_start(self.lbl_mac, True, True)
self.hbox_status.pack_start(self.lbl_mode, True, True)
self.hbox_status.pack_start(self.lbl_channel, True, True)
# Add the wireless network specific parts to the NetworkEntry # Add the wireless network specific parts to the NetworkEntry
# VBox objects. # VBox objects.
self.vbox_top.pack_start(self.chkbox_autoconnect, False, False) self.vbox_top.pack_start(self.chkbox_autoconnect, False, False)
self.vbox_top.pack_start(self.hbox_status, True, True) # self.vbox_top.pack_start(self.hbox_status, True, True)
if to_bool(self.format_entry(networkID, "automatic")): if to_bool(self.format_entry(networkID, "automatic")):
self.chkbox_autoconnect.set_active(True) self.chkbox_autoconnect.set_active(True)
@@ -820,7 +837,6 @@ class WirelessNetworkEntry(NetworkEntry):
# Connect signals. # Connect signals.
self.chkbox_autoconnect.connect("toggled", self.update_autoconnect) self.chkbox_autoconnect.connect("toggled", self.update_autoconnect)
self.script_button.connect("button-press-event", self.edit_scripts)
# Show everything # Show everything
self.show_all() self.show_all()
@@ -836,6 +852,13 @@ class WirelessNetworkEntry(NetworkEntry):
""" Save wireless network settings. """ """ Save wireless network settings. """
return self.advanced_dialog.save_settings(networkid) return self.advanced_dialog.save_settings(networkid)
def update_autoconnect(self, widget=None):
""" Called when the autoconnect checkbox is toggled. """
wireless.SetWirelessProperty(self.networkID, "automatic",
noneToString(self.chkbox_autoconnect.
get_active()))
wireless.SaveWirelessNetworkProperty(self.networkID, "automatic")
def destroy_called(self, *args): def destroy_called(self, *args):
""" Clean up everything. """ """ Clean up everything. """
self.disconnect(self.wifides) self.disconnect(self.wifides)
@@ -845,6 +868,18 @@ class WirelessNetworkEntry(NetworkEntry):
self.destroy() self.destroy()
del self del self
def update_connect_button(self, state, apbssid):
""" Update the connection/disconnect button for this entry. """
if not apbssid:
apbssid = wireless.GetApBssid()
if state == misc.WIRELESS and \
apbssid == wireless.GetWirelessProperty(self.networkID, "bssid"):
self.disconnect_button.show()
self.connect_button.hide()
else:
self.disconnect_button.hide()
self.connect_button.show()
def set_signal_strength(self, strength, dbm_strength): def set_signal_strength(self, strength, dbm_strength):
""" Set the signal strength displayed in the WirelessNetworkEntry. """ """ Set the signal strength displayed in the WirelessNetworkEntry. """
if strength is not None: if strength is not None:
@@ -883,21 +918,127 @@ class WirelessNetworkEntry(NetworkEntry):
signal_img = 'signal-25.png' signal_img = 'signal-25.png'
ending = "%" ending = "%"
disp_strength = str(strength) disp_strength = str(strength)
self.image.set_from_file(wpath.images + signal_img) self.image.set_from_file(wpath.images + signal_img)
self.lbl_strength.set_label(disp_strength + ending) self.lbl_strength.set_label(disp_strength + ending)
self.image.show()
def update_connect_button(self, state, apbssid): def set_encryption(self, on, ttype):
""" Update the connection/disconnect button for this entry. """ """ Set the encryption value for the WirelessNetworkEntry. """
if not apbssid: if on and ttype:
apbssid = wireless.GetApBssid() self.lbl_encryption.set_label(str(ttype))
if state == misc.WIRELESS and \ if on and not ttype:
apbssid == wireless.GetWirelessProperty(self.networkID, "bssid"): self.lbl_encryption.set_label(language['secured'])
self.disconnect_button.show() if not on:
self.connect_button.hide() self.lbl_encryption.set_label(language['unsecured'])
def set_channel(self, channel):
""" Set the channel value for the WirelessNetworkEntry. """
self.lbl_channel.set_label(language['channel'] + ' ' + str(channel))
def format_entry(self, networkid, label):
""" Helper method for fetching/formatting wireless properties. """
return noneToBlankString(wireless.GetWirelessProperty(networkid, label))
class WirelessInformationDialog(gtk.Dialog):
def __init__(self, networkID):
gtk.Dialog.__init__(self)
# Make the combo box.
self.lbl_strength = gtk.Label()
self.lbl_strength.set_alignment(0, 0.5)
self.lbl_encryption = gtk.Label()
self.lbl_encryption.set_alignment(0, 0.5)
self.lbl_mac = gtk.Label()
self.lbl_mac.set_alignment(0, 0.5)
self.lbl_channel = gtk.Label()
self.lbl_channel.set_alignment(0, 0.5)
self.lbl_mode = gtk.Label()
self.lbl_mode.set_alignment(0, 0.5)
self.hbox_status = gtk.HBox(False, 5)
# Set the values of the network info labels.
self.set_signal_strength(wireless.GetWirelessProperty(networkID,
'quality'),
wireless.GetWirelessProperty(networkID,
'strength'))
self.set_mac_address(wireless.GetWirelessProperty(networkID, 'bssid'))
self.set_mode(wireless.GetWirelessProperty(networkID, 'mode'))
self.set_channel(wireless.GetWirelessProperty(networkID, 'channel'))
self.set_encryption(wireless.GetWirelessProperty(networkID,
'encryption'),
wireless.GetWirelessProperty(networkID,
'encryption_method'))
self.set_title('Network Information')
vbox = self.vbox
self.set_has_separator(False)
table = gtk.Table(5, 2)
table.set_col_spacings(12)
vbox.pack_start(table)
# Pack the network status HBox.
table.attach(LeftAlignedLabel('Signal strength:'), 0, 1, 0, 1)
table.attach(self.lbl_strength, 1, 2, 0, 1)
table.attach(LeftAlignedLabel('Encryption type:'), 0, 1, 1, 2)
table.attach(self.lbl_encryption, 1, 2, 1, 2)
table.attach(LeftAlignedLabel('Access point address:'), 0, 1, 2, 3)
table.attach(self.lbl_mac, 1, 2, 2, 3)
table.attach(LeftAlignedLabel('Mode:'), 0, 1, 3, 4)
table.attach(self.lbl_mode, 1, 2, 3, 4)
table.attach(LeftAlignedLabel('Channel:'), 0, 1, 4, 5)
table.attach(self.lbl_channel, 1, 2, 4, 5)
vbox.show_all()
self.add_button(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE)
self.show()
self.run()
self.destroy()
def set_signal_strength(self, strength, dbm_strength):
""" Set the signal strength displayed in the WirelessNetworkEntry. """
if strength is not None:
strength = int(strength)
else: else:
self.disconnect_button.hide() strength = -1
self.connect_button.show() if dbm_strength is not None:
dbm_strength = int(dbm_strength)
else:
dbm_strength = -100
display_type = daemon.GetSignalDisplayType()
if daemon.GetWPADriver() == 'ralink legacy' or display_type == 1:
# Use the -xx dBm signal strength to display a signal icon
# I'm not sure how accurately the dBm strength is being
# "converted" to strength bars, so suggestions from people
# for a better way would be welcome.
if dbm_strength >= -60:
signal_img = 'signal-100.png'
elif dbm_strength >= -70:
signal_img = 'signal-75.png'
elif dbm_strength >= -80:
signal_img = 'signal-50.png'
else:
signal_img = 'signal-25.png'
ending = "dBm"
disp_strength = str(dbm_strength)
else:
# Uses normal link quality, should be fine in most cases
if strength > 75:
signal_img = 'signal-100.png'
elif strength > 50:
signal_img = 'signal-75.png'
elif strength > 25:
signal_img = 'signal-50.png'
else:
signal_img = 'signal-25.png'
ending = "%"
disp_strength = str(strength)
self.lbl_strength.set_label(disp_strength + ending)
def set_mac_address(self, address): def set_mac_address(self, address):
""" Set the MAC address for the WirelessNetworkEntry. """ """ Set the MAC address for the WirelessNetworkEntry. """
@@ -923,24 +1064,3 @@ class WirelessNetworkEntry(NetworkEntry):
def format_entry(self, networkid, label): def format_entry(self, networkid, label):
""" Helper method for fetching/formatting wireless properties. """ """ Helper method for fetching/formatting wireless properties. """
return noneToBlankString(wireless.GetWirelessProperty(networkid, label)) return noneToBlankString(wireless.GetWirelessProperty(networkid, label))
def edit_scripts(self, widget=None, event=None):
""" Launch the script editting dialog. """
cmdend = [os.path.join(wpath.lib, "configscript.py"),
str(self.networkID), "wireless"]
if os.getuid() != 0:
cmdbase = misc.get_sudo_cmd(language['scripts_need_pass'])
if not cmdbase:
error(None, language["no_sudo_prog"])
return
cmdbase.extend(cmdend)
misc.LaunchAndWait(cmdbase)
else:
misc.LaunchAndWait(cmdend)
def update_autoconnect(self, widget=None):
""" Called when the autoconnect checkbox is toggled. """
wireless.SetWirelessProperty(self.networkID, "automatic",
noneToString(self.chkbox_autoconnect.
get_active()))
wireless.SaveWirelessNetworkProperty(self.networkID, "automatic")

View File

@@ -254,8 +254,10 @@ class PreferencesDialog(object):
if width > -1 and height > -1: if width > -1 and height > -1:
self.dialog.resize(int(width), int(height)) self.dialog.resize(int(width), int(height))
else: else:
self.dialog.resize(gtk.gdk.screen_width() / 3, width = int(gtk.gdk.screen_width() / 2.4)
gtk.gdk.screen_height() / 2) if width > 450:
width = 450
self.dialog.resize(width, int(gtk.gdk.screen_height() / 2))
self.wiredcheckbox = setup_label("pref_always_check", self.wiredcheckbox = setup_label("pref_always_check",
'wired_always_on') 'wired_always_on')

View File

@@ -91,6 +91,7 @@ class WicdDaemon(dbus.service.Object):
self.vpn_session = None self.vpn_session = None
self.gui_open = False self.gui_open = False
self.suspended = False self.suspended = False
self.debug_mode = False
self.connection_state = misc.NOT_CONNECTED self.connection_state = misc.NOT_CONNECTED
self.connection_info = [""] self.connection_info = [""]
self.auto_connecting = False self.auto_connecting = False
@@ -421,6 +422,7 @@ class WicdDaemon(dbus.service.Object):
started. started.
""" """
if self.debug_mode and value: print "Forced disconnect on"
self.forced_disconnect = bool(value) self.forced_disconnect = bool(value)
self.wireless_bus.SetForcedDisconnect(bool(value)) self.wireless_bus.SetForcedDisconnect(bool(value))
self.wired_bus.SetForcedDisconnect(bool(value)) self.wired_bus.SetForcedDisconnect(bool(value))
@@ -630,13 +632,13 @@ class WicdDaemon(dbus.service.Object):
""" """
if win_name == "main": if win_name == "main":
default_width = 605 default_width = -1
default_height = 400 default_height = -1
width_str = "window_width" width_str = "window_width"
height_str = "window_height" height_str = "window_height"
else: else:
default_width = 125 default_width = -1
default_height = 500 default_height = -1
width_str = "pref_width" width_str = "pref_width"
height_str = "pref_height" height_str = "pref_height"