1
0
mirror of https://github.com/gryf/wicd.git synced 2026-02-14 12:55:49 +01:00

Change "Advanced Settings" to "Properties"

Remove some unneeded debugging output.
Replace gobject.timeout_add_seconds / gobject.timeout_add if/else logic with calls to a misc.timeout_add method that does it internally.
Only display the dbus lost error message if dbus has been gone for 5 seconds without coming back.
This commit is contained in:
Dan O'Reilly
2009-02-10 00:58:11 -05:00
parent 896510324d
commit 30b59d1a59
7 changed files with 30 additions and 40 deletions

View File

@@ -223,10 +223,7 @@ class appGui(object):
self._do_statusbar_update(*daemon.GetConnectionStatus())
self.wait_for_events(0.1)
if hasattr(gobject, "timeout_add_seconds"):
self.update_cb = gobject.timeout_add_seconds(2, self.update_statusbar)
else:
self.update_cb = gobject.timeout_add(2000, self.update_statusbar)
self.update_cb = misc.timeout_add(2, self.update_statusbar)
self.refresh_clicked()
def handle_connection_results(self, results):
@@ -412,7 +409,7 @@ class appGui(object):
self.connecting = True
if not self.pulse_active:
self.pulse_active = True
gobject.timeout_add(100, self.pulse_progress_bar)
misc.timeout_add(100, self.pulse_progress_bar, milli=True)
gobject.idle_add(self.network_list.set_sensitive, False)
gobject.idle_add(self.status_area.show_all)
if self.statusID:
@@ -715,10 +712,7 @@ class appGui(object):
gobject.idle_add(self.refresh_clicked)
bus.add_signal_receiver(self._do_statusbar_update, 'StatusChanged',
'org.wicd.daemon')
if hasattr(gobject, "timeout_add_seconds"):
self.update_cb = gobject.timeout_add_seconds(2, self.update_statusbar)
else:
self.update_cb = gobject.timeout_add(2000, self.update_statusbar)
self.update_cb = misc.timeout_add(2, self.update_statusbar)
if __name__ == '__main__':

View File

