cell_renderer_image now take in argument the index of the column and the index in the model

This commit is contained in:
Yann Leboulanger 2006-01-07 18:36:56 +00:00
parent 9c954dfe15
commit 4b6ff22001
4 changed files with 14 additions and 20 deletions

View File

@ -33,9 +33,11 @@ class CellRendererImage(gtk.GenericCellRenderer):
'Image', gobject.PARAM_READWRITE), 'Image', gobject.PARAM_READWRITE),
} }
def __init__(self): def __init__(self, col_index, tv_index):
self.__gobject_init__() self.__gobject_init__()
self.image = None self.image = None
self.col_index = col_index
self.tv_index = tv_index
self.iters = {} self.iters = {}
def do_set_property(self, pspec, value): def do_set_property(self, pspec, value):
@ -45,10 +47,12 @@ class CellRendererImage(gtk.GenericCellRenderer):
return getattr(self, pspec.name) return getattr(self, pspec.name)
def func(self, model, path, iter, (image, tree)): 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 return
self.redraw = 1 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, tree.queue_draw_area(cell_area.x, cell_area.y,
cell_area.width, cell_area.height) cell_area.width, cell_area.height)

View File

@ -127,7 +127,7 @@ class PreferencesWindow:
iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets')) iconsets_list = os.listdir(os.path.join(gajim.DATA_DIR, 'iconsets'))
# new model, image in 0, string in 1 # new model, image in 0, string in 1
model = gtk.ListStore(gtk.Image, str) 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 = gtk.CellRendererText()
renderer_text.set_property('xpad', 5) renderer_text.set_property('xpad', 5)
self.iconset_combobox.pack_start(renderer_image, expand = False) self.iconset_combobox.pack_start(renderer_image, expand = False)
@ -1950,7 +1950,7 @@ class ManageEmoticonsWindow:
col = gtk.TreeViewColumn(_('Image')) col = gtk.TreeViewColumn(_('Image'))
self.emot_tree.append_column(col) 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.pack_start(renderer, expand = False)
col.add_attribute(renderer, 'image', 2) col.add_attribute(renderer, 'image', 2)
@ -2005,12 +2005,7 @@ class ManageEmoticonsWindow:
continue continue
img = gtk.Image() img = gtk.Image()
img.show() img.show()
if file.find('.gif') != -1: img.set_from_file(file)
pix = gtk.gdk.PixbufAnimation(file)
img.set_from_animation(pix)
else:
pix = gtk.gdk.pixbuf_new_from_file(file)
img.set_from_pixbuf(pix)
model.set(iter, 2, img) model.set(iter, 2, img)
def on_emot_cell_edited(self, cell, row, new_text): def on_emot_cell_edited(self, cell, row, new_text):
@ -2103,12 +2098,7 @@ class ManageEmoticonsWindow:
model.set_value(iter, 1, file) model.set_value(iter, 1, file)
img = gtk.Image() img = gtk.Image()
img.show() img.show()
if file.find('.gif') != -1: img.set_from_file(file)
pix = gtk.gdk.PixbufAnimation(file)
img.set_from_animation(pix)
else:
pix = gtk.gdk.pixbuf_new_from_file(file)
img.set_from_pixbuf(pix)
model.set(iter, 2, img) model.set(iter, 2, img)
def on_button_new_emoticon_clicked(self, widget, data=None): def on_button_new_emoticon_clicked(self, widget, data=None):

View File

@ -1444,7 +1444,7 @@ current room topic.') % command, room_jid)
store = gtk.TreeStore(gtk.Image, str, str, str) store = gtk.TreeStore(gtk.Image, str, str, str)
store.set_sort_column_id(C_TEXT, gtk.SORT_ASCENDING) store.set_sort_column_id(C_TEXT, gtk.SORT_ASCENDING)
column = gtk.TreeViewColumn('contacts') column = gtk.TreeViewColumn('contacts')
renderer_image = cell_renderer_image.CellRendererImage() renderer_image = cell_renderer_image.CellRendererImage(0, 0)
renderer_image.set_property('width', 20) renderer_image.set_property('width', 20)
column.pack_start(renderer_image, expand = False) column.pack_start(renderer_image, expand = False)
column.add_attribute(renderer_image, 'image', 0) column.add_attribute(renderer_image, 'image', 0)

View File

@ -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) liststore = gtk.ListStore(str, gtk.Image, str, bool)
self.status_combobox = self.xml.get_widget('status_combobox') 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) self.status_combobox.pack_start(cell, False)
# img to show is in in 2nd column of liststore # 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 # this col has two cells: first one img, second one text
col = gtk.TreeViewColumn() 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.pack_start(render_image, expand = False)
col.add_attribute(render_image, 'image', C_IMG) col.add_attribute(render_image, 'image', C_IMG)
col.set_cell_data_func(render_image, self.iconCellDataFunc, None) col.set_cell_data_func(render_image, self.iconCellDataFunc, None)