2011-09-28 13:16:26 +00:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
2009-11-10 17:13:58 +00:00
|
|
|
|
2011-05-10 14:13:05 +00:00
|
|
|
const AccountsService = imports.gi.AccountsService;
|
2012-05-19 23:19:25 +00:00
|
|
|
const Gdm = imports.gi.Gdm;
|
2011-03-21 12:51:46 +00:00
|
|
|
const Gio = imports.gi.Gio;
|
2009-11-10 17:13:58 +00:00
|
|
|
const GLib = imports.gi.GLib;
|
2013-02-11 16:39:29 +00:00
|
|
|
const Gtk = imports.gi.Gtk;
|
2009-11-10 17:13:58 +00:00
|
|
|
const Lang = imports.lang;
|
|
|
|
const St = imports.gi.St;
|
2013-02-11 16:39:29 +00:00
|
|
|
const Clutter = imports.gi.Clutter;
|
2009-11-10 17:13:58 +00:00
|
|
|
|
2012-09-19 03:02:15 +00:00
|
|
|
const BoxPointer = imports.ui.boxpointer;
|
2010-04-29 17:13:20 +00:00
|
|
|
const GnomeSession = imports.misc.gnomeSession;
|
2012-10-19 15:41:10 +00:00
|
|
|
const LoginManager = imports.misc.loginManager;
|
2010-06-03 23:21:08 +00:00
|
|
|
const Main = imports.ui.main;
|
2013-02-11 16:39:29 +00:00
|
|
|
const ModalDialog = imports.ui.modalDialog;
|
2010-06-22 21:02:26 +00:00
|
|
|
const PanelMenu = imports.ui.panelMenu;
|
2010-05-20 15:18:46 +00:00
|
|
|
const PopupMenu = imports.ui.popupMenu;
|
2010-11-17 16:43:08 +00:00
|
|
|
const Util = imports.misc.util;
|
2013-04-24 02:31:08 +00:00
|
|
|
const UserWidget = imports.ui.userWidget;
|
2009-11-10 17:13:58 +00:00
|
|
|
|
2011-03-21 12:51:46 +00:00
|
|
|
const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
|
2012-08-13 23:51:51 +00:00
|
|
|
const SCREENSAVER_SCHEMA = 'org.gnome.desktop.screensaver';
|
2013-01-15 08:30:43 +00:00
|
|
|
const PRIVACY_SCHEMA = 'org.gnome.desktop.privacy'
|
2011-03-21 12:51:46 +00:00
|
|
|
const DISABLE_USER_SWITCH_KEY = 'disable-user-switching';
|
|
|
|
const DISABLE_LOCK_SCREEN_KEY = 'disable-lock-screen';
|
|
|
|
const DISABLE_LOG_OUT_KEY = 'disable-log-out';
|
2012-10-29 04:27:18 +00:00
|
|
|
const ALWAYS_SHOW_LOG_OUT_KEY = 'always-show-log-out';
|
2011-03-21 12:51:46 +00:00
|
|
|
|
2013-02-11 16:39:29 +00:00
|
|
|
const MAX_USERS_IN_SESSION_DIALOG = 5;
|
|
|
|
|
|
|
|
const SystemdLoginSessionIface = <interface name='org.freedesktop.login1.Session'>
|
2013-02-18 17:03:13 +00:00
|
|
|
<property name="Id" type="s" access="read"/>
|
2013-02-11 16:39:29 +00:00
|
|
|
<property name="Remote" type="b" access="read"/>
|
|
|
|
<property name="Class" type="s" access="read"/>
|
|
|
|
<property name="Type" type="s" access="read"/>
|
2013-03-02 15:53:50 +00:00
|
|
|
<property name="State" type="s" access="read"/>
|
2013-02-11 16:39:29 +00:00
|
|
|
</interface>;
|
|
|
|
|
|
|
|
const SystemdLoginSession = Gio.DBusProxy.makeProxyWrapper(SystemdLoginSessionIface);
|
|
|
|
|
2011-11-20 14:38:48 +00:00
|
|
|
const UserMenuButton = new Lang.Class({
|
|
|
|
Name: 'UserMenuButton',
|
2013-04-23 21:33:54 +00:00
|
|
|
Extends: PanelMenu.SystemStatusButton,
|
2010-05-10 13:46:54 +00:00
|
|
|
|
2009-11-10 17:13:58 +00:00
|
|
|
_init: function() {
|
2013-04-23 21:33:54 +00:00
|
|
|
this.parent('user-available-symbolic', _("User Menu"));
|
2010-05-10 13:46:54 +00:00
|
|
|
|
2012-08-13 23:51:51 +00:00
|
|
|
this._screenSaverSettings = new Gio.Settings({ schema: SCREENSAVER_SCHEMA });
|
2011-03-21 12:51:46 +00:00
|
|
|
this._lockdownSettings = new Gio.Settings({ schema: LOCKDOWN_SCHEMA });
|
2013-01-15 08:30:43 +00:00
|
|
|
this._privacySettings = new Gio.Settings({ schema: PRIVACY_SCHEMA });
|
2011-03-21 12:51:46 +00:00
|
|
|
|
2011-03-12 20:34:01 +00:00
|
|
|
this._session = new GnomeSession.SessionManager();
|
2011-06-03 22:10:55 +00:00
|
|
|
this._haveShutdown = true;
|
2012-10-19 15:41:10 +00:00
|
|
|
this._haveSuspend = true;
|
2009-11-10 17:13:58 +00:00
|
|
|
|
|
|
|
this._createSubMenu();
|
2011-11-11 21:41:47 +00:00
|
|
|
|
2013-04-23 21:33:54 +00:00
|
|
|
this._loginManager = LoginManager.getLoginManager();
|
|
|
|
this._userManager = AccountsService.UserManager.get_default();
|
|
|
|
this._user = this._userManager.get_user(GLib.get_user_name());
|
2011-05-10 14:13:05 +00:00
|
|
|
this._userManager.connect('notify::is-loaded',
|
2012-05-10 11:16:15 +00:00
|
|
|
Lang.bind(this, this._updateMultiUser));
|
2011-10-18 18:57:24 +00:00
|
|
|
this._userManager.connect('notify::has-multiple-users',
|
2012-05-10 11:16:15 +00:00
|
|
|
Lang.bind(this, this._updateMultiUser));
|
2011-05-10 14:13:05 +00:00
|
|
|
this._userManager.connect('user-added',
|
2012-05-10 11:16:15 +00:00
|
|
|
Lang.bind(this, this._updateMultiUser));
|
2011-05-10 14:13:05 +00:00
|
|
|
this._userManager.connect('user-removed',
|
2012-05-10 11:16:15 +00:00
|
|
|
Lang.bind(this, this._updateMultiUser));
|
2011-03-21 12:51:46 +00:00
|
|
|
this._lockdownSettings.connect('changed::' + DISABLE_USER_SWITCH_KEY,
|
|
|
|
Lang.bind(this, this._updateSwitchUser));
|
|
|
|
this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
|
|
|
|
Lang.bind(this, this._updateLogout));
|
|
|
|
this._lockdownSettings.connect('changed::' + DISABLE_LOCK_SCREEN_KEY,
|
|
|
|
Lang.bind(this, this._updateLockScreen));
|
2013-01-30 14:19:54 +00:00
|
|
|
global.settings.connect('changed::' + ALWAYS_SHOW_LOG_OUT_KEY,
|
|
|
|
Lang.bind(this, this._updateLogout));
|
2011-03-21 12:51:46 +00:00
|
|
|
this._updateSwitchUser();
|
|
|
|
this._updateLogout();
|
|
|
|
this._updateLockScreen();
|
2011-02-04 23:37:54 +00:00
|
|
|
|
2012-06-03 15:35:37 +00:00
|
|
|
this._updatesFile = Gio.File.new_for_path('/var/lib/PackageKit/prepared-update');
|
|
|
|
this._updatesMonitor = this._updatesFile.monitor(Gio.FileMonitorFlags.NONE, null);
|
|
|
|
this._updatesMonitor.connect('changed', Lang.bind(this, this._updateInstallUpdates));
|
|
|
|
|
2011-06-03 22:10:55 +00:00
|
|
|
// Whether shutdown is available or not depends on both lockdown
|
|
|
|
// settings (disable-log-out) and Polkit policy - the latter doesn't
|
|
|
|
// notify, so we update the menu item each time the menu opens or
|
|
|
|
// the lockdown setting changes, which should be close enough.
|
|
|
|
this.menu.connect('open-state-changed', Lang.bind(this,
|
|
|
|
function(menu, open) {
|
2012-10-19 15:41:10 +00:00
|
|
|
if (!open)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._updateHaveShutdown();
|
|
|
|
this._updateHaveSuspend();
|
2011-06-03 22:10:55 +00:00
|
|
|
}));
|
|
|
|
this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
|
|
|
|
Lang.bind(this, this._updateHaveShutdown));
|
|
|
|
|
2012-09-01 12:42:53 +00:00
|
|
|
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
|
|
|
|
this._sessionUpdated();
|
2009-11-10 17:13:58 +00:00
|
|
|
},
|
|
|
|
|
2012-09-01 12:42:53 +00:00
|
|
|
_sessionUpdated: function() {
|
2012-09-10 09:34:49 +00:00
|
|
|
this.actor.visible = !Main.sessionMode.isGreeter;
|
2012-09-01 21:44:46 +00:00
|
|
|
this.setSensitive(!Main.sessionMode.isLocked);
|
2009-11-10 17:13:58 +00:00
|
|
|
},
|
|
|
|
|
2012-05-10 11:16:15 +00:00
|
|
|
_updateMultiUser: function() {
|
|
|
|
this._updateSwitchUser();
|
|
|
|
this._updateLogout();
|
|
|
|
},
|
|
|
|
|
2009-11-10 17:13:58 +00:00
|
|
|
_updateSwitchUser: function() {
|
2011-03-21 12:51:46 +00:00
|
|
|
let allowSwitch = !this._lockdownSettings.get_boolean(DISABLE_USER_SWITCH_KEY);
|
2012-05-13 15:11:06 +00:00
|
|
|
let multiUser = this._userManager.can_switch() && this._userManager.has_multiple_users;
|
|
|
|
|
2012-09-28 16:52:12 +00:00
|
|
|
this._loginScreenItem.actor.visible = allowSwitch && multiUser;
|
2011-03-21 12:51:46 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_updateLogout: function() {
|
|
|
|
let allowLogout = !this._lockdownSettings.get_boolean(DISABLE_LOG_OUT_KEY);
|
2012-10-29 04:27:18 +00:00
|
|
|
let alwaysShow = global.settings.get_boolean(ALWAYS_SHOW_LOG_OUT_KEY);
|
2012-10-29 03:55:43 +00:00
|
|
|
let systemAccount = this._user.system_account;
|
|
|
|
let localAccount = this._user.local_account;
|
2012-05-13 15:11:06 +00:00
|
|
|
let multiUser = this._userManager.has_multiple_users;
|
2012-05-19 23:19:25 +00:00
|
|
|
let multiSession = Gdm.get_session_ids().length > 1;
|
2012-05-13 15:11:06 +00:00
|
|
|
|
2012-10-29 04:27:18 +00:00
|
|
|
this._logoutItem.actor.visible = allowLogout && (alwaysShow || multiUser || multiSession || systemAccount || !localAccount);
|
2011-03-21 12:51:46 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_updateLockScreen: function() {
|
|
|
|
let allowLockScreen = !this._lockdownSettings.get_boolean(DISABLE_LOCK_SCREEN_KEY);
|
2013-03-04 18:33:36 +00:00
|
|
|
this._lockScreenItem.actor.visible = allowLockScreen && LoginManager.canLock();
|
2009-11-10 17:13:58 +00:00
|
|
|
},
|
|
|
|
|
2012-06-03 15:35:37 +00:00
|
|
|
_updateInstallUpdates: function() {
|
|
|
|
let haveUpdates = this._updatesFile.query_exists(null);
|
|
|
|
this._installUpdatesItem.actor.visible = haveUpdates && this._haveShutdown;
|
|
|
|
},
|
|
|
|
|
2011-06-03 22:10:55 +00:00
|
|
|
_updateHaveShutdown: function() {
|
|
|
|
this._session.CanShutdownRemote(Lang.bind(this,
|
|
|
|
function(result, error) {
|
|
|
|
if (!error) {
|
2012-06-26 15:44:24 +00:00
|
|
|
this._haveShutdown = result[0];
|
2012-06-03 15:35:37 +00:00
|
|
|
this._updateInstallUpdates();
|
2011-06-03 22:10:55 +00:00
|
|
|
this._updateSuspendOrPowerOff();
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
2012-10-19 15:41:10 +00:00
|
|
|
_updateHaveSuspend: function() {
|
|
|
|
this._loginManager.canSuspend(Lang.bind(this,
|
|
|
|
function(result) {
|
|
|
|
this._haveSuspend = result;
|
|
|
|
this._updateSuspendOrPowerOff();
|
|
|
|
}));
|
|
|
|
},
|
2011-02-04 23:37:54 +00:00
|
|
|
|
2012-10-19 15:41:10 +00:00
|
|
|
_updateSuspendOrPowerOff: function() {
|
2011-02-04 23:37:54 +00:00
|
|
|
if (!this._suspendOrPowerOffItem)
|
|
|
|
return;
|
|
|
|
|
2012-03-16 22:53:14 +00:00
|
|
|
this._suspendOrPowerOffItem.actor.visible = this._haveShutdown || this._haveSuspend;
|
2011-06-03 22:10:55 +00:00
|
|
|
|
2012-05-10 11:24:12 +00:00
|
|
|
// If we can't power off show Suspend instead
|
2011-02-04 23:37:54 +00:00
|
|
|
// and disable the alt key
|
2012-05-10 11:24:12 +00:00
|
|
|
if (!this._haveShutdown) {
|
2011-06-03 22:10:55 +00:00
|
|
|
this._suspendOrPowerOffItem.updateText(_("Suspend"), null);
|
2012-05-10 11:24:12 +00:00
|
|
|
} else if (!this._haveSuspend) {
|
|
|
|
this._suspendOrPowerOffItem.updateText(_("Power Off"), null);
|
2011-02-04 23:37:54 +00:00
|
|
|
} else {
|
2012-05-10 11:24:12 +00:00
|
|
|
this._suspendOrPowerOffItem.updateText(_("Power Off"), _("Suspend"));
|
2011-02-04 23:37:54 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-11-10 17:13:58 +00:00
|
|
|
_createSubMenu: function() {
|
|
|
|
let item;
|
|
|
|
|
2013-04-25 19:45:53 +00:00
|
|
|
this.menu.addSettingsAction(_("Settings"), 'gnome-control-center.desktop');
|
2009-11-10 17:13:58 +00:00
|
|
|
|
2012-05-10 11:24:12 +00:00
|
|
|
item = new PopupMenu.PopupSeparatorMenuItem();
|
2010-05-10 13:46:54 +00:00
|
|
|
this.menu.addMenuItem(item);
|
2009-11-10 17:13:58 +00:00
|
|
|
|
2010-10-19 15:59:23 +00:00
|
|
|
item = new PopupMenu.PopupMenuItem(_("Switch User"));
|
2009-11-10 17:13:58 +00:00
|
|
|
item.connect('activate', Lang.bind(this, this._onLoginScreenActivate));
|
2010-05-10 13:46:54 +00:00
|
|
|
this.menu.addMenuItem(item);
|
2009-11-10 17:13:58 +00:00
|
|
|
this._loginScreenItem = item;
|
|
|
|
|
2012-05-10 11:24:12 +00:00
|
|
|
item = new PopupMenu.PopupMenuItem(_("Log Out"));
|
2009-11-10 17:13:58 +00:00
|
|
|
item.connect('activate', Lang.bind(this, this._onQuitSessionActivate));
|
2010-05-10 13:46:54 +00:00
|
|
|
this.menu.addMenuItem(item);
|
2011-03-21 12:51:46 +00:00
|
|
|
this._logoutItem = item;
|
2009-11-10 17:13:58 +00:00
|
|
|
|
2012-05-10 11:24:12 +00:00
|
|
|
item = new PopupMenu.PopupMenuItem(_("Lock"));
|
|
|
|
item.connect('activate', Lang.bind(this, this._onLockScreenActivate));
|
2010-05-10 13:46:54 +00:00
|
|
|
this.menu.addMenuItem(item);
|
2012-05-10 11:24:12 +00:00
|
|
|
this._lockScreenItem = item;
|
2012-06-28 10:22:17 +00:00
|
|
|
|
|
|
|
item = new PopupMenu.PopupSeparatorMenuItem();
|
|
|
|
this.menu.addMenuItem(item);
|
|
|
|
|
|
|
|
item = new PopupMenu.PopupAlternatingMenuItem(_("Power Off"),
|
|
|
|
_("Suspend"));
|
|
|
|
this.menu.addMenuItem(item);
|
|
|
|
item.connect('activate', Lang.bind(this, this._onSuspendOrPowerOffActivate));
|
|
|
|
this._suspendOrPowerOffItem = item;
|
|
|
|
this._updateSuspendOrPowerOff();
|
2012-07-17 10:20:56 +00:00
|
|
|
|
|
|
|
item = new PopupMenu.PopupMenuItem(_("Install Updates & Restart"));
|
|
|
|
item.connect('activate', Lang.bind(this, this._onInstallUpdatesActivate));
|
|
|
|
this.menu.addMenuItem(item);
|
|
|
|
this._installUpdatesItem = item;
|
2009-11-10 17:13:58 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onLockScreenActivate: function() {
|
2013-06-18 08:46:44 +00:00
|
|
|
this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
|
2010-06-03 23:21:08 +00:00
|
|
|
Main.overview.hide();
|
2012-06-02 22:10:23 +00:00
|
|
|
Main.screenShield.lock(true);
|
2009-11-10 17:13:58 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onLoginScreenActivate: function() {
|
2013-06-18 08:46:44 +00:00
|
|
|
this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
|
2010-06-03 23:21:08 +00:00
|
|
|
Main.overview.hide();
|
2013-03-04 18:33:36 +00:00
|
|
|
if (Main.screenShield)
|
|
|
|
Main.screenShield.lock(false);
|
2012-08-14 15:49:46 +00:00
|
|
|
Gdm.goto_login_session_sync(null);
|
2009-11-10 17:13:58 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onQuitSessionActivate: function() {
|
2010-06-03 23:21:08 +00:00
|
|
|
Main.overview.hide();
|
2011-03-12 20:34:01 +00:00
|
|
|
this._session.LogoutRemote(0);
|
2009-11-10 17:13:58 +00:00
|
|
|
},
|
|
|
|
|
2012-06-03 15:35:37 +00:00
|
|
|
_onInstallUpdatesActivate: function() {
|
|
|
|
Main.overview.hide();
|
|
|
|
Util.spawn(['pkexec', '/usr/libexec/pk-trigger-offline-update']);
|
|
|
|
|
|
|
|
this._session.RebootRemote();
|
|
|
|
},
|
|
|
|
|
2013-02-11 16:39:29 +00:00
|
|
|
_openSessionWarnDialog: function(sessions) {
|
|
|
|
let dialog = new ModalDialog.ModalDialog();
|
|
|
|
let subjectLabel = new St.Label({ style_class: 'end-session-dialog-subject',
|
|
|
|
text: _("Other users are logged in.") });
|
|
|
|
dialog.contentLayout.add(subjectLabel, { y_fill: true,
|
|
|
|
y_align: St.Align.START });
|
|
|
|
|
|
|
|
let descriptionLabel = new St.Label({ style_class: 'end-session-dialog-description'});
|
|
|
|
descriptionLabel.set_text(_("Shutting down might cause them to lose unsaved work."));
|
2013-03-02 15:55:13 +00:00
|
|
|
descriptionLabel.clutter_text.line_wrap = true;
|
2013-02-11 16:39:29 +00:00
|
|
|
dialog.contentLayout.add(descriptionLabel, { x_fill: true,
|
|
|
|
y_fill: true,
|
|
|
|
y_align: St.Align.START });
|
|
|
|
|
|
|
|
let scrollView = new St.ScrollView({ style_class: 'end-session-dialog-app-list' });
|
|
|
|
scrollView.add_style_class_name('vfade');
|
|
|
|
scrollView.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
|
|
|
|
dialog.contentLayout.add(scrollView, { x_fill: true, y_fill: true });
|
|
|
|
|
|
|
|
let userList = new St.BoxLayout({ vertical: true });
|
|
|
|
scrollView.add_actor(userList);
|
|
|
|
|
|
|
|
for (let i = 0; i < sessions.length; i++) {
|
|
|
|
let session = sessions[i];
|
|
|
|
let userEntry = new St.BoxLayout({ style_class: 'login-dialog-user-list-item',
|
|
|
|
vertical: false });
|
2013-04-24 02:31:08 +00:00
|
|
|
let avatar = new UserWidget.Avatar(session.user);
|
2013-02-11 16:39:29 +00:00
|
|
|
avatar.update();
|
|
|
|
userEntry.add(avatar.actor);
|
|
|
|
|
|
|
|
let userLabelText = "";;
|
|
|
|
let userName = session.user.get_real_name() ?
|
|
|
|
session.user.get_real_name() : session.username;
|
|
|
|
|
|
|
|
if (session.info.remote)
|
2013-03-10 23:37:52 +00:00
|
|
|
/* Translators: Remote here refers to a remote session, like a ssh login */
|
2013-02-11 16:39:29 +00:00
|
|
|
userLabelText = _("%s (remote)").format(userName);
|
|
|
|
else if (session.info.type == "tty")
|
2013-03-10 23:37:52 +00:00
|
|
|
/* Translators: Console here refers to a tty like a VT console */
|
2013-02-11 16:39:29 +00:00
|
|
|
userLabelText = _("%s (console)").format(userName);
|
|
|
|
else
|
|
|
|
userLabelText = userName;
|
|
|
|
|
|
|
|
let textLayout = new St.BoxLayout({ style_class: 'login-dialog-user-list-item-text-box',
|
|
|
|
vertical: true });
|
|
|
|
textLayout.add(new St.Label({ text: userLabelText }),
|
|
|
|
{ y_fill: false,
|
|
|
|
y_align: St.Align.MIDDLE,
|
|
|
|
expand: true });
|
|
|
|
userEntry.add(textLayout, { expand: true });
|
|
|
|
userList.add(userEntry, { x_fill: true });
|
|
|
|
}
|
|
|
|
|
|
|
|
let cancelButton = { label: _("Cancel"),
|
|
|
|
action: function() { dialog.close(); },
|
|
|
|
key: Clutter.Escape };
|
|
|
|
|
|
|
|
let powerOffButton = { label: _("Power Off"), action: Lang.bind(this, function() {
|
|
|
|
dialog.close();
|
|
|
|
this._session.ShutdownRemote();
|
|
|
|
}), default: true };
|
|
|
|
|
|
|
|
dialog.setButtons([cancelButton, powerOffButton]);
|
|
|
|
|
|
|
|
dialog.open();
|
|
|
|
},
|
|
|
|
|
2011-02-04 23:37:54 +00:00
|
|
|
_onSuspendOrPowerOffActivate: function() {
|
2010-06-03 23:21:08 +00:00
|
|
|
Main.overview.hide();
|
2011-02-04 23:37:54 +00:00
|
|
|
|
2012-05-10 11:24:12 +00:00
|
|
|
if (this._haveShutdown &&
|
2011-02-04 23:37:54 +00:00
|
|
|
this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
|
2013-02-11 16:39:29 +00:00
|
|
|
this._loginManager.listSessions(Lang.bind(this,
|
|
|
|
function(result) {
|
|
|
|
let sessions = [];
|
|
|
|
let n = 0;
|
|
|
|
for (let i = 0; i < result.length; i++) {
|
|
|
|
let[id, uid, userName, seat, sessionPath] = result[i];
|
|
|
|
let proxy = new SystemdLoginSession(Gio.DBus.system,
|
|
|
|
'org.freedesktop.login1',
|
|
|
|
sessionPath);
|
|
|
|
|
2013-02-19 07:44:01 +00:00
|
|
|
if (proxy.Class != 'user')
|
2013-02-11 16:39:29 +00:00
|
|
|
continue;
|
|
|
|
|
2013-03-02 15:53:50 +00:00
|
|
|
if (proxy.State == 'closing')
|
|
|
|
continue;
|
|
|
|
|
2013-02-18 17:03:13 +00:00
|
|
|
if (proxy.Id == GLib.getenv('XDG_SESSION_ID'))
|
2013-02-11 16:39:29 +00:00
|
|
|
continue;
|
|
|
|
|
|
|
|
sessions.push({ user: this._userManager.get_user(userName),
|
|
|
|
username: userName,
|
2013-02-19 07:44:01 +00:00
|
|
|
info: { type: proxy.Type,
|
|
|
|
remote: proxy.Remote }
|
2013-02-11 16:39:29 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// limit the number of entries
|
|
|
|
n++;
|
|
|
|
if (n == MAX_USERS_IN_SESSION_DIALOG)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (n != 0)
|
|
|
|
this._openSessionWarnDialog(sessions);
|
|
|
|
else
|
|
|
|
this._session.ShutdownRemote();
|
|
|
|
}));
|
2012-05-10 11:24:12 +00:00
|
|
|
} else {
|
2013-06-18 08:46:44 +00:00
|
|
|
this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
|
2012-10-23 13:49:25 +00:00
|
|
|
this._loginManager.suspend();
|
2011-02-04 23:37:54 +00:00
|
|
|
}
|
2009-11-10 17:13:58 +00:00
|
|
|
}
|
2011-11-20 14:38:48 +00:00
|
|
|
});
|