1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-22 05:48:03 +01:00

More tweaking of how the GUI updates the status bar. Should be more efficient now.

This commit is contained in:
Dan O'Reilly
2009-02-04 19:13:06 -05:00
parent 22e134b78e
commit 70c93746dd
3 changed files with 44 additions and 28 deletions

View File

@@ -38,6 +38,7 @@ from wicd import misc
from wicd import wpath
from wicd import dbusmanager
from wicd import prefs
from wicd import netentry
from wicd.misc import noneToString
from wicd.netentry import WiredNetworkEntry, WirelessNetworkEntry
from wicd.prefs import PreferencesDialog
@@ -67,6 +68,7 @@ def setup_dbus(force=True):
else:
return False
prefs.setup_dbus()
netentry.setup_dbus()
bus = dbusmanager.get_bus()
dbus_ifaces = dbusmanager.get_dbus_ifaces()
daemon = dbus_ifaces['daemon']
@@ -91,7 +93,7 @@ class WiredProfileChooser:
""" Initializes and runs the wired profile chooser. """
# Import and init WiredNetworkEntry to steal some of the
# functions and widgets it uses.
wired_net_entry = WiredNetworkEntry(dbusmanager.get_dbus_ifaces())
wired_net_entry = WiredNetworkEntry()
dialog = gtk.Dialog(title = language['wired_network_found'],
flags = gtk.DIALOG_MODAL,
@@ -213,14 +215,17 @@ class appGui(object):
'ConnectResultsSent', 'org.wicd.daemon')
bus.add_signal_receiver(lambda: setup_dbus(force=False),
"DaemonStarting", "org.wicd.daemon")
bus.add_signal_receiver(self._do_statusbar_update, 'StatusChanged',
'org.wicd.daemon')
if standalone:
bus.add_signal_receiver(handle_no_dbus, "DaemonClosing",
"org.wicd.daemon")
try:
gobject.timeout_add_seconds(2, self.update_statusbar)
except:
gobject.timeout_add(2000, self.update_statusbar)
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._do_statusbar_update(*daemon.GetConnectionStatus())
self.refresh_clicked()
def handle_connection_results(self, results):
@@ -349,18 +354,17 @@ class appGui(object):
return True
def update_statusbar(self):
""" Updates the status bar
Queries the daemon for network connection information and
updates the GUI status bar based on the results.
"""
""" Triggers a status update in wicd-monitor. """
if not self.is_visible or self.refreshing:
return True
daemon.UpdateState()
[state, info] = daemon.GetConnectionStatus()
return True
def _do_statusbar_update(self, state, info):
if not self.is_visible or self.refreshing:
return True
if state == misc.WIRED:
return self.set_wired_state(info)
elif state == misc.WIRELESS:
@@ -485,7 +489,7 @@ class appGui(object):
if wired.CheckPluggedIn() or daemon.GetAlwaysShowWiredInterface():
printLine = True # In this case we print a separator.
wirednet = WiredNetworkEntry(dbusmanager.get_dbus_ifaces())
wirednet = WiredNetworkEntry()
self.network_list.pack_start(wirednet, False, False)
wirednet.connect_button.connect("button-press-event", self.connect,
"wired", 0, wirednet)
@@ -499,7 +503,6 @@ class appGui(object):
instruct_label = self.wTree.get_widget("label_instructions")
if num_networks > 0:
instruct_label.show()
dbus_ifaces = dbusmanager.get_dbus_ifaces()
for x in range(0, num_networks):
if printLine:
sep = gtk.HSeparator()
@@ -508,7 +511,7 @@ class appGui(object):
sep.show()
else:
printLine = True
tempnet = WirelessNetworkEntry(x, dbus_ifaces)
tempnet = WirelessNetworkEntry(x)
self.network_list.pack_start(tempnet, False, False)
tempnet.connect_button.connect("button-press-event",
self.connect, "wireless", x,
@@ -676,6 +679,9 @@ class appGui(object):
"""
self.window.hide()
gobject.source_remove(self.update_cb)
bus.remove_signal_receiver(self._do_statusbar_update, 'StatusChanged',
'org.wicd.daemon')
[width, height] = self.window.get_size()
try:
daemon.WriteWindowSize(width, height, "main")
@@ -702,6 +708,12 @@ class appGui(object):
daemon.SetGUIOpen(True)
self.wait_for_events(0.1)
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)
if __name__ == '__main__':