userMenu: Use LoginManager for suspend
https://bugzilla.gnome.org/show_bug.cgi?id=686482
This commit is contained in:
parent
990443465f
commit
fed007ecae
@ -9,11 +9,11 @@ const Pango = imports.gi.Pango;
|
|||||||
const Shell = imports.gi.Shell;
|
const Shell = imports.gi.Shell;
|
||||||
const St = imports.gi.St;
|
const St = imports.gi.St;
|
||||||
const Tp = imports.gi.TelepathyGLib;
|
const Tp = imports.gi.TelepathyGLib;
|
||||||
const UPowerGlib = imports.gi.UPowerGlib;
|
|
||||||
const Atk = imports.gi.Atk;
|
const Atk = imports.gi.Atk;
|
||||||
|
|
||||||
const BoxPointer = imports.ui.boxpointer;
|
const BoxPointer = imports.ui.boxpointer;
|
||||||
const GnomeSession = imports.misc.gnomeSession;
|
const GnomeSession = imports.misc.gnomeSession;
|
||||||
|
const LoginManager = imports.misc.loginManager;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const PanelMenu = imports.ui.panelMenu;
|
const PanelMenu = imports.ui.panelMenu;
|
||||||
const PopupMenu = imports.ui.popupMenu;
|
const PopupMenu = imports.ui.popupMenu;
|
||||||
@ -482,10 +482,11 @@ const UserMenuButton = new Lang.Class({
|
|||||||
this._presence = new GnomeSession.Presence();
|
this._presence = new GnomeSession.Presence();
|
||||||
this._session = new GnomeSession.SessionManager();
|
this._session = new GnomeSession.SessionManager();
|
||||||
this._haveShutdown = true;
|
this._haveShutdown = true;
|
||||||
|
this._haveSuspend = true;
|
||||||
|
|
||||||
this._accountMgr = Tp.AccountManager.dup();
|
this._accountMgr = Tp.AccountManager.dup();
|
||||||
|
|
||||||
this._upClient = new UPowerGlib.Client();
|
this._loginManager = LoginManager.getLoginManager();
|
||||||
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||||
|
|
||||||
this._iconBox = new St.Bin();
|
this._iconBox = new St.Bin();
|
||||||
@ -565,14 +566,15 @@ const UserMenuButton = new Lang.Class({
|
|||||||
// the lockdown setting changes, which should be close enough.
|
// the lockdown setting changes, which should be close enough.
|
||||||
this.menu.connect('open-state-changed', Lang.bind(this,
|
this.menu.connect('open-state-changed', Lang.bind(this,
|
||||||
function(menu, open) {
|
function(menu, open) {
|
||||||
if (open)
|
if (!open)
|
||||||
|
return;
|
||||||
|
|
||||||
this._updateHaveShutdown();
|
this._updateHaveShutdown();
|
||||||
|
this._updateHaveSuspend();
|
||||||
}));
|
}));
|
||||||
this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
|
this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
|
||||||
Lang.bind(this, this._updateHaveShutdown));
|
Lang.bind(this, this._updateHaveShutdown));
|
||||||
|
|
||||||
this._upClient.connect('notify::can-suspend', Lang.bind(this, this._updateSuspendOrPowerOff));
|
|
||||||
|
|
||||||
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
|
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
|
||||||
this._sessionUpdated();
|
this._sessionUpdated();
|
||||||
},
|
},
|
||||||
@ -641,9 +643,15 @@ const UserMenuButton = new Lang.Class({
|
|||||||
}));
|
}));
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateSuspendOrPowerOff: function() {
|
_updateHaveSuspend: function() {
|
||||||
this._haveSuspend = this._upClient.get_can_suspend();
|
this._loginManager.canSuspend(Lang.bind(this,
|
||||||
|
function(result) {
|
||||||
|
this._haveSuspend = result;
|
||||||
|
this._updateSuspendOrPowerOff();
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
|
_updateSuspendOrPowerOff: function() {
|
||||||
if (!this._suspendOrPowerOffItem)
|
if (!this._suspendOrPowerOffItem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -846,13 +854,13 @@ const UserMenuButton = new Lang.Class({
|
|||||||
let tmpId = Main.screenShield.connect('lock-screen-shown', Lang.bind(this, function() {
|
let tmpId = Main.screenShield.connect('lock-screen-shown', Lang.bind(this, function() {
|
||||||
Main.screenShield.disconnect(tmpId);
|
Main.screenShield.disconnect(tmpId);
|
||||||
|
|
||||||
this._upClient.suspend_sync(null);
|
this._loginManager.suspend();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.menu.close(BoxPointer.PopupAnimation.NONE);
|
this.menu.close(BoxPointer.PopupAnimation.NONE);
|
||||||
Main.screenShield.lock(true);
|
Main.screenShield.lock(true);
|
||||||
} else {
|
} else {
|
||||||
this._upClient.suspend_sync(null);
|
this._loginManager.suspend();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user