mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-05 16:08:40 +00:00
Display progress bar in torrentview properly.
This commit is contained in:
parent
0c012133cd
commit
f7b537ad81
2 changed files with 29 additions and 6 deletions
|
@ -287,10 +287,14 @@ class ListView:
|
||||||
self.columns[header].column_indices[0])
|
self.columns[header].column_indices[0])
|
||||||
elif column_type == "progress":
|
elif column_type == "progress":
|
||||||
column.pack_start(render)
|
column.pack_start(render)
|
||||||
column.add_attribute(render, "text",
|
if function is None:
|
||||||
self.columns[header].column_indices[text])
|
column.add_attribute(render, "text",
|
||||||
column.add_attribute(render, "value",
|
self.columns[header].column_indices[text])
|
||||||
self.columns[header].column_indices[value])
|
column.add_attribute(render, "value",
|
||||||
|
self.columns[header].column_indices[value])
|
||||||
|
else:
|
||||||
|
column.set_cell_data_func(render, function,
|
||||||
|
tuple(self.columns[header].column_indices))
|
||||||
elif column_type == "texticon":
|
elif column_type == "texticon":
|
||||||
column.pack_start(render[pixbuf])
|
column.pack_start(render[pixbuf])
|
||||||
if function is not None:
|
if function is not None:
|
||||||
|
@ -354,12 +358,14 @@ class ListView:
|
||||||
hidden=False,
|
hidden=False,
|
||||||
position=None,
|
position=None,
|
||||||
status_field=None,
|
status_field=None,
|
||||||
|
function=None,
|
||||||
column_type="progress"):
|
column_type="progress"):
|
||||||
"""Add a progress column to the listview."""
|
"""Add a progress column to the listview."""
|
||||||
|
|
||||||
render = gtk.CellRendererProgress()
|
render = gtk.CellRendererProgress()
|
||||||
self.add_column(header, render, col_types, hidden, position,
|
self.add_column(header, render, col_types, hidden, position,
|
||||||
status_field, sortid, column_type=column_type,
|
status_field, sortid, function=function,
|
||||||
|
column_type=column_type,
|
||||||
value=0, text=1)
|
value=0, text=1)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
@ -65,6 +65,20 @@ def cell_data_statusicon(column, cell, model, row, data):
|
||||||
|
|
||||||
icon = gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap(fname))
|
icon = gtk.gdk.pixbuf_new_from_file(deluge.common.get_pixmap(fname))
|
||||||
cell.set_property("pixbuf", icon)
|
cell.set_property("pixbuf", icon)
|
||||||
|
|
||||||
|
def cell_data_progress(column, cell, model, row, data):
|
||||||
|
"""Display progress bar with text"""
|
||||||
|
column1, column2 = data
|
||||||
|
value = model.get_value(row, column1)
|
||||||
|
text = model.get_value(row, column2)
|
||||||
|
cell.set_property("value", value)
|
||||||
|
textstr = "%s" % _(deluge.common.TORRENT_STATE[text])
|
||||||
|
if deluge.common.TORRENT_STATE[text] == "Downloading" or\
|
||||||
|
deluge.common.TORRENT_STATE[text] == "Downloading Metadata" or\
|
||||||
|
deluge.common.TORRENT_STATE[text] == "Checking" or\
|
||||||
|
deluge.common.TORRENT_STATE[text] == "Allocating":
|
||||||
|
textstr = textstr + " %.2f%%" % value
|
||||||
|
cell.set_property("text", textstr)
|
||||||
|
|
||||||
class TorrentView(listview.ListView):
|
class TorrentView(listview.ListView):
|
||||||
"""TorrentView handles the listing of torrents."""
|
"""TorrentView handles the listing of torrents."""
|
||||||
|
@ -89,7 +103,10 @@ class TorrentView(listview.ListView):
|
||||||
listview.cell_data_size,
|
listview.cell_data_size,
|
||||||
[long],
|
[long],
|
||||||
status_field=["total_size"])
|
status_field=["total_size"])
|
||||||
self.add_progress_column(_("Progress"), status_field=["progress", "state"])
|
self.add_progress_column(_("Progress"),
|
||||||
|
status_field=["progress", "state"],
|
||||||
|
col_types=[float, int],
|
||||||
|
function=cell_data_progress)
|
||||||
self.add_func_column(_("Seeders"),
|
self.add_func_column(_("Seeders"),
|
||||||
listview.cell_data_peer,
|
listview.cell_data_peer,
|
||||||
[int, int],
|
[int, int],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue