21
const DBus = imports.dbus;
22
21
const Lang = imports.lang;
23
22
const Signals = imports.signals;
25
24
const AccountsService = imports.gi.AccountsService;
26
25
const Clutter = imports.gi.Clutter;
26
const Gio = imports.gi.Gio;
27
27
const GLib = imports.gi.GLib;
28
28
const Gtk = imports.gi.Gtk;
29
29
const Pango = imports.gi.Pango;
30
30
const St = imports.gi.St;
31
31
const Shell = imports.gi.Shell;
33
const GnomeSession = imports.misc.gnomeSession
33
const GnomeSession = imports.misc.gnomeSession;
34
34
const Lightbox = imports.ui.lightbox;
35
35
const Main = imports.ui.main;
36
36
const ModalDialog = imports.ui.modalDialog;
44
44
const GSM_SESSION_MANAGER_LOGOUT_FORCE = 2;
46
const EndSessionDialogIface = {
47
name: 'org.gnome.SessionManager.EndSessionDialog',
48
methods: [{ name: 'Open',
53
signals: [{ name: 'Canceled',
46
const EndSessionDialogIface = <interface name="org.gnome.SessionManager.EndSessionDialog">
48
<arg type="u" direction="in" />
49
<arg type="u" direction="in" />
50
<arg type="u" direction="in" />
51
<arg type="ao" direction="in" />
53
<signal name="ConfirmedLogout" />
54
<signal name="ConfirmedReboot" />
55
<signal name="ConfirmedShutdown" />
56
<signal name="Canceled" />
57
<signal name="Closed" />
59
60
const logoutDialogContent = {
60
subjectWithUser: _("Log Out %s"),
61
subject: _("Log Out"),
61
subjectWithUser: C_("title", "Log Out %s"),
62
subject: C_("title", "Log Out"),
62
63
inhibitedDescription: _("Click Log Out to quit these applications and log out of the system."),
63
64
uninhibitedDescriptionWithUser: function(user, seconds) {
64
65
return ngettext("%s will be logged out automatically in %d second.",
73
74
endDescription: _("Logging out of the system."),
74
75
confirmButtons: [{ signal: 'ConfirmedLogout',
75
label: _("Log Out") }],
76
label: C_("button", "Log Out") }],
76
77
iconStyleClass: 'end-session-dialog-logout-icon'
79
80
const shutdownDialogContent = {
80
subject: _("Power Off"),
81
subject: C_("title", "Power Off"),
81
82
inhibitedDescription: _("Click Power Off to quit these applications and power off the system."),
82
83
uninhibitedDescription: function(seconds) {
83
84
return ngettext("The system will power off automatically in %d second.",
87
88
endDescription: _("Powering off the system."),
88
89
confirmButtons: [{ signal: 'ConfirmedReboot',
89
label: _("Restart") },
90
label: C_("button", "Restart") },
90
91
{ signal: 'ConfirmedShutdown',
91
label: _("Power Off") }],
92
label: C_("button", "Power Off") }],
92
93
iconName: 'system-shutdown',
93
94
iconStyleClass: 'end-session-dialog-shutdown-icon'
96
97
const restartDialogContent = {
97
subject: _("Restart"),
98
subject: C_("title", "Restart"),
98
99
inhibitedDescription: _("Click Restart to quit these applications and restart the system."),
99
100
uninhibitedDescription: function(seconds) {
100
101
return ngettext("The system will restart automatically in %d second.",
104
105
endDescription: _("Restarting the system."),
105
106
confirmButtons: [{ signal: 'ConfirmedReboot',
106
label: _("Restart") }],
107
label: C_("button", "Restart") }],
107
108
iconName: 'system-shutdown',
108
109
iconStyleClass: 'end-session-dialog-shutdown-icon'
232
function EndSessionDialog() {
233
if (_endSessionDialog == null) {
235
DBus.session.exportObject('/org/gnome/SessionManager/EndSessionDialog',
237
_endSessionDialog = this;
240
return _endSessionDialog;
243
231
function init() {
244
232
// This always returns the same singleton object
245
233
// By instantiating it initially, we register the
246
234
// bus object, etc.
247
let dialog = new EndSessionDialog();
235
_endSessionDialog = new EndSessionDialog();
250
EndSessionDialog.prototype = {
251
__proto__: ModalDialog.ModalDialog.prototype,
238
const EndSessionDialog = new Lang.Class({
239
Name: 'EndSessionDialog',
240
Extends: ModalDialog.ModalDialog,
253
242
_init: function() {
254
ModalDialog.ModalDialog.prototype._init.call(this, { styleClass: 'end-session-dialog' });
243
this.parent({ styleClass: 'end-session-dialog' });
256
245
this._user = AccountsService.UserManager.get_default().get_user(GLib.get_user_name());
441
434
close: function() {
442
ModalDialog.ModalDialog.prototype.close.call(this);
443
DBus.session.emit_signal('/org/gnome/SessionManager/EndSessionDialog',
444
'org.gnome.SessionManager.EndSessionDialog',
436
this._dbusImpl.emit_signal('Closed', null);
448
439
cancel: function() {
449
440
this._stopTimer();
450
DBus.session.emit_signal('/org/gnome/SessionManager/EndSessionDialog',
451
'org.gnome.SessionManager.EndSessionDialog',
441
this._dbusImpl.emit_signal('Canceled', null);
453
442
this.close(global.get_current_time());
456
445
_confirm: function(signal) {
457
446
this._fadeOutDialog();
458
447
this._stopTimer();
459
DBus.session.emit_signal('/org/gnome/SessionManager/EndSessionDialog',
460
'org.gnome.SessionManager.EndSessionDialog',
448
this._dbusImpl.emit_signal(signal, null);
464
451
_onOpened: function() {
510
497
this._updateContent();
513
OpenAsync: function(type, timestamp, totalSecondsToStayOpen, inhibitorObjectPaths, callback) {
500
OpenAsync: function(parameters, invocation) {
501
let [type, timestamp, totalSecondsToStayOpen, inhibitorObjectPaths] = parameters;
514
502
this._totalSecondsToStayOpen = totalSecondsToStayOpen;
515
503
this._inhibitors = [];
516
this._applicationList.destroy_children();
504
this._applicationList.destroy_all_children();
517
505
this._type = type;
519
if (!(this._type in DialogContent))
520
throw new DBus.DBusError('org.gnome.Shell.ModalDialog.TypeError',
521
"Unknown dialog type requested");
507
if (!(this._type in DialogContent)) {
508
invocation.report_dbus_error('org.gnome.Shell.ModalDialog.TypeError',
509
"Unknown dialog type requested");
523
513
for (let i = 0; i < inhibitorObjectPaths.length; i++) {
524
let inhibitor = new GnomeSession.Inhibitor(inhibitorObjectPaths[i]);
514
let inhibitor = new GnomeSession.Inhibitor(inhibitorObjectPaths[i], Lang.bind(this, function(proxy, error) {
515
this._onInhibitorLoaded(proxy);
526
inhibitor.connect('is-loaded',
527
Lang.bind(this, function() {
528
this._onInhibitorLoaded(inhibitor);
530
518
this._inhibitors.push(inhibitor);
533
521
this._updateButtons();
535
if (!this.open(timestamp))
536
throw new DBus.DBusError('org.gnome.Shell.ModalDialog.GrabError',
537
"Cannot grab pointer and keyboard");
523
if (!this.open(timestamp)) {
524
invocation.report_dbus_error('org.gnome.Shell.ModalDialog.GrabError',
525
"Cannot grab pointer and keyboard");
539
529
this._updateContent();
541
531
let signalId = this.connect('opened',
542
532
Lang.bind(this, function() {
533
invocation.return_value(null);
544
534
this.disconnect(signalId);
548
DBus.conformExport(EndSessionDialog.prototype, EndSessionDialogIface);