From 76d5bc935a093080fa789bb5634dadde72435970 Mon Sep 17 00:00:00 2001 From: Kevin Woo Date: Fri, 24 Apr 2009 13:26:50 -0400 Subject: [PATCH] Cleaned up docstrings and aligned connection summary window text. --- wicd/translations.py | 4 ++-- wicd/wicd-client.py | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/wicd/translations.py b/wicd/translations.py index c298791..c690484 100644 --- a/wicd/translations.py +++ b/wicd/translations.py @@ -85,8 +85,8 @@ language['tray_connected_to_wireless'] = _('Wireless Network\n$A at $B\nSpeed: $ language['connected_to_wired'] = _('Connected to wired network (IP: $A)') language['tray_connected_to_wired'] = _('Wired Network\nIP: $A') language['not_connected'] = _('Not connected') -language['conn_info_wired'] = _('Wired\nIP: $A\nRX: $B KB/s\nTX: $C KB/s') -language['conn_info_wireless'] = _('Wireless\nSSID: $A\nSpeed $B\nIP: $C\nStrength: $D\nRX: $E KB/s\nTX: $F KB/s') +language['conn_info_wired'] = _('Wired\nIP:\t\t$A\nRX:\t\t$B KB/s\nTX:\t\t$C KB/s\n\n\n') +language['conn_info_wireless'] = _('Wireless\nSSID:\t$A\nSpeed\t$B\nIP:\t\t$C\nStrength:\t$D\nRX:\t\t$E KB/s\nTX:\t\t$F KB/s') language['no_wireless_networks_found'] = _('No wireless networks found.') language['killswitch_enabled'] = _('Wireless Kill Switch Enabled') language['key'] = _('Key') diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index a94e1e9..ee04674 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -133,6 +133,7 @@ class TrayIcon(object): return self.tr.is_embedded() def get_bandwidth_bytes(self): + """ Gets the amount of byte sent sine the last time I checked """ dev_dir = '/sys/class/net/' iface = daemon.GetCurrentInterface() @@ -151,7 +152,7 @@ class TrayIcon(object): class TrayConnectionInfo(object): """ Class for updating the tray icon status. """ def __init__(self, parent, tr, animate=True): - """ Initialize variables needed for the icon status methods. """ + # Initialize variables needed for the icon status methods. self.last_strength = -2 self.tried_reconnect = False self.connection_lost_counter = 0 @@ -171,10 +172,13 @@ class TrayIcon(object): handle_no_dbus() self.set_not_connected_state() - """ Initial update of the tooltip """ - self.update_tooltip + # Initial update of the tooltip + self.update_tooltip() def update_tooltip(self): + """ + Updates the trayicon tooltip based on current connection status + """ if (self.network_type == "none"): self.tr.set_tooltip(language['not_connected']) elif (self.network_type == "wireless"): @@ -405,7 +409,7 @@ class TrayIcon(object): net_menuitem.connect("activate", self.on_net_menu_activate) self.parent = parent - self.time = 2 + self.time = 2 # Time between updates self.cont = 'Stop' self.conn_info_txt = '' @@ -450,24 +454,24 @@ class TrayIcon(object): msg = gtk.Label() msg.show() - """ Start updates """ + # Start updates self.cont = 'Go' gobject.timeout_add(5000, self.update_conn_info_win, msg) self.update_conn_info_win(msg) - """ Setup Window """ + # Setup Window content = window.get_content_area() content.pack_start(msg, True, True, 0) content.visible = True window.run() - """ Destroy window and stop updates """ + # Destroy window and stop updates window.destroy() self.cont = 'Stop' def update_conn_info_win(self, msg): - + """ Updates the information in the connection summary window """ if (self.cont == "Stop"): return False @@ -496,6 +500,10 @@ class TrayIcon(object): return True def get_current_bandwidth(self): + """ + Calculates the current bandwidth based on sent/received bytes + divided over time. Unit is in KB/s + """ self.parent.get_bandwidth_bytes() rxb = self.parent.cur_rcvbytes - self.parent.last_rcvbytes txb = self.parent.cur_sndbytes - self.parent.last_sndbytes