Permalink
Newer
100644
119 lines (100 sloc)
4.99 KB
1
// -*- mode: js2; indent-tabs-mode: nil; js2-basic-offset: 4 -*-
2
3
const Gio = imports.gi.Gio;
4
const Lang = imports.lang;
6
7
function BackgroundManager() {
8
this._init();
9
}
10
11
BackgroundManager.prototype = {
12
13
_init: function() {
14
let schema = Gio.SettingsSchemaSource.get_default();
15
if (!schema.lookup("org.gnome.desktop.background", true))
16
return
17
18
this._gnomeSettings = new Gio.Settings({ schema_id: "org.gnome.desktop.background" });
19
this._cinnamonSettings = new Gio.Settings({ schema_id: "org.cinnamon.desktop.background" });
21
this.color_shading_type = this._gnomeSettings.get_string("color-shading-type");
22
this._gnomeSettings.connect("changed::color-shading-type", Lang.bind(this, this._onColorShadingTypeChanged));
24
this.picture_options = this._gnomeSettings.get_string("picture-options");
25
this._gnomeSettings.connect("changed::picture-options", Lang.bind(this, this._onPictureOptionsChanged));
27
this.picture_uri = this._gnomeSettings.get_string("picture-uri");
28
this._gnomeSettings.connect("changed::picture-uri", Lang.bind(this, this._onPictureURIChanged));
30
this.primary_color = this._gnomeSettings.get_string("primary-color");
31
this._gnomeSettings.connect("changed::primary-color", Lang.bind(this, this._onPrimaryColorChanged));
33
this.secondary_color = this._gnomeSettings.get_string("secondary-color");
34
this._gnomeSettings.connect("changed::secondary-color", Lang.bind(this, this._onSecondaryColorChanged));
35
36
this.picture_opacity = this._gnomeSettings.get_int("picture-opacity");
37
this._gnomeSettings.connect("changed::picture-opacity", Lang.bind(this, this._onPictureOpacityChanged));
40
_onColorShadingTypeChanged: function(schema, key) {
41
let oldValue = this.color_shading_type
42
let newValue = this._gnomeSettings.get_string(key);
43
if (oldValue != newValue) {
44
let cinnamonValue = this._cinnamonSettings.get_string(key);
45
if (cinnamonValue != newValue) {
46
global.log("BackgroundManager: %s changed (%s --> %s)".format(key, oldValue, newValue));
47
this._cinnamonSettings.set_string(key, newValue);
48
}
49
this.color_shading_type = newValue;
51
},
52
53
_onPictureOptionsChanged: function(schema, key) {
54
let oldValue = this.picture_options
55
let newValue = this._gnomeSettings.get_string(key);
56
if (oldValue != newValue) {
57
let cinnamonValue = this._cinnamonSettings.get_string(key);
58
if (cinnamonValue != newValue) {
59
global.log("BackgroundManager: %s changed (%s --> %s)".format(key, oldValue, newValue));
60
this._cinnamonSettings.set_string(key, newValue);
62
this.picture_options = newValue;
63
}
64
},
65
66
_onPictureURIChanged: function(schema, key) {
67
let oldValue = this.picture_uri
68
let newValue = this._gnomeSettings.get_string(key);
69
if (oldValue != newValue) {
70
let cinnamonValue = this._cinnamonSettings.get_string(key);
71
if (cinnamonValue != newValue) {
72
global.log("BackgroundManager: %s changed (%s --> %s)".format(key, oldValue, newValue));
73
this._cinnamonSettings.set_string(key, newValue);
79
_onPrimaryColorChanged: function(schema, key) {
80
let oldValue = this.primary_color
81
let newValue = this._gnomeSettings.get_string(key);
82
if (oldValue != newValue) {
83
let cinnamonValue = this._cinnamonSettings.get_string(key);
84
if (cinnamonValue != newValue) {
85
global.log("BackgroundManager: %s changed (%s --> %s)".format(key, oldValue, newValue));
86
this._cinnamonSettings.set_string(key, newValue);
92
_onSecondaryColorChanged: function(schema, key) {
93
let oldValue = this.secondary_color
94
let newValue = this._gnomeSettings.get_string(key);
95
if (oldValue != newValue) {
96
let cinnamonValue = this._cinnamonSettings.get_string(key);
97
if (cinnamonValue != newValue) {
98
global.log("BackgroundManager: %s changed (%s --> %s)".format(key, oldValue, newValue));
99
this._cinnamonSettings.set_string(key, newValue);
103
},
104
105
_onPictureOpacityChanged: function(schema, key) {
106
let oldValue = this.picture_opacity
107
let newValue = this._gnomeSettings.get_int(key);
108
if (oldValue != newValue) {
109
let cinnamonValue = this._cinnamonSettings.get_int(key);
110
if (cinnamonValue != newValue) {
111
global.log("BackgroundManager: %s changed (%s --> %s)".format(key, oldValue, newValue));
112
this._cinnamonSettings.set_int(key, newValue);