~ubuntu-branches/ubuntu/precise/gnome-shell/precise

« back to all changes in this revision

Viewing changes to js/ui/magnifierDBus.js

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2012-03-14 13:47:20 UTC
  • mfrom: (1.1.36) (18.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20120314134720-202sbjbu4a3z1fru
Tags: 3.3.90-0ubuntu1
* Sync with Debian experimental svn packaging (LP: #941755, #937709).
  Remaining changes:
  - debian/gnome-shell.gsettings-override: Update for Ubuntu defaults
  - debian/control.in: Recommend cups-pk-helper
  - debian/patches/10-make-NetworkManager-optional.patch: Disabled
  - Don't run dh-autoreconf

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 DBus = imports.dbus;
 
3
const Gio = imports.gi.Gio;
 
4
const Lang = imports.lang;
4
5
const Main = imports.ui.main;
5
6
 
6
7
const MAG_SERVICE_NAME = 'org.gnome.Magnifier';
10
11
 
11
12
// Subset of gnome-mag's Magnifier dbus interface -- to be expanded.  See:
12
13
// http://git.gnome.org/browse/gnome-mag/tree/xml/...Magnifier.xml
13
 
const MagnifierIface = {
14
 
    name: MAG_SERVICE_NAME,
15
 
    methods: [
16
 
                { name: 'setActive', inSignature: 'b', outSignature: '' },
17
 
                { name: 'isActive', inSignature: '', outSignature: 'b' },
18
 
                { name: 'showCursor', inSignature: '', outSignature: '' },
19
 
                { name: 'hideCursor', inSignature: '', outSignature: ''  },
20
 
                { name: 'createZoomRegion', inSignature: 'ddaiai', outSignature: 'o' },
21
 
                { name: 'addZoomRegion', inSignature: 'o', outSignature: 'b' },
22
 
                { name: 'getZoomRegions', inSignature: '', outSignature: 'ao' },
23
 
                { name: 'clearAllZoomRegions', inSignature: '', outSignature: '' },
24
 
                { name: 'fullScreenCapable', inSignature: '', outSignature: 'b' },
25
 
 
26
 
                { name: 'setCrosswireSize', inSignature: 'i', outSignature: '' },
27
 
                { name: 'getCrosswireSize', inSignature: '', outSignature: 'i' },
28
 
                { name: 'setCrosswireLength', inSignature: 'i', outSignature: '' },
29
 
                { name: 'getCrosswireLength', inSignature: '', outSignature: 'i' },
30
 
                { name: 'setCrosswireClip', inSignature: 'b', outSignature: '' },
31
 
                { name: 'getCrosswireClip', inSignature: '', outSignature: 'b' },
32
 
                { name: 'setCrosswireColor', inSignature: 'u', outSignature: '' },
33
 
                { name: 'getCrosswireColor', inSignature: '', outSignature: 'u' }
34
 
             ],
35
 
    signals: [],
36
 
    properties: []
37
 
};
 
14
const MagnifierIface = <interface name={MAG_SERVICE_NAME}>
 
15
<method name="setActive">
 
16
    <arg type="b" direction="in" />
 
17
</method>
 
18
<method name="isActive">
 
19
    <arg type="b" direction="out" />
 
20
</method>
 
21
<method name="showCursor" />
 
22
<method name="hideCursor" />
 
23
<method name="createZoomRegion">
 
24
    <arg type="d" direction="in" />
 
25
    <arg type="d" direction="in" />
 
26
    <arg type="ai" direction="in" />
 
27
    <arg type="ai" direction="in" />
 
28
    <arg type="o" direction="out" />
 
29
</method>
 
30
<method name="addZoomRegion">
 
31
    <arg type="o" direction="in" />
 
32
    <arg type="b" direction="out" />
 
33
</method>
 
34
<method name="getZoomRegions">
 
35
    <arg type="ao" direction="out" />
 
36
</method>
 
37
<method name="clearAllZoomRegions" />
 
38
<method name="fullScreenCapable">
 
39
    <arg type="b" direction="out" />
 
40
</method>
 
41
<method name="setCrosswireSize">
 
42
    <arg type="i" direction="in" />
 
43
</method>
 
44
<method name="getCrosswireSize">
 
45
    <arg type="i" direction="out" />
 
46
</method>
 
47
<method name="setCrosswireLength">
 
48
    <arg type="i" direction="in" />
 
49
</method>
 
50
<method name="getCrosswireLength">
 
51
    <arg type="i" direction="out" />
 
52
</method>
 
53
<method name="setCrosswireClip">
 
54
    <arg type="b" direction="in" />
 
55
</method>
 
56
<method name="getCrosswireClip">
 
57
    <arg type="b" direction="out" />
 
58
</method>
 
59
<method name="setCrosswireColor">
 
60
    <arg type="u" direction="in" />
 
61
</method>
 
62
<method name="getCrosswireColor">
 
63
    <arg type="u" direction="out" />
 
64
</method>
 
65
</interface>;
38
66
 
39
67
// Subset of gnome-mag's ZoomRegion dbus interface -- to be expanded.  See:
40
68
// http://git.gnome.org/browse/gnome-mag/tree/xml/...ZoomRegion.xml
41
 
const ZoomRegionIface = {
42
 
    name: ZOOM_SERVICE_NAME,
43
 
    methods: [
44
 
                { name: 'setMagFactor', inSignature: 'dd', outSignature: ''},
45
 
                { name: 'getMagFactor', inSignature: '', outSignature: 'dd' },
46
 
                { name: 'setRoi', inSignature: 'ai', outSignature: '' },
47
 
                { name: 'getRoi', inSignature: '', outSignature: 'ai' },
48
 
                { name: 'shiftContentsTo', inSignature: 'ii', outSignature: 'b' },
49
 
                { name: 'moveResize', inSignature: 'ai', outSignature: '' }
50
 
             ],
51
 
    signals: [],
52
 
    properties: []
53
 
};
 
69
const ZoomRegionIface = <interface name={ZOOM_SERVICE_NAME}>
 
70
<method name="setMagFactor">
 
71
    <arg type="d" direction="in" />
 
72
    <arg type="d" direction="in" />
 
73
</method>
 
74
<method name="getMagFactor">
 
75
    <arg type="d" direction="out" />
 
76
    <arg type="d" direction="out" />
 
77
</method>
 
78
<method name="setRoi">
 
79
    <arg type="ai" direction="in" />
 
80
</method>
 
81
<method name="getRoi">
 
82
    <arg type="ai" direction="out" />
 
83
</method>
 
84
<method name="shiftContentsTo">
 
85
    <arg type="i" direction="in" />
 
86
    <arg type="i" direction="in" />
 
87
    <arg type="b" direction="out" />
 
88
</method>
 
89
<method name="moveResize">
 
90
    <arg type="ai" direction="in" />
 
91
</method>
 
92
</interface>;
54
93
 
55
94
// For making unique ZoomRegion DBus proxy object paths of the form:
56
95
// '/org/gnome/Magnifier/ZoomRegion/zoomer0',
57
96
// '/org/gnome/Magnifier/ZoomRegion/zoomer1', etc.
58
97
let _zoomRegionInstanceCount = 0;
59
98
 
60
 
function ShellMagnifier() {
61
 
    this._init();
62
 
}
 
99
const ShellMagnifier = new Lang.Class({
 
100
    Name: 'ShellMagnifier',
63
101
 
64
 
ShellMagnifier.prototype = {
65
102
    _init: function() {
66
103
        this._zoomers = {};
67
 
        DBus.session.exportObject(MAG_SERVICE_PATH, this);
 
104
 
 
105
        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(MagnifierIface, this);
 
106
        this._dbusImpl.export(Gio.DBus.session, MAG_SERVICE_PATH);
68
107
    },
69
108
 
70
109
    /**
195
234
        Main.magnifier.clearAllZoomRegions();
196
235
        for (let objectPath in this._zoomers) {
197
236
            let proxyAndZoomer = this._zoomers[objectPath];
 
237
            proxyAndZoomer.proxy.destroy();
198
238
            proxyAndZoomer.proxy = null;
199
239
            proxyAndZoomer.zoomRegion = null;
200
240
            delete this._zoomers[objectPath];
201
 
            DBus.session.unexportObject(proxyAndZoomer);
202
241
        }
203
242
        this._zoomers = {};
204
243
    },
285
324
        // Drop the leading '#'.
286
325
        return parseInt(colorString.slice(1), 16);
287
326
     }
288
 
};
 
327
});
289
328
 
290
329
/**
291
330
 * ShellMagnifierZoomRegion:
293
332
 * @zoomerObjectPath:   String that is the path to a DBus ZoomRegion.
294
333
 * @zoomRegion:         The actual zoom region associated with the object path.
295
334
 */
296
 
function ShellMagnifierZoomRegion(zoomerObjectPath, zoomRegion) {
297
 
    this._init(zoomerObjectPath, zoomRegion);
298
 
}
 
335
const ShellMagnifierZoomRegion = new Lang.Class({
 
336
    Name: 'ShellMagnifierZoomRegion',
299
337
 
300
 
ShellMagnifierZoomRegion.prototype = {
301
338
    _init: function(zoomerObjectPath, zoomRegion) {
302
339
        this._zoomRegion = zoomRegion;
303
 
        DBus.session.proxifyObject(this, ZOOM_SERVICE_NAME, zoomerObjectPath);
304
 
        DBus.session.exportObject(zoomerObjectPath, this);
 
340
 
 
341
        this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(ZoomRegionIface, this);
 
342
        this._dbusImpl.export(Gio.DBus.session, zoomerObjectPath);
305
343
    },
306
344
 
307
345
    /**
376
414
    moveResize: function(viewPort) {
377
415
        let viewRect = { x: viewPort[0], y: viewPort[1], width: viewPort[2] - viewPort[0], height: viewPort[3] - viewPort[1] };
378
416
        this._zoomRegion.setViewPort(viewRect);
 
417
    },
 
418
 
 
419
    destroy: function() {
 
420
        this._dbusImpl.unexport();
379
421
    }
380
 
};
381
 
 
382
 
DBus.conformExport(ShellMagnifier.prototype, MagnifierIface);
383
 
DBus.conformExport(ShellMagnifierZoomRegion.prototype, ZoomRegionIface);
 
422
});