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;
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;
19
const GNOME_PANEL_PIXMAPDIR = '../gnome-panel/fish';
20
22
const FISH_GROUP = 'Fish Animation';
22
24
const MAGIC_FISH_KEY = 'free the fish';
26
28
Extends: IconGrid.BaseIcon,
28
30
_init : function(fish, label, params) {
31
this.parent(label, params);
30
let file = GLib.build_filenamev([global.datadir, GNOME_PANEL_PIXMAPDIR, fish + '.fish']);
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);
36
this._imageFile = GLib.build_filenamev([global.datadir, GNOME_PANEL_PIXMAPDIR,
37
this._keyfile.get_string(FISH_GROUP, 'image')]);
39
let tmpPixbuf = GdkPixbuf.Pixbuf.new_from_file(this._imageFile);
41
this._imgHeight = tmpPixbuf.height;
42
this._imgWidth = tmpPixbuf.width / this._keyfile.get_integer(FISH_GROUP, 'frames');
44
this._imageFile = null;
47
this.parent(label, params);
34
this._imageFile = GLib.build_filenamev([global.datadir, fish + '.png']);
36
this._imgHeight = FISH_HEIGHT;
37
this._imgWidth = FISH_WIDTH;
50
40
createIcon: function(iconSize) {
51
if (!this._imageFile) {
52
return new St.Icon({ icon_name: 'face-smile',
53
icon_size: iconSize });
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));
63
} else if (!this._animations.mapped && this._timeoutId) {
64
GLib.source_remove(this._timeoutId);
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;
72
46
_createIconTexture: function(size) {
80
let n = this._animations.get_n_children();
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();
93
54
const WandaIconBin = new Lang.Class({
94
55
Name: 'WandaIconBin',
96
57
_init: function(fish, label, params) {
97
this.actor = new St.Bin({ style_class: 'search-result-content',
58
this.actor = new St.Bin({ reactive: true,
99
59
track_hover: true });
100
60
this.icon = new WandaIcon(fish, label, params);
157
117
const WandaSearchProvider = new Lang.Class({
158
118
Name: 'WandaSearchProvider',
159
Extends: Search.SearchProvider,
161
120
_init: function() {
162
this.parent(_("Your favorite Easter Egg"));
165
124
getResultMetas: function(fish, callback) {
185
144
this.getInitialResultSet(terms);
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);