[gnome-shell/wip/message-tray-menu: 78/109] userMenu: Move UserAvatarWidget into UserWidget
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/message-tray-menu: 78/109] userMenu: Move UserAvatarWidget into UserWidget
- Date: Thu, 9 May 2013 15:42:54 +0000 (UTC)
commit 269ad7eab344a20bba46a7022623ffc7e3d70b44
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Apr 23 22:31:08 2013 -0400
userMenu: Move UserAvatarWidget into UserWidget
js/gdm/loginDialog.js | 5 +--
js/ui/components/polkitAgent.js | 6 ++--
js/ui/endSessionDialog.js | 8 +++---
js/ui/unlockDialog.js | 1 -
js/ui/userMenu.js | 50 ++------------------------------------
js/ui/userWidget.js | 50 +++++++++++++++++++++++++++++++++++++-
6 files changed, 60 insertions(+), 60 deletions(-)
---
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index 4355c1d..68a9938 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 15307f3..a159005 100644
--- a/js/ui/components/polkitAgent.js
+++ b/js/ui/components/polkitAgent.js
@@ -101,9 +101,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 d322581..fa60619 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 16fdbfa..f09a09b 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 29d6694..2a0a323 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 = <interface name='org.freedesktop.login1.Session
const SystemdLoginSession = Gio.DBusProxy.makeProxyWrapper(SystemdLoginSessionIface);
-// 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.
-
-const UserAvatarWidget = new Lang.Class({
- Name: 'UserAvatarWidget',
-
- _init: function(user, params) {
- this._user = user;
- params = Params.parse(params, { reactive: false,
- iconSize: DIALOG_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 IMStatusItem = new Lang.Class({
Name: 'IMStatusItem',
Extends: PopupMenu.PopupBaseMenuItem,
@@ -170,7 +126,7 @@ const IMStatusChooserItem = new Lang.Class({
this._userManager = AccountsService.UserManager.get_default();
this._user = this._userManager.get_user(GLib.get_user_name());
- this._avatar = new UserAvatarWidget(this._user, { reactive: true });
+ this._avatar = new UserWidget.Avatar(this._user, { reactive: true });
this._iconBin = new St.Button({ child: this._avatar.actor });
this.addActor(this._iconBin);
@@ -908,7 +864,7 @@ const UserMenuButton = new Lang.Class({
let session = sessions[i];
let userEntry = new St.BoxLayout({ style_class: 'login-dialog-user-list-item',
vertical: false });
- let avatar = new UserAvatarWidget(session.user);
+ let avatar = new UserWidget.Avatar(session.user);
avatar.update();
userEntry.add(avatar.actor);
diff --git a/js/ui/userWidget.js b/js/ui/userWidget.js
index 06de0fc..c896b58 100644
--- a/js/ui/userWidget.js
+++ b/js/ui/userWidget.js
@@ -3,10 +3,56 @@
//
// A widget showing the user avatar and name
const AccountsService = imports.gi.AccountsService;
+const GLib = imports.gi.GLib;
+const Gio = imports.gi.Gio;
const Lang = imports.lang;
const St = imports.gi.St;
-const UserMenu = imports.ui.userMenu;
+const Params = imports.misc.params;
+
+const AVATAR_ICON_SIZE = 64;
+
+// 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.
+
+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',
@@ -17,7 +63,7 @@ const UserWidget = new Lang.Class({
this.actor = new St.BoxLayout({ style_class: 'user-widget',
vertical: false });
- this._avatar = new UserMenu.UserAvatarWidget(user);
+ this._avatar = new Avatar(user);
this.actor.add(this._avatar.actor,
{ x_fill: true, y_fill: true });
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]