~dobey/ubuntuone-installer/unicode-gettext

« back to all changes in this revision

Viewing changes to ubuntuone/installer/gui.py

  • Committer: Rodney Dawes
  • Date: 2011-08-24 17:27:17 UTC
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: rodney.dawes@canonical.com-20110824172717-52r104nffmf3dycr
Update the main page to the new/final design
Update the _find_data_file method to work within trial tmp dir

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
import aptdaemon.client as aptclient
20
20
import os
21
21
 
22
 
from gi.repository import Gtk, GObject, GLib, Gdk
 
22
from gi.repository import Gtk, GObject, GLib, Gdk, Pango
23
23
 
24
24
# Some shenanigans to deal with pyflakes complaining
25
25
inline_callbacks = None
36
36
    """Exception for when on an unsupported distribution."""
37
37
 
38
38
 
 
39
class VSeparator(Gtk.VSeparator):
 
40
    """A dotted line separator."""
 
41
 
 
42
    def do_draw(self, cairo_context):
 
43
        """Draw some magic."""
 
44
        sc = self.get_style_context()
 
45
        state = self.get_state_flags()
 
46
        width = self.get_allocated_width()
 
47
        height = self.get_allocated_height()
 
48
 
 
49
        sc.save()
 
50
        sc.set_state(state)
 
51
 
 
52
        y = 0
 
53
        x = width / 2
 
54
        while y < height:
 
55
            Gtk.render_activity(sc, cairo_context, float(x), float(y), 1, 1)
 
56
            y += 3
 
57
 
 
58
        sc.restore()
 
59
        return True
 
60
 
 
61
 
39
62
class Window(Gtk.Window):
40
63
    """The main dialog to use."""
41
64
 
51
74
        self.set_position(Gtk.WindowPosition.CENTER)
52
75
 
53
76
        vbox = Gtk.VBox()
 
77
        vbox.set_spacing(24)
54
78
        self.add(vbox)
55
79
        vbox.show()
56
80
 
57
 
        self.__header = Gtk.Image()
58
 
        self.__header.set_size_request(734, 162)
 
81
        self.__header = Gtk.HBox()
 
82
        self.__header.set_border_width(12)
 
83
        self.__header.set_spacing(64)
59
84
        vbox.pack_start(self.__header, False, False, 0)
60
85
        self.__header.show()
61
86
 
62
 
        header = self.__find_data_file('header.png')
63
 
        if header:
64
 
            self.__header.set_from_file(header)
 
87
        self.__hlabelbox = Gtk.VBox()
 
88
        self.__hlabelbox.set_spacing(12)
 
89
        self.__header.pack_start(self.__hlabelbox, True, True, 0)
 
90
        self.__hlabelbox.show()
 
91
 
 
92
        self.__hlabel = Gtk.Label((u'<span size="xx-large">{}</span>').format(
 
93
                u'Install Ubuntu One'))
 
94
        self.__hlabel.set_use_markup(True)
 
95
        self.__hlabel.set_alignment(0.0, 0.0)
 
96
        self.__hlabelbox.pack_start(self.__hlabel, False, False, 0)
 
97
        self.__hlabel.show()
 
98
 
 
99
        self.__hlabel2 = Gtk.Label((u'<span size="large">{}</span>').format(
 
100
                u'Discover the freedom of your personal cloud'))
 
101
        self.__hlabel2.set_use_markup(True)
 
102
        self.__hlabel2.set_alignment(0.0, 0.0)
 
103
        self.__hlabelbox.pack_start(self.__hlabel2, False, False, 0)
 
104
        self.__hlabel2.show()
 
105
 
 
106
        self.__hlogo = Gtk.Image()
 
107
        self.__header.pack_end(self.__hlogo, False, False, 0)
 
108
        self.__hlogo.show()
 
109
 
 
110
        logo = self.__find_data_file('u1logo.png')
 
111
        if logo:
 
112
            self.__hlogo.set_from_file(logo)
65
113
 
66
114
        self.__notebook = Gtk.Notebook()
67
115
        self.__notebook.set_show_tabs(False)
68
116
        self.__notebook.set_show_border(False)
69
117
        self.__notebook.set_scrollable(False)
70
118
        self.__notebook.popup_disable()
71
 
        self.__notebook.set_size_request(734, 240)
 
119
        #self.__notebook.set_size_request(734, 240)
72
120
 
73
121
        self.__info_page = self.__construct_info_page()
74
122
        self.__notebook.append_page(self.__info_page, None)
81
129
        self.__notebook.append_page(self.__progress_page, None)
82
130
        self.__progress_page.show()
83
131
 
84
 
        vbox.add(self.__notebook)
 
132
        vbox.pack_start(self.__notebook, False, False, 0)
85
133
        self.__notebook.show()
86
134
 
87
135
        self.__action_area = Gtk.HButtonBox()
129
177
        if os.path.exists(path):
130
178
            return os.path.abspath(path)
131
179
 
 
180
        path = os.path.join(os.getcwd(), os.path.pardir, os.path.pardir,
 
181
                            'data', filename)
 
182
        if os.path.exists(path):
 
183
            return os.path.abspath(path)
 
184
 
132
185
        for folder in GLib.get_system_data_dirs():
