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



commit e9f838b6db04ee65c86a0fbb69e7a893d00e0b4d
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 7b5b803bd9..c5450f4804 100644
--- a/js/gdm/authPrompt.js
+++ b/js/gdm/authPrompt.js
@@ -277,10 +277,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 75d2361e27..5e5107cfe5 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': {} },
@@ -323,16 +322,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();
 
@@ -357,6 +347,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);
     }
 
@@ -494,6 +485,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 });
@@ -507,16 +507,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;
 
@@ -561,6 +551,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();
 
@@ -617,6 +620,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
@@ -715,6 +722,9 @@ var LoginDialog = GObject.registerClass({
 
         if (logoAllocation)
             this._logoBin.allocate(logoAllocation, flags);
+
+        if (sessionMenuButtonAllocation)
+            this._sessionMenuButton.allocate(sessionMenuButtonAllocation, flags);
     }
 
     _ensureUserListLoaded() {
@@ -810,12 +820,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();
     }
 
@@ -837,7 +845,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]