fixed the percentage complete column in the peers display

This commit is contained in:
Andrew Resch 2007-06-11 08:54:17 +00:00
parent 0b78316d65
commit 7d0aa62671
1 changed files with 18 additions and 29 deletions

View File

@ -426,18 +426,25 @@ class DelugeGTK:
self.text_summary_compact_allocation = self.wtree.get_widget("summary_compact_allocation")
self.text_summary_eta = self.wtree.get_widget("summary_eta")
def build_peer_tab(self):
def percent(column, cell, model, iter, data):
percent = float(model.get_value(iter, data))
percent_str = "%.2f%%"%percent
cell.set_property("text", percent_str)
self.peer_view = self.wtree.get_widget("peer_view")
self.peer_store = gtk.ListStore(str, str, str, str, str)
self.peer_store = gtk.ListStore(str, str, float, str, str)
self.peer_view.set_model(self.peer_store)
self.peer_ip_column = dgtk.add_text_column(self.peer_view, _("IP Address"), 0)
self.peer_client_column = dgtk.add_text_column(self.peer_view, _("Client"), 1)
self.peer_complete_column = dgtk.add_text_column(self.peer_view, _("Percent Complete"), 2)
self.peer_complete_column = dgtk.add_func_column(self.peer_view, _("Percent Complete"), percent, 2)
self.peer_download_column = dgtk.add_text_column(self.peer_view, _("Download Rate"), 3)
self.peer_upload_column = dgtk.add_text_column(self.peer_view, _("Upload Rate"), 4)
def build_file_tab(self):
self.file_view = self.wtree.get_widget("file_view")
self.file_store = gtk.ListStore(bool, str, str, str, str)
@ -742,42 +749,24 @@ class DelugeGTK:
for peer in new_peer_info:
if peer['ip'] in curr_ips.keys():
if peer["peer_has"] < 10:
peer_has = '00''%.2f%%'%peer["peer_has"]
elif peer["peer_has"] >= 10 and peer["peer_has"] < 100:
peer_has = '0''%.2f%%'%peer["peer_has"]
elif peer["peer_has"] == 100:
peer_has = '%.2f%%'%peer["peer_has"]
self.peer_store.set(self.peer_store.get_iter_from_string(curr_ips[peer['ip']]),
1, unicode(peer['client'], 'Latin-1'),
2, peer_has,
2, round(peer["peer_has"],2),
3, common.frate(peer["download_speed"]),
4, common.frate(peer["upload_speed"]))
for peer in new_peer_info:
if peer['ip'] not in curr_ips.keys() and peer['client'] is not "":
if peer["peer_has"] < 10:
peer_has = '00''%.2f%%'%peer["peer_has"]
elif peer["peer_has"] >= 10 and peer["peer_has"] < 100:
peer_has = '0''%.2f%%'%peer["peer_has"]
elif peer["peer_has"] == 100:
peer_has = '%.2f%%'%peer["peer_has"]
if peer['ip'] not in curr_ips.keys() and peer['client'] is not "":
self.peer_store.append([peer["ip"],
unicode(peer["client"], 'Latin-1'),
peer_has,
common.frate(peer["download_speed"]),
common.frate(peer["upload_speed"])])
#print new_ips
#print curr_ips
#print new_peer_info
unicode(peer["client"], 'Latin-1'),
round(peer["peer_has"],2),
common.frate(peer["download_speed"]),
common.frate(peer["upload_speed"])])
del new_peer_info
del new_ips
del curr_ips
elif tab == 2: #File List
pass
else: