mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-03 15:08:40 +00:00
Remove idea of a 'get_function'. Updated add_row() to use new
status_fields.
This commit is contained in:
parent
f185f19cfb
commit
f3c80eb816
2 changed files with 71 additions and 110 deletions
|
@ -69,7 +69,6 @@ class GtkUI:
|
||||||
self.torrentview.add_text_column("#",
|
self.torrentview.add_text_column("#",
|
||||||
col_type=int,
|
col_type=int,
|
||||||
position=0,
|
position=0,
|
||||||
get_function=self.column_get_function,
|
|
||||||
status_field=["queue"])
|
status_field=["queue"])
|
||||||
# Add a toolbar buttons
|
# Add a toolbar buttons
|
||||||
self.plugin.get_toolbar().add_separator()
|
self.plugin.get_toolbar().add_separator()
|
||||||
|
@ -108,8 +107,3 @@ class GtkUI:
|
||||||
self.torrentview.update(["#"])
|
self.torrentview.update(["#"])
|
||||||
return
|
return
|
||||||
|
|
||||||
def column_get_function(self, torrent_id):
|
|
||||||
"""Returns the queue position for torrent_id"""
|
|
||||||
# Return the value + 1 because we want the queue list to start at 1
|
|
||||||
# for the user display.
|
|
||||||
return self.core.get_position(torrent_id) + 1
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ class TorrentView(listview.ListView):
|
||||||
|
|
||||||
# Add the columns to the listview
|
# Add the columns to the listview
|
||||||
self.add_text_column("torrent_id", hidden=True)
|
self.add_text_column("torrent_id", hidden=True)
|
||||||
self.add_texticon_column("Name", status_field=["name"])
|
self.add_text_column("Name", status_field=["name"])
|
||||||
self.add_func_column("Size",
|
self.add_func_column("Size",
|
||||||
listview.cell_data_size,
|
listview.cell_data_size,
|
||||||
[long],
|
[long],
|
||||||
|
@ -104,9 +104,13 @@ class TorrentView(listview.ListView):
|
||||||
"""Update the view. If columns is not None, it will attempt to only
|
"""Update the view. If columns is not None, it will attempt to only
|
||||||
update those columns selected.
|
update those columns selected.
|
||||||
"""
|
"""
|
||||||
# This function is used for the foreach method of the treemodel
|
# Iterates through every row and updates them accordingly
|
||||||
def update_row(model, path, row, user_data):
|
if self.liststore is not None:
|
||||||
torrent_id = self.liststore.get_value(row, 0)
|
self.liststore.foreach(self.update_row, columns)
|
||||||
|
|
||||||
|
def update_row(self, model, path, row, columns=None):
|
||||||
|
torrent_id = self.liststore.get_value(row,
|
||||||
|
self.columns["torrent_id"].column_indices[0])
|
||||||
# Store the 'status_fields' we need to send to core
|
# Store the 'status_fields' we need to send to core
|
||||||
status_keys = []
|
status_keys = []
|
||||||
# Store the actual columns we will be updating
|
# Store the actual columns we will be updating
|
||||||
|
@ -162,54 +166,17 @@ class TorrentView(listview.ListView):
|
||||||
pass
|
pass
|
||||||
i = i + 1
|
i = i + 1
|
||||||
|
|
||||||
|
|
||||||
# Iterates through every row and updates them accordingly
|
|
||||||
if self.liststore is not None:
|
|
||||||
self.liststore.foreach(update_row, None)
|
|
||||||
|
|
||||||
def add_row(self, torrent_id):
|
def add_row(self, torrent_id):
|
||||||
"""Adds a new torrent row to the treeview"""
|
"""Adds a new torrent row to the treeview"""
|
||||||
## REWRITE TO USE STATUS FIELDS
|
# Insert a new row to the liststore
|
||||||
# Get the status and info dictionaries
|
row = self.liststore.append()
|
||||||
status_keys = ["name", "total_size", "progress", "state",
|
# Store the torrent id
|
||||||
"num_seeds", "num_peers", "download_payload_rate",
|
self.liststore.set_value(
|
||||||
"upload_payload_rate", "eta"]
|
row,
|
||||||
status = functions.get_torrent_status(self.core, torrent_id,
|
self.columns["torrent_id"].column_indices[0],
|
||||||
status_keys)
|
torrent_id)
|
||||||
|
# Update the new row so
|
||||||
row_list = [
|
self.update_row(None, None, row)
|
||||||
torrent_id,
|
|
||||||
None,
|
|
||||||
status["name"],
|
|
||||||
status["total_size"],
|
|
||||||
status["progress"]*100,
|
|
||||||
status["state"],
|
|
||||||
status["num_seeds"],
|
|
||||||
status["num_seeds"],
|
|
||||||
status["num_peers"],
|
|
||||||
status["num_peers"],
|
|
||||||
status["download_payload_rate"],
|
|
||||||
status["upload_payload_rate"],
|
|
||||||
status["eta"],
|
|
||||||
0.0
|
|
||||||
]
|
|
||||||
|
|
||||||
# Insert any column info from get_functions.. this is usually from
|
|
||||||
# plugins
|
|
||||||
for column in self.columns.values():
|
|
||||||
if column.get_function is not None:
|
|
||||||
if len(column.column_indices) == 1:
|
|
||||||
row_list.insert(column.column_indices[0],
|
|
||||||
column.get_function(torrent_id))
|
|
||||||
else:
|
|
||||||
result = column.get_function(torrent_id)
|
|
||||||
r_index = 0
|
|
||||||
for index in column.column_indices:
|
|
||||||
row_list.insert(index, result[r_index])
|
|
||||||
r_index = r_index + 1
|
|
||||||
|
|
||||||
# Insert the row with info provided from core
|
|
||||||
self.liststore.append(row_list)
|
|
||||||
|
|
||||||
def remove_row(self, torrent_id):
|
def remove_row(self, torrent_id):
|
||||||
"""Removes a row with torrent_id"""
|
"""Removes a row with torrent_id"""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue