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
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# -*- coding: utf-8 -*-
# Copyright (C) 2011 ceibalJAM! - ceibaljam.org
# This file is part of Saludame.
#
# Saludame is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Saludame 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 Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Saludame. If not, see <http://www.gnu.org/licenses/>.
import gtk
import rsvg
class Credits(gtk.Fixed):
def __init__(self):
gtk.Fixed.__init__(self)
self.loaded = False
self.reloaded = False
self.connect("expose-event", self._expose_cb)
self.viewport_initialized = False
def before_show(self):
if not self.loaded:
self.pixbuf = gtk.gdk.pixbuf_new_from_file("credits/background.jpg")
self.credits_pixbuf = rsvg.Handle(file="credits/saludame.svg").get_pixbuf()
height = self.credits_pixbuf.get_height()
self.adj = gtk.Adjustment(value=0, lower=0, upper=height, step_incr=20, page_incr=200, page_size=550)
scroll = gtk.VScrollbar(self.adj)
scroll.set_size_request(40, 550)
scroll.show()
scroll.connect("value-changed", self.scrolled)
self.put(scroll, 1158, 150)
self.loaded = True
elif not self.reloaded:
self.credits_pixbuf = rsvg.Handle(file="credits/saludame.svg").get_pixbuf()
self.reloaded = True
def ditch(self):
self.credits_pixbuf = None
self.reloaded = False
def scrolled(self, gtkrange):
self.queue_draw()
def _expose_cb(self, widget, event):
widget.window.draw_pixbuf(widget.style.bg_gc[gtk.STATE_NORMAL], self.pixbuf, 0, 0, 0, 0)
y = int(self.adj.get_value())
width = self.credits_pixbuf.get_width()
height = 550
widget.window.draw_pixbuf(widget.style.bg_gc[gtk.STATE_NORMAL], self.credits_pixbuf, 0, y, 50, 150, width, height)
if __name__ == "__main__":
c = Credits()
c.before_show()
main_window = gtk.Window(gtk.WINDOW_TOPLEVEL)
main_window.set_size_request(1200,700)
main_window.add(c)
main_window.show_all()
gtk.main()
|