File: slideshowManager.js

package info (click to toggle)
cinnamon 3.2.7-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 11,624 kB
  • sloc: ansic: 33,269; python: 18,048; xml: 1,504; makefile: 780; sh: 90; cpp: 54
file content (60 lines) | stat: -rw-r--r-- 1,584 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*-

const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;

const dbusIFace =
    '<node> \
        <interface name="org.Cinnamon.Slideshow"> \
            <method name="begin" /> \
            <method name="end" /> \
            <method name="getNextImage" /> \
        </interface> \
    </node>';

const proxy = Gio.DBusProxy.makeProxyWrapper(dbusIFace);

function SlideshowManager() {
    this._init();
}

SlideshowManager.prototype = {

    _init: function() {
        this.proxy = null;
        this._slideshowSettings = new Gio.Settings({ schema_id: "org.cinnamon.desktop.background.slideshow" });
        this._slideshowSettings.connect("changed::slideshow-enabled", Lang.bind(this, this._onSlideshowEnabledChanged));

        if (this._slideshowSettings.get_boolean("slideshow-enabled")) {
            this.begin();
        }
    },

    _onSlideshowEnabledChanged: function() {
        if (this._slideshowSettings.get_boolean("slideshow-enabled"))
            this.begin();
        else
            this.end();
    },

    ensureProxy: function() {
        if (!this.proxy)
            this.proxy = new proxy(Gio.DBus.session, 'org.Cinnamon.Slideshow', '/org/Cinnamon/Slideshow');
    },

    begin: function() {
        this.ensureProxy();
        this.proxy.beginRemote();
    },

    end: function() {
        this.ensureProxy();
        this.proxy.endRemote();
    },

    getNextImage: function() {
        this.ensureProxy();
        this.proxy.getNextImageRemote();
    }
};