133
186
            path = os.path.join(folder, 'ubuntuone-installer', filename)
134
187
            if os.path.exists(path):
146
199
 
147
200
    def __construct_info_page(self):
148
201
        """Build the initial info page."""
149
 
        page = Gtk.VBox()
150
 
        page.set_border_width(24)
 
202
        page = Gtk.HBox()
 
203
        page.set_border_width(12)
 
204
        page.set_spacing(12)
151
205
        page.show()
152
206
 
153
 
        label = Gtk.Label(
154
 
            u'<big><b>{}</b></big>\n\n {}\n {}\n {}'.format(
155
 
                u'The personal cloud that brings your digital life together',
156
 
                u'•  Synchronize files across devices\n',
157
 
                u'•  Access files from anywhere\n',
158
 
                (u'•  Add Music Streaming for unlimited'
159
 
                 u' music on the go')))
160
 
        label.set_use_markup(True)
161
 
        label.set_alignment(0.0, 0.0)
162
 
        page.add(label)
 
207
        # Get the width of a larger character in pixels
 
208
        layout = page.create_pango_layout(u'W')
 
209
        (width, height) = layout.get_size()
 
210
        width = width / Pango.SCALE
 
211
        height = height / Pango.SCALE
 
212
 
 
213
        table = Gtk.Table(3, 5, False)
 
214
        table.set_row_spacings(12)
 
215
        table.set_col_spacings(12)
 
216
        page.pack_start(table, True, True, 24)
 
217
        table.show()
 
218
 
 
219
        label = Gtk.Label(u'<big>{}</big>'.format(u'Sync'))
 
220
        label.set_use_markup(True)
 
221
        table.attach_defaults(label, 0, 1, 0, 1)
 
222
        label.show()
 
223
 
 
224
        image = Gtk.Image()
 
225
        table.attach_defaults(image, 0, 1, 1, 2)
 
226
        image.show()
 
227
        path = self.__find_data_file('sync.png')
 
228
        if path:
 
229
            image.set_from_file(path)
 
230
 
 
231
        # Get the width in chars to set max for description labels
 
232
        width_chars = (image.get_pixbuf().get_width() / width) * 2.5
 
233
 
 
234
        label = Gtk.Label(u'<small>{}</small>'.format(
 
235
                (u'Sync files across your devices.')))
 
236
        label.set_max_width_chars(width_chars)
 
237
        label.set_width_chars(width_chars)
 
238
        label.set_use_markup(True)
 
239
        label.set_line_wrap(True)
 
240
        label.set_alignment(0.5, 0.0)
 
241
        label.set_justify(Gtk.Justification.CENTER)
 
242
        table.attach_defaults(label, 0, 1, 2, 3)
 
243
        label.show()
 
244
 
 
245
        separator = VSeparator()
 
246
        table.attach_defaults(separator, 1, 2, 0, 3)
 
247
        separator.show()
 
248
 
 
249
        label = Gtk.Label(u'<big>{}</big>'.format(u'Stream'))
 
250
        label.set_use_markup(True)
 
251
        table.attach_defaults(label, 2, 3, 0, 1)
 
252
        label.show()
 
253
 
 
254
        image = Gtk.Image()
 
255
        table.attach_defaults(image, 2, 3, 1, 2)
 
256
        image.show()
 
257
        path = self.__find_data_file('stream.png')
 
258
        if path:
 
259
            image.set_from_file(path)
 
260
 
 
261
        label = Gtk.Label(u'<small>{}</small>'.format(
 
262
                (u'Stream your music on the move and offline.')))
 
263
        label.set_max_width_chars(width_chars)
 
264
        label.set_width_chars(width_chars)
 
265
        label.set_use_markup(True)
 
266
        label.set_line_wrap(True)
 
267
        label.set_alignment(0.5, 0.0)
 
268
        label.set_justify(Gtk.Justification.CENTER)
 
269
        table.attach_defaults(label, 2, 3, 2, 3)
 
270
        label.show()
 
271
 
 
272
        separator = VSeparator()
 
273
        table.attach_defaults(separator, 3, 4, 0, 3)
 
274
        separator.show()
 
275
 
 
276
        label = Gtk.Label(u'<big>{}</big>'.format(u'Share'))
 
277
        label.set_use_markup(True)
 
278
        table.attach_defaults(label, 4, 5, 0, 1)
 
279
        label.show()
 
280
 
 
281
        image = Gtk.Image()
 
282
        table.attach_defaults(image, 4, 5, 1, 2)
 
283
        image.show()
 
284
        path = self.__find_data_file('share.png')
 
285
        if path:
 
286
            image.set_from_file(path)
 
287
 
 
288
        label = Gtk.Label(u'<small>{}</small>'.format(
 
289
                (u'Share with colleagues, friends, and family.')))
 
290
        label.set_max_width_chars(width_chars)
 
291
        label.set_width_chars(width_chars)
 
292
        label.set_use_markup(True)
 
293
        label.set_line_wrap(True)
 
294
        label.set_alignment(0.5, 0.0)
 
295
        label.set_justify(Gtk.Justification.CENTER)
 
296
        table.attach_defaults(label, 4, 5, 2, 3)
163
297
        label.show()
164
298
 
165
299
        return page