4
4
const Gdm = imports.gi.Gdm;
5
5
const Gio = imports.gi.Gio;
6
6
const GLib = imports.gi.GLib;
7
const Gtk = imports.gi.Gtk;
7
8
const Lang = imports.lang;
8
9
const Pango = imports.gi.Pango;
9
10
const Shell = imports.gi.Shell;
10
11
const St = imports.gi.St;
11
12
const Tp = imports.gi.TelepathyGLib;
12
const UPowerGlib = imports.gi.UPowerGlib;
13
13
const Atk = imports.gi.Atk;
14
const Clutter = imports.gi.Clutter;
15
16
const BoxPointer = imports.ui.boxpointer;
16
17
const GnomeSession = imports.misc.gnomeSession;
18
const LoginManager = imports.misc.loginManager;
17
19
const Main = imports.ui.main;
20
const ModalDialog = imports.ui.modalDialog;
18
21
const PanelMenu = imports.ui.panelMenu;
19
22
const PopupMenu = imports.ui.popupMenu;
20
23
const Params = imports.misc.params;
21
const UnlockDialog = imports.ui.unlockDialog;
22
24
const Util = imports.misc.util;
24
26
const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
25
27
const SCREENSAVER_SCHEMA = 'org.gnome.desktop.screensaver';
28
const PRIVACY_SCHEMA = 'org.gnome.desktop.privacy'
26
29
const DISABLE_USER_SWITCH_KEY = 'disable-user-switching';
27
30
const DISABLE_LOCK_SCREEN_KEY = 'disable-lock-screen';
28
31
const DISABLE_LOG_OUT_KEY = 'disable-log-out';
29
const LOCK_ENABLED_KEY = 'lock-enabled';
30
32
const ALWAYS_SHOW_LOG_OUT_KEY = 'always-show-log-out';
31
const SUSPEND_LOCK_ENABLED_KEY = 'ubuntu-lock-on-suspend';
33
const SHOW_FULL_NAME_IN_TOP_BAR_KEY = 'show-full-name-in-top-bar';
33
35
const DIALOG_ICON_SIZE = 64;
37
const MAX_USERS_IN_SESSION_DIALOG = 5;
556
568
Lang.bind(this, this._updateSwitchUser));
557
569
this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
558
570
Lang.bind(this, this._updateLogout));
560
571
this._lockdownSettings.connect('changed::' + DISABLE_LOCK_SCREEN_KEY,
561
572
Lang.bind(this, this._updateLockScreen));
573
global.settings.connect('changed::' + ALWAYS_SHOW_LOG_OUT_KEY,
574
Lang.bind(this, this._updateLogout));
575
this._screenSaverSettings.connect('changed::' + SHOW_FULL_NAME_IN_TOP_BAR_KEY,
576
Lang.bind(this, this._updateUserName));
577
this._privacySettings.connect('changed::' + SHOW_FULL_NAME_IN_TOP_BAR_KEY,
578
Lang.bind(this, this._updateUserName));
562
579
this._updateSwitchUser();
563
580
this._updateLogout();
564
581
this._updateLockScreen();
573
590
// the lockdown setting changes, which should be close enough.
574
591
this.menu.connect('open-state-changed', Lang.bind(this,
575
592
function(menu, open) {
577
this._updateHaveShutdown();
596
this._updateHaveShutdown();
597
this._updateHaveSuspend();
579
599
this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
580
600
Lang.bind(this, this._updateHaveShutdown));
582
this._upClient.connect('notify::can-suspend', Lang.bind(this, this._updateSuspendOrPowerOff));
584
602
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
603
if (Main.screenShield)
604
Main.screenShield.connect('locked-changed', Lang.bind(this, this._updatePresenceIcon));
585
605
this._sessionUpdated();
849
884
this._session.RebootRemote();
887
_openSessionWarnDialog: function(sessions) {
888
let dialog = new ModalDialog.ModalDialog();
889
let subjectLabel = new St.Label({ style_class: 'end-session-dialog-subject',
890
text: _("Other users are logged in.") });
891
dialog.contentLayout.add(subjectLabel, { y_fill: true,
892
y_align: St.Align.START });
894
let descriptionLabel = new St.Label({ style_class: 'end-session-dialog-description'});
895
descriptionLabel.set_text(_("Shutting down might cause them to lose unsaved work."));
896
descriptionLabel.clutter_text.line_wrap = true;
897
dialog.contentLayout.add(descriptionLabel, { x_fill: true,
899
y_align: St.Align.START });
901
let scrollView = new St.ScrollView({ style_class: 'end-session-dialog-app-list' });
902
scrollView.add_style_class_name('vfade');
903
scrollView.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC);
904
dialog.contentLayout.add(scrollView, { x_fill: true, y_fill: true });
906
let userList = new St.BoxLayout({ vertical: true });
907
scrollView.add_actor(userList);
909
for (let i = 0; i < sessions.length; i++) {
910
let session = sessions[i];
911
let userEntry = new St.BoxLayout({ style_class: 'login-dialog-user-list-item',
913
let avatar = new UserAvatarWidget(session.user);
915
userEntry.add(avatar.actor);
917
let userLabelText = "";;
918
let userName = session.user.get_real_name() ?
919
session.user.get_real_name() : session.username;
921
if (session.info.remote)
922
/* Translators: Remote here refers to a remote session, like a ssh login */
923
userLabelText = _("%s (remote)").format(userName);
924
else if (session.info.type == "tty")
925
/* Translators: Console here refers to a tty like a VT console */
926
userLabelText = _("%s (console)").format(userName);
928
userLabelText = userName;
930
let textLayout = new St.BoxLayout({ style_class: 'login-dialog-user-list-item-text-box',
932
textLayout.add(new St.Label({ text: userLabelText }),
934
y_align: St.Align.MIDDLE,
936
userEntry.add(textLayout, { expand: true });
937
userList.add(userEntry, { x_fill: true });
940
let cancelButton = { label: _("Cancel"),
941
action: function() { dialog.close(); },
942
key: Clutter.Escape };
944
let powerOffButton = { label: _("Power Off"), action: Lang.bind(this, function() {
946
this._session.ShutdownRemote();
949
dialog.setButtons([cancelButton, powerOffButton]);
852
954
_onSuspendOrPowerOffActivate: function() {
853
955
Main.overview.hide();
855
957
if (this._haveShutdown &&
856
958
this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
857
this._session.ShutdownRemote();
959
this._loginManager.listSessions(Lang.bind(this,
963
for (let i = 0; i < result.length; i++) {
964
let[id, uid, userName, seat, sessionPath] = result[i];
965
let proxy = new SystemdLoginSession(Gio.DBus.system,
966
'org.freedesktop.login1',
969
if (proxy.Class != 'user')
972
if (proxy.State == 'closing')
975
if (proxy.Id == GLib.getenv('XDG_SESSION_ID'))
978
sessions.push({ user: this._userManager.get_user(userName),
980
info: { type: proxy.Type,
981
remote: proxy.Remote }
984
// limit the number of entries
986
if (n == MAX_USERS_IN_SESSION_DIALOG)
991
this._openSessionWarnDialog(sessions);
993
this._session.ShutdownRemote();
859
if (this._screenSaverSettings.get_boolean(SUSPEND_LOCK_ENABLED_KEY)) {
860
let tmpId = Main.screenShield.connect('lock-screen-shown', Lang.bind(this, function() {
861
Main.screenShield.disconnect(tmpId);
863
this._upClient.suspend_sync(null);
866
this.menu.close(BoxPointer.PopupAnimation.NONE);
867
Main.screenShield.lock(true);
869
this._upClient.suspend_sync(null);
996
this.menu.close(BoxPointer.PopupAnimation.NONE);
997
this._loginManager.suspend();
873
1001
_lightdmLoginSession: function() {
875
1003
let seat = GLib.getenv("XDG_SEAT_PATH");