2009-11-10 12:13:58 -05:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
|
|
|
|
|
const Gdm = imports.gi.Gdm;
|
2011-03-09 15:59:26 -05:00
|
|
|
const DBus = imports.dbus;
|
2011-03-21 08:51:46 -04:00
|
|
|
const Gio = imports.gi.Gio;
|
2009-11-10 12:13:58 -05:00
|
|
|
const GLib = imports.gi.GLib;
|
|
|
|
const Lang = imports.lang;
|
|
|
|
const Shell = imports.gi.Shell;
|
|
|
|
const St = imports.gi.St;
|
2011-02-28 11:03:35 -05:00
|
|
|
const Tp = imports.gi.TelepathyGLib;
|
2011-02-04 18:37:54 -05:00
|
|
|
const UPowerGlib = imports.gi.UPowerGlib;
|
2009-11-10 12:13:58 -05:00
|
|
|
|
2010-04-29 13:13:20 -04:00
|
|
|
const GnomeSession = imports.misc.gnomeSession;
|
2010-06-03 19:21:08 -04:00
|
|
|
const Main = imports.ui.main;
|
2010-06-22 17:02:26 -04:00
|
|
|
const PanelMenu = imports.ui.panelMenu;
|
2010-05-20 11:18:46 -04:00
|
|
|
const PopupMenu = imports.ui.popupMenu;
|
2011-07-12 11:42:33 -04:00
|
|
|
const ScreenSaver = imports.misc.screenSaver;
|
2010-11-17 11:43:08 -05:00
|
|
|
const Util = imports.misc.util;
|
2009-11-10 12:13:58 -05:00
|
|
|
|
2011-03-21 08:51:46 -04:00
|
|
|
const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
|
|
|
|
const DISABLE_USER_SWITCH_KEY = 'disable-user-switching';
|
|
|
|
const DISABLE_LOCK_SCREEN_KEY = 'disable-lock-screen';
|
|
|
|
const DISABLE_LOG_OUT_KEY = 'disable-log-out';
|
|
|
|
|
2009-11-10 12:13:58 -05:00
|
|
|
// Adapted from gdm/gui/user-switch-applet/applet.c
|
|
|
|
//
|
|
|
|
// Copyright (C) 2004-2005 James M. Cape <jcape@ignore-your.tv>.
|
|
|
|
// Copyright (C) 2008,2009 Red Hat, Inc.
|
|
|
|
|
2010-05-10 09:46:54 -04:00
|
|
|
function StatusMenuButton() {
|
2009-11-10 12:13:58 -05:00
|
|
|
this._init();
|
|
|
|
}
|
|
|
|
|
2010-05-10 09:46:54 -04:00
|
|
|
StatusMenuButton.prototype = {
|
2010-06-22 17:02:26 -04:00
|
|
|
__proto__: PanelMenu.Button.prototype,
|
2010-05-10 09:46:54 -04:00
|
|
|
|
2009-11-10 12:13:58 -05:00
|
|
|
_init: function() {
|
2011-02-09 12:27:00 -05:00
|
|
|
PanelMenu.Button.prototype._init.call(this, 0.0);
|
2010-05-10 09:46:54 -04:00
|
|
|
let box = new St.BoxLayout({ name: 'panelStatusMenu' });
|
|
|
|
this.actor.set_child(box);
|
|
|
|
|
2011-03-21 08:51:46 -04:00
|
|
|
this._lockdownSettings = new Gio.Settings({ schema: LOCKDOWN_SCHEMA });
|
|
|
|
|
2009-11-10 12:13:58 -05:00
|
|
|
this._gdm = Gdm.UserManager.ref_default();
|
2010-11-17 11:43:08 -05:00
|
|
|
this._gdm.queue_load();
|
2010-10-07 18:22:20 -04:00
|
|
|
|
2009-11-10 12:13:58 -05:00
|
|
|
this._user = this._gdm.get_user(GLib.get_user_name());
|
2010-04-29 13:13:20 -04:00
|
|
|
this._presence = new GnomeSession.Presence();
|
2010-10-20 12:43:22 -04:00
|
|
|
this._presenceItems = {};
|
2011-03-12 15:34:01 -05:00
|
|
|
this._session = new GnomeSession.SessionManager();
|
2011-06-03 18:10:55 -04:00
|
|
|
this._haveShutdown = true;
|
2009-11-10 12:13:58 -05:00
|
|
|
|
2011-02-28 11:03:35 -05:00
|
|
|
this._account_mgr = Tp.AccountManager.dup()
|
|
|
|
|
2011-02-04 18:37:54 -05:00
|
|
|
this._upClient = new UPowerGlib.Client();
|
2011-07-12 11:42:33 -04:00
|
|
|
this._screenSaverProxy = new ScreenSaver.ScreenSaverProxy();
|
2009-11-10 12:13:58 -05:00
|
|
|
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
|
|
|
|
2009-11-10 16:34:13 -05:00
|
|
|
this._iconBox = new St.Bin();
|
2010-05-10 09:46:54 -04:00
|
|
|
box.add(this._iconBox, { y_align: St.Align.MIDDLE, y_fill: false });
|
2009-11-10 16:34:13 -05:00
|
|
|
|
2010-02-09 12:42:07 -05:00
|
|
|
let textureCache = St.TextureCache.get_default();
|
2010-11-02 18:33:22 -04:00
|
|
|
this._availableIcon = new St.Icon({ icon_name: 'user-available', style_class: 'popup-menu-icon' });
|
|
|
|
this._busyIcon = new St.Icon({ icon_name: 'user-busy', style_class: 'popup-menu-icon' });
|
|
|
|
this._invisibleIcon = new St.Icon({ icon_name: 'user-invisible', style_class: 'popup-menu-icon' });
|
|
|
|
this._idleIcon = new St.Icon({ icon_name: 'user-idle', style_class: 'popup-menu-icon' });
|
2009-11-10 16:34:13 -05:00
|
|
|
|
|
|
|
this._presence.connect('StatusChanged', Lang.bind(this, this._updatePresenceIcon));
|
|
|
|
this._presence.getStatus(Lang.bind(this, this._updatePresenceIcon));
|
|
|
|
|
2010-10-07 18:22:20 -04:00
|
|
|
this._name = new St.Label();
|
2010-05-10 09:46:54 -04:00
|
|
|
box.add(this._name, { y_align: St.Align.MIDDLE, y_fill: false });
|
2010-10-07 18:22:20 -04:00
|
|
|
this._userLoadedId = this._user.connect('notify::is-loaded', Lang.bind(this, this._updateUserName));
|
|
|
|
this._userChangedId = this._user.connect('changed', Lang.bind(this, this._updateUserName));
|
2009-11-10 12:13:58 -05:00
|
|
|
|
|
|
|
this._createSubMenu();
|
2010-10-07 18:22:20 -04:00
|
|
|
this._gdm.connect('notify::is-loaded', Lang.bind(this, this._updateSwitchUser));
|
2009-11-10 12:13:58 -05:00
|
|
|
this._gdm.connect('user-added', Lang.bind(this, this._updateSwitchUser));
|
|
|
|
this._gdm.connect('user-removed', Lang.bind(this, this._updateSwitchUser));
|
2011-03-21 08:51:46 -04: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));
|
2011-06-03 18:10:55 -04:00
|
|
|
|
2011-03-21 08:51:46 -04:00
|
|
|
this._lockdownSettings.connect('changed::' + DISABLE_LOCK_SCREEN_KEY,
|
|
|
|
Lang.bind(this, this._updateLockScreen));
|
|
|
|
this._updateSwitchUser();
|
|
|
|
this._updateLogout();
|
|
|
|
this._updateLockScreen();
|
2011-02-04 18:37:54 -05:00
|
|
|
|
2011-06-03 18:10:55 -04: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) {
|
|
|
|
if (open)
|
|
|
|
this._updateHaveShutdown();
|
|
|
|
}));
|
|
|
|
this._lockdownSettings.connect('changed::' + DISABLE_LOG_OUT_KEY,
|
|
|
|
Lang.bind(this, this._updateHaveShutdown));
|
|
|
|
|
2011-02-04 18:37:54 -05:00
|
|
|
this._upClient.connect('notify::can-suspend', Lang.bind(this, this._updateSuspendOrPowerOff));
|
2009-11-10 12:13:58 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onDestroy: function() {
|
2010-10-07 18:22:20 -04:00
|
|
|
this._user.disconnect(this._userLoadedId);
|
|
|
|
this._user.disconnect(this._userChangedId);
|
2009-11-10 12:13:58 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_updateUserName: function() {
|
2010-10-07 18:22:20 -04:00
|
|
|
if (this._user.is_loaded)
|
|
|
|
this._name.set_text(this._user.get_real_name());
|
|
|
|
else
|
|
|
|
this._name.set_text("");
|
2009-11-10 12:13:58 -05:00
|
|
|
},
|
|
|
|
|
2011-03-21 08:51:46 -04:00
|
|
|
_updateSessionSeparator: function() {
|
2011-06-03 18:10:55 -04:00
|
|
|
let sessionItemsVisible = this._loginScreenItem.actor.visible ||
|
|
|
|
this._logoutItem.actor.visible ||
|
|
|
|
this._lockScreenItem.actor.visible;
|
|
|
|
|
|
|
|
let showSessionSeparator = sessionItemsVisible &&
|
|
|
|
this._suspendOrPowerOffItem.actor.visible;
|
|
|
|
|
|
|
|
let showSettingsSeparator = sessionItemsVisible ||
|
|
|
|
this._suspendOrPowerOffItem.actor.visible;
|
|
|
|
|
|
|
|
if (showSessionSeparator)
|
2011-03-21 08:51:46 -04:00
|
|
|
this._sessionSeparator.actor.show();
|
|
|
|
else
|
|
|
|
this._sessionSeparator.actor.hide();
|
2011-06-03 18:10:55 -04:00
|
|
|
|
|
|
|
if (showSettingsSeparator)
|
|
|
|
this._settingsSeparator.actor.show();
|
|
|
|
else
|
|
|
|
this._settingsSeparator.actor.hide();
|
2011-03-21 08:51:46 -04:00
|
|
|
},
|
|
|
|
|
2009-11-10 12:13:58 -05:00
|
|
|
_updateSwitchUser: function() {
|
2011-03-21 08:51:46 -04:00
|
|
|
let allowSwitch = !this._lockdownSettings.get_boolean(DISABLE_USER_SWITCH_KEY);
|
|
|
|
if (allowSwitch && this._gdm.can_switch ())
|
2010-05-10 09:46:54 -04:00
|
|
|
this._loginScreenItem.actor.show();
|
2009-11-10 12:13:58 -05:00
|
|
|
else
|
2010-05-10 09:46:54 -04:00
|
|
|
this._loginScreenItem.actor.hide();
|
2011-03-21 08:51:46 -04:00
|
|
|
this._updateSessionSeparator();
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateLogout: function() {
|
|
|
|
let allowLogout = !this._lockdownSettings.get_boolean(DISABLE_LOG_OUT_KEY);
|
|
|
|
if (allowLogout)
|
|
|
|
this._logoutItem.actor.show();
|
|
|
|
else
|
|
|
|
this._logoutItem.actor.hide();
|
|
|
|
this._updateSessionSeparator();
|
|
|
|
},
|
|
|
|
|
|
|
|
_updateLockScreen: function() {
|
|
|
|
let allowLockScreen = !this._lockdownSettings.get_boolean(DISABLE_LOCK_SCREEN_KEY);
|
|
|
|
if (allowLockScreen)
|
|
|
|
this._lockScreenItem.actor.show();
|
|
|
|
else
|
|
|
|
this._lockScreenItem.actor.hide();
|
|
|
|
this._updateSessionSeparator();
|
2009-11-10 12:13:58 -05:00
|
|
|
},
|
|
|
|
|
2011-06-03 18:10:55 -04:00
|
|
|
_updateHaveShutdown: function() {
|
|
|
|
this._session.CanShutdownRemote(Lang.bind(this,
|
|
|
|
function(result, error) {
|
|
|
|
if (!error) {
|
|
|
|
this._haveShutdown = result;
|
|
|
|
this._updateSuspendOrPowerOff();
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
},
|
|
|
|
|
2011-02-04 18:37:54 -05:00
|
|
|
_updateSuspendOrPowerOff: function() {
|
|
|
|
this._haveSuspend = this._upClient.get_can_suspend();
|
|
|
|
|
|
|
|
if (!this._suspendOrPowerOffItem)
|
|
|
|
return;
|
|
|
|
|
2011-06-03 18:10:55 -04:00
|
|
|
if (!this._haveShutdown && !this._haveSuspend)
|
|
|
|
this._suspendOrPowerOffItem.actor.hide();
|
|
|
|
else
|
|
|
|
this._suspendOrPowerOffItem.actor.show();
|
|
|
|
this._updateSessionSeparator();
|
|
|
|
|
2011-02-04 18:37:54 -05:00
|
|
|
// If we can't suspend show Power Off... instead
|
|
|
|
// and disable the alt key
|
|
|
|
if (!this._haveSuspend) {
|
|
|
|
this._suspendOrPowerOffItem.updateText(_("Power Off..."), null);
|
2011-06-03 18:10:55 -04:00
|
|
|
} else if (!this._haveShutdown) {
|
|
|
|
this._suspendOrPowerOffItem.updateText(_("Suspend"), null);
|
2011-02-04 18:37:54 -05:00
|
|
|
} else {
|
2011-03-24 14:11:20 -04:00
|
|
|
this._suspendOrPowerOffItem.updateText(_("Suspend"), _("Power Off..."));
|
2011-02-04 18:37:54 -05:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2009-11-10 16:34:13 -05:00
|
|
|
_updatePresenceIcon: function(presence, status) {
|
2010-04-29 13:13:20 -04:00
|
|
|
if (status == GnomeSession.PresenceStatus.AVAILABLE)
|
2009-11-10 16:34:13 -05:00
|
|
|
this._iconBox.child = this._availableIcon;
|
2010-04-29 13:13:20 -04:00
|
|
|
else if (status == GnomeSession.PresenceStatus.BUSY)
|
2009-11-10 16:34:13 -05:00
|
|
|
this._iconBox.child = this._busyIcon;
|
2010-04-29 13:13:20 -04:00
|
|
|
else if (status == GnomeSession.PresenceStatus.INVISIBLE)
|
2009-11-10 16:34:13 -05:00
|
|
|
this._iconBox.child = this._invisibleIcon;
|
|
|
|
else
|
|
|
|
this._iconBox.child = this._idleIcon;
|
2010-10-20 12:43:22 -04:00
|
|
|
|
|
|
|
for (let itemStatus in this._presenceItems)
|
|
|
|
this._presenceItems[itemStatus].setShowDot(itemStatus == status);
|
2009-11-10 16:34:13 -05:00
|
|
|
},
|
|
|
|
|
2009-11-10 12:13:58 -05:00
|
|
|
_createSubMenu: function() {
|
|
|
|
let item;
|
|
|
|
|
2011-01-25 16:06:40 -05:00
|
|
|
item = new PopupMenu.PopupImageMenuItem(_("Available"), 'user-available');
|
2010-04-29 13:13:20 -04:00
|
|
|
item.connect('activate', Lang.bind(this, this._setPresenceStatus, GnomeSession.PresenceStatus.AVAILABLE));
|
2010-05-10 09:46:54 -04:00
|
|
|
this.menu.addMenuItem(item);
|
2010-10-20 12:43:22 -04:00
|
|
|
this._presenceItems[GnomeSession.PresenceStatus.AVAILABLE] = item;
|
2009-11-10 16:34:13 -05:00
|
|
|
|
2011-01-25 16:06:40 -05:00
|
|
|
item = new PopupMenu.PopupImageMenuItem(_("Busy"), 'user-busy');
|
2010-04-29 13:13:20 -04:00
|
|
|
item.connect('activate', Lang.bind(this, this._setPresenceStatus, GnomeSession.PresenceStatus.BUSY));
|
2010-05-10 09:46:54 -04:00
|
|
|
this.menu.addMenuItem(item);
|
2010-10-20 12:43:22 -04:00
|
|
|
this._presenceItems[GnomeSession.PresenceStatus.BUSY] = item;
|
2009-11-10 16:34:13 -05:00
|
|
|
|
2010-05-20 11:18:46 -04:00
|
|
|
item = new PopupMenu.PopupSeparatorMenuItem();
|
2010-05-10 09:46:54 -04:00
|
|
|
this.menu.addMenuItem(item);
|
2009-11-10 16:34:13 -05:00
|
|
|
|
2010-11-22 15:19:37 -05:00
|
|
|
item = new PopupMenu.PopupMenuItem(_("My Account"));
|
2010-10-19 12:04:58 -04:00
|
|
|
item.connect('activate', Lang.bind(this, this._onMyAccountActivate));
|
2010-05-10 09:46:54 -04:00
|
|
|
this.menu.addMenuItem(item);
|
2009-11-10 12:13:58 -05:00
|
|
|
|
2010-11-22 15:19:37 -05:00
|
|
|
item = new PopupMenu.PopupMenuItem(_("System Settings"));
|
2009-11-10 12:13:58 -05:00
|
|
|
item.connect('activate', Lang.bind(this, this._onPreferencesActivate));
|
2010-05-10 09:46:54 -04:00
|
|
|
this.menu.addMenuItem(item);
|
2009-11-10 12:13:58 -05:00
|
|
|
|
2010-05-20 11:18:46 -04:00
|
|
|
item = new PopupMenu.PopupSeparatorMenuItem();
|
2010-05-10 09:46:54 -04:00
|
|
|
this.menu.addMenuItem(item);
|
2011-06-03 18:10:55 -04:00
|
|
|
this._settingsSeparator = item;
|
2009-11-10 12:13:58 -05:00
|
|
|
|
2010-10-19 11:59:23 -04:00
|
|
|
item = new PopupMenu.PopupMenuItem(_("Lock Screen"));
|
2009-11-10 12:13:58 -05:00
|
|
|
item.connect('activate', Lang.bind(this, this._onLockScreenActivate));
|
2010-05-10 09:46:54 -04:00
|
|
|
this.menu.addMenuItem(item);
|
2011-03-21 08:51:46 -04:00
|
|
|
this._lockScreenItem = item;
|
2009-11-10 12:13:58 -05:00
|
|
|
|
2010-10-19 11:59:23 -04:00
|
|
|
item = new PopupMenu.PopupMenuItem(_("Switch User"));
|
2009-11-10 12:13:58 -05:00
|
|
|
item.connect('activate', Lang.bind(this, this._onLoginScreenActivate));
|
2010-05-10 09:46:54 -04:00
|
|
|
this.menu.addMenuItem(item);
|
2009-11-10 12:13:58 -05:00
|
|
|
this._loginScreenItem = item;
|
|
|
|
|
2010-10-19 11:59:23 -04:00
|
|
|
item = new PopupMenu.PopupMenuItem(_("Log Out..."));
|
2009-11-10 12:13:58 -05:00
|
|
|
item.connect('activate', Lang.bind(this, this._onQuitSessionActivate));
|
2010-05-10 09:46:54 -04:00
|
|
|
this.menu.addMenuItem(item);
|
2011-03-21 08:51:46 -04:00
|
|
|
this._logoutItem = item;
|
2009-11-10 12:13:58 -05:00
|
|
|
|
2010-10-19 12:04:58 -04:00
|
|
|
item = new PopupMenu.PopupSeparatorMenuItem();
|
|
|
|
this.menu.addMenuItem(item);
|
2011-03-21 08:51:46 -04:00
|
|
|
this._sessionSeparator = item;
|
2010-10-19 12:04:58 -04:00
|
|
|
|
2011-02-04 18:37:54 -05:00
|
|
|
item = new PopupMenu.PopupAlternatingMenuItem(_("Suspend"),
|
|
|
|
_("Power Off..."));
|
2010-05-10 09:46:54 -04:00
|
|
|
this.menu.addMenuItem(item);
|
2011-02-04 18:37:54 -05:00
|
|
|
this._suspendOrPowerOffItem = item;
|
|
|
|
item.connect('activate', Lang.bind(this, this._onSuspendOrPowerOffActivate));
|
|
|
|
this._updateSuspendOrPowerOff();
|
2009-11-10 12:13:58 -05:00
|
|
|
},
|
|
|
|
|
2010-05-11 14:20:01 -04:00
|
|
|
_setPresenceStatus: function(item, event, status) {
|
2009-11-10 16:34:13 -05:00
|
|
|
this._presence.setStatus(status);
|
2011-02-28 11:03:35 -05:00
|
|
|
|
|
|
|
this._setIMStatus(status);
|
2009-11-10 16:34:13 -05:00
|
|
|
},
|
|
|
|
|
2010-10-19 12:04:58 -04:00
|
|
|
_onMyAccountActivate: function() {
|
2010-06-03 19:21:08 -04:00
|
|
|
Main.overview.hide();
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
let app = Shell.AppSystem.get_default().lookup_setting('gnome-user-accounts-panel.desktop');
|
2011-03-10 12:19:10 -05:00
|
|
|
app.activate(-1);
|
2009-11-10 12:13:58 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onPreferencesActivate: function() {
|
2010-06-03 19:21:08 -04:00
|
|
|
Main.overview.hide();
|
Kill off ShellAppInfo, move into ShellApp
This dramatically thins down and sanitizes the application code.
The ShellAppSystem changes in a number of ways:
* Preferences are special cased more explicitly; they aren't apps,
they're shortcuts for an app), and we don't have many of them, so
don't need e.g. the optimizations in ShellAppSystem for searching.
* get_app() changes to lookup_app() and returns null if an app isn't
found. The semantics where it tried to find the .desktop file
if we didn't know about it were just broken; I am pretty sure no
caller needs this, and if they do we'll fix them.
* ShellAppSystem maintains two indexes on apps (by desktop file id
and by GMenuTreeEntry), but is no longer in the business of
dealing with GMenuTree as far as hierarchy and categories go. That
is moved up into js/ui/appDisplay.js. Actually, it flattens both
apps and settings.
Also, ShellWindowTracker is now the sole reference-owner for
window-backed apps. We still do the weird "window:0x1234beef" id
for these apps, but a reference is not stored in ShellAppSystem.
The js/ui/appDisplay.js code is rewritten, and sucks a lot less.
Variable names are clearer:
_apps -> _appIcons
_filterApp -> _visibleApps
_filters -> _categoryBox
Similarly for function names. We no longer call (for every app) a
recursive lookup in GMenuTree to see if it's in a particular section
on every category switch; it's all cached.
NOTE - this intentionally reverts the incremental loading code from
commit 7813c5b93f6bcde8c4beae286e82bfc472b2b656. It's fast enough
here without that.
https://bugzilla.gnome.org/show_bug.cgi?id=648149
2011-04-21 13:35:01 -04:00
|
|
|
let app = Shell.AppSystem.get_default().lookup_app('gnome-control-center.desktop');
|
2011-03-10 12:19:10 -05:00
|
|
|
app.activate(-1);
|
2009-11-10 12:13:58 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onLockScreenActivate: function() {
|
2010-06-03 19:21:08 -04:00
|
|
|
Main.overview.hide();
|
2011-03-09 15:59:26 -05:00
|
|
|
this._screenSaverProxy.LockRemote();
|
2009-11-10 12:13:58 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onLoginScreenActivate: function() {
|
2010-06-03 19:21:08 -04:00
|
|
|
Main.overview.hide();
|
2011-07-05 09:29:05 -04:00
|
|
|
// Ensure we only move to GDM after the screensaver has activated; in some
|
|
|
|
// OS configurations, the X server may block event processing on VT switch
|
2011-07-13 17:43:23 -04:00
|
|
|
this._screenSaverProxy.SetActiveRemote(true, Lang.bind(this, function() {
|
2011-07-05 09:29:05 -04:00
|
|
|
this._gdm.goto_login_session();
|
|
|
|
}));
|
2009-11-10 12:13:58 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_onQuitSessionActivate: function() {
|
2010-06-03 19:21:08 -04:00
|
|
|
Main.overview.hide();
|
2011-03-12 15:34:01 -05:00
|
|
|
this._session.LogoutRemote(0);
|
2009-11-10 12:13:58 -05:00
|
|
|
},
|
|
|
|
|
2011-02-04 18:37:54 -05:00
|
|
|
_onSuspendOrPowerOffActivate: function() {
|
2010-06-03 19:21:08 -04:00
|
|
|
Main.overview.hide();
|
2011-02-04 18:37:54 -05:00
|
|
|
|
|
|
|
if (this._haveSuspend &&
|
|
|
|
this._suspendOrPowerOffItem.state == PopupMenu.PopupAlternatingMenuItemState.DEFAULT) {
|
2011-07-05 09:29:05 -04:00
|
|
|
// Ensure we only suspend after the screensaver has activated
|
2011-06-10 16:58:54 -04:00
|
|
|
this._screenSaverProxy.SetActiveRemote(true, Lang.bind(this, function() {
|
2011-03-09 15:59:50 -05:00
|
|
|
this._upClient.suspend_sync(null);
|
|
|
|
}));
|
2011-02-04 18:37:54 -05:00
|
|
|
} else {
|
2011-03-12 15:34:01 -05:00
|
|
|
this._session.ShutdownRemote();
|
2011-02-04 18:37:54 -05:00
|
|
|
}
|
2011-02-28 11:03:35 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
_setIMStatus: function(session_status) {
|
|
|
|
let [presence_type, presence_status, msg] = this._account_mgr.get_most_available_presence();
|
|
|
|
let type, status;
|
|
|
|
|
|
|
|
// We change the IM presence only if there are connected accounts
|
|
|
|
if (presence_type == Tp.ConnectionPresenceType.UNSET ||
|
|
|
|
presence_type == Tp.ConnectionPresenceType.OFFLINE ||
|
|
|
|
presence_type == Tp.ConnectionPresenceType.UNKNOWN ||
|
|
|
|
presence_type == Tp.ConnectionPresenceType.ERROR)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (session_status == GnomeSession.PresenceStatus.AVAILABLE) {
|
|
|
|
type = Tp.ConnectionPresenceType.AVAILABLE;
|
|
|
|
status = "available";
|
|
|
|
}
|
|
|
|
else if (session_status == GnomeSession.PresenceStatus.BUSY) {
|
|
|
|
type = Tp.ConnectionPresenceType.BUSY;
|
|
|
|
status = "busy";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._account_mgr.set_all_requested_presences(type, status, msg);
|
2009-11-10 12:13:58 -05:00
|
|
|
}
|
|
|
|
};
|