-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathWelcomeView.py
129 lines (100 loc) · 4.12 KB
/
WelcomeView.py
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# InstructionsView.py por:
# Flavio Danesse <[email protected]>
# Uruguay
# 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 2 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 St, Fifth Floor, Boston, MA 02110-1301 USA
import gtk
import gobject
import pango
from Globales import COLORES, is_xo
class WelcomeView(gtk.EventBox):
__gsignals__ = {
"instructions": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, ( )),
"credits": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, ( )),
"start": (gobject.SIGNAL_RUN_FIRST,
gobject.TYPE_NONE, ( ))}
def __init__(self):
gtk.EventBox.__init__(self)
self.modify_bg(gtk.STATE_NORMAL, COLORES["contenido"])
self.set_border_width(4)
self.image = gtk.Image()
self.image.set_from_file("Imagenes/ple.png")
tabla = gtk.Table(rows=10, columns=2, homogeneous=False)
tabla.set_border_width(16)
tabla.attach(self.image, 0, 2, 0, 9)
bb = gtk.HButtonBox()
bb.set_layout(gtk.BUTTONBOX_SPREAD)
b = gtk.Button("")
b.set_relief(gtk.RELIEF_NONE)
b.modify_bg(gtk.STATE_NORMAL, COLORES["toolbar"])
b.connect("enter-notify-event", self.__color, "manual")
b.connect("leave-notify-event", self.__decolor, "manual")
b.connect("clicked", self.__instructions)
img = gtk.Image()
img.set_from_file("Imagenes/manual_disabled.png")
b.set_image(img)
bb.pack_start(b, True, True, 0)
img.show()
b = gtk.Button("")
b.set_relief(gtk.RELIEF_NONE)
b.modify_bg(gtk.STATE_NORMAL, COLORES["toolbar"])
b.connect("enter-notify-event", self.__color, "contributors")
b.connect("leave-notify-event", self.__decolor, "contributors")
b.connect("clicked", self.__credits)
img = gtk.Image()
img.set_from_file("Imagenes/contributors_disabled.png")
b.set_image(img)
bb.pack_start(b, True, True, 0)
img.show()
bb.show_all()
b = gtk.Button("")
b.set_relief(gtk.RELIEF_NONE)
b.modify_bg(gtk.STATE_NORMAL, COLORES["toolbar"])
b.connect("clicked", self.__start)
#b.connect("enter-notify-event", self.__color, "start")
#b.connect("leave-notify-event", self.__decolor, "start")
img = gtk.Image()
img.set_from_file("Imagenes/start.png")
b.set_image(img)
bb.pack_start(b, True, True, 0)
img.show()
bb.show_all()
tabla.attach(bb, 0, 2, 9, 10)
self.add(tabla)
self.show_all()
def __decolor(self, widget, event, filestub):
widget.get_image().set_from_file("Imagenes/%s_disabled.png" % filestub)
def __color(self, widget, event, filestub):
widget.get_image().set_from_file("Imagenes/%s.png" % filestub)
def __instructions(self, widget):
self.emit("instructions")
def __credits(self, widget):
self.emit("credits")
def __start(self, widget):
self.emit("start")
def stop(self):
self.hide()
def fix_scale(self):
pixbuf = gtk.gdk.pixbuf_new_from_file("Imagenes/welcome_slide.png")
screen = self.parent.get_screen()
offset = 220 if not is_xo() else 340
desired_height = screen.get_height() - offset
desired_width = pixbuf.get_height() / desired_height * pixbuf.get_width()
pixbuf = pixbuf.scale_simple(desired_width , desired_height, gtk.gdk.INTERP_BILINEAR)
self.image.set_from_pixbuf(pixbuf)
def run(self):
self.fix_scale()
self.show()