1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# images_list.py
#
# Copyright 2012 S. Daniel Francis <francis@sugarlabs.org>,
# Agustin Zubiaga <aguz@sugarlabs.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
import gtk
class FramesList(gtk.ScrolledWindow):
def __init__(self):
super(FramesList, self).__init__()
self.set_size_request(225, -1)
self.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
self.store = gtk.ListStore(int, gtk.gdk.Pixbuf, str)
self.treeview = gtk.TreeView(self.store)
self.set_vadjustment(self.treeview.get_vadjustment())
self.treeview.connect("row-activated", self._row_activated_cb)
column = gtk.TreeViewColumn("Frame")
self.treeview.append_column(column)
num_cell = gtk.CellRendererText()
preview_cell = gtk.CellRendererPixbuf()
path_cell = gtk.CellRendererText()
column.pack_start(num_cell)
column.pack_start(preview_cell)
column.pack_start(path_cell)
column.add_attribute(num_cell, 'text', 0)
column.add_attribute(preview_cell, 'pixbuf', 1)
column.add_attribute(path_cell, 'text', 2)
path_cell.set_property('visible', False)
self.treeview.show()
self.add(self.treeview)
self.frames = 0
def add_frame(self, pixbuf, imagepath):
self.frames += 1
width = pixbuf.get_width()
height = pixbuf.get_height()
preview_pixbuf = pixbuf.scale_simple(200,
200 * height / width,
gtk.gdk.INTERP_TILES)
self.store.append([self.frames, preview_pixbuf, imagepath])
def _row_activated_cb(self, treeview, treepath, column):
#FIXME: I don't show the correct image always
self._animation.images = [i[-1] for i in self.store]
self._animation.set_pos(treepath[0])
|