start supporting animated images in treeview.
This commit is contained in:
parent
0d6bfe5f8d
commit
75a55e513c
|
@ -21,7 +21,7 @@
|
||||||
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
## along with Gajim. If not, see <http://www.gnu.org/licenses/>.
|
||||||
##
|
##
|
||||||
|
|
||||||
|
from gi.repository import GLib
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
from gi.repository import Gdk
|
from gi.repository import Gdk
|
||||||
from gi.repository import GObject
|
from gi.repository import GObject
|
||||||
|
@ -62,15 +62,17 @@ class CellRendererImage(Gtk.CellRendererPixbuf):
|
||||||
col = tree.get_column(self.col_index)
|
col = tree.get_column(self.col_index)
|
||||||
cell_area = tree.get_cell_area(path, col)
|
cell_area = tree.get_cell_area(path, 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.width, cell_area.height)
|
cell_area.height)
|
||||||
|
|
||||||
def animation_timeout(self, tree, image):
|
def animation_timeout(self, tree, image):
|
||||||
if image.get_storage_type() != Gtk.ImageType.ANIMATION:
|
if image.get_storage_type() != Gtk.ImageType.ANIMATION:
|
||||||
return
|
return
|
||||||
self.redraw = 0
|
self.redraw = 0
|
||||||
iter_ = self.iters[image]
|
iter_ = self.iters[image]
|
||||||
iter_.advance()
|
timeval = GLib.TimeVal()
|
||||||
|
timeval.tv_sec = GLib.get_current_time()
|
||||||
|
iter_.advance(timeval)
|
||||||
model = tree.get_model()
|
model = tree.get_model()
|
||||||
if model:
|
if model:
|
||||||
model.foreach(self.func, (image, tree))
|
model.foreach(self.func, (image, tree))
|
||||||
|
@ -89,7 +91,9 @@ class CellRendererImage(Gtk.CellRendererPixbuf):
|
||||||
if not isinstance(widget, Gtk.TreeView):
|
if not isinstance(widget, Gtk.TreeView):
|
||||||
return
|
return
|
||||||
animation = self.image.get_animation()
|
animation = self.image.get_animation()
|
||||||
iter_ = animation.get_iter()
|
timeval = GLib.TimeVal()
|
||||||
|
timeval.tv_sec = GLib.get_current_time()
|
||||||
|
iter_ = animation.get_iter(timeval)
|
||||||
self.iters[self.image] = iter_
|
self.iters[self.image] = iter_
|
||||||
GObject.timeout_add(iter_.get_delay_time(),
|
GObject.timeout_add(iter_.get_delay_time(),
|
||||||
self.animation_timeout, widget, self.image)
|
self.animation_timeout, widget, self.image)
|
||||||
|
@ -115,7 +119,9 @@ class CellRendererImage(Gtk.CellRendererPixbuf):
|
||||||
return 0, 0, 0, 0
|
return 0, 0, 0, 0
|
||||||
if self.image.get_storage_type() == Gtk.ImageType.ANIMATION:
|
if self.image.get_storage_type() == Gtk.ImageType.ANIMATION:
|
||||||
animation = self.image.get_animation()
|
animation = self.image.get_animation()
|
||||||
pix = animation.get_iter().get_pixbuf()
|
timeval = GLib.TimeVal()
|
||||||
|
timeval.tv_sec = GLib.get_current_time()
|
||||||
|
pix = animation.get_iter(timeval).get_pixbuf()
|
||||||
elif self.image.get_storage_type() == Gtk.ImageType.PIXBUF:
|
elif self.image.get_storage_type() == Gtk.ImageType.PIXBUF:
|
||||||
pix = self.image.get_pixbuf()
|
pix = self.image.get_pixbuf()
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue