diff --git a/deluge/ui/gtkui/filtertreeview.py b/deluge/ui/gtkui/filtertreeview.py index 99ac66e81..afb0ddc20 100644 --- a/deluge/ui/gtkui/filtertreeview.py +++ b/deluge/ui/gtkui/filtertreeview.py @@ -237,12 +237,17 @@ class FilterTreeView(component.Component): return None def set_row_image(self, cat, value, filename): + pix = None try: #assume we could get trashed images here.. - pix = gtk.gdk.pixbuf_new_from_file(filename) - row = self.filters[(cat, value)] - self.treestore.set_value(row, 4, pix) + pix = gtk.gdk.pixbuf_new_from_file_at_size(filename, 16, 16) except Exception, e: log.debug(e.message) + + if not pix: + pix = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, 16, 16) + pix.fill(0x00000000) + row = self.filters[(cat, value)] + self.treestore.set_value(row, 4, pix) return False diff --git a/deluge/ui/tracker_icons.py b/deluge/ui/tracker_icons.py index 988ba9d3b..6c094bfdf 100644 --- a/deluge/ui/tracker_icons.py +++ b/deluge/ui/tracker_icons.py @@ -45,10 +45,10 @@ RENAMES = { "aelitis.com":"www.vuze.com" } -VALID_ICO_TYPES = ["octet-stream","x-icon"] -VALID_PNG_TYPES = ["octet-stream","png"] +VALID_ICO_TYPES = ["octet-stream", "x-icon", "image/vnd.microsoft.icon"] +VALID_PNG_TYPES = ["octet-stream", "png"] -def fetch_url(url, valid_subtypes = None): +def fetch_url(url, valid_subtypes=None): """ returns: data or None """ @@ -90,14 +90,33 @@ class TrackerIcons(object): """ host_name = RENAMES.get(tracker_host, tracker_host) #HACK! - ico = fetch_url("http://%s/favicon.ico" % host_name, VALID_ICO_TYPES) + ico = fetch_url("http://%s/favicon.ico" % host_name, VALID_ICO_TYPES) if ico: return ("ico", ico) - png = fetch_url("http://%s/favicon.png" % host_name, VALID_PNG_TYPES) + png = fetch_url("http://%s/favicon.png" % host_name, VALID_PNG_TYPES) if png: return ("png", png) + # FIXME: This should be cleaned up and not copy the top code + html = urlopen("http://%s/" % (host_name,)) + if html: + icon_path = "" + line = html.readline() + while line: + if '