From d7fa383da3a0bc5ed7f48d3cc6dc745406a05305 Mon Sep 17 00:00:00 2001 From: John Garland Date: Tue, 4 May 2010 02:19:01 +1000 Subject: [PATCH] Update gtk ui to use new TrackerIcons --- deluge/ui/gtkui/filtertreeview.py | 7 ++++++- deluge/ui/gtkui/torrentview.py | 24 +++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/deluge/ui/gtkui/filtertreeview.py b/deluge/ui/gtkui/filtertreeview.py index d5ce592ce..598ce9c08 100644 --- a/deluge/ui/gtkui/filtertreeview.py +++ b/deluge/ui/gtkui/filtertreeview.py @@ -195,6 +195,10 @@ class FilterTreeView(component.Component): self.select_default_filter() def update_row(self, cat, value , count): + def on_get_icon(icon): + if icon: + self.set_row_image(cat, value, icon.get_filename()) + if (cat, value) in self.filters: row = self.filters[(cat, value)] self.treestore.set_value(row, 3, count) @@ -207,7 +211,8 @@ class FilterTreeView(component.Component): self.filters[(cat, value)] = row if cat == "tracker_host" or cat == "label": - self.tracker_icons.get_async(value, lambda filename: self.set_row_image(cat, value, filename)) + d = self.tracker_icons.get(value) + d.addCallback(on_get_icon) self.treestore.set_value(row, FILTER_COLUMN, True) return row diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index 0862aaeb6..6ea75fd10 100644 --- a/deluge/ui/gtkui/torrentview.py +++ b/deluge/ui/gtkui/torrentview.py @@ -87,19 +87,21 @@ def cell_data_statusicon(column, cell, model, row, data): pass def cell_data_trackericon(column, cell, model, row, data): - icon_path = component.get("TrackerIcons").get(model[row][data]) - if icon_path: - try: - icon = gtk.gdk.pixbuf_new_from_file_at_size(icon_path, 16, 16) - except Exception, e: - pass - else: - icon = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, 16, 16) - icon.fill(0x00000000) + def on_get_icon(icon): + if icon: + try: + icon = gtk.gdk.pixbuf_new_from_file_at_size(icon.get_filename(), 16, 16) + except Exception, e: + pass + else: + icon = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, 16, 16) + icon.fill(0x00000000) - if cell.get_property("pixbuf") != icon: - cell.set_property("pixbuf", icon) + if cell.get_property("pixbuf") != icon: + cell.set_property("pixbuf", icon) + d = component.get("TrackerIcons").get(model[row][data]) + d.addCallback(on_get_icon) def cell_data_progress(column, cell, model, row, data): """Display progress bar with text"""