From 1c9c765cb16565ffa42df46cc0495dd57808d21c Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Mon, 21 Jan 2008 01:58:19 +0000 Subject: [PATCH] Change update intervals of several components. Have StatusBar update the respected label when it receives a 'config_value_changed' signal. --- deluge/ui/gtkui/statusbar.py | 24 ++++++++++++++++++------ deluge/ui/gtkui/systemtray.py | 2 +- deluge/ui/gtkui/torrentdetails.py | 2 +- deluge/ui/gtkui/torrentview.py | 4 ++-- 4 files changed, 22 insertions(+), 10 deletions(-) diff --git a/deluge/ui/gtkui/statusbar.py b/deluge/ui/gtkui/statusbar.py index 3428ad27d..53f58e7c2 100644 --- a/deluge/ui/gtkui/statusbar.py +++ b/deluge/ui/gtkui/statusbar.py @@ -93,7 +93,7 @@ class StatusBarItem: class StatusBar(component.Component): def __init__(self): - component.Component.__init__(self, "StatusBar") + component.Component.__init__(self, "StatusBar", interval=3000) self.window = component.get("MainWindow") self.statusbar = self.window.main_glade.get_widget("statusbar") @@ -193,23 +193,26 @@ class StatusBar(component.Component): def _on_max_connections_global(self, max_connections): self.max_connections = max_connections + self.update_connections_label() def _on_get_num_connections(self, num_connections): self.num_connections = num_connections def _on_max_download_speed(self, max_download_speed): self.max_download_speed = max_download_speed + self.update_download_label() def _on_get_download_rate(self, download_rate): self.download_rate = deluge.common.fsize(download_rate) def _on_max_upload_speed(self, max_upload_speed): self.max_upload_speed = max_upload_speed - + self.update_upload_label() + def _on_get_upload_rate(self, upload_rate): self.upload_rate = deluge.common.fsize(upload_rate) - - def update(self): + + def update_connections_label(self): # Set the max connections label max_connections = self.max_connections if max_connections < 0: @@ -217,7 +220,8 @@ class StatusBar(component.Component): self.connections_item.set_text("%s (%s)" % ( self.num_connections, max_connections)) - + + def update_download_label(self): # Set the download speed label max_download_speed = self.max_download_speed if max_download_speed < 0: @@ -227,7 +231,8 @@ class StatusBar(component.Component): self.download_item.set_text("%s/s (%s)" % ( self.download_rate, max_download_speed)) - + + def update_upload_label(self): # Set the upload speed label max_upload_speed = self.max_upload_speed if max_upload_speed < 0: @@ -238,5 +243,12 @@ class StatusBar(component.Component): self.upload_item.set_text("%s/s (%s)" % ( self.upload_rate, max_upload_speed)) + + def update(self): + # Update the labels + self.update_connections_label() + self.update_download_label() + self.update_upload_label() + # Send status request self.send_status_request() diff --git a/deluge/ui/gtkui/systemtray.py b/deluge/ui/gtkui/systemtray.py index ac2fa6d79..828d1771e 100644 --- a/deluge/ui/gtkui/systemtray.py +++ b/deluge/ui/gtkui/systemtray.py @@ -42,7 +42,7 @@ from deluge.log import LOG as log class SystemTray(component.Component): def __init__(self): - component.Component.__init__(self, "SystemTray") + component.Component.__init__(self, "SystemTray", interval=4000) self.window = component.get("MainWindow") self.config = ConfigManager("gtkui.conf") # List of widgets that need to be hidden when not connected to a host diff --git a/deluge/ui/gtkui/torrentdetails.py b/deluge/ui/gtkui/torrentdetails.py index f47c4b1e4..f9d63d894 100644 --- a/deluge/ui/gtkui/torrentdetails.py +++ b/deluge/ui/gtkui/torrentdetails.py @@ -57,7 +57,7 @@ def fpcnt(value): class TorrentDetails(component.Component): def __init__(self): - component.Component.__init__(self, "TorrentDetails") + component.Component.__init__(self, "TorrentDetails", interval=2000) self.window = component.get("MainWindow") glade = self.window.main_glade diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index da4ce2cd8..f3a641267 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -102,7 +102,7 @@ def cell_data_progress(column, cell, model, row, data): class TorrentView(listview.ListView, component.Component): """TorrentView handles the listing of torrents.""" def __init__(self): - component.Component.__init__(self, "TorrentView") + component.Component.__init__(self, "TorrentView", interval=2000) self.window = component.get("MainWindow") # Call the ListView constructor listview.ListView.__init__(self, @@ -113,7 +113,7 @@ class TorrentView(listview.ListView, component.Component): # This is where status updates are put self.status = {} - + # Register the columns menu with the listview so it gets updated # accordingly. self.register_checklist_menu(