1
0
mirror of https://github.com/gryf/wicd.git synced 2026-02-19 00:15:47 +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._do_statusbar_update(*daemon.GetConnectionStatus())
self.wait_for_events(0.1) self.wait_for_events(0.1)
if hasattr(gobject, "timeout_add_seconds"): self.update_cb = misc.timeout_add(2, self.update_statusbar)
self.update_cb = gobject.timeout_add_seconds(2, self.update_statusbar)
else:
self.update_cb = gobject.timeout_add(2000, self.update_statusbar)
self.refresh_clicked() self.refresh_clicked()
def handle_connection_results(self, results): def handle_connection_results(self, results):
@@ -412,7 +409,7 @@ class appGui(object):
self.connecting = True self.connecting = True
if not self.pulse_active: if not self.pulse_active:
self.pulse_active = True 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.network_list.set_sensitive, False)
gobject.idle_add(self.status_area.show_all) gobject.idle_add(self.status_area.show_all)
if self.statusID: if self.statusID:
@@ -715,10 +712,7 @@ class appGui(object):
gobject.idle_add(self.refresh_clicked) gobject.idle_add(self.refresh_clicked)
bus.add_signal_receiver(self._do_statusbar_update, 'StatusChanged', bus.add_signal_receiver(self._do_statusbar_update, 'StatusChanged',
'org.wicd.daemon') 'org.wicd.daemon')
if hasattr(gobject, "timeout_add_seconds"): self.update_cb = misc.timeout_add(2, self.update_statusbar)
self.update_cb = gobject.timeout_add_seconds(2, self.update_statusbar)
else:
self.update_cb = gobject.timeout_add(2000, self.update_statusbar)
if __name__ == '__main__': if __name__ == '__main__':

View File

@@ -22,6 +22,7 @@ import locale
import gettext import gettext
import sys import sys
import re import re
import gobject
from threading import Thread from threading import Thread
from subprocess import Popen, STDOUT, PIPE, call from subprocess import Popen, STDOUT, PIPE, call
from commands import getoutput from commands import getoutput
@@ -421,7 +422,6 @@ def choose_sudo_prog(prog_num=0):
for path in paths: for path in paths:
if os.path.exists(path): if os.path.exists(path):
print "returning %s" % path
return path return path
return None return None
@@ -461,6 +461,7 @@ def get_language_list_gui():
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'] = _('Advanced Settings')
language['properties'] = _('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'
@@ -656,3 +657,11 @@ def threaded(f):
wrapper.__module__ = f.__module__ wrapper.__module__ = f.__module__
return wrapper 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(): def add_poll_callback():
global monitor, to_time, update_callback global monitor, to_time, update_callback
if hasattr(gobject, "timeout_add_seconds"): update_callback = misc.timeout_add(to_time,
update_callback = gobject.timeout_add_seconds(to_time, monitor.update_connection_status)
monitor.update_connection_status)
else:
update_callback = gobject.timeout_add(to_time * 1000,
monitor.update_connection_status)
def main(): def main():
""" Starts the connection monitor. """ Starts the connection monitor.

View File

@@ -45,7 +45,7 @@ class AdvancedSettingsDialog(gtk.Dialog):
the WiredSettingsDialog and WirelessSettingsDialog. 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, flags=gtk.DIALOG_MODAL, buttons=(gtk.STOCK_CANCEL,
gtk.RESPONSE_REJECT, gtk.RESPONSE_REJECT,
gtk.STOCK_OK, gtk.STOCK_OK,
@@ -149,7 +149,6 @@ class AdvancedSettingsDialog(gtk.Dialog):
self.chkbox_static_dns.set_sensitive(False) self.chkbox_static_dns.set_sensitive(False)
else: else:
self.chkbox_static_dns.set_sensitive(True) 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_ip.set_sensitive(self.chkbox_static_ip.get_active())
self.txt_netmask.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_from_stock(gtk.STOCK_EDIT, 4)
self.advanced_image.set_padding(4, 0) self.advanced_image.set_padding(4, 0)
self.advanced_button.set_alignment(.5, .5) 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.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.connect_hbox, False, False)
self.buttons_hbox.pack_start(self.advanced_button, False, False) self.buttons_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.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.name_label)
self.expander_vbox.pack_start(self.vbox_top) self.expander_vbox.pack_start(self.vbox_top)
self.expander_vbox.pack_start(self.buttons_hbox) self.expander_vbox.pack_start(self.buttons_hbox)
@@ -550,7 +544,6 @@ class WiredNetworkEntry(NetworkEntry):
self.name_label.set_label(language['wired_network']) self.name_label.set_label(language['wired_network'])
#self.reset_static_checkboxes()
self.is_full_gui = True self.is_full_gui = True
self.button_add = gtk.Button(stock=gtk.STOCK_ADD) 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 # 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)
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)
@@ -813,11 +805,11 @@ class WirelessNetworkEntry(NetworkEntry):
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:
strength = int(strength) strength = int(strength)
else: else:
strength = -1 strength = -1
if dbm_strength is not None: if dbm_strength:
dbm_strength = int(dbm_strength) dbm_strength = int(dbm_strength)
else: else:
dbm_strength = -100 dbm_strength = -100

View File

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

View File

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

View File

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