kuuko pushed a commit to branch master.

http://git.enlightenment.org/apps/epour.git/commit/?id=66afea1f70a57f3125fa482421c1ea0a3d3ff203

commit 66afea1f70a57f3125fa482421c1ea0a3d3ff203
Author: Kai Huuhko <kai.huu...@gmail.com>
Date:   Tue Jul 1 21:16:47 2014 +0300

    Tooltips for torrent list items
---
 TODO                  |  2 +-
 epour/gui/__init__.py | 30 +++++++++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/TODO b/TODO
index a45afe7..4d5d115 100644
--- a/TODO
+++ b/TODO
@@ -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
diff --git a/epour/gui/__init__.py b/epour/gui/__init__.py
index 496f8bc..7d46891 100644
--- a/epour/gui/__init__.py
+++ b/epour/gui/__init__.py
@@ -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):

-- 


Reply via email to