From 4b6ff2200189519df0945374edcbb11df07e40a4 Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Sat, 7 Jan 2006 18:36:56 +0000 Subject: [PATCH] cell_renderer_image now take in argument the index of the column and the index in the model --- src/cell_renderer_image.py | 10 +++++++--- src/config.py | 18 ++++-------------- src/groupchat_window.py | 2 +- src/roster_window.py | 4 ++-- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/cell_renderer_image.py b/src/cell_renderer_image.py index 2af7fd551..ff94a11d9 100644 --- a/src/cell_renderer_image.py +++ b/src/cell_renderer_image.py @@ -33,9 +33,11 @@ class CellRendererImage(gtk.GenericCellRenderer): 'Image', gobject.PARAM_READWRITE), } - def __init__(self): + def __init__(self, col_index, tv_index): self.__gobject_init__() self.image = None + self.col_index = col_index + self.tv_index = tv_index self.iters = {} def do_set_property(self, pspec, value): @@ -45,10 +47,12 @@ class CellRendererImage(gtk.GenericCellRenderer): return getattr(self, pspec.name) def func(self, model, path, iter, (image, tree)): - if model.get_value(iter, 0) != image: + if model.get_value(iter, self.tv_index) != image: return self.redraw = 1 - cell_area = tree.get_cell_area(path, tree.get_column(0)) + col = tree.get_column(self.col_index) + cell_area = tree.get_cell_area((path[0]+1), col) + tree.queue_draw_area(cell_area.x, cell_area.y, cell_area.width, cell_area.height) diff --git a/src/config.py b/src/config.py index c92606164..e7e9391f7 100644 --- a/src/config.py +++ b/src/config.py @@ -127,7 +127,7 @@ class PreferencesWindow: iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets')) # new model, image in 0, string in 1 model = gtk.ListStore(gtk.Image, str) - renderer_image = cell_renderer_image.CellRendererImage() + renderer_image = cell_renderer_image.CellRendererImage(0, 0) renderer_text = gtk.CellRendererText() renderer_text.set_property('xpad', 5) self.iconset_combobox.pack_start(renderer_image, expand = False) @@ -1950,7 +1950,7 @@ class ManageEmoticonsWindow: col = gtk.TreeViewColumn(_('Image')) self.emot_tree.append_column(col) - renderer = cell_renderer_image.CellRendererImage() + renderer = cell_renderer_image.CellRendererImage(1, 2) col.pack_start(renderer, expand = False) col.add_attribute(renderer, 'image', 2) @@ -2005,12 +2005,7 @@ class ManageEmoticonsWindow: continue img = gtk.Image() img.show() - if file.find('.gif') != -1: - pix = gtk.gdk.PixbufAnimation(file) - img.set_from_animation(pix) - else: - pix = gtk.gdk.pixbuf_new_from_file(file) - img.set_from_pixbuf(pix) + img.set_from_file(file) model.set(iter, 2, img) def on_emot_cell_edited(self, cell, row, new_text): @@ -2103,12 +2098,7 @@ class ManageEmoticonsWindow: model.set_value(iter, 1, file) img = gtk.Image() img.show() - if file.find('.gif') != -1: - pix = gtk.gdk.PixbufAnimation(file) - img.set_from_animation(pix) - else: - pix = gtk.gdk.pixbuf_new_from_file(file) - img.set_from_pixbuf(pix) + img.set_from_file(file) model.set(iter, 2, img) def on_button_new_emoticon_clicked(self, widget, data=None): diff --git a/src/groupchat_window.py b/src/groupchat_window.py index fd1489f91..ebd9512d4 100644 --- a/src/groupchat_window.py +++ b/src/groupchat_window.py @@ -1444,7 +1444,7 @@ current room topic.') % command, room_jid) store = gtk.TreeStore(gtk.Image, str, str, str) store.set_sort_column_id(C_TEXT, gtk.SORT_ASCENDING) column = gtk.TreeViewColumn('contacts') - renderer_image = cell_renderer_image.CellRendererImage() + renderer_image = cell_renderer_image.CellRendererImage(0, 0) renderer_image.set_property('width', 20) column.pack_start(renderer_image, expand = False) column.add_attribute(renderer_image, 'image', 0) diff --git a/src/roster_window.py b/src/roster_window.py index 600084760..819e861a4 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -2658,7 +2658,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid) liststore = gtk.ListStore(str, gtk.Image, str, bool) self.status_combobox = self.xml.get_widget('status_combobox') - cell = cell_renderer_image.CellRendererImage() + cell = cell_renderer_image.CellRendererImage(0, 1) self.status_combobox.pack_start(cell, False) # img to show is in in 2nd column of liststore @@ -2719,7 +2719,7 @@ _('If "%s" accepts this request you will know his or her status.') % jid) # this col has two cells: first one img, second one text col = gtk.TreeViewColumn() - render_image = cell_renderer_image.CellRendererImage() # show img or +- + render_image = cell_renderer_image.CellRendererImage(0, 0) # show img or +- col.pack_start(render_image, expand = False) col.add_attribute(render_image, 'image', C_IMG) col.set_cell_data_func(render_image, self.iconCellDataFunc, None)