~darkxst/ubuntu/saucy/gnome-shell/upstart_log

« back to all changes in this revision

Viewing changes to js/ui/wanda.js

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-05-31 12:01:12 UTC
  • mfrom: (1.1.49) (19.1.36 experimental)
  • Revision ID: package-import@ubuntu.com-20130531120112-ew91khxf051x9i2r
Tags: 3.8.2-1ubuntu1
* Merge with Debian (LP: #1185869, #1185721). Remaining changes:
  - debian/control.in:
    + Build-depend on libsystemd-login-dev & libsystemd-daemon-dev
    + Depend on gdm instead of gdm3
    + Don't recommend gnome-session-fallback
  - debian/patches/40_change-pam-name-to-match-gdm.patch:
  - debian/patches/revert-suspend-break.patch:
    + Disabled, not needed on Ubuntu
  - debian/patches/ubuntu-lightdm-user-switching.patch:
    + Allow user switching when using LightDM. Thanks Gerhard Stein
      for rebasing against gnome-shell 3.8!
  - debian/patches/ubuntu_lock_on_suspend.patch
    + Respect Ubuntu's lock-on-suspend setting.
      Disabled until it can be rewritten.
  - debian/patches/git_relock_screen_after_crash.patch:
    + Add Upstream fix for unlocked session after crash (LP: #1064584)
* Note that the new GNOME Classic mode (which requires installing
  gnome-shell-extensions) won't work until gnome-session 3.8 is
  available in Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
const IconGrid = imports.ui.iconGrid;
10
10
const Layout = imports.ui.layout;
11
11
const Main = imports.ui.main;
12
 
const Search = imports.ui.search;
 
12
const Panel = imports.ui.panel;
13
13
 
14
 
// we could make these gsettings
15
14
const FISH_NAME = 'wanda';
 
15
const FISH_FILENAME = 'wanda.png';
16
16
const FISH_SPEED = 300;
17
17
const FISH_COMMAND = 'fortune';
 
18
// The size of an individual frame in the animation
 
19
const FISH_HEIGHT = 22;
 
20
const FISH_WIDTH = 36;
18
21
 
19
 
const GNOME_PANEL_PIXMAPDIR = '../gnome-panel/fish';
20
22
const FISH_GROUP = 'Fish Animation';
21
23
 
22
24
const MAGIC_FISH_KEY = 'free the fish';
26
28
    Extends: IconGrid.BaseIcon,
27
29
 
28
30
    _init : function(fish, label, params) {
 
31
        this.parent(label, params);
 
32
 
29
33
        this._fish = fish;
30
 
        let file = GLib.build_filenamev([global.datadir, GNOME_PANEL_PIXMAPDIR, fish + '.fish']);
31
 
 
32
 
        if (GLib.file_test(file, GLib.FileTest.EXISTS)) {
33
 
            this._keyfile = new GLib.KeyFile();
34
 
            this._keyfile.load_from_file(file, GLib.KeyFileFlags.NONE);
35
 
 
36
 
            this._imageFile = GLib.build_filenamev([global.datadir, GNOME_PANEL_PIXMAPDIR,
37
 
                                                    this._keyfile.get_string(FISH_GROUP, 'image')]);
38
 
 
39
 
            let tmpPixbuf = GdkPixbuf.Pixbuf.new_from_file(this._imageFile);
40
 
 
41
 
            this._imgHeight = tmpPixbuf.height;
42
 
            this._imgWidth = tmpPixbuf.width / this._keyfile.get_integer(FISH_GROUP, 'frames');
43
 
        } else {
44
 
            this._imageFile = null;
45
 
        }
46
 
 
47
 
        this.parent(label, params);
 
34
        this._imageFile = GLib.build_filenamev([global.datadir, fish + '.png']);
 
35
 
 
36
        this._imgHeight = FISH_HEIGHT;
 
37
        this._imgWidth = FISH_WIDTH;
48
38
    },
49
39
 
50
40
    createIcon: function(iconSize) {
51
 
        if (!this._imageFile) {
52
 
            return new St.Icon({ icon_name: 'face-smile',
53
 
                                 icon_size: iconSize });
54
 
        }
55
 
 
56
 
        this._animations = St.TextureCache.get_default().load_sliced_image(this._imageFile, this._imgWidth, this._imgHeight);
57
 
        this._animations.connect('notify::mapped', Lang.bind(this, function() {
58
 
            if (this._animations.mapped && !this._timeoutId) {
59
 
                this._timeoutId = GLib.timeout_add(GLib.PRIORITY_DEFAULT, FISH_SPEED, Lang.bind(this, this._update));
60
 
 
61
 
                this._i = 0;
62
 
                this._update();
63
 
            } else if (!this._animations.mapped && this._timeoutId) {
64
 
                GLib.source_remove(this._timeoutId);
65
 
                this._timeoutId = 0;
66
 
            }
67
 
        }));
68
 
 
69
 
        return this._animations;
 
41
        this._animations = new Panel.Animation(this._imageFile, this._imgWidth, this._imgHeight, FISH_SPEED);
 
42
        this._animations.play();
 
43
        return this._animations.actor;
70
44
    },
71
45
 
72
46
    _createIconTexture: function(size) {
74
48
            return;
75
49
 
76
50
        this.parent(size);
77
 
    },
78
 
 
79
 
    _update: function() {
80
 
        let n = this._animations.get_n_children();
81
 
        if (n == 0) {
82
 
            return true;
83
 
        }
84
 
 
85
 
        this._animations.get_child_at_index(this._i).hide();
86
 
        this._i = (this._i + 1) % n;
87
 
        this._animations.get_child_at_index(this._i).show();
88
 
 
89
 
        return true;
90
 
    },
 
51
    }
91
52
});
92
53
 
93
54
const WandaIconBin = new Lang.Class({
94
55
    Name: 'WandaIconBin',
95
56
 
96
57
    _init: function(fish, label, params) {
97
 
        this.actor = new St.Bin({ style_class: 'search-result-content',
98
 
                                  reactive: true,
 
58
        this.actor = new St.Bin({ reactive: true,
99
59
                                  track_hover: true });
100
60
        this.icon = new WandaIcon(fish, label, params);
101
61
 
156
116
 
157
117
const WandaSearchProvider = new Lang.Class({
158
118
    Name: 'WandaSearchProvider',
159
 
    Extends: Search.SearchProvider,
160
119
 
161
120
    _init: function() {
162
 
        this.parent(_("Your favorite Easter Egg"));
 
121
        this.id = 'wanda';
163
122
    },
164
123
 
165
124
    getResultMetas: function(fish, callback) {
185
144
        this.getInitialResultSet(terms);
186
145
    },
187
146
 
188
 
    activateResult: function(fish, params) {
 
147
    activateResult: function(fish) {
189
148
        if (this._dialog)
190
149
            this._dialog.destroy();
191
150
        this._dialog = new FortuneDialog(capitalize(fish), FISH_COMMAND);