@@ -22,6 +22,7 @@ import locale
import gettext
import sys
import re
import gobject
from threading import Thread
from subprocess import Popen, STDOUT, PIPE, call
from commands import getoutput
@@ -421,7 +422,6 @@ def choose_sudo_prog(prog_num=0):
for path in paths:
if os.path.exists(path):
print "returning %s" % path
return path
return None
@@ -461,6 +461,7 @@ def get_language_list_gui():
language['use_static_dns'] = _('Use Static DNS')
language['use_encryption'] = _('Use Encryption')
language['advanced_settings'] = _('Advanced Settings')
language['properties'] = _('Properties')
language['wired_network'] = _('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'
@@ -656,3 +657,11 @@ def threaded(f):
wrapper.__module__ = f.__module__
return wrapper
def timeout_add(time, func, milli=False):
""" Convience function for running a function on a timer. """
if hasattr(gobject, "timeout_add_seconds") and not milli:
return gobject.timeout_add_seconds(time, func)
else:
return gobject.timeout_add(time * 1000, func)

View File

@@ -330,12 +330,8 @@ def err_handle(error):
def add_poll_callback():
global monitor, to_time, update_callback
if hasattr(gobject, "timeout_add_seconds"):
update_callback = gobject.timeout_add_seconds(to_time,
monitor.update_connection_status)
else:
update_callback = gobject.timeout_add(to_time * 1000,
monitor.update_connection_status)
update_callback = misc.timeout_add(to_time,
monitor.update_connection_status)
def main():
""" Starts the connection monitor.

View File

@@ -45,7 +45,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
the WiredSettingsDialog and WirelessSettingsDialog.
"""
gtk.Dialog.__init__(self, title=language['advanced_settings'],
gtk.Dialog.__init__(self, title=language['properties'],
flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_CANCEL,
gtk.RESPONSE_REJECT,
gtk.STOCK_OK,
@@ -149,7 +149,6 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.chkbox_static_dns.set_sensitive(False)
else:
self.chkbox_static_dns.set_sensitive(True)
#self.chkbox_static_dns.set_active(False)
self.txt_ip.set_sensitive(self.chkbox_static_ip.get_active())
self.txt_netmask.set_sensitive(self.chkbox_static_ip.get_active())
@@ -513,18 +512,13 @@ class NetworkEntry(gtk.HBox):
self.advanced_image.set_from_stock(gtk.STOCK_EDIT, 4)
self.advanced_image.set_padding(4, 0)
self.advanced_button.set_alignment(.5, .5)
self.advanced_button.set_label(language['advanced_settings'])
self.advanced_button.set_label(language['properties'])
self.advanced_button.set_image(self.advanced_image)
#self.buttons_hbox.pack_start(self.script_button, False, False)
self.buttons_hbox.pack_start(self.connect_hbox, False, False)
self.buttons_hbox.pack_start(self.advanced_button, False, False)
self.vbox_top = gtk.VBox(False, 0)
#self.vbox_top.pack_end(self.buttons_hbox, False, False)
#self.vbox_top.pack_end(self.connect_hbox, False, False)
self.expander_vbox.pack_start(self.name_label)
self.expander_vbox.pack_start(self.vbox_top)
self.expander_vbox.pack_start(self.buttons_hbox)
@@ -550,7 +544,6 @@ class WiredNetworkEntry(NetworkEntry):
self.name_label.set_label(language['wired_network'])
#self.reset_static_checkboxes()
self.is_full_gui = True
self.button_add = gtk.Button(stock=gtk.STOCK_ADD)
@@ -759,7 +752,6 @@ class WirelessNetworkEntry(NetworkEntry):
# Add the wireless network specific parts to the NetworkEntry
# VBox objects.
self.vbox_top.pack_start(self.chkbox_autoconnect, False, False)
# self.vbox_top.pack_start(self.hbox_status, True, True)
if to_bool(self.format_entry(networkID, "automatic")):
self.chkbox_autoconnect.set_active(True)
@@ -813,11 +805,11 @@ class WirelessNetworkEntry(NetworkEntry):
def set_signal_strength(self, strength, dbm_strength):
""" Set the signal strength displayed in the WirelessNetworkEntry. """
if strength is not None:
if strength:
strength = int(strength)
else:
strength = -1
if dbm_strength is not None:
if dbm_strength:
dbm_strength = int(dbm_strength)
else:
dbm_strength = -100

View File

@@ -254,7 +254,6 @@ class ConnectThread(threading.Thread):
"""
is_connecting = None
connecting_thread = None
should_die = False
lock = thread.allocate_lock()

View File

@@ -69,7 +69,7 @@ misc.RenameProcess("wicd-client")
if __name__ == '__main__':
wpath.chdir(__file__)
daemon = wireless = wired = None
daemon = wireless = wired = lost_dbus_id = None
DBUS_AVAIL = False
language = misc.get_language_list_tray()
@@ -664,7 +664,7 @@ Arguments:
""" % wpath.version
def setup_dbus(force=True):
global daemon, wireless, wired, DBUS_AVAIL
global daemon, wireless, wired, DBUS_AVAIL, lost_dbus_id
print "Connecting to daemon..."
try:
dbusmanager.connect_to_dbus()
@@ -681,13 +681,15 @@ def setup_dbus(force=True):
else:
return False
if lost_dbus_id:
gobject.source_remove(lost_dbus_id)
lost_dbus_id = None
dbus_ifaces = dbusmanager.get_dbus_ifaces()
daemon = dbus_ifaces['daemon']
wireless = dbus_ifaces['wireless']
wired = dbus_ifaces['wired']
DBUS_AVAIL = True
print "Connected."
return True
def on_exit():
@@ -698,11 +700,13 @@ def on_exit():
pass
def handle_no_dbus():
global DBUS_AVAIL
""" Called when dbus announces its shutting down. """
global DBUS_AVAIL, lost_dbus_id
DBUS_AVAIL = False
gui.handle_no_dbus(from_tray=True)
print "Wicd daemon is shutting down!"
error(None, language['lost_dbus'], block=False)
lost_dbus_id = misc.timeout_add(5, lambda:error(None, language['lost_dbus'],
block=False))
return False
def main(argv):

View File

@@ -1012,10 +1012,7 @@ class WirelessDaemon(dbus.service.Object):
value = self.LastScan[networkid].get(property)
except IndexError:
return ""
try:
value = misc.to_unicode(value)
except:
pass
value = misc.to_unicode(value)
return value
@dbus.service.method('org.wicd.daemon.wireless')
@@ -1027,14 +1024,13 @@ class WirelessDaemon(dbus.service.Object):
+ " permitted."
return False
self.LastScan[networkid][property] = misc.Noneify(value)
#end function SetProperty
@dbus.service.method('org.wicd.daemon.wireless')
def DetectWirelessInterface(self):
""" Returns an automatically detected wireless interface. """
iface = self.wifi.DetectWirelessInterface()
if iface:
print 'automatically detected wireless interface ' + iface
print 'Automatically detected wireless interface ' + iface
else:
print "Couldn't detect a wireless interface."
return str(iface)