forked from sakithb/media-controls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.js
246 lines (224 loc) · 9.39 KB
/
settings.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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
const ExtensionUtils = imports.misc.extensionUtils;
class Settings {
constructor(parent) {
this._settings = ExtensionUtils.getSettings();
this._extension = parent;
this.connectSignals();
this.maxWidgetWidth = this._settings.get_int("max-widget-width");
this.updateDelay = this._settings.get_int("update-delay");
this.showTrackName = this._settings.get_boolean("show-text");
this.showPlayerIcon = this._settings.get_boolean("show-player-icon");
this.showControls = this._settings.get_boolean("show-control-icons");
this.showSeperators = this._settings.get_boolean("show-seperators");
this.showMenu = this._settings.get_boolean("show-sources-menu");
this.showPlayPauseButton = this._settings.get_boolean(
"show-playpause-icon"
);
this.showPrevButton = this._settings.get_boolean("show-prev-icon");
this.showNextButton = this._settings.get_boolean("show-next-icon");
this.extensionPosition =
this._settings.get_string("extension-position");
this.extensionIndex = this._settings.get_int("extension-index");
this.coloredPlayerIcon = this._settings.get_boolean(
"colored-player-icon"
);
this.mouseActions = this._settings.get_strv("mouse-actions");
this.sepChars = this._settings.get_strv("seperator-chars");
this.elementOrder = this._settings.get_strv("element-order");
this.trackLabel = this._settings.get_strv("track-label");
this.cacheImages = this._settings.get_boolean("cache-images");
this.blacklistApps = this._settings.get_strv("backlist-apps");
this.hideMediaNotification = this._settings.get_boolean(
"hide-media-notification"
);
}
connectSignals() {
this._onMaxWidgetWidthChanged = this._settings.connect(
"changed::max-widget-width",
() => {
this.maxWidgetWidth =
this._settings.get_int("max-widget-width");
this._extension.player.updateWidgetWidths();
}
);
this._onUpdateDelayChanged = this._settings.connect(
"changed::update-delay",
() => {
this.updateDelay = this._settings.get_int("update-delay");
}
);
this._onShowTrackNameChanged = this._settings.connect(
"changed::show-text",
() => {
this.showTrackName = this._settings.get_boolean("show-text");
this._extension.removeWidgets();
this._extension.addWidgets();
}
);
this._onShowPlayerIconChanged = this._settings.connect(
"changed::show-player-icon",
() => {
this.showPlayerIcon =
this._settings.get_boolean("show-player-icon");
this._extension.removeWidgets();
this._extension.addWidgets();
}
);
this._onShowControlsChanged = this._settings.connect(
"changed::show-control-icons",
() => {
this.showControls =
this._settings.get_boolean("show-control-icons");
this._extension.removeWidgets();
this._extension.addWidgets();
}
);
this._onShowSeperatorsChanged = this._settings.connect(
"changed::show-seperators",
() => {
this.showSeperators =
this._settings.get_boolean("show-seperators");
this._extension.removeWidgets();
this._extension.addWidgets();
}
);
this._onShowPlayPauseButtonChanged = this._settings.connect(
"changed::show-playpause-icon",
() => {
this.showPlayPauseButton = this._settings.get_boolean(
"show-playpause-icon"
);
this._extension.removeWidgets();
this._extension.addWidgets();
}
);
this._onShowPrevButtonChanged = this._settings.connect(
"changed::show-prev-icon",
() => {
this.showPrevButton =
this._settings.get_boolean("show-prev-icon");
this._extension.removeWidgets();
this._extension.addWidgets();
}
);
this._onShowNextButtonChanged = this._settings.connect(
"changed::show-next-icon",
() => {
this.showNextButton =
this._settings.get_boolean("show-next-icon");
this._extension.removeWidgets();
this._extension.addWidgets();
}
);
this._onShowMenuChanged = this._settings.connect(
"changed::show-sources-menu",
() => {
this.showMenu = this._settings.get_boolean("show-sources-menu");
this._extension.removeWidgets();
this._extension.addWidgets();
}
);
this._onExtensionPositionChanged = this._settings.connect(
"changed::extension-position",
() => {
this._extension.removeWidgets();
this.extensionPosition =
this._settings.get_string("extension-position");
this._extension.addWidgets();
}
);
this._onExtensionIndexChanged = this._settings.connect(
"changed::extension-index",
() => {
this.extensionIndex = this._settings.get_int("extension-index");
this._extension.removeWidgets();
this._extension.addWidgets();
}
);
this._onColoredPlayerIconChanged = this._settings.connect(
"changed::colored-player-icon",
() => {
this.coloredPlayerIcon = this._settings.get_boolean(
"colored-player-icon"
);
this._extension.player.updateIconEffects();
}
);
this._onSepCharsChanged = this._settings.connect(
"changed::seperator-chars",
() => {
this.sepChars = this._settings.get_strv("seperator-chars");
this._extension.player.labelSeperatorStart.set_text(
this.sepChars[0]
);
this._extension.player.labelSeperatorEnd.set_text(
this.sepChars[1]
);
}
);
this._onMouseActionsChanged = this._settings.connect(
"changed::mouse-actions",
() => {
this.mouseActions = this._settings.get_strv("mouse-actions");
}
);
this._onElementOrderChanged = this._settings.connect(
"changed::element-order",
() => {
this.elementOrder = this._settings.get_strv("element-order");
this._extension.removeWidgets();
this._extension.addWidgets();
}
);
this._onTrackLabelChanged = this._settings.connect(
"changed::track-label",
() => {
this.trackLabel = this._settings.get_strv("track-label");
this._extension.player.updateWidgets();
}
);
this._onCacheImagesChanged = this._settings.connect(
"changed::cache-images",
() => {
this.cacheImages = this._settings.get_boolean("cache-images");
}
);
this._onBacklistAppsChanged = this._settings.connect(
"changed::backlist-apps",
() => {
this.blacklistApps = this._settings.get_strv("backlist-apps");
}
);
this._onHideMediaNotificationChanged = this._settings.connect(
"changed::hide-media-notification",
() => {
this.hideMediaNotification = this._settings.get_boolean(
"hide-media-notification"
);
this._extension.updateMediaNotification();
}
);
}
disconnectSignals() {
this._settings.disconnect(this._onMaxWidgetWidthChanged);
this._settings.disconnect(this._onUpdateDelayChanged);
this._settings.disconnect(this._onShowControlsChanged);
this._settings.disconnect(this._onShowPlayerIconChanged);
this._settings.disconnect(this._onShowTrackNameChanged);
this._settings.disconnect(this._onShowSeperatorsChanged);
this._settings.disconnect(this._onExtensionPositionChanged);
this._settings.disconnect(this._onShowPlayPauseButtonChanged);
this._settings.disconnect(this._onShowNextButtonChanged);
this._settings.disconnect(this._onShowPrevButtonChanged);
this._settings.disconnect(this._onExtensionIndexChanged);
this._settings.disconnect(this._onShowSourcesInInfoMenuChanged);
this._settings.disconnect(this._onColoredPlayerIconChanged);
this._settings.disconnect(this._onMouseActionsChanged);
this._settings.disconnect(this._onSepCharsChanged);
this._settings.disconnect(this._onElementOrderChanged);
this._settings.disconnect(this._onTrackLabelChanged);
this._settings.disconnect(this._onCacheImagesChanged);
this._settings.disconnect(this._onBacklistAppsChanged);
this._settings.disconnect(this._onHideMediaNotificationChanged);
}
}