Skip to content

Commit 3e7ec4f

Browse files
committed
loginManager.js: Use a normal signal connection for PrepareForSleep.
Update the calendar and power applets to refresh on resume, and update the ScreenShield to connect to the signal directly. The UPowerGLib.Client code in the calendar applet has been dead code since 0.99 (notify-resume signal was removed and the 'resume' property was never never a thing).
1 parent 9bc41ec commit 3e7ec4f

4 files changed

Lines changed: 20 additions & 21 deletions

File tree

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

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const Clutter = imports.gi.Clutter;
66
const St = imports.gi.St;
77
const Util = imports.misc.util;
88
const PopupMenu = imports.ui.popupMenu;
9-
const UPowerGlib = imports.gi.UPowerGlib;
9+
const LoginManager = imports.misc.loginManager;
1010
const Settings = imports.ui.settings;
1111
const CinnamonDesktop = imports.gi.CinnamonDesktop;
1212
const Main = imports.ui.main;
@@ -151,13 +151,11 @@ class CinnamonCalendarApplet extends Applet.TextApplet {
151151
this._onSettingsChanged();
152152
}));
153153

154-
// https://bugzilla.gnome.org/show_bug.cgi?id=655129
155-
this._upClient = new UPowerGlib.Client();
156-
try {
157-
this._upClient.connect('notify-resume', Lang.bind(this, this._updateClockAndDate));
158-
} catch (e) {
159-
this._upClient.connect('notify::resume', Lang.bind(this, this._updateClockAndDate));
160-
}
154+
this._loginManager = LoginManager.getLoginManager();
155+
this._loginManager.connect('prepare-for-sleep', (aboutToSuspend) => {
156+
if (!aboutToSuspend)
157+
this._updateClockAndDate();
158+
});
161159

162160
// Change the format string if the mouse is over the calender to account for the tooltip.
163161
this._is_entered = false;

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ const Clutter = imports.gi.Clutter;
33
const Gio = imports.gi.Gio;
44
const Interfaces = imports.misc.interfaces
55
const Lang = imports.lang;
6+
const LoginManager = imports.misc.loginManager;
67
const PowerUtils = imports.misc.powerUtils;
78
const St = imports.gi.St;
89
const Tooltips = imports.ui.tooltips;
9-
const UPowerGlib = imports.gi.UPowerGlib;
1010
const PopupMenu = imports.ui.popupMenu;
1111
const Main = imports.ui.main;
1212
const Settings = imports.ui.settings;
@@ -337,6 +337,12 @@ class CinnamonPowerApplet extends Applet.TextIconApplet {
337337
}));
338338
}, null);
339339

340+
this._loginManager = LoginManager.getLoginManager();
341+
this._loginManager.connect('prepare-for-sleep', (aboutToSuspend) => {
342+
if (!aboutToSuspend)
343+
this._devicesChanged();
344+
});
345+
340346
this.set_show_label_in_vertical_panels(false);
341347
}
342348

js/misc/loginManager.js

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ var LoginManagerSystemd = class {
9393
'/org/freedesktop/login1'
9494
);
9595

96+
this._connectPrepareForSleep();
9697
this._getCurrentSession();
9798
} catch (e) {
9899
global.logError('LoginManager: Failed to connect to logind: ' + e.message);
@@ -175,14 +176,13 @@ var LoginManagerSystemd = class {
175176
}
176177
}
177178

178-
connectPrepareForSleep(callback) {
179-
if (!this._managerProxy) {
180-
return null;
181-
}
179+
_connectPrepareForSleep() {
180+
if (!this._managerProxy)
181+
return;
182182

183-
return this._managerProxy.connectSignal('PrepareForSleep', (proxy, sender, [aboutToSuspend]) => {
183+
this._managerProxy.connectSignal('PrepareForSleep', (proxy, sender, [aboutToSuspend]) => {
184184
_log(`LoginManager: PrepareForSleep signal received (aboutToSuspend=${aboutToSuspend})`);
185-
callback(aboutToSuspend);
185+
this.emit('prepare-for-sleep', aboutToSuspend);
186186
});
187187
}
188188

@@ -296,11 +296,6 @@ var LoginManagerConsoleKit = class {
296296
}
297297
}
298298

299-
connectPrepareForSleep(callback) {
300-
// ConsoleKit doesn't have PrepareForSleep
301-
return null;
302-
}
303-
304299
inhibit(reason, callback) {
305300
// ConsoleKit doesn't have inhibitors
306301
callback(null);

js/ui/screensaver/screenShield.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ var ScreenShield = GObject.registerClass({
183183
this._lastMotionY = -1;
184184

185185
this._loginManager = LoginManager.getLoginManager();
186-
this._loginManager.connectPrepareForSleep(this._prepareForSleep.bind(this));
186+
this._loginManager.connect('prepare-for-sleep', this._prepareForSleep.bind(this));
187187
this._syncInhibitor();
188188

189189
this._loginManager.connect('lock', this._onSessionLock.bind(this));

0 commit comments

Comments
 (0)