mirror of
https://github.com/codex-storage/deluge.git
synced 2025-01-12 12:34:43 +00:00
Modify common.TORRENT_STATE to be a list instead of a dictionary. The
state is now sent as a string instead of an int. This will break UIs.
This commit is contained in:
parent
eb15b5da37
commit
87a59662e4
@ -51,14 +51,16 @@ LT_TORRENT_STATE = {
|
||||
"Paused": 8
|
||||
}
|
||||
|
||||
TORRENT_STATE = {
|
||||
"Allocating": 0,
|
||||
"Checking": 1,
|
||||
"Downloading": 2,
|
||||
"Seeding": 3,
|
||||
"Paused": 4,
|
||||
"Error": 5
|
||||
}
|
||||
TORRENT_STATE = [
|
||||
"Allocating",
|
||||
"Checking",
|
||||
"Downloading",
|
||||
"Seeding",
|
||||
"Paused",
|
||||
"Error",
|
||||
"Queued"
|
||||
]
|
||||
|
||||
def get_version():
|
||||
"""Returns the program version from the egg metadata"""
|
||||
return pkg_resources.require("Deluge")[0].version.split("r")[0]
|
||||
|
@ -67,7 +67,7 @@ class Torrent:
|
||||
# Where the torrent is being saved to
|
||||
self.save_path = save_path
|
||||
# The state of the torrent
|
||||
self.state = None
|
||||
self.state = "Paused"
|
||||
|
||||
# Holds status info so that we don't need to keep getting it from lt
|
||||
self.status = self.handle.status()
|
||||
@ -146,15 +146,16 @@ class Torrent:
|
||||
def set_state(self, state):
|
||||
"""Accepts state strings, ie, "Paused", "Seeding", etc."""
|
||||
|
||||
if state not in TORRENT_STATE:
|
||||
log.debug("Trying to set an invalid state %s", state)
|
||||
return
|
||||
|
||||
# Only set 'Downloading' or 'Seeding' state if not paused
|
||||
if state == "Downloading" or state == "Seeding":
|
||||
if self.handle.is_paused():
|
||||
state = "Paused"
|
||||
|
||||
try:
|
||||
self.state = TORRENT_STATE[state]
|
||||
except:
|
||||
pass
|
||||
self.state = state
|
||||
|
||||
def get_eta(self):
|
||||
"""Returns the ETA in seconds for this torrent"""
|
||||
@ -308,7 +309,7 @@ class Torrent:
|
||||
|
||||
def resume(self):
|
||||
"""Resumes this torrent"""
|
||||
if self.state != TORRENT_STATE["Paused"]:
|
||||
if self.state != "Paused":
|
||||
return False
|
||||
|
||||
try:
|
||||
|
@ -41,6 +41,16 @@ class TorrentQueue(component.Component):
|
||||
# This is a list of torrent_ids in the queueing order
|
||||
self.queue = []
|
||||
|
||||
self.torrents = component.get("TorrentManager")
|
||||
|
||||
def update(self):
|
||||
pass
|
||||
# seeding = []
|
||||
# downloading = []
|
||||
|
||||
# for torrent_id in self.torrents.get_torrent_list():
|
||||
# if self.torrents[torrent_id].get_status(["state"],
|
||||
|
||||
def set_size(self, size):
|
||||
"""Clear and set the self.queue list to the length of size"""
|
||||
log.debug("Setting queue size to %s..", size)
|
||||
|
@ -462,7 +462,7 @@ class ListView:
|
||||
|
||||
return True
|
||||
|
||||
def add_texticon_column(self, header, col_types=[int, str],
|
||||
def add_texticon_column(self, header, col_types=[str, str],
|
||||
sortid=1,
|
||||
hidden=False,
|
||||
position=None,
|
||||
|
@ -38,8 +38,6 @@ import deluge.component as component
|
||||
import deluge.common
|
||||
from deluge.log import LOG as log
|
||||
|
||||
TORRENT_STATE = deluge.common.TORRENT_STATE
|
||||
|
||||
class SideBar(component.Component):
|
||||
def __init__(self):
|
||||
component.Component.__init__(self, "SideBar")
|
||||
@ -104,11 +102,11 @@ class SideBar(component.Component):
|
||||
component.get("TorrentView").set_filter(None, None)
|
||||
if value == "Downloading":
|
||||
component.get("TorrentView").set_filter("state",
|
||||
TORRENT_STATE["Downloading"])
|
||||
"Downloading")
|
||||
if value == "Seeding":
|
||||
component.get("TorrentView").set_filter("state",
|
||||
TORRENT_STATE["Seeding"])
|
||||
"Seeding")
|
||||
if value == "Paused":
|
||||
component.get("TorrentView").set_filter("state",
|
||||
TORRENT_STATE["Paused"])
|
||||
"Paused")
|
||||
|
||||
|
@ -182,7 +182,7 @@ class ToolBar(component.Component):
|
||||
except KeyError, e:
|
||||
log.debug("Error getting torrent state: %s", e)
|
||||
continue
|
||||
if status == TORRENT_STATE["Paused"]:
|
||||
if status == "Paused":
|
||||
resume = True
|
||||
else:
|
||||
pause = True
|
||||
|
@ -48,8 +48,6 @@ from deluge.ui.client import aclient as client
|
||||
from deluge.log import LOG as log
|
||||
import deluge.ui.gtkui.listview as listview
|
||||
|
||||
TORRENT_STATE = deluge.common.TORRENT_STATE
|
||||
|
||||
# Status icons.. Create them from file only once to avoid constantly
|
||||
# re-creating them.
|
||||
icon_downloading = gtk.gdk.pixbuf_new_from_file(
|
||||
@ -60,35 +58,37 @@ icon_inactive = gtk.gdk.pixbuf_new_from_file(
|
||||
deluge.common.get_pixmap("inactive16.png"))
|
||||
icon_alert = gtk.gdk.pixbuf_new_from_file(
|
||||
deluge.common.get_pixmap("alert16.png"))
|
||||
icon_queued = gtk.gdk.pixbuf_new_from_file(
|
||||
deluge.common.get_pixmap("queued16.png"))
|
||||
|
||||
# Holds the info for which status icon to display based on state
|
||||
ICON_STATE = [
|
||||
icon_inactive,
|
||||
icon_inactive,
|
||||
icon_downloading,
|
||||
icon_seeding,
|
||||
icon_inactive,
|
||||
icon_alert
|
||||
]
|
||||
ICON_STATE = {
|
||||
"Allocating": icon_inactive,
|
||||
"Checking": icon_inactive,
|
||||
"Downloading": icon_downloading,
|
||||
"Seeding": icon_seeding,
|
||||
"Paused": icon_inactive,
|
||||
"Error": icon_alert,
|
||||
"Queued": icon_queued
|
||||
}
|
||||
|
||||
def cell_data_statusicon(column, cell, model, row, data):
|
||||
"""Display text with an icon"""
|
||||
try:
|
||||
icon = ICON_STATE[model.get_value(row, data)]
|
||||
if cell.get_property("pixbuf") != icon:
|
||||
cell.set_property("pixbuf", icon)
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
def cell_data_progress(column, cell, model, row, data):
|
||||
"""Display progress bar with text"""
|
||||
(value, text) = model.get(row, *data)
|
||||
(value, state_str) = model.get(row, *data)
|
||||
if cell.get_property("value") != value:
|
||||
cell.set_property("value", value)
|
||||
state_str = ""
|
||||
for key in TORRENT_STATE.keys():
|
||||
if TORRENT_STATE[key] == text:
|
||||
state_str = key
|
||||
break
|
||||
|
||||
textstr = "%s" % state_str
|
||||
if state_str != "Seeding" and state_str != "Finished" and value < 100:
|
||||
if state_str != "Seeding" and value < 100:
|
||||
textstr = textstr + " %.2f%%" % value
|
||||
if cell.get_property("text") != textstr:
|
||||
cell.set_property("text", textstr)
|
||||
@ -125,7 +125,7 @@ class TorrentView(listview.ListView, component.Component):
|
||||
status_field=["total_size"])
|
||||
self.add_progress_column(_("Progress"),
|
||||
status_field=["progress", "state"],
|
||||
col_types=[float, int],
|
||||
col_types=[float, str],
|
||||
function=cell_data_progress)
|
||||
self.add_func_column(_("Seeders"),
|
||||
listview.cell_data_peer,
|
||||
|
Loading…
x
Reference in New Issue
Block a user