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:
parent
58e4e1b2f4
commit
4f0882ebbe
6
TODO
6
TODO
|
@ -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
|
||||
|
|
|
@ -522,6 +522,10 @@ class Core(
|
|||
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):
|
||||
log.debug("Attempting to queue %s to top", torrent_ids)
|
||||
|
|
|
@ -154,6 +154,7 @@ class Torrent:
|
|||
component.get("TorrentManager").append_not_state_paused(self.torrent_id)
|
||||
self.handle.pause()
|
||||
|
||||
if state != self.state:
|
||||
self.state = state
|
||||
|
||||
# Update the torrentqueue on any state changes
|
||||
|
|
|
@ -126,8 +126,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]:
|
||||
num_to_queue = max(self.downloading)[0] - min(self.queued_downloading)[0]
|
||||
|
@ -136,8 +134,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:
|
||||
if len(self.seeding) > self.config["max_active_seeding"]:
|
||||
|
@ -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"""
|
||||
|
|
|
@ -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,
|
||||
|
@ -148,6 +149,11 @@ class StatusBar(component.Component):
|
|||
self.upload_item.get_eventbox(), expand=False, fill=False)
|
||||
self.dht_item = StatusBarItem(
|
||||
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")
|
||||
|
|
Loading…
Reference in New Issue