~mterry/ubuntu/natty/gnome-shell/wip

« back to all changes in this revision

Viewing changes to js/ui/shellDBus.js

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2009-10-12 22:44:00 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20091012224400-k91p42yvou07i525
Tags: 2.28.0-0ubuntu1
* New upstream version
* debian/control:
  - updated build requirement
* debian/patches/80_git_change_fix_alt_tab_ressource_usage.patch:
  - git change to fix ressources not being freed on alt-tab

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
 
2
 
 
3
const DBus = imports.dbus;
 
4
const Lang = imports.lang;
 
5
const Shell = imports.gi.Shell;
 
6
const Mainloop = imports.mainloop;
 
7
 
 
8
const Main = imports.ui.main;
 
9
 
 
10
const GnomeShellIface = {
 
11
    name: "org.gnome.Shell",
 
12
    methods: [{ name: "Eval",
 
13
                inSignature: "s",
 
14
                outSignature: "bs"
 
15
              }
 
16
             ],
 
17
    signals: [],
 
18
    properties: [{ name: "OverviewActive",
 
19
                   signature: "b",
 
20
                   access: "readwrite" }]
 
21
};
 
22
 
 
23
function GnomeShell() {
 
24
    this._init();
 
25
}
 
26
 
 
27
GnomeShell.prototype = {
 
28
    _init: function() {
 
29
        DBus.session.exportObject('/org/gnome/Shell', this);
 
30
    },
 
31
 
 
32
    /**
 
33
     * Eval:
 
34
     * @code: A string containing JavaScript code
 
35
     *
 
36
     * This function executes arbitrary code in the main
 
37
     * loop, and returns a boolean success and
 
38
     * JSON representation of the object as a string.
 
39
     *
 
40
     * If evaluation completes without throwing an exception,
 
41
     * then the return value will be [true, JSON.stringify(result)].
 
42
     * If evaluation fails, then the return value will be
 
43
     * [false, JSON.stringify(exception)];
 
44
     *
 
45
     */
 
46
    Eval: function(code) {
 
47
        let returnValue;
 
48
        let success;
 
49
        try {
 
50
            returnValue = JSON.stringify(eval(code));
 
51
            success = true;
 
52
        } catch (e) {
 
53
            returnValue = JSON.stringify(e);
 
54
            success = false;
 
55
        }
 
56
        return [success, returnValue];
 
57
    },
 
58
 
 
59
    get OverviewActive() {
 
60
        return Main.overview.visible;
 
61
    },
 
62
 
 
63
    set OverviewActive(visible) {
 
64
        if (visible)
 
65
            Main.overview.show();
 
66
        else
 
67
            Main.overview.hide();
 
68
    }
 
69
};
 
70
 
 
71
DBus.conformExport(GnomeShell.prototype, GnomeShellIface);
 
72