broke too long lines

This commit is contained in:
Vincent Hanquez 2005-04-21 23:36:18 +00:00
parent ba5acab7f7
commit 6c797723c5
1 changed files with 40 additions and 31 deletions

View File

@ -38,25 +38,28 @@ 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, 0) != image:
return
self.redraw = 1 self.redraw = 1
cell_area = tree.get_cell_area(path, tree.get_column(0)) cell_area = tree.get_cell_area(path, tree.get_column(0))
tree.queue_draw_area(cell_area.x, cell_area.y, cell_area.width, \ tree.queue_draw_area(cell_area.x, cell_area.y,
cell_area.height) cell_area.width, cell_area.height)
def animation_timeout(self, tree, image): def animation_timeout(self, tree, image):
if image.get_storage_type() == gtk.IMAGE_ANIMATION: if image.get_storage_type() != gtk.IMAGE_ANIMATION:
return
self.redraw = 0 self.redraw = 0
image.get_data('iter').advance() image.get_data('iter').advance()
model = tree.get_model() model = tree.get_model()
model.foreach(self.func, (image, tree)) model.foreach(self.func, (image, tree))
if self.redraw: if self.redraw:
gobject.timeout_add(image.get_data('iter').get_delay_time(), \ iter = image.get_data('iter')
gobject.timeout_add(iter.get_delay_time(),
self.animation_timeout, tree, image) self.animation_timeout, tree, image)
else: else:
image.set_data('iter', None) image.set_data('iter', None)
def on_render(self, window, widget, background_area,cell_area, \ def on_render(self, window, widget, background_area, cell_area,
expose_area, flags): expose_area, flags):
if not self.image: if not self.image:
return return
@ -76,17 +79,21 @@ class CellRendererImage(gtk.GenericCellRenderer):
if not self.image.get_data('iter'): if not self.image.get_data('iter'):
animation = self.image.get_animation() animation = self.image.get_animation()
self.image.set_data('iter', animation.get_iter()) self.image.set_data('iter', animation.get_iter())
gobject.timeout_add(self.image.get_data('iter').get_delay_time(), \ iter = self.image.get_data('iter')
self.animation_timeout, widget, self.image) gobject.timeout_add(iter.get_delay_time(),
self.animation_timeout,
widget, self.image)
pix = self.image.get_data('iter').get_pixbuf() pix = self.image.get_data('iter').get_pixbuf()
elif self.image.get_storage_type() == gtk.IMAGE_PIXBUF: elif self.image.get_storage_type() == gtk.IMAGE_PIXBUF:
pix = self.image.get_pixbuf() pix = self.image.get_pixbuf()
else: else:
return return
window.draw_pixbuf(widget.style.black_gc, pix, \ window.draw_pixbuf(widget.style.black_gc, pix,
draw_rect.x - pix_rect.x, draw_rect.y - pix_rect.y, draw_rect.x, \ draw_rect.x - pix_rect.x,
draw_rect.y + 2, draw_rect.width, draw_rect.height, \ draw_rect.y - pix_rect.y,
draw_rect.x, draw_rect.y + 2,
draw_rect.width, draw_rect.height,
gtk.gdk.RGB_DITHER_NONE, 0, 0) gtk.gdk.RGB_DITHER_NONE, 0, 0)
def on_get_size(self, widget, cell_area): def on_get_size(self, widget, cell_area):
@ -106,10 +113,12 @@ class CellRendererImage(gtk.GenericCellRenderer):
x_offset = 0 x_offset = 0
y_offset = 0 y_offset = 0
if cell_area and pixbuf_width > 0 and pixbuf_height > 0: if cell_area and pixbuf_width > 0 and pixbuf_height > 0:
x_offset = self.get_property('xalign') * (cell_area.width - \ x_offset = self.get_property('xalign') *
calc_width - self.get_property('xpad')) (cell_area.width - calc_width -
y_offset = self.get_property('yalign') * (cell_area.height - \ self.get_property('xpad'))
calc_height - self.get_property('ypad')) y_offset = self.get_property('yalign') *
(cell_area.height - calc_height -
self.get_property('ypad'))
return x_offset, y_offset, calc_width, calc_height return x_offset, y_offset, calc_width, calc_height
gobject.type_register(CellRendererImage) gobject.type_register(CellRendererImage)