[gnome-shell/uajain/adapt-user-avatar-part2: 16/18] loginDialog: Move and relayout sessionMenuButton to bottom right



commit 31bc9061b1eeb45dfab8aa40a366cd301811e472
Author: Umang Jain <mailumangjain gmail com>
Date:   Thu Jan 16 12:13:29 2020 +0530

    loginDialog: Move and relayout sessionMenuButton to bottom right
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/922

 js/gdm/authPrompt.js  |  4 ----
 js/gdm/loginDialog.js | 64 +++++++++++++++++++++++++++++----------------------
 2 files changed, 36 insertions(+), 32 deletions(-)
---
diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js
index 99387bda05..f9c15bc693 100644
--- a/js/gdm/authPrompt.js
+++ b/js/gdm/authPrompt.js
@@ -269,10 +269,6 @@ var AuthPrompt = GObject.registerClass({
         this.reset();
     }
 
-    addActorToDefaultButtonWell(actor) {
-        this._defaultButtonWell.add_child(actor);
-    }
-
     setActorInDefaultButtonWell(actor, animate) {
         if (!this._defaultButtonWellActor &&
             !actor)
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index 68ca8d71e5..aadc748646 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -36,7 +36,6 @@ const _FADE_ANIMATION_TIME = 250;
 const _SCROLL_ANIMATION_TIME = 500;
 const _TIMED_LOGIN_IDLE_THRESHOLD = 5.0;
 const _LOGO_ICON_HEIGHT = 48;
-const _MAX_BOTTOM_MENU_ITEMS = 5;
 
 var UserListItem = GObject.registerClass({
     Signals: { 'activate': {} },
@@ -326,16 +325,7 @@ var SessionMenuButton = GObject.registerClass({
         super._init({ child: button });
         this._button = button;
 
-        let side = St.Side.TOP;
-        let align = 0;
-        if (Gdm.get_session_ids().length > _MAX_BOTTOM_MENU_ITEMS) {
-            if (this.text_direction == Clutter.TextDirection.RTL)
-                side = St.Side.RIGHT;
-            else
-                side = St.Side.LEFT;
-            align = 0.5;
-        }
-        this._menu = new PopupMenu.PopupMenu(this._button, align, side);
+        this._menu = new PopupMenu.PopupMenu(this._button, 0, St.Side.BOTTOM);
         Main.uiGroup.add_actor(this._menu.actor);
         this._menu.actor.hide();
 
@@ -360,6 +350,7 @@ var SessionMenuButton = GObject.registerClass({
     updateSensitivity(sensitive) {
         this._button.reactive = sensitive;
         this._button.can_focus = sensitive;
+        this.opacity = sensitive ? 255 : 0;
         this._menu.close(BoxPointer.PopupAnimation.NONE);
     }
 
@@ -497,6 +488,15 @@ var LoginDialog = GObject.registerClass({
         bannerBox.add_child(this._bannerLabel);
         this._updateBanner();
 
+        this._sessionMenuButton = new SessionMenuButton();
+        this._sessionMenuButton.connect('session-activated',
+            (list, sessionId) => {
+                this._greeter.call_select_session_sync(sessionId, null);
+            });
+        this._sessionMenuButton.opacity = 0;
+        this._sessionMenuButton.show();
+        this.add_child(this._sessionMenuButton);
+
         this._logoBin = new St.Widget({ style_class: 'login-dialog-logo-bin',
                                         x_align: Clutter.ActorAlign.CENTER,
                                         y_align: Clutter.ActorAlign.END });
@@ -510,16 +510,6 @@ var LoginDialog = GObject.registerClass({
             this._onUserListActivated(item);
         });
 
-
-        this._sessionMenuButton = new SessionMenuButton();
-        this._sessionMenuButton.connect('session-activated',
-            (list, sessionId) => {
-                this._greeter.call_select_session_sync(sessionId, null);
-            });
-        this._sessionMenuButton.opacity = 0;
-        this._sessionMenuButton.show();
-        this._authPrompt.addActorToDefaultButtonWell(this._sessionMenuButton);
-
         this._disableUserList = undefined;
         this._userListLoaded = false;
 
@@ -564,6 +554,19 @@ var LoginDialog = GObject.registerClass({
         return actorBox;
     }
 
+    _getSessionMenuButtonAllocation(dialogBox) {
+        let actorBox = new Clutter.ActorBox();
+
+        let [, , natWidth, natHeight] = this._sessionMenuButton.get_preferred_size();
+
+        actorBox.x1 = dialogBox.x2 - (natWidth * 2);
+        actorBox.y1 = dialogBox.y2 - (natHeight * 2);
+        actorBox.x2 = actorBox.x1 + natWidth;
+        actorBox.y2 = actorBox.y1 + natHeight;
+
+        return actorBox;
+    }
+
     _getCenterActorAllocation(dialogBox, actor) {
         let actorBox = new Clutter.ActorBox();
 
@@ -620,6 +623,10 @@ var LoginDialog = GObject.registerClass({
             logoHeight = logoAllocation.y2 - logoAllocation.y1;
         }
 
+        let sessionMenuButtonAllocation = null;
+        if (this._sessionMenuButton.visible)
+            sessionMenuButtonAllocation = this._getSessionMenuButtonAllocation(dialogBox);
+
         // Then figure out if we're overly constrained and need to
         // try a different layout, or if we have what extra space we
         // can hand out
@@ -718,6 +725,9 @@ var LoginDialog = GObject.registerClass({
 
         if (logoAllocation)
             this._logoBin.allocate(logoAllocation, flags);
+
+        if (sessionMenuButtonAllocation)
+            this._sessionMenuButton.allocate(sessionMenuButtonAllocation, flags);
     }
 
     _ensureUserListLoaded() {
@@ -813,12 +823,10 @@ var LoginDialog = GObject.registerClass({
     }
 
     _onPrompted() {
-        if (this._shouldShowSessionMenuButton()) {
-            this._sessionMenuButton.updateSensitivity(true);
-            this._authPrompt.setActorInDefaultButtonWell(this._sessionMenuButton);
-        } else {
-            this._sessionMenuButton.updateSensitivity(false);
-        }
+        const showSessionMenu = this._shouldShowSessionMenuButton();
+
+        this._sessionMenuButton.updateSensitivity(showSessionMenu);
+        this._sessionMenuButton.visible = showSessionMenu;
         this._showPrompt();
     }
 
@@ -840,7 +848,7 @@ var LoginDialog = GObject.registerClass({
 
     _onReset(authPrompt, beginRequest) {
         this._resetGreeterProxy();
-        this._sessionMenuButton.updateSensitivity(true);
+        this._sessionMenuButton.updateSensitivity(false);
 
         this._user = null;
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]