~ubuntu-branches/ubuntu/quantal/gnome-documents/quantal

« back to all changes in this revision

Viewing changes to src/errorBox.js

  • Committer: Package Import Robot
  • Author(s): Robert Ancell
  • Date: 2012-08-22 10:01:18 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20120822100118-3837rqfy72e1op72
Tags: 3.5.90-0ubuntu1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2011 Red Hat, Inc.
3
 
 *
4
 
 * Gnome Documents is free software; you can redistribute it and/or modify
5
 
 * it under the terms of the GNU General Public License as published by the
6
 
 * Free Software Foundation; either version 2 of the License, or (at your
7
 
 * option) any later version.
8
 
 *
9
 
 * Gnome Documents is distributed in the hope that it will be useful, but
10
 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11
 
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
12
 
 * for more details.
13
 
 *
14
 
 * You should have received a copy of the GNU General Public License along
15
 
 * with Gnome Documents; if not, write to the Free Software Foundation,
16
 
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
 
 *
18
 
 * Author: Cosimo Cecchi <cosimoc@redhat.com>
19
 
 *
20
 
 */
21
 
 
22
 
const GLib = imports.gi.GLib;
23
 
const Gtk = imports.gi.Gtk;
24
 
const GtkClutter = imports.gi.GtkClutter;
25
 
 
26
 
const Lang = imports.lang;
27
 
const Tweener = imports.util.tweener;
28
 
 
29
 
const _ICON_SIZE = 128;
30
 
 
31
 
const ErrorBox = new Lang.Class({
32
 
    Name: 'ErrorBox',
33
 
 
34
 
    _init: function(primary, secondary) {
35
 
        this.widget = new Gtk.Grid({ orientation: Gtk.Orientation.VERTICAL,
36
 
                                     row_spacing: 12,
37
 
                                     hexpand: true,
38
 
                                     vexpand: true,
39
 
                                     halign: Gtk.Align.CENTER,
40
 
                                     valign: Gtk.Align.CENTER });
41
 
 
42
 
        this._image = new Gtk.Image({ pixel_size: _ICON_SIZE,
43
 
                                      icon_name: 'dialog-error',
44
 
                                      halign: Gtk.Align.CENTER,
45
 
                                      valign: Gtk.Align.CENTER });
46
 
 
47
 
        this.widget.add(this._image);
48
 
 
49
 
        this._primaryLabel =
50
 
            new Gtk.Label({ label: '',
51
 
                            use_markup: true,
52
 
                            halign: Gtk.Align.CENTER,
53
 
                            valign: Gtk.Align.CENTER });
54
 
        this.widget.add(this._primaryLabel);
55
 
 
56
 
        this._secondaryLabel =
57
 
            new Gtk.Label({ label: '',
58
 
                            use_markup: true,
59
 
                            halign: Gtk.Align.CENTER,
60
 
                            valign: Gtk.Align.CENTER });
61
 
        this.widget.add(this._secondaryLabel);
62
 
 
63
 
        this.widget.show_all();
64
 
 
65
 
        this.actor = new GtkClutter.Actor({ contents: this.widget,
66
 
                                            opacity: 255 });
67
 
    },
68
 
 
69
 
    update: function(primary, secondary) {
70
 
        let primaryMarkup = '<big><b>' + GLib.markup_escape_text(primary, -1) + '</b></big>';
71
 
        let secondaryMarkup = GLib.markup_escape_text(secondary, -1);
72
 
 
73
 
        this._primaryLabel.label = primaryMarkup;
74
 
        this._secondaryLabel.label = secondaryMarkup;
75
 
    },
76
 
 
77
 
    moveIn: function() {
78
 
        this.actor.raise_top();
79
 
 
80
 
        Tweener.addTween(this.actor, { opacity: 255,
81
 
                                       time: 0.30,
82
 
                                       transition: 'easeOutQuad' });
83
 
    },
84
 
 
85
 
    moveOut: function() {
86
 
        Tweener.addTween(this.actor, { opacity: 0,
87
 
                                       time: 0.30,
88
 
                                       transition: 'easeOutQuad',
89
 
                                       onComplete: function () {
90
 
                                           this.actor.lower_bottom();
91
 
                                       },
92
 
                                       onCompleteScope: this });
93
 
    }
94
 
});