Update gtk ui to use new TrackerIcons

This commit is contained in:
John Garland 2010-05-04 02:19:01 +10:00
parent 6ded75caef
commit d7fa383da3
2 changed files with 19 additions and 12 deletions

View File

@ -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

View File

@ -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"""