Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src/controlpanel/aboutxo/view.py
blob: f85e8d271413d95b040a13c29aff47a49e956294 (plain)
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# coding=utf-8
# Copyright (C) 2008, OLPC
#
# 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
from gettext import gettext as _

import config
from sugar.graphics import style

from controlpanel.sectionview import SectionView

class AboutXO(SectionView):
    def __init__(self, model, alerts=None):
        SectionView.__init__(self)

        self._model = model

        self.set_border_width(style.DEFAULT_SPACING * 2)
        self.set_spacing(style.DEFAULT_SPACING)

        self._group = gtk.SizeGroup(gtk.SIZE_GROUP_HORIZONTAL)

        scrollwindow = gtk.ScrolledWindow()
        scrollwindow.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
        self.pack_start(scrollwindow, expand=True)
        scrollwindow.show()

        self._vbox = gtk.VBox()
        scrollwindow.add_with_viewport(self._vbox)
        self._vbox.show()

        self._setup_identity()
        self._setup_software()
        self._setup_copyright()

    def _setup_identity(self):
        separator_identity = gtk.HSeparator()
        self._vbox.pack_start(separator_identity, expand=False)
        separator_identity.show()

        label_identity = gtk.Label(_('Identity'))
        label_identity.set_alignment(0, 0)
        self._vbox.pack_start(label_identity, expand=False)
        label_identity.show()
        vbox_identity = gtk.VBox()
        vbox_identity.set_border_width(style.DEFAULT_SPACING * 2)
        vbox_identity.set_spacing(style.DEFAULT_SPACING)

        box_identity = gtk.HBox(spacing=style.DEFAULT_SPACING)
        label_serial = gtk.Label(_('Serial Number:'))
        label_serial.set_alignment(1, 0)
        label_serial.modify_fg(gtk.STATE_NORMAL, 
                               style.COLOR_SELECTION_GREY.get_gdk_color())
        box_identity.pack_start(label_serial, expand=False)
        self._group.add_widget(label_serial)
        label_serial.show()
        label_serial_no = gtk.Label(self._model.get_serial_number())
        label_serial_no.set_alignment(0, 0)
        box_identity.pack_start(label_serial_no, expand=False)
        label_serial_no.show()
        vbox_identity.pack_start(box_identity, expand=False)
        box_identity.show()

        self._vbox.pack_start(vbox_identity, expand=False)
        vbox_identity.show()
    

    def _setup_software(self):   
        separator_software = gtk.HSeparator()
        self._vbox.pack_start(separator_software, expand=False)
        separator_software.show()

        label_software = gtk.Label(_('Software'))
        label_software.set_alignment(0, 0)
        self._vbox.pack_start(label_software, expand=False)
        label_software.show()
        box_software = gtk.VBox()
        box_software.set_border_width(style.DEFAULT_SPACING * 2)
        box_software.set_spacing(style.DEFAULT_SPACING)

        box_build = gtk.HBox(spacing=style.DEFAULT_SPACING)
        label_build = gtk.Label(_('Build:'))
        label_build.set_alignment(1, 0)
        label_build.modify_fg(gtk.STATE_NORMAL, 
                              style.COLOR_SELECTION_GREY.get_gdk_color())
        box_build.pack_start(label_build, expand=False)
        self._group.add_widget(label_build)
        label_build.show()
        label_build_no = gtk.Label(self._model.get_build_number())
        label_build_no.set_alignment(0, 0)
        box_build.pack_start(label_build_no, expand=False)
        label_build_no.show()
        box_software.pack_start(box_build, expand=False)
        box_build.show()

        box_sugar = gtk.HBox(spacing=style.DEFAULT_SPACING)
        label_sugar = gtk.Label(_('Sugar:'))
        label_sugar.set_alignment(1, 0)
        label_sugar.modify_fg(gtk.STATE_NORMAL,
                              style.COLOR_SELECTION_GREY.get_gdk_color())
        box_sugar.pack_start(label_sugar, expand=False)
        self._group.add_widget(label_sugar)
        label_sugar.show()
        label_sugar_ver = gtk.Label(config.version)
        label_sugar_ver.set_alignment(0, 0)
        box_sugar.pack_start(label_sugar_ver, expand=False)
        label_sugar_ver.show()
        box_software.pack_start(box_sugar, expand=False)
        box_sugar.show()

        box_firmware = gtk.HBox(spacing=style.DEFAULT_SPACING)
        label_firmware = gtk.Label(_('Firmware:'))
        label_firmware.set_alignment(1, 0)
        label_firmware.modify_fg(gtk.STATE_NORMAL, 
                              style.COLOR_SELECTION_GREY.get_gdk_color())
        box_firmware.pack_start(label_firmware, expand=False)
        self._group.add_widget(label_firmware)
        label_firmware.show()
        label_firmware_no = gtk.Label(self._model.get_firmware_number())
        label_firmware_no.set_alignment(0, 0)
        box_firmware.pack_start(label_firmware_no, expand=False)
        label_firmware_no.show()
        box_software.pack_start(box_firmware, expand=False)
        box_firmware.show()

        self._vbox.pack_start(box_software, expand=False)
        box_software.show()

    def _setup_copyright(self):
        separator_copyright = gtk.HSeparator()
        self._vbox.pack_start(separator_copyright, expand=False)
        separator_copyright.show()

        label_copyright = gtk.Label(_('Copyright and License'))
        label_copyright.set_alignment(0, 0)
        self._vbox.pack_start(label_copyright, expand=False)
        label_copyright.show()
        vbox_copyright = gtk.VBox()
        vbox_copyright.set_border_width(style.DEFAULT_SPACING * 2)
        vbox_copyright.set_spacing(style.DEFAULT_SPACING)

        label_copyright = gtk.Label(_("© 2008 One Laptop per Child "
                                      "Association Inc; Red Hat Inc; "
                                      "and Contributors."))
        label_copyright.set_alignment(0, 0)
        label_copyright.show()
        vbox_copyright.pack_start(label_copyright, expand=False)

        label_info = gtk.Label(_("Sugar is the graphical user interface that "
                                 "you are looking at. Sugar is free software, "
                                 "covered by the GNU General Public License, "
                                 "and you are welcome to change it and/or "
                                 "distribute copies of it under certain "
                                 "conditions described therein."))
        label_info.set_alignment(0, 0)
        label_info.set_line_wrap(True)
        label_info.set_size_request(gtk.gdk.screen_width() / 2, -1)
        label_info.show()
        vbox_copyright.pack_start(label_info, expand=False)

        expander = gtk.Expander(_("Full license:"))
        expander.connect("notify::expanded", self.license_expander_cb)
        expander.show()
        vbox_copyright.pack_start(expander, expand=True)

        self._vbox.pack_start(vbox_copyright, expand=True)
        vbox_copyright.show()

    def license_expander_cb(self, expander, param_spec):
        # load/destroy the license viewer on-demand, to avoid storing the
        # GPL in memory at all times
        if expander.get_expanded():
            view_license = gtk.TextView()
            view_license.set_editable(False)
            view_license.get_buffer().set_text(self._model.get_license())
            view_license.show()
            expander.add(view_license)
        else:
            expander.get_child().destroy()