Add Network Health icon to StatusBar.

Fix issue of adding a torrent to the top of the queue if no torrents in 
the session.
This commit is contained in:
Andrew Resch 2008-03-10 07:32:25 +00:00
parent 58e4e1b2f4
commit 4f0882ebbe
5 changed files with 40 additions and 24 deletions

6
TODO
View File

@ -1,17 +1,12 @@
* Queue plugin 'apply_queue' stuff.. Just finishing the queue plugin and it's
intended functionality.
* Figure out easy way for user-made plugins to add i18n support.
* Restart daemon function
* Docstrings!
* Implement open folder
* Maybe add pop-up menus to the status bar items
* Address issue where torrents will redownload if the storage is moved outside
of deluge.
* Implement 'Classic' mode
* Add autoload folder
* Add wizard
* Add a health indication to the statusbar
* Fix up preferences for when using a remote host.. the download folders, etc..
* Add decay items to statusbar.. items that will disappear after X seconds
* Add command line option to change config dir.. --config
* Add method for plugins to add labels
@ -20,7 +15,6 @@
* Use the batch torrent status info as a cache for other torrent status requests
* Don't save fastresume files on exit for finished or paused torrents
* Add Files and Peers tabs, but make them optional through View menu
* Add per-torrent speed settings to the torrent menu
* Add per-torrent settings to the details pane.. max_download_speed, etc.. So
the user know what limits are set on the torrent.
* Add number of torrents to labels

View File

@ -521,6 +521,10 @@ class Core(
"""Clears the ip filter"""
self.ip_filter = lt.ip_filter()
self.session.set_ip_filter(self.ip_filter)
def export_get_health(self):
"""Returns True if we have established incoming connections"""
return self.session.status().has_incoming_connections
## Queueing functions ##
def export_queue_top(self, torrent_ids):

View File

@ -154,10 +154,11 @@ class Torrent:
component.get("TorrentManager").append_not_state_paused(self.torrent_id)
self.handle.pause()
self.state = state
if state != self.state:
self.state = state
# Update the torrentqueue on any state changes
self.torrentqueue.update_queue()
# Update the torrentqueue on any state changes
self.torrentqueue.update_queue()
def get_eta(self):
"""Returns the ETA in seconds for this torrent"""

View File

@ -125,8 +125,6 @@ class TorrentQueue(component.Component):
for (pos, torrent_id) in self.seeding[-num_to_queue:]:
self.torrents[torrent_id].set_state("Queued")
self.update_state_lists()
if self.downloading != [] and self.queued_downloading != []:
if min(self.queued_downloading)[0] < max(self.downloading)[0]:
@ -135,8 +133,6 @@ class TorrentQueue(component.Component):
for (pos, torrent_id) in self.downloading[-num_to_queue:]:
self.torrents[torrent_id].set_state("Queued")
self.update_state_lists()
def update_max_active(self):
if self.config["max_active_seeding"] > -1:
@ -221,19 +217,23 @@ class TorrentQueue(component.Component):
for q in self.queue:
if q == None:
self.queue[self.queue.index(q)] = torrent_id
break
return self.queue.index(q)
else:
if self.queue[position] == None:
if position > (len(self.queue) - 1):
self.queue.insert(position, torrent_id)
try:
value = self.queue[position]
except KeyError:
self.queue.insert(position, torrent_id)
return position
if value == None:
self.queue[position] = torrent_id
else:
self.queue.insert(position, torrent_id)
try:
return self.queue.index(torrent_id)
except ValueError:
self.queue.append(torrent_id)
return self.queue.index(torrent_id)
return position
def remove(self, torrent_id):
"""Removes torrent_id from the list"""

View File

@ -108,6 +108,7 @@ class StatusBar(component.Component):
self.upload_rate = 0.0
self.dht_nodes = 0
self.dht_status = False
self.health = False
self.config_value_changed_dict = {
"max_connections_global": self._on_max_connections_global,
@ -147,7 +148,12 @@ class StatusBar(component.Component):
self.hbox.pack_start(
self.upload_item.get_eventbox(), expand=False, fill=False)
self.dht_item = StatusBarItem(
image=deluge.common.get_pixmap("dht16.png"))
image=deluge.common.get_pixmap("dht16.png"))
self.health_item = self.add_item(
stock=gtk.STOCK_NO,
text=_("No Incoming Connections!"),
callback=self._on_health_icon_clicked)
# Get some config values
client.get_config_value(
@ -158,6 +164,7 @@ class StatusBar(component.Component):
self._on_max_upload_speed, "max_upload_speed")
client.get_config_value(
self._on_dht, "dht")
client.get_health(self._on_get_health)
self.send_status_request()
@ -169,6 +176,7 @@ class StatusBar(component.Component):
self.remove_item(self.download_item)
self.remove_item(self.upload_item)
self.remove_item(self.not_connected_item)
self.remove_item(self.heath_item)
except Exception, e:
log.debug("Unable to remove StatusBar item: %s", e)
self.show_not_connected()
@ -204,6 +212,9 @@ class StatusBar(component.Component):
client.get_dht_nodes(self._on_get_dht_nodes)
client.get_download_rate(self._on_get_download_rate)
client.get_upload_rate(self._on_get_upload_rate)
if not self.health:
# Only request health status while False
client.get_health(self._on_get_health)
def config_value_changed(self, key, value):
"""This is called when we received a config_value_changed signal from
@ -249,6 +260,11 @@ class StatusBar(component.Component):
self.upload_rate = deluge.common.fsize(upload_rate)
self.update_upload_label()
def _on_get_health(self, value):
self.health = value
if self.health:
self.remove_item(self.health_item)
def update_connections_label(self):
# Set the max connections label
if self.max_connections < 0:
@ -371,4 +387,5 @@ class StatusBar(component.Component):
if value != self.max_connections:
client.set_config({"max_connections_global": value})
def _on_health_icon_clicked(self, widget, event):
component.get("Preferences").show("Network")