cell_renderer_image now take in argument the index of the column and the index in the model
This commit is contained in:
parent
9c954dfe15
commit
4b6ff22001
|
@ -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)
|
||||
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue