-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathextension.js
executable file
·114 lines (96 loc) · 3.35 KB
/
extension.js
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*jshint esversion: 6 */
const Gio = imports.gi.Gio;
const Meta = imports.gi.Meta;
const Settings = imports.ui.settings;
const Cinnamon = imports.gi.Cinnamon;
let settings;
let shadow_factory = Meta.ShadowFactory.get_default();
let shadow_classes = ["normal", "dialog", "modal_dialog", "utility", "border", "menu", "popup-menu", "dropdown-menu", "attached"];
function create_params(r) {
return new Meta.ShadowParams({"radius": r[0], "top_fade": r[1], "x_offset": r[2], "y_offset": r[3], "opacity": r[4]});
}
function backup_settings(){
let user_settings = {
focused: {},
unfocused: {}
};
for (let shadow of shadow_classes){
let f_obj = shadow_factory.get_params(shadow, true);
let u_obj = shadow_factory.get_params(shadow, false);
user_settings.focused[shadow] = [f_obj.radius,f_obj.top_fade,f_obj.x_offset,f_obj.y_offset,f_obj.opacity];
user_settings.unfocused[shadow] = [u_obj.radius,u_obj.top_fade,u_obj.x_offset,u_obj.y_offset,u_obj.opacity];
}
settings.prefs.default = user_settings;
settings.prefs.save();
return true;
}
function activate_preset(preset, overwrite_active = true) {
if (preset in settings.prefs)
{
let focused = settings.prefs[preset].focused;
let unfocused = settings.prefs[preset].unfocused;
let focused_params = [], unfocused_params = [];
for (var record in focused)
{
shadow_factory.set_params(record, true, create_params(focused[record]));
}
for (var record in unfocused)
{
shadow_factory.set_params(record, false, create_params(unfocused[record]));
}
if (overwrite_active)
settings.current_active = preset;
}
}
function restart_cinnamon() {
global.reexec_self();
}
function SettingsHandler(uuid) {
this._init(uuid);
}
SettingsHandler.prototype = {
_init: function(uuid) {
this.settings = new Settings.ExtensionSettings(this, uuid);
this.settings.bindProperty(Settings.BindingDirection.BIDIRECTIONAL, "first_launch" , "first_launch", function(){});
this.settings.bindProperty(Settings.BindingDirection.BIDIRECTIONAL, "current_active" , "current_active", function(){});
this.settings.bindProperty(Settings.BindingDirection.IN, "preset" , "preset", this._launch);
this.settings.bindProperty(Settings.BindingDirection.IN, "prefs" , "prefs", this._launch);
},
_launch: function() {
activate_preset(this.preset);
},
_destroy: function() {
this.settings.unbindProperty('first_launch');
this.settings.unbindProperty('current_active');
this.settings.unbindProperty('preset');
this.settings.unbindProperty('prefs');
this.settings = null;
delete this.settings;
}
};
const Callbacks = {
restart_cinnamon: function() {
global.reexec_self();
},
apply_changes: function() {
activate_preset(settings.current_active);
}
};
function init(meta)
{
settings = new SettingsHandler(meta.uuid);
settings.first_launch = false;
// if (settings.first_launch)
// {
// backup_settings()
// settings.first_launch = false
// }
}
function enable() {
activate_preset(settings.current_active);
return Callbacks;
}
function disable() {
activate_preset('default', false);
settings._destroy();
}