Skip to content

Commit 18d2377

Browse files
rcalixtemtwebster
authored andcommitted
Cleanup whitespace
1 parent 4a921f4 commit 18d2377

File tree

1 file changed

+68
-66
lines changed

1 file changed

+68
-66
lines changed

files/usr/share/cinnamon/applets/[email protected]/applet.js

Lines changed: 68 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ class InhibitSwitch extends PopupMenu.PopupBaseMenuItem {
2121

2222
this.actor.label_actor = this.label;
2323

24-
this._statusIcon = new St.Icon({ style_class: 'popup-menu-icon',
25-
icon_type: St.IconType.SYMBOLIC,
26-
icon_name: "dialog-warning-symbolic",
27-
reactive: true});
24+
this._statusIcon = new St.Icon({
25+
style_class: 'popup-menu-icon',
26+
icon_type: St.IconType.SYMBOLIC,
27+
icon_name: "dialog-warning-symbolic",
28+
reactive: true
29+
});
2830

2931
this._switch = new PopupMenu.Switch(true);
3032

@@ -50,12 +52,12 @@ class InhibitSwitch extends PopupMenu.PopupBaseMenuItem {
5052
this.sessionProxy = proxy;
5153
this.actor.show();
5254
this.updateStatus();
53-
55+
5456
this.sigAddedId = this.sessionProxy.connectSignal(
55-
"InhibitorAdded",
57+
"InhibitorAdded",
5658
Lang.bind(this, this.updateStatus)
5759
);
58-
60+
5961
this.sigRemovedId = this.sessionProxy.connectSignal(
6062
"InhibitorRemoved",
6163
Lang.bind(this, this.updateStatus)
@@ -100,13 +102,13 @@ class InhibitSwitch extends PopupMenu.PopupBaseMenuItem {
100102
toggled(active) {
101103
if (!active && !this.sessionCookie) {
102104
this.sessionProxy.InhibitRemote("[email protected]",
103-
0,
104-
"prevent idle functions like screen blanking and dimming",
105-
INHIBIT_IDLE_FLAG,
106-
Lang.bind(this, function(cookie) {
107-
this.sessionCookie = cookie;
108-
this.updateStatus();
109-
}));
105+
0,
106+
"prevent idle functions like screen blanking and dimming",
107+
INHIBIT_IDLE_FLAG,
108+
Lang.bind(this, function(cookie) {
109+
this.sessionCookie = cookie;
110+
this.updateStatus();
111+
}));
110112
} else if (active && this.sessionCookie) {
111113
this.sessionProxy.UninhibitRemote(this.sessionCookie, Lang.bind(this, this.updateStatus));
112114
this.sessionCookie = null;
@@ -125,7 +127,7 @@ class InhibitSwitch extends PopupMenu.PopupBaseMenuItem {
125127
if (this.sigAddedId) {
126128
this.sessionProxy.disconnectSignal(this.sigAddedId);
127129
}
128-
130+
129131
if (this.sigRemovedId) {
130132
this.sessionProxy.disconnectSignal(this.sigRemovedId);
131133
}
@@ -135,127 +137,127 @@ class InhibitSwitch extends PopupMenu.PopupBaseMenuItem {
135137
class InhibitingAppMenuItem extends PopupMenu.PopupIconMenuItem {
136138
constructor(appId) {
137139
super(
138-
appId,
139-
"dialog-information-symbolic",
140-
St.IconType.SYMBOLIC,
140+
appId,
141+
"dialog-information-symbolic",
142+
St.IconType.SYMBOLIC,
141143
{ activate: false, hover: false }
142144
);
143-
145+
144146
this.appId = appId;
145147
this._reasonsByObjPath = {};
146148
this._inhibitorCount = 0;
147149
this._tooltip = new Tooltips.Tooltip(this.actor, "");
148150
}
149-
151+
150152
addInhibitor(objectPath, reason) {
151153
if (!(objectPath in this._reasonsByObjPath)) {
152154
this._reasonsByObjPath[objectPath] = reason;
153155
this._inhibitorCount++;
154156
this._updateTooltip();
155157
}
156158
}
157-
159+
158160
updateInhibitor(objectPath, reason) {
159161
if (objectPath in this._reasonsByObjPath) {
160162
this._reasonsByObjPath[objectPath] = reason;
161163
this._updateTooltip();
162164
}
163165
}
164-
166+
165167
removeInhibitor(objectPath) {
166168
if (objectPath in this._reasonsByObjPath) {
167169
delete this._reasonsByObjPath[objectPath];
168170
this._inhibitorCount--;
169171
this._updateTooltip();
170172
}
171173
}
172-
174+
173175
hasInhibitor() {
174176
return !!this._inhibitorCount;
175177
}
176-
178+
177179
_updateTooltip() {
178180
let reasons = Object.values(this._reasonsByObjPath)
179181
.map(r => r && r.trim()) // Remove extraneous whitespace.
180182
.filter(Boolean); // Discard null/empty reasons.
181-
183+
182184
reasons = Array.from(new Set(reasons)); // Keep only unique reasons.
183-
185+
184186
this._tooltip.set_text(reasons.join("\n"));
185187
}
186188
}
187189

188190
class InhibitorMenuSection extends PopupMenu.PopupMenuSection {
189191
constructor() {
190192
super();
191-
193+
192194
// Menu items indexed by app ID e.g. "org.gnome.Rhythmbox3".
193195
// Each menu item is associated with exactly one app ID and vice versa.
194196
this._itemsByAppId = {};
195-
197+
196198
// Menu items indexed by object path e.g. "/org/gnome/SessionManager/Inhibitor42".
197199
// Multiple paths may point to the same item if an app creates multiple inhibitors.
198200
this._itemsByObjPath = {};
199-
201+
200202
this._itemCount = 0;
201203
this._updateId = 0; // light-weight way to abort an in-progress update (by incrementing)
202-
204+
203205
this._createHeading();
204-
206+
205207
this.actor.hide();
206208
}
207-
209+
208210
_createHeading() {
209211
let headingText = _("Apps inhibiting power management:");
210212
let heading = new PopupMenu.PopupMenuItem(headingText, { reactive: false });
211213
this.addMenuItem(heading);
212214
}
213-
215+
214216
resetInhibitors() {
215217
// Abort any in-progress update or else it may continue to add menu items
216218
// even after we've cleared them.
217219
this._updateId++;
218-
220+
219221
if (this._itemCount) {
220222
this._itemsByAppId = {};
221223
this._itemsByObjPath = {};
222224
this._itemCount = 0;
223-
225+
224226
// Clear all, but make sure we still have a heading for next time we're shown.
225227
this.removeAll();
226228
this._createHeading();
227-
229+
228230
this.actor.hide();
229231
}
230232
}
231-
233+
232234
updateInhibitors(sessionProxy) {
233235
// Grab a new ID for this update while at the same time aborting any other in-progress
234236
// update. We don't want to end up with duplicate menu items!
235237
let updateId = ++this._updateId;
236-
238+
237239
sessionProxy.GetInhibitorsRemote(Lang.bind(this, function(objectPaths) {
238240
if (updateId != this._updateId) {
239241
return;
240242
}
241-
243+
242244
objectPaths = String(objectPaths).split(','); // Given object, convert to string[].
243-
245+
244246
// Add menu items for any paths we haven't seen before, and keep track of the paths
245247
// iterated so we can figure out which of our existing paths are no longer present.
246-
248+
247249
let pathsPresent = {};
248-
250+
249251
for (let objectPath of objectPaths) {
250252
if (objectPath) {
251253
pathsPresent[objectPath] = true;
252-
254+
253255
if (!(objectPath in this._itemsByObjPath)) {
254256
this._addInhibitor(objectPath, updateId);
255257
}
256258
}
257259
}
258-
260+
259261
// Remove menu items for those paths no longer present.
260262
for (let objectPath in this._itemsByObjPath) {
261263
if (!(objectPath in pathsPresent)) {
@@ -264,33 +266,33 @@ class InhibitorMenuSection extends PopupMenu.PopupMenuSection {
264266
}
265267
}));
266268
}
267-
269+
268270
// Precondition: objectPath not already in _itemsByObjPath
269271
_addInhibitor(objectPath, updateId) {
270272
GnomeSession.Inhibitor(objectPath, Lang.bind(this, function(inhibitorProxy, error) {
271273
if (error || updateId != this._updateId) {
272274
return;
273275
}
274-
276+
275277
inhibitorProxy.GetFlagsRemote(Lang.bind(this, function(flags) {
276278
if (updateId != this._updateId) {
277279
return;
278280
}
279-
281+
280282
flags = parseInt(flags, 10); // Given object, convert to integer.
281-
283+
282284
// Only include those inhibiting sleep, idle, or both.
283285
if (flags < INHIBIT_SLEEP_FLAG) {
284286
return;
285287
}
286-
288+
287289
inhibitorProxy.GetAppIdRemote(Lang.bind(this, function(appId) {
288290
if (updateId != this._updateId) {
289291
return;
290292
}
291-
293+
292294
appId = String(appId); // Given object, convert to string.
293-
295+
294296
// Get/create the menu item for this app.
295297
let menuItem;
296298
if (appId in this._itemsByAppId) {
@@ -299,42 +301,42 @@ class InhibitorMenuSection extends PopupMenu.PopupMenuSection {
299301
menuItem = new InhibitingAppMenuItem(appId);
300302
this._itemsByAppId[appId] = menuItem;
301303
this.addMenuItem(menuItem);
302-
304+
303305
// Show the menu section upon adding the first menu item.
304306
if (!(this._itemCount++)) {
305307
this.actor.show();
306308
}
307309
}
308-
310+
309311
this._itemsByObjPath[objectPath] = menuItem;
310-
312+
311313
// Go ahead and add the inhibitor to the item now and fill in the reason later.
312314
menuItem.addInhibitor(objectPath);
313-
315+
314316
inhibitorProxy.GetReasonRemote(Lang.bind(this, function(reason) {
315317
if (updateId != this._updateId) {
316318
return;
317319
}
318-
320+
319321
reason = String(reason); // Given object, convert to string.
320322
menuItem.updateInhibitor(objectPath, reason);
321323
}));
322324
}));
323325
}));
324326
}));
325327
}
326-
328+
327329
// Precondition: objectPath already in _itemsByObjPath
328330
_removeInhibitor(objectPath) {
329331
let menuItem = this._itemsByObjPath[objectPath];
330332
delete this._itemsByObjPath[objectPath];
331333
menuItem.removeInhibitor(objectPath);
332-
334+
333335
// Remove the menu item if the last inhibitor for the app has been removed.
334336
if (!menuItem.hasInhibitor()) {
335337
delete this._itemsByAppId[menuItem.appId];
336338
menuItem.destroy();
337-
339+
338340
// Hide the menu section upon removing the last menu item.
339341
if (!(--this._itemCount)) {
340342
this.actor.hide();
@@ -370,19 +372,19 @@ class CinnamonInhibitApplet extends Applet.IconApplet {
370372
}));
371373

372374
this.menu.addMenuItem(this.notificationsSwitch);
373-
375+
374376
this.settings = new Settings.AppletSettings(this, metadata.uuid, instanceId);
375377
this.settings.bind("keyPower", "keyPower", this._setKeybinding);
376378
this.settings.bind("keyNotifications", "keyNotifications", this._setKeybinding);
377379
this._setKeybinding();
378380

379381
this._createInhibitorMenuSection(orientation);
380382
}
381-
383+
382384
_createInhibitorMenuSection(orientation) {
383385
this._inhibitorMenuSection = new InhibitorMenuSection();
384386
this._inhibitorSeparator = new PopupMenu.PopupSeparatorMenuItem();
385-
387+
386388
if (orientation == St.Side.BOTTOM) {
387389
// Add above the switches.
388390
this.menu.addMenuItem(this._inhibitorSeparator, 0);
@@ -420,17 +422,17 @@ class CinnamonInhibitApplet extends Applet.IconApplet {
420422
Main.keybindingManager.removeHotKey("inhibit-notifications-" + this.instance_id);
421423
this.inhibitSwitch.kill();
422424
}
423-
425+
424426
on_orientation_changed(orientation) {
425427
this._inhibitorMenuSection.destroy();
426428
this._inhibitorSeparator.destroy();
427-
429+
428430
this._createInhibitorMenuSection(orientation);
429-
431+
430432
// Will put the inhibitor menu section into the correct state.
431433
this.inhibitSwitch.updateStatus();
432434
}
433-
435+
434436
toggle_inhibit_power() {
435437
this.inhibitSwitch._switch.toggle();
436438
this.inhibitSwitch.toggled(this.inhibitSwitch._switch.state);

0 commit comments

Comments
 (0)