Ticket #1885: 10fc58779baa0e5baa94f3a697a9ffa355763f61.patch
File 10fc58779baa0e5baa94f3a697a9ffa355763f61.patch, 5.0 KB (added by , 12 years ago) |
---|
-
deluge/ui/gtkui/filtertreeview.py
From 10fc58779baa0e5baa94f3a697a9ffa355763f61 Mon Sep 17 00:00:00 2001 From: bendikro <bendikro@gmail.com> Date: Mon, 18 Feb 2013 01:18:54 +0100 Subject: [PATCH] Fixed bug in tracker icons for torrentview. --- deluge/ui/gtkui/filtertreeview.py | 2 +- deluge/ui/gtkui/torrentview.py | 65 ++++++++++++++++++++++--------------- deluge/ui/tracker_icons.py | 18 ++++++++++ 3 files changed, 57 insertions(+), 28 deletions(-) diff --git a/deluge/ui/gtkui/filtertreeview.py b/deluge/ui/gtkui/filtertreeview.py index 51cde26..8c29c39 100644
a b def on_get_icon(icon): 247 247 self.filters[(cat, value)] = row 248 248 249 249 if cat == "tracker_host" and value not in ("All", "Error") and value: 250 d = self.tracker_icons. get(value)250 d = self.tracker_icons.fetch(value) 251 251 d.addCallback(on_get_icon) 252 252 253 253 self.treestore.set_value(row, FILTER_COLUMN, True) -
deluge/ui/gtkui/torrentview.py
diff --git a/deluge/ui/gtkui/torrentview.py b/deluge/ui/gtkui/torrentview.py index cdfbcc8..a15ea7e 100644
a b def cell_data_statusicon(column, cell, model, row, data): 109 109 except KeyError: 110 110 pass 111 111 112 def cell_data_trackericon(column, cell, model, row, data): 113 def on_get_icon(icon): 114 def create_blank_pixbuf(): 115 i = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, 16, 16) 116 i.fill(0x00000000) 117 return i 118 119 if icon: 120 pixbuf = icon.get_cached_icon() 121 if not pixbuf: 122 try: 123 pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon.get_filename(), 16, 16) 124 except gobject.GError, e: 125 # Failed to load the pixbuf (Bad image file), so set a blank pixbuf 126 pixbuf = create_blank_pixbuf() 127 finally: 128 icon.set_cached_icon(pixbuf) 129 else: 130 pixbuf = create_blank_pixbuf() 112 def create_blank_pixbuf(): 113 i = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, 16, 16) 114 i.fill(0x00000000) 115 return i 116 117 def set_icon(icon, cell): 118 if icon: 119 pixbuf = icon.get_cached_icon() 120 if pixbuf is None: 121 try: 122 pixbuf = gtk.gdk.pixbuf_new_from_file_at_size(icon.get_filename(), 16, 16) 123 except gobject.GError, e: 124 # Failed to load the pixbuf (Bad image file), so set a blank pixbuf 125 pixbuf = create_blank_pixbuf() 126 finally: 127 icon.set_cached_icon(pixbuf) 128 else: 129 pixbuf = create_blank_pixbuf() 130 131 #Suppress Warning: g_object_set_qdata: assertion `G_IS_OBJECT (object)' failed 132 with warnings.catch_warnings(): 133 warnings.simplefilter("ignore") 134 cell.set_property("pixbuf", pixbuf) 131 135 132 #Suppress Warning: g_object_set_qdata: assertion `G_IS_OBJECT (object)' failed 133 with warnings.catch_warnings(): 134 warnings.simplefilter("ignore") 135 if cell.get_property("pixbuf") != pixbuf: 136 cell.set_property("pixbuf", pixbuf) 136 last_host = None 137 137 138 def cell_data_trackericon(column, cell, model, row, data): 139 global last_host 138 140 host = model[row][data] 139 141 if host: 140 d = component.get("TrackerIcons").get(host) 141 d.addCallback(on_get_icon) 142 if last_host == host: 143 return 144 else: 145 last_host = host 146 147 if not component.get("TrackerIcons").has(host): 148 # Set blank icon while waiting for the icon to be loaded 149 set_icon(None, cell) 150 component.get("TrackerIcons").fetch(host) 151 else: 152 set_icon(component.get("TrackerIcons").get(host), cell) 142 153 else: 143 on_get_icon(None)154 set_icon(None, cell) 144 155 145 156 def cell_data_progress(column, cell, model, row, data): 146 157 """Display progress bar with text""" -
deluge/ui/tracker_icons.py
diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py index ffc099c..8fa58fc 100644
a b def __init__(self, icon_dir=None, no_icon=None): 178 178 self.pending = {} 179 179 self.redirects = {} 180 180 181 def has(self, host): 182 return host in self.icons 183 181 184 def get(self, host): 182 185 """ 183 186 Returns a TrackerIcon for the given tracker's host 184 187 185 188 :param host: the host to obtain the TrackerIcon for 186 189 :type host: string 190 :returns: the TrackerIcon for the host 191 :rtype: TrackerIcon 192 """ 193 host = host.lower() 194 if host in self.icons: 195 return self.icons[host] 196 else: 197 return None 198 199 def fetch(self, host): 200 """ 201 Returns a TrackerIcon for the given tracker's host 202 203 :param host: the host to obtain the TrackerIcon for 204 :type host: string 187 205 :returns: a Deferred which fires with the TrackerIcon for the given host 188 206 :rtype: Deferred 189 207 """