diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js index 4355c1d3e..68a9938bf 100644 --- a/js/gdm/loginDialog.js +++ b/js/gdm/loginDialog.js @@ -42,7 +42,6 @@ const Main = imports.ui.main; const ModalDialog = imports.ui.modalDialog; const PanelMenu = imports.ui.panelMenu; const Tweener = imports.ui.tweener; -const UserMenu = imports.ui.userMenu; const UserWidget = imports.ui.userWidget; const _FADE_ANIMATION_TIME = 0.25; @@ -69,8 +68,8 @@ const UserListItem = new Lang.Class({ x_align: St.Align.START, x_fill: true }); - this._userAvatar = new UserMenu.UserAvatarWidget(this.user, - { styleClass: 'login-dialog-user-list-item-icon' }); + this._userAvatar = new UserWidget.Avatar(this.user, + { styleClass: 'login-dialog-user-list-item-icon' }); layout.add(this._userAvatar.actor); let textLayout = new St.BoxLayout({ style_class: 'login-dialog-user-list-item-text-box', vertical: true }); diff --git a/js/ui/components/polkitAgent.js b/js/ui/components/polkitAgent.js index 20e8b2a50..87a490f0b 100644 --- a/js/ui/components/polkitAgent.js +++ b/js/ui/components/polkitAgent.js @@ -16,7 +16,7 @@ const PolkitAgent = imports.gi.PolkitAgent; const Components = imports.ui.components; const ModalDialog = imports.ui.modalDialog; const ShellEntry = imports.ui.shellEntry; -const UserMenu = imports.ui.userMenu; +const UserWidget = imports.ui.userWidget; const DIALOG_ICON_SIZE = 48; @@ -100,9 +100,9 @@ const AuthenticationDialog = new Lang.Class({ let userBox = new St.BoxLayout({ style_class: 'polkit-dialog-user-layout', vertical: false }); messageBox.add(userBox); - this._userAvatar = new UserMenu.UserAvatarWidget(this._user, - { iconSize: DIALOG_ICON_SIZE, - styleClass: 'polkit-dialog-user-icon' }); + this._userAvatar = new UserWidget.Avatar(this._user, + { iconSize: DIALOG_ICON_SIZE, + styleClass: 'polkit-dialog-user-icon' }); this._userAvatar.actor.hide(); userBox.add(this._userAvatar.actor, { x_fill: true, diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js index d3225819a..fa606193f 100644 --- a/js/ui/endSessionDialog.js +++ b/js/ui/endSessionDialog.js @@ -35,7 +35,7 @@ const GnomeSession = imports.misc.gnomeSession; const Main = imports.ui.main; const ModalDialog = imports.ui.modalDialog; const Tweener = imports.ui.tweener; -const UserMenu = imports.ui.userMenu; +const UserWidget = imports.ui.userWidget; let _endSessionDialog = null; @@ -360,9 +360,9 @@ const EndSessionDialog = new Lang.Class({ icon_size: _DIALOG_ICON_SIZE, style_class: dialogContent.iconStyleClass }); } else { - let avatarWidget = new UserMenu.UserAvatarWidget(this._user, - { iconSize: _DIALOG_ICON_SIZE, - styleClass: dialogContent.iconStyleClass }); + let avatarWidget = new UserWidget.Avatar(this._user, + { iconSize: _DIALOG_ICON_SIZE, + styleClass: dialogContent.iconStyleClass }); this._iconBin.child = avatarWidget.actor; avatarWidget.update(); } diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js index 16fdbfa96..f09a09b05 100644 --- a/js/ui/unlockDialog.js +++ b/js/ui/unlockDialog.js @@ -17,7 +17,6 @@ const ModalDialog = imports.ui.modalDialog; const Panel = imports.ui.panel; const ShellEntry = imports.ui.shellEntry; const Tweener = imports.ui.tweener; -const UserMenu = imports.ui.userMenu; const UserWidget = imports.ui.userWidget; const Batch = imports.gdm.batch; diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js index 29d669448..2a0a32345 100644 --- a/js/ui/userMenu.js +++ b/js/ui/userMenu.js @@ -20,8 +20,8 @@ const Main = imports.ui.main; const ModalDialog = imports.ui.modalDialog; const PanelMenu = imports.ui.panelMenu; const PopupMenu = imports.ui.popupMenu; -const Params = imports.misc.params; const Util = imports.misc.util; +const UserWidget = imports.ui.userWidget; const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown'; const SCREENSAVER_SCHEMA = 'org.gnome.desktop.screensaver'; @@ -32,8 +32,6 @@ const DISABLE_LOG_OUT_KEY = 'disable-log-out'; const ALWAYS_SHOW_LOG_OUT_KEY = 'always-show-log-out'; const SHOW_FULL_NAME_IN_TOP_BAR_KEY = 'show-full-name-in-top-bar'; -const DIALOG_ICON_SIZE = 64; - const MAX_USERS_IN_SESSION_DIALOG = 5; const IMStatus = { @@ -57,48 +55,6 @@ const SystemdLoginSessionIface = . +// Copyright (C) 2008,2009 Red Hat, Inc. + +const Avatar = new Lang.Class({ + Name: 'Avatar', + + _init: function(user, params) { + this._user = user; + params = Params.parse(params, { reactive: false, + iconSize: AVATAR_ICON_SIZE, + styleClass: 'status-chooser-user-icon' }); + this._iconSize = params.iconSize; + + this.actor = new St.Bin({ style_class: params.styleClass, + track_hover: params.reactive, + reactive: params.reactive }); + }, + + setSensitive: function(sensitive) { + this.actor.can_focus = sensitive; + this.actor.reactive = sensitive; + }, + + update: function() { + let iconFile = this._user.get_icon_file(); + if (iconFile && !GLib.file_test(iconFile, GLib.FileTest.EXISTS)) + iconFile = null; + + if (iconFile) { + let file = Gio.File.new_for_path(iconFile); + this.actor.child = null; + this.actor.style = 'background-image: url("%s");'.format(iconFile); + } else { + this.actor.style = null; + this.actor.child = new St.Icon({ icon_name: 'avatar-default-symbolic', + icon_size: this._iconSize }); + } + } +}); const UserWidget = new Lang.Class({ Name: 'UserWidget', @@ -18,7 +64,7 @@ const UserWidget = new Lang.Class({ vertical: false }); this.actor.connect('destroy', Lang.bind(this, this._onDestroy)); - this._avatar = new UserMenu.UserAvatarWidget(user); + this._avatar = new Avatar(user); this.actor.add(this._avatar.actor, { x_fill: true, y_fill: true });