2011-09-28 09:16:26 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
/*
|
2011-01-06 10:30:15 -05:00
|
|
|
* Copyright 2010 Red Hat, Inc
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const Lang = imports.lang;
|
|
|
|
const Signals = imports.signals;
|
|
|
|
|
2011-05-10 10:13:05 -04:00
|
|
|
const AccountsService = imports.gi.AccountsService;
|
2011-01-06 10:30:15 -05:00
|
|
|
const Clutter = imports.gi.Clutter;
|
2011-08-16 08:24:39 -04:00
|
|
|
const Gio = imports.gi.Gio;
|
2011-01-06 10:30:15 -05:00
|
|
|
const GLib = imports.gi.GLib;
|
|
|
|
const Gtk = imports.gi.Gtk;
|
|
|
|
const Pango = imports.gi.Pango;
|
|
|
|
const St = imports.gi.St;
|
|
|
|
const Shell = imports.gi.Shell;
|
|
|
|
|
2011-08-16 08:24:39 -04:00
|
|
|
const GnomeSession = imports.misc.gnomeSession;
|
2011-01-06 10:30:15 -05:00
|
|
|
const Main = imports.ui.main;
|
|
|
|
const ModalDialog = imports.ui.modalDialog;
|
|
|
|
const Tweener = imports.ui.tweener;
|
2012-08-31 17:18:26 -04:00
|
|
|
const UserMenu = imports.ui.userMenu;
|
2011-01-06 10:30:15 -05:00
|
|
|
|
|
|
|
let _endSessionDialog = null;
|
|
|
|
|
|
|
|
const _ITEM_ICON_SIZE = 48;
|
|
|
|
const _DIALOG_ICON_SIZE = 32;
|
|
|
|
|
|
|
|
const GSM_SESSION_MANAGER_LOGOUT_FORCE = 2;
|
|
|
|
|
2011-08-16 08:24:39 -04:00
|
|
|
const EndSessionDialogIface = <interface name="org.gnome.SessionManager.EndSessionDialog">
|
|
|
|
<method name="Open">
|
|
|
|
<arg type="u" direction="in" />
|
|
|
|
<arg type="u" direction="in" />
|
|
|
|
<arg type="u" direction="in" />
|
|
|
|
<arg type="ao" direction="in" />
|
|
|
|
</method>
|
|
|
|
<signal name="ConfirmedLogout" />
|
|
|
|
<signal name="ConfirmedReboot" />
|
|
|
|
<signal name="ConfirmedShutdown" />
|
|
|
|
<signal name="Canceled" />
|
|
|
|
<signal name="Closed" />
|
|
|
|
</interface>;
|
2011-01-06 10:30:15 -05:00
|
|
|
|
|
|
|
const logoutDialogContent = {
|
2011-10-21 16:29:13 -04:00
|
|
|
subjectWithUser: C_("title", "Log Out %s"),
|
|
|
|
subject: C_("title", "Log Out"),
|
2011-01-06 10:30:15 -05:00
|
|
|
inhibitedDescription: _("Click Log Out to quit these applications and log out of the system."),
|
2011-09-07 07:34:48 -04:00
|
|
|
uninhibitedDescriptionWithUser: function(user, seconds) {
|
|
|
|
return ngettext("%s will be logged out automatically in %d second.",
|
|
|
|
"%s will be logged out automatically in %d seconds.",
|
|
|
|
seconds).format(user, seconds);
|
|
|
|
},
|
|
|
|
uninhibitedDescription: function(seconds) {
|
|
|
|
return ngettext("You will be logged out automatically in %d second.",
|
|
|
|
"You will be logged out automatically in %d seconds.",
|
|
|
|
seconds).format(seconds);
|
|
|
|
},
|
2011-01-06 10:30:15 -05:00
|
|
|
endDescription: _("Logging out of the system."),
|
2011-03-21 16:12:30 -04:00
|
|
|
confirmButtons: [{ signal: 'ConfirmedLogout',
|
2011-10-21 16:29:13 -04:00
|
|
|
label: C_("button", "Log Out") }],
|
2011-01-06 10:30:15 -05:00
|
|
|
iconStyleClass: 'end-session-dialog-logout-icon'
|
|
|
|
};
|
|
|
|
|
|
|
|
const shutdownDialogContent = {
|
2011-10-21 16:29:13 -04:00
|
|
|
subject: C_("title", "Power Off"),
|
2011-03-21 16:12:30 -04:00
|
|
|
inhibitedDescription: _("Click Power Off to quit these applications and power off the system."),
|
2011-09-07 07:34:48 -04:00
|
|
|
uninhibitedDescription: function(seconds) {
|
|
|
|
return ngettext("The system will power off automatically in %d second.",
|
|
|
|
"The system will power off automatically in %d seconds.",
|
|
|
|
seconds).format(seconds);
|
|
|
|
},
|
2011-03-21 16:12:30 -04:00
|
|
|
endDescription: _("Powering off the system."),
|
|
|
|
confirmButtons: [{ signal: 'ConfirmedReboot',
|
2011-10-21 16:29:13 -04:00
|
|
|
label: C_("button", "Restart") },
|
2011-03-21 16:12:30 -04:00
|
|
|
{ signal: 'ConfirmedShutdown',
|
2011-10-21 16:29:13 -04:00
|
|
|
label: C_("button", "Power Off") }],
|
2012-05-30 09:58:37 -04:00
|
|
|
iconName: 'system-shutdown-symbolic',
|
2011-01-06 10:30:15 -05:00
|
|
|
iconStyleClass: 'end-session-dialog-shutdown-icon'
|
|
|
|
};
|
|
|
|
|
|
|
|
const restartDialogContent = {
|
2011-10-21 16:29:13 -04:00
|
|
|
subject: C_("title", "Restart"),
|
2011-01-06 10:30:15 -05:00
|
|
|
inhibitedDescription: _("Click Restart to quit these applications and restart the system."),
|
2011-09-07 07:34:48 -04:00
|
|
|
uninhibitedDescription: function(seconds) {
|
|
|
|
return ngettext("The system will restart automatically in %d second.",
|
|
|
|
"The system will restart automatically in %d seconds.",
|
|
|
|
seconds).format(seconds);
|
|
|
|
},
|
2011-01-06 10:30:15 -05:00
|
|
|
endDescription: _("Restarting the system."),
|
2011-03-21 16:12:30 -04:00
|
|
|
confirmButtons: [{ signal: 'ConfirmedReboot',
|
2011-10-21 16:29:13 -04:00
|
|
|
label: C_("button", "Restart") }],
|
2012-11-01 12:18:32 -04:00
|
|
|
iconName: 'view-refresh-symbolic',
|
2011-01-06 10:30:15 -05:00
|
|
|
iconStyleClass: 'end-session-dialog-shutdown-icon'
|
|
|
|
};
|
|
|
|
|
|
|
|
const DialogContent = {
|
|
|
|
0 /* GSM_SHELL_END_SESSION_DIALOG_TYPE_LOGOUT */: logoutDialogContent,
|
|
|
|
1 /* GSM_SHELL_END_SESSION_DIALOG_TYPE_SHUTDOWN */: shutdownDialogContent,
|
|
|
|
2 /* GSM_SHELL_END_SESSION_DIALOG_TYPE_RESTART */: restartDialogContent
|
|
|
|
};
|
|
|
|
|
|
|
|
function findAppFromInhibitor(inhibitor) {
|
2012-03-16 22:13:37 -04:00
|
|
|
let [desktopFile] = inhibitor.GetAppIdSync();
|
2011-01-06 10:30:15 -05:00
|
|
|
|
|
|
|
if (!GLib.str_has_suffix(desktopFile, '.desktop'))
|
2012-03-16 22:13:37 -04:00
|
|
|
desktopFile += '.desktop';
|
2011-01-06 10:30:15 -05:00
|
|
|
|
2012-03-16 22:16:30 -04:00
|
|
|
return Shell.AppSystem.get_default().lookup_heuristic_basename(desktopFile);
|
2011-01-06 10:30:15 -05:00
|
|
|
}
|
|
|
|
|
2011-11-20 12:56:27 -05:00
|
|
|
const ListItem = new Lang.Class({
|
|
|
|
Name: 'ListItem',
|
2011-01-06 10:30:15 -05:00
|
|
|
|
|
|
|
_init: function(app, reason) {
|
|
|
|
this._app = app;
|
|
|
|
this._reason = reason;
|
|
|
|
|
|
|
|
if (this._reason == null)
|
|
|
|
this._reason = '';
|
|
|
|
|
|
|
|
let layout = new St.BoxLayout({ vertical: false});
|
|
|
|
|
2011-01-25 16:22:00 -05:00
|
|
|
this.actor = new St.Button({ style_class: 'end-session-dialog-app-list-item',
|
|
|
|
can_focus: true,
|
|
|
|
child: layout,
|
|
|
|
reactive: true,
|
|
|
|
x_align: St.Align.START,
|
|
|
|
x_fill: true });
|
2011-01-06 10:30:15 -05:00
|
|
|
|
|
|
|
this._icon = this._app.create_icon_texture(_ITEM_ICON_SIZE);
|
|
|
|
|
|
|
|
let iconBin = new St.Bin({ style_class: 'end-session-dialog-app-list-item-icon',
|
|
|
|
child: this._icon });
|
|
|
|
layout.add(iconBin);
|
|
|
|
|
|
|
|
let textLayout = new St.BoxLayout({ style_class: 'end-session-dialog-app-list-item-text-box',
|
|
|
|
vertical: true });
|
|
|
|
layout.add(textLayout);
|
|
|
|
|
|
|
|
this._nameLabel = new St.Label({ text: this._app.get_name(),
|
|
|
|
style_class: 'end-session-dialog-app-list-item-name' });
|
|
|
|
textLayout.add(this._nameLabel,
|
|
|
|
{ expand: false,
|
|
|
|
x_fill: true });
|
|
|
|
|
|
|
|
this._descriptionLabel = new St.Label({ text: this._reason,
|
|
|
|
style_class: 'end-session-dialog-app-list-item-description' });
|
2012-06-06 05:36:28 -04:00
|
|
|
this.actor.label_actor = this._nameLabel;
|
2011-01-06 10:30:15 -05:00
|
|
|
textLayout.add(this._descriptionLabel,
|
|
|
|
{ expand: true,
|
|
|
|
x_fill: true });
|
|
|
|
|
|
|
|
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
|
|
|
|
},
|
|
|
|
|
|
|
|
_onClicked: function() {
|
|
|
|
this.emit('activate');
|
2011-08-11 05:35:23 -04:00
|
|
|
this._app.activate();
|
2011-01-06 10:30:15 -05:00
|
|
|
}
|
2011-11-20 12:56:27 -05:00
|
|
|
});
|
2011-01-06 10:30:15 -05:00
|
|
|
Signals.addSignalMethods(ListItem.prototype);
|
|
|
|
|
|
|
|
// The logout timer only shows updates every 10 seconds
|
|
|
|
// until the last 10 seconds, then it shows updates every
|
|
|
|
// second. This function takes a given time and returns
|
|
|
|
// what we should show to the user for that time.
|
|
|
|
function _roundSecondsToInterval(totalSeconds, secondsLeft, interval) {
|
|
|
|
let time;
|
|
|
|
|
|
|
|
time = Math.ceil(secondsLeft);
|
|
|
|
|
|
|
|
// Final count down is in decrements of 1
|
|
|
|
if (time <= interval)
|
|
|
|
return time;
|
|
|
|
|
|
|
|
// Round up higher than last displayable time interval
|
|
|
|
time += interval - 1;
|
|
|
|
|
|
|
|
// Then round down to that time interval
|
|
|
|
if (time > totalSeconds)
|
|
|
|
time = Math.ceil(totalSeconds);
|
|
|
|
else
|
|
|
|
time -= time % interval;
|
|
|
|
|
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
|
|
|
function _setLabelText(label, text) {
|
|
|
|
if (text) {
|
|
|
|
label.set_text(text);
|
|
|
|
label.show();
|
|
|
|
} else {
|
|
|
|
label.set_text('');
|
|
|
|
label.hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
// This always returns the same singleton object
|
|
|
|
// By instantiating it initially, we register the
|
|
|
|
// bus object, etc.
|
2011-11-20 10:32:59 -05:00
|
|
|
_endSessionDialog = new EndSessionDialog();
|
2011-01-06 10:30:15 -05:00
|
|
|
}
|
|
|
|
|
2011-11-20 10:32:59 -05:00
|
|
|
const EndSessionDialog = new Lang.Class({
|
|
|
|
Name: 'EndSessionDialog',
|
|
|
|
Extends: ModalDialog.ModalDialog,
|
2011-01-06 10:30:15 -05:00
|
|
|
|
|
|
|
_init: function() {
|
2011-11-20 10:32:59 -05:00
|
|
|
this.parent({ styleClass: 'end-session-dialog' });
|
2011-01-06 10:30:15 -05:00
|
|
|
|
2011-05-10 10:13:05 -04:00
|
|
|
this._user = AccountsService.UserManager.get_default().get_user(GLib.get_user_name());
|
2011-01-06 10:30:15 -05:00
|
|
|
|
|
|
|
this._secondsLeft = 0;
|
|
|
|
this._totalSecondsToStayOpen = 0;
|
|
|
|
this._inhibitors = [];
|
|
|
|
|
|
|
|
this.connect('destroy',
|
|
|
|
Lang.bind(this, this._onDestroy));
|
|
|
|
this.connect('opened',
|
|
|
|
Lang.bind(this, this._onOpened));
|
|
|
|
|
|
|
|
this._userLoadedId = this._user.connect('notify::is_loaded',
|
|
|
|
Lang.bind(this, this._updateContent));
|
|
|
|
|
|
|
|
this._userChangedId = this._user.connect('changed',
|
|
|
|
Lang.bind(this, this._updateContent));
|
|
|
|
|
|
|
|
let mainContentLayout = new St.BoxLayout({ vertical: false });
|
|
|
|
this.contentLayout.add(mainContentLayout,
|
|
|
|
{ x_fill: true,
|
|
|
|
y_fill: false });
|
|
|
|
|
|
|
|
this._iconBin = new St.Bin();
|
|
|
|
mainContentLayout.add(this._iconBin,
|
|
|
|
{ x_fill: true,
|
|
|
|
y_fill: false,
|
|
|
|
x_align: St.Align.END,
|
|
|
|
y_align: St.Align.START });
|
|
|
|
|
|
|
|
let messageLayout = new St.BoxLayout({ vertical: true });
|
|
|
|
mainContentLayout.add(messageLayout,
|
|
|
|
{ y_align: St.Align.START });
|
|
|
|
|
|
|
|
this._subjectLabel = new St.Label({ style_class: 'end-session-dialog-subject' });
|
|
|
|
|
|
|
|
messageLayout.add(this._subjectLabel,
|
|
|
|
{ y_fill: false,
|
|
|
|
y_align: St.Align.START });
|
|
|
|
|
|
|
|
this._descriptionLabel = new St.Label({ style_class: 'end-session-dialog-description' });
|
|
|
|
this._descriptionLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
|
|
|
|
this._descriptionLabel.clutter_text.line_wrap = true;
|
|
|
|
|
|
|
|
messageLayout.add(this._descriptionLabel,
|
|
|
|
{ y_fill: true,
|
|
|
|
y_align: St.Align.START });
|
|
|
|
|
|
|
|
let scrollView = new St.ScrollView({ style_class: 'end-session-dialog-app-list'});
|
|
|
|
scrollView.set_policy(Gtk.PolicyType.NEVER,
|
|
|
|
Gtk.PolicyType.AUTOMATIC);
|
|
|
|
this.contentLayout.add(scrollView,
|
|
|
|
{ x_fill: true,
|
|
|
|
y_fill: true });
|
2011-03-21 16:11:15 -04:00
|
|
|
scrollView.hide();
|
|
|
|
|
2011-01-06 10:30:15 -05:00
|
|
|
this._applicationList = new St.BoxLayout({ vertical: true });
|
2012-07-18 20:15:04 -04:00
|
|
|
scrollView.add_actor(this._applicationList);
|
2011-03-21 16:11:15 -04:00
|
|
|
|
|
|
|
this._applicationList.connect('actor-added',
|
|
|
|
Lang.bind(this, function() {
|
2012-05-29 20:36:45 -04:00
|
|
|
if (this._applicationList.get_n_children() == 1)
|
2011-03-21 16:11:15 -04:00
|
|
|
scrollView.show();
|
|
|
|
}));
|
|
|
|
|
|
|
|
this._applicationList.connect('actor-removed',
|
|
|
|
Lang.bind(this, function() {
|
2012-05-29 20:36:45 -04:00
|
|
|
if (this._applicationList.get_n_children() == 0)
|
2011-03-21 16:11:15 -04:00
|
|
|
scrollView.hide();
|
|
|
|
}));
|
2011-08-16 08:24:39 -04:00
|
|
|
|
|
|
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(EndSessionDialogIface, this);
|
|
|
|
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/SessionManager/EndSessionDialog');
|
2011-01-06 10:30:15 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onDestroy: function() {
|
|
|
|
this._user.disconnect(this._userLoadedId);
|
|
|
|
this._user.disconnect(this._userChangedId);
|
|
|
|
},
|
|
|
|
|
2012-06-05 05:51:36 -04:00
|
|
|
_updateDescription: function() {
|
2011-01-06 10:30:15 -05:00
|
|
|
if (this.state != ModalDialog.State.OPENING &&
|
|
|
|
this.state != ModalDialog.State.OPENED)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let dialogContent = DialogContent[this._type];
|
|
|
|
|
|
|
|
let subject = dialogContent.subject;
|
|
|
|
let description;
|
|
|
|
|
|
|
|
if (this._inhibitors.length > 0) {
|
|
|
|
this._stopTimer();
|
|
|
|
description = dialogContent.inhibitedDescription;
|
|
|
|
} else if (this._secondsLeft > 0 && this._inhibitors.length == 0) {
|
|
|
|
let displayTime = _roundSecondsToInterval(this._totalSecondsToStayOpen,
|
|
|
|
this._secondsLeft,
|
|
|
|
10);
|
|
|
|
|
|
|
|
if (this._user.is_loaded) {
|
|
|
|
let realName = this._user.get_real_name();
|
|
|
|
|
|
|
|
if (realName != null) {
|
|
|
|
if (dialogContent.subjectWithUser)
|
|
|
|
subject = dialogContent.subjectWithUser.format(realName);
|
|
|
|
|
|
|
|
if (dialogContent.uninhibitedDescriptionWithUser)
|
2011-09-07 07:34:48 -04:00
|
|
|
description = dialogContent.uninhibitedDescriptionWithUser(realName, displayTime);
|
2011-01-06 10:30:15 -05:00
|
|
|
else
|
2011-09-07 07:34:48 -04:00
|
|
|
description = dialogContent.uninhibitedDescription(displayTime);
|
2011-01-06 10:30:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!description)
|
2011-09-07 07:34:48 -04:00
|
|
|
description = dialogContent.uninhibitedDescription(displayTime);
|
2011-01-06 10:30:15 -05:00
|
|
|
} else {
|
|
|
|
description = dialogContent.endDescription;
|
|
|
|
}
|
|
|
|
|
|
|
|
_setLabelText(this._subjectLabel, subject);
|
|
|
|
_setLabelText(this._descriptionLabel, description);
|
|
|
|
},
|
|
|
|
|
2012-06-05 05:51:36 -04:00
|
|
|
_updateContent: function() {
|
|
|
|
if (this.state != ModalDialog.State.OPENING &&
|
|
|
|
this.state != ModalDialog.State.OPENED)
|
|
|
|
return;
|
|
|
|
|
|
|
|
let dialogContent = DialogContent[this._type];
|
2012-08-31 17:18:26 -04:00
|
|
|
if (dialogContent.iconName) {
|
|
|
|
this._iconBin.child = new St.Icon({ icon_name: dialogContent.iconName,
|
|
|
|
icon_size: _DIALOG_ICON_SIZE,
|
|
|
|
style_class: dialogContent.iconStyleClass });
|
|
|
|
} else {
|
|
|
|
let avatarWidget = new UserMenu.UserAvatarWidget(this._user,
|
|
|
|
{ iconSize: _DIALOG_ICON_SIZE,
|
|
|
|
styleClass: dialogContent.iconStyleClass });
|
|
|
|
this._iconBin.child = avatarWidget.actor;
|
|
|
|
avatarWidget.update();
|
2012-06-05 05:51:36 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
this._updateDescription();
|
|
|
|
},
|
|
|
|
|
2011-01-06 10:30:15 -05:00
|
|
|
_updateButtons: function() {
|
|
|
|
let dialogContent = DialogContent[this._type];
|
2011-03-21 16:12:30 -04:00
|
|
|
let buttons = [{ action: Lang.bind(this, this.cancel),
|
|
|
|
label: _("Cancel"),
|
|
|
|
key: Clutter.Escape }];
|
|
|
|
|
|
|
|
for (let i = 0; i < dialogContent.confirmButtons.length; i++) {
|
|
|
|
let signal = dialogContent.confirmButtons[i].signal;
|
|
|
|
let label = dialogContent.confirmButtons[i].label;
|
|
|
|
buttons.push({ action: Lang.bind(this, function() {
|
|
|
|
this._confirm(signal);
|
|
|
|
}),
|
|
|
|
label: label });
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setButtons(buttons);
|
2011-01-06 10:30:15 -05:00
|
|
|
},
|
|
|
|
|
2011-03-22 12:50:56 -04:00
|
|
|
close: function() {
|
2011-11-20 10:32:59 -05:00
|
|
|
this.parent();
|
2011-08-16 08:24:39 -04:00
|
|
|
this._dbusImpl.emit_signal('Closed', null);
|
2011-03-22 12:50:56 -04:00
|
|
|
},
|
|
|
|
|
2011-01-06 10:30:15 -05:00
|
|
|
cancel: function() {
|
|
|
|
this._stopTimer();
|
2011-08-16 08:24:39 -04:00
|
|
|
this._dbusImpl.emit_signal('Canceled', null);
|
2011-01-06 10:30:15 -05:00
|
|
|
this.close(global.get_current_time());
|
|
|
|
},
|
|
|
|
|
2011-03-21 16:12:30 -04:00
|
|
|
_confirm: function(signal) {
|
2011-01-06 10:30:15 -05:00
|
|
|
this._fadeOutDialog();
|
|
|
|
this._stopTimer();
|
2011-08-16 08:24:39 -04:00
|
|
|
this._dbusImpl.emit_signal(signal, null);
|
2011-01-06 10:30:15 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onOpened: function() {
|
|
|
|
if (this._inhibitors.length == 0)
|
|
|
|
this._startTimer();
|
|
|
|
},
|
|
|
|
|
|
|
|
_startTimer: function() {
|
|
|
|
this._secondsLeft = this._totalSecondsToStayOpen;
|
|
|
|
Tweener.addTween(this,
|
|
|
|
{ _secondsLeft: 0,
|
|
|
|
time: this._secondsLeft,
|
|
|
|
transition: 'linear',
|
2012-06-05 05:51:36 -04:00
|
|
|
onUpdate: Lang.bind(this, this._updateDescription),
|
2011-03-21 16:12:30 -04:00
|
|
|
onComplete: Lang.bind(this, function() {
|
|
|
|
let dialogContent = DialogContent[this._type];
|
|
|
|
let button = dialogContent.confirmButtons[dialogContent.confirmButtons.length - 1];
|
|
|
|
this._confirm(button.signal);
|
|
|
|
}),
|
2011-01-06 10:30:15 -05:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
_stopTimer: function() {
|
|
|
|
Tweener.removeTweens(this);
|
|
|
|
this._secondsLeft = 0;
|
|
|
|
},
|
|
|
|
|
|
|
|
_onInhibitorLoaded: function(inhibitor) {
|
|
|
|
if (this._inhibitors.indexOf(inhibitor) < 0) {
|
|
|
|
// Stale inhibitor
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
let app = findAppFromInhibitor(inhibitor);
|
|
|
|
|
|
|
|
if (app) {
|
2012-03-16 22:13:37 -04:00
|
|
|
let [reason] = inhibitor.GetReasonSync();
|
|
|
|
let item = new ListItem(app, reason);
|
2011-01-06 10:30:15 -05:00
|
|
|
item.connect('activate',
|
|
|
|
Lang.bind(this, function() {
|
|
|
|
this.close(global.get_current_time());
|
|
|
|
}));
|
|
|
|
this._applicationList.add(item.actor, { x_fill: true });
|
|
|
|
this._stopTimer();
|
|
|
|
} else {
|
|
|
|
// inhibiting app is a service, not an application
|
|
|
|
this._inhibitors.splice(this._inhibitors.indexOf(inhibitor), 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
this._updateContent();
|
|
|
|
},
|
|
|
|
|
2011-08-16 08:24:39 -04:00
|
|
|
OpenAsync: function(parameters, invocation) {
|
|
|
|
let [type, timestamp, totalSecondsToStayOpen, inhibitorObjectPaths] = parameters;
|
2011-01-06 10:30:15 -05:00
|
|
|
this._totalSecondsToStayOpen = totalSecondsToStayOpen;
|
|
|
|
this._inhibitors = [];
|
2012-02-16 13:27:09 -05:00
|
|
|
this._applicationList.destroy_all_children();
|
2011-01-06 10:30:15 -05:00
|
|
|
this._type = type;
|
|
|
|
|
2011-08-16 08:24:39 -04:00
|
|
|
if (!(this._type in DialogContent)) {
|
2012-02-28 18:45:33 -05:00
|
|
|
invocation.return_dbus_error('org.gnome.Shell.ModalDialog.TypeError',
|
2011-08-16 08:24:39 -04:00
|
|
|
"Unknown dialog type requested");
|
|
|
|
return;
|
|
|
|
}
|
2011-01-06 10:30:15 -05:00
|
|
|
|
|
|
|
for (let i = 0; i < inhibitorObjectPaths.length; i++) {
|
2011-08-16 08:24:39 -04:00
|
|
|
let inhibitor = new GnomeSession.Inhibitor(inhibitorObjectPaths[i], Lang.bind(this, function(proxy, error) {
|
|
|
|
this._onInhibitorLoaded(proxy);
|
|
|
|
}));
|
2011-01-06 10:30:15 -05:00
|
|
|
|
|
|
|
this._inhibitors.push(inhibitor);
|
|
|
|
}
|
|
|
|
|
2011-04-06 12:54:47 -04:00
|
|
|
this._updateButtons();
|
|
|
|
|
2011-08-16 08:24:39 -04:00
|
|
|
if (!this.open(timestamp)) {
|
2012-02-28 18:45:33 -05:00
|
|
|
invocation.return_dbus_error('org.gnome.Shell.ModalDialog.GrabError',
|
2011-08-16 08:24:39 -04:00
|
|
|
"Cannot grab pointer and keyboard");
|
|
|
|
return;
|
|
|
|
}
|
2011-01-06 10:30:15 -05:00
|
|
|
|
|
|
|
this._updateContent();
|
|
|
|
|
|
|
|
let signalId = this.connect('opened',
|
|
|
|
Lang.bind(this, function() {
|
2011-08-16 08:24:39 -04:00
|
|
|
invocation.return_value(null);
|
2011-01-06 10:30:15 -05:00
|
|
|
this.disconnect(signalId);
|
|
|
|
}));
|
|
|
|
}
|
2011-11-20 10:32:59 -05:00
|
|
|
});
|