~ubuntu-branches/debian/jessie/gnome-shell/jessie

« back to all changes in this revision

Viewing changes to js/ui/lightbox.js

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2012-05-30 13:19:38 UTC
  • mfrom: (18.1.24 experimental)
  • Revision ID: package-import@ubuntu.com-20120530131938-i3trc1g1p3is2u6x
Tags: 3.4.1-3
Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
2
2
 
 
3
const Clutter = imports.gi.Clutter;
3
4
const Lang = imports.lang;
4
5
const Meta = imports.gi.Meta;
5
6
const St = imports.gi.St;
30
31
 * @container and will track any changes in its size. You can override
31
32
 * this by passing an explicit width and height in @params.
32
33
 */
33
 
function Lightbox(container, params) {
34
 
    this._init(container, params);
35
 
}
 
34
const Lightbox = new Lang.Class({
 
35
    Name: 'Lightbox',
36
36
 
37
 
Lightbox.prototype = {
38
37
    _init : function(container, params) {
39
38
        params = Params.parse(params, { inhibitEvents: false,
40
39
                                        width: null,
59
58
        if (params.width && params.height) {
60
59
            this.actor.width = params.width;
61
60
            this.actor.height = params.height;
62
 
            this._allocationChangedSignalId = 0;
63
61
        } else {
64
 
            this.actor.width = container.width;
65
 
            this.actor.height = container.height;
66
 
            this._allocationChangedSignalId = container.connect('allocation-changed', Lang.bind(this, this._allocationChanged));
 
62
            let constraint = new Clutter.BindConstraint({ source: container,
 
63
                                                          coordinate: Clutter.BindCoordinate.ALL });
 
64
            this.actor.add_constraint(constraint);
67
65
        }
68
66
 
69
67
        this._actorAddedSignalId = container.connect('actor-added', Lang.bind(this, this._actorAdded));
72
70
        this._highlighted = null;
73
71
    },
74
72
 
75
 
    _allocationChanged : function(container, box, flags) {
76
 
        Meta.later_add(Meta.LaterType.BEFORE_REDRAW, Lang.bind(this, function() {
77
 
            this.actor.width = this.width;
78
 
            this.actor.height = this.height;
79
 
            return false;
80
 
        }));
81
 
        this.width = this._container.width;
82
 
        this.height = this._container.height;
83
 
    },
84
 
 
85
73
    _actorAdded : function(container, newChild) {
86
74
        let children = this._container.get_children();
87
75
        let myIndex = children.indexOf(this.actor);
189
177
     * by destroying its container or by explicitly calling this.destroy().
190
178
     */
191
179
    _onDestroy: function() {
192
 
        if (this._allocationChangedSignalId != 0)
193
 
            this._container.disconnect(this._allocationChangedSignalId);
194
180
        this._container.disconnect(this._actorAddedSignalId);
195
181
        this._container.disconnect(this._actorRemovedSignalId);
196
182
 
197
183
        this.highlight(null);
198
184
    }
199
 
};
 
185
});