From 2542745c1685ca4439ab3b7c15b4426ce66c04b6 Mon Sep 17 00:00:00 2001 From: Andrew Resch Date: Sat, 18 Apr 2009 17:46:14 +0000 Subject: [PATCH] Add tracker icon to Tracker column --- deluge/ui/gtkui/torrentview.py | 15 ++++++++++++++- deluge/ui/tracker_icons.py | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index 882418c48..98bea604e 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -37,6 +37,7 @@ import deluge.component as component from deluge.ui.client import client from deluge.log import LOG as log import deluge.ui.gtkui.listview as listview +from deluge.ui.tracker_icons import TrackerIcons # Status icons.. Create them from file only once to avoid constantly # re-creating them. @@ -73,6 +74,17 @@ def cell_data_statusicon(column, cell, model, row, data): except KeyError: pass +def cell_data_trackericon(column, cell, model, row, data): + icon_path = TrackerIcons().get(model[row][data]) + if icon_path: + try: + icon = gtk.gdk.pixbuf_new_from_file(icon_path) + except Exception, e: + pass + if cell.get_property("pixbuf") != icon: + cell.set_property("pixbuf", icon) + + def cell_data_progress(column, cell, model, row, data): """Display progress bar with text""" (value, state_str) = model.get(row, *data) @@ -176,7 +188,8 @@ class TorrentView(listview.ListView, component.Component): listview.cell_data_date, [float], status_field=["time_added"]) - self.add_text_column(_("Tracker"), status_field=["tracker_host"]) + self.add_texticon_column(_("Tracker"), status_field=["tracker_host", "tracker_host"], + function=cell_data_trackericon) # Set filter to None for now self.filter = None diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py index 40bdc14cc..d50e33467 100644 --- a/deluge/ui/tracker_icons.py +++ b/deluge/ui/tracker_icons.py @@ -156,7 +156,7 @@ class TrackerIcons(object): threading.Thread(target=self. _fetch_icon_thread, args=(tracker_host, callback)).start() - def get(self, tracker_host): + def get(self, tracker_host): """ returns None if the icon is not fetched(yet) or not fond. """