Tooltips for torrent list items

This commit is contained in:
Kai Huuhko 2014-07-01 21:16:47 +03:00
parent d04fdf23f5
commit 66afea1f70
2 changed files with 30 additions and 2 deletions

2
TODO
View File

@ -12,7 +12,7 @@ Add Torrent-dialog:
✔ Storage path @done (15:57 30.06.2014)
☐ Add preferences for initial/automatic values for the above
Misc:
☐ Torrent tooltips
✔ Torrent tooltips @done (21:17 01.07.2014)
Using handle.status()
☐ More tooltips in general
☐ More D-Bus controls ./epour/Epour.py>EpourDBus

View File

@ -21,7 +21,7 @@
import cgi
import logging
from datetime import timedelta
from datetime import timedelta, datetime
from efl.evas import EVAS_HINT_EXPAND, EVAS_HINT_FILL, \
EVAS_ASPECT_CONTROL_VERTICAL, Rectangle
@ -249,11 +249,39 @@ class MainInterface(object):
"elm.swallow.icon", ELM_GENLIST_ITEM_FIELD_CONTENT
)
def _torrent_item_tooltip_cb(self, gl, it, tooltip, h):
if not h.is_valid():
return
s = h.status()
table = Table(tooltip, size_hint_weight=EXPAND_BOTH)
for i, (name, info) in enumerate((
("Time when added", datetime.fromtimestamp(s.added_time)),
("Time when completed", datetime.fromtimestamp(s.completed_time)),
("All time downloaded", intrepr(s.all_time_download)),
("All time uploaded", intrepr(s.all_time_upload)),
("Total wanted done", intrepr(s.total_wanted_done)),
("Total wanted", intrepr(s.total_wanted)),
("Total downloaded this session", intrepr(s.total_payload_download)),
("Total uploaded this session", intrepr(s.total_payload_upload)),
("Total failed", intrepr(s.total_failed_bytes)),
("Number of seeds", s.num_seeds),
("Number of peers", s.num_peers),
)):
l1 = Label(table, text=name)
l1.show()
table.pack(l1, 0, i, 1, 1)
l2 = Label(table, text=str(info))
l2.show()
table.pack(l2, 1, i, 1, 1)
return table
def add_torrent_item(self, h):
ihash = str(h.info_hash())
itc = TorrentClass(self.session, "double_label")
item = self.tlist.item_append(itc, h)
item.tooltip_content_cb_set(self._torrent_item_tooltip_cb, h)
self.torrentitems[ihash] = item
def remove_torrent_item(self, info_hash):