[gnome-shell/wip/login-unlock-merge: 7/9] loginDialog: conditionalize out gdm specific bits



commit 09e08554a79549afdcc8a2b3ce2a58981c3825fa
Author: Ray Strode <rstrode redhat com>
Date:   Mon Jul 8 23:03:48 2013 -0400

    loginDialog: conditionalize out gdm specific bits
    
    The unlock dialog and login dialog are very similar and should probably
    be derived from a common codebase.
    
    This commit moves toward that goal by passing in the session mode to the
    login dialog constructor, and then checking if the mode is 'gdm' before
    doing login dialog specific stuff.
    
    A subsequent commit will add in unlock-dialog specific bits.

 js/gdm/loginDialog.js |  236 +++++++++++++++++++++++++++----------------------
 js/ui/screenShield.js |    2 +-
 2 files changed, 131 insertions(+), 107 deletions(-)
---
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index 8c34c7a..2e90d48 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -400,7 +400,7 @@ Signals.addSignalMethods(SessionMenuButton.prototype);
 const LoginDialog = new Lang.Class({
     Name: 'LoginDialog',
 
-    _init: function(parentActor) {
+    _init: function(parentActor, mode) {
         this.actor = new St.Widget({ accessible_role: Atk.Role.WINDOW,
                                      style_class: 'login-dialog',
                                      visible: false });
@@ -409,10 +409,12 @@ const LoginDialog = new Lang.Class({
         this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
         parentActor.add_child(this.actor);
 
+        this._mode = mode;
+
         this._userManager = AccountsService.UserManager.get_default()
         this._greeterClient = new Gdm.Client();
 
-        if (GLib.getenv('GDM_GREETER_TEST') != '1') {
+        if (this._mode == 'gdm' && GLib.getenv('GDM_GREETER_TEST') != '1') {
             this._greeter = this._greeterClient.get_greeter_sync(null);
 
             this._greeter.connect('default-session-name-changed',
@@ -433,38 +435,40 @@ const LoginDialog = new Lang.Class({
         this._userVerifier.connect('hide-login-hint', Lang.bind(this, this._hideLoginHint));
         this._verifyingUser = false;
 
-        this._settings = new Gio.Settings({ schema: GdmUtil.LOGIN_SCREEN_SCHEMA });
-
-        this._settings.connect('changed::' + GdmUtil.BANNER_MESSAGE_KEY,
-                               Lang.bind(this, this._updateBanner));
-        this._settings.connect('changed::' + GdmUtil.BANNER_MESSAGE_TEXT_KEY,
-                               Lang.bind(this, this._updateBanner));
-        this._settings.connect('changed::' + GdmUtil.DISABLE_USER_LIST_KEY,
-                               Lang.bind(this, this._updateDisableUserList));
-        this._settings.connect('changed::' + GdmUtil.LOGO_KEY,
-                               Lang.bind(this, this._updateLogo));
-
-        this._textureCache = St.TextureCache.get_default();
-        this._textureCache.connect('texture-file-changed',
-                                   Lang.bind(this, this._updateLogoTexture));
-
-        this._userSelectionBox = new St.BoxLayout({ style_class: 'login-dialog-user-selection-box',
-                                                    vertical: true });
-        this._userSelectionBox.add_constraint(new Clutter.AlignConstraint({ source: this.actor,
-                                                                            align_axis: 
Clutter.AlignAxis.BOTH,
-                                                                            factor: 0.5 }));
-        this.actor.add_child(this._userSelectionBox);
-
-        this._bannerLabel = new St.Label({ style_class: 'login-dialog-banner',
-                                           text: '' });
-        this._userSelectionBox.add(this._bannerLabel);
-        this._updateBanner();
-
-        this._userList = new UserList();
-        this._userSelectionBox.add(this._userList.actor,
-                                   { expand: true,
-                                     x_fill: true,
-                                     y_fill: true });
+        if (this._mode == 'gdm') {
+            this._settings = new Gio.Settings({ schema: GdmUtil.LOGIN_SCREEN_SCHEMA });
+
+            this._settings.connect('changed::' + GdmUtil.BANNER_MESSAGE_KEY,
+                                   Lang.bind(this, this._updateBanner));
+            this._settings.connect('changed::' + GdmUtil.BANNER_MESSAGE_TEXT_KEY,
+                                   Lang.bind(this, this._updateBanner));
+            this._settings.connect('changed::' + GdmUtil.DISABLE_USER_LIST_KEY,
+                                   Lang.bind(this, this._updateDisableUserList));
+            this._settings.connect('changed::' + GdmUtil.LOGO_KEY,
+                                   Lang.bind(this, this._updateLogo));
+
+            this._textureCache = St.TextureCache.get_default();
+            this._textureCache.connect('texture-file-changed',
+                                       Lang.bind(this, this._updateLogoTexture));
+            this._userSelectionBox = new St.BoxLayout({ style_class: 'login-dialog-user-selection-box',
+                                                        vertical: true });
+            this._userSelectionBox.add_constraint(new Clutter.AlignConstraint({ source: this.actor,
+                                                                                align_axis: 
Clutter.AlignAxis.BOTH,
+                                                                                factor: 0.5 }));
+            this.actor.add_child(this._userSelectionBox);
+
+            this._bannerLabel = new St.Label({ style_class: 'login-dialog-banner',
+                                               text: '' });
+
+            this._userSelectionBox.add(this._bannerLabel);
+            this._updateBanner();
+
+            this._userList = new UserList();
+            this._userSelectionBox.add(this._userList.actor,
+                                       { expand: true,
+                                         x_fill: true,
+                                         y_fill: true });
+        }
 
         this._promptBox = new St.BoxLayout({ style_class: 'login-dialog-prompt-layout',
                                              vertical: true });
@@ -481,8 +485,9 @@ const LoginDialog = new Lang.Class({
                                                                      factor: 0.5 }));
 
         this.actor.add_child(this._promptBox);
-        this._userList.actor.add_constraint(new Clutter.BindConstraint({ source: this._promptBox,
-                                                                         coordinate: 
Clutter.BindCoordinate.WIDTH }));
+        if (this._mode == 'gdm')
+            this._userList.actor.add_constraint(new Clutter.BindConstraint({ source: this._promptBox,
+                                                                             coordinate: 
Clutter.BindCoordinate.WIDTH }));
 
         this._promptUser = new St.Bin({ x_fill: true,
                                         x_align: St.Align.START });
@@ -527,66 +532,72 @@ const LoginDialog = new Lang.Class({
 
         this._promptBox.hide();
 
-        // translators: this message is shown below the user list on the
-        // login screen. It can be activated to reveal an entry for
-        // manually entering the username.
-        let notListedLabel = new St.Label({ text: _("Not listed?"),
-                                            style_class: 'login-dialog-not-listed-label' });
-        this._notListedButton = new St.Button({ style_class: 'login-dialog-not-listed-button',
-                                                button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
-                                                can_focus: true,
-                                                child: notListedLabel,
-                                                reactive: true,
-                                                x_align: St.Align.START,
-                                                x_fill: true });
-
-        this._notListedButton.connect('clicked', Lang.bind(this, this._hideUserListAndLogIn));
-        this._notListedButton.hide();
-
-        this._userSelectionBox.add(this._notListedButton,
-                                   { expand: false,
-                                     x_align: St.Align.START,
-                                     x_fill: true });
-
-        this._logoBin = new St.Bin({ style_class: 'login-dialog-logo-bin', y_expand: true });
-        this._logoBin.set_y_align(Clutter.ActorAlign.END);
-        this._logoBin.add_constraint(new Clutter.AlignConstraint({ source: this.actor,
-                                                                   align_axis: Clutter.AlignAxis.X_AXIS,
-                                                                   factor: 0.5 }));
-        this._logoBin.add_constraint(new Clutter.AlignConstraint({ source: this.actor,
-                                                                   align_axis: Clutter.AlignAxis.Y_AXIS,
-                                                                   factor: 1.0 }));
-        this.actor.add_child(this._logoBin);
-        this._updateLogo();
-
-        if (!this._userManager.is_loaded)
-            this._userManagerLoadedId = this._userManager.connect('notify::is-loaded',
-                                                                  Lang.bind(this, function() {
-                                                                      if (this._userManager.is_loaded) {
-                                                                          this._loadUserList();
-                                                                          
this._userManager.disconnect(this._userManagerLoadedId);
-                                                                          this._userManagerLoadedId = 0;
-                                                                      }
-                                                                  }));
-        else
-            this._loadUserList();
+        if (this._mode == 'gdm') {
+            // translators: this message is shown below the user list on the
+            // login screen. It can be activated to reveal an entry for
+            // manually entering the username.
+            let notListedLabel = new St.Label({ text: _("Not listed?"),
+                                                style_class: 'login-dialog-not-listed-label' });
+            this._notListedButton = new St.Button({ style_class: 'login-dialog-not-listed-button',
+                                                    button_mask: St.ButtonMask.ONE | St.ButtonMask.THREE,
+                                                    can_focus: true,
+                                                    child: notListedLabel,
+                                                    reactive: true,
+                                                    x_align: St.Align.START,
+                                                    x_fill: true });
+
+            this._notListedButton.connect('clicked', Lang.bind(this, this._hideUserListAndLogIn));
+            this._notListedButton.hide();
+
+            this._userSelectionBox.add(this._notListedButton,
+                                       { expand: false,
+                                         x_align: St.Align.START,
+                                         x_fill: true });
 
-        this._userList.connect('activate',
-                               Lang.bind(this, function(userList, item) {
-                                   this._onUserListActivated(item);
-                               }));
+        }
 
         this._defaultButtonWell = new St.Widget();
         this._defaultButtonWellMode = DefaultButtonWellMode.NONE;
 
-        this._sessionMenuButton = new SessionMenuButton();
-        this._sessionMenuButton.connect('session-activated',
-                                  Lang.bind(this, function(list, sessionId) {
-                                                this._greeter.call_select_session_sync (sessionId, null);
-                                            }));
-        this._sessionMenuButton.actor.opacity = 0;
-        this._sessionMenuButton.actor.show();
-        this._defaultButtonWell.add_child(this._sessionMenuButton.actor);
+
+        if (this._mode == 'gdm') {
+            this._logoBin = new St.Bin({ style_class: 'login-dialog-logo-bin', y_expand: true });
+            this._logoBin.set_y_align(Clutter.ActorAlign.END);
+            this._logoBin.add_constraint(new Clutter.AlignConstraint({ source: this.actor,
+                                                                       align_axis: Clutter.AlignAxis.X_AXIS,
+                                                                       factor: 0.5 }));
+            this._logoBin.add_constraint(new Clutter.AlignConstraint({ source: this.actor,
+                                                                       align_axis: Clutter.AlignAxis.Y_AXIS,
+                                                                       factor: 1.0 }));
+            this.actor.add_child(this._logoBin);
+            this._updateLogo();
+
+            if (!this._userManager.is_loaded)
+                this._userManagerLoadedId = this._userManager.connect('notify::is-loaded',
+                                                                      Lang.bind(this, function() {
+                                                                          if (this._userManager.is_loaded) {
+                                                                              this._loadUserList();
+                                                                              
this._userManager.disconnect(this._userManagerLoadedId);
+                                                                              this._userManagerLoadedId = 0;
+                                                                          }
+                                                                      }));
+            else
+                this._loadUserList();
+
+            this._userList.connect('activate',
+                                   Lang.bind(this, function(userList, item) {
+                                       this._onUserListActivated(item);
+                                   }));
+
+            this._sessionMenuButton = new SessionMenuButton();
+            this._sessionMenuButton.connect('session-activated',
+                                      Lang.bind(this, function(list, sessionId) {
+                                                    this._greeter.call_select_session_sync (sessionId, null);
+                                                }));
+            this._sessionMenuButton.actor.opacity = 0;
+            this._sessionMenuButton.actor.show();
+            this._defaultButtonWell.add_child(this._sessionMenuButton.actor);
+        }
 
         let spinnerIcon = global.datadir + '/theme/process-working.svg';
         this._workSpinner = new Animation.AnimatedIcon(spinnerIcon, _DEFAULT_BUTTON_WELL_ICON_SIZE);
@@ -594,9 +605,11 @@ const LoginDialog = new Lang.Class({
         this._workSpinner.actor.show();
 
         this._defaultButtonWell.add_child(this._workSpinner.actor);
-        this._sessionMenuButton.actor.add_constraint(new Clutter.AlignConstraint({ source: 
this._workSpinner.actor,
-                                                                                   align_axis: 
Clutter.AlignAxis.BOTH,
-                                                                                   factor: 0.5 }));
+        if (this._mode == 'gdm') {
+            this._sessionMenuButton.actor.add_constraint(new Clutter.AlignConstraint({ source: 
this._workSpinner.actor,
+                                                                                       align_axis: 
Clutter.AlignAxis.BOTH,
+                                                                                       factor: 0.5 }));
+        }
    },
 
     _updateDisableUserList: function() {
@@ -648,10 +661,12 @@ const LoginDialog = new Lang.Class({
         this._user = null;
         this._verifyingUser = false;
 
-        if (this._disableUserList)
-            this._hideUserListAndLogIn();
-        else
-            this._showUserList();
+        if (this._mode == 'gdm') {
+            if (this._disableUserList)
+                this._hideUserListAndLogIn();
+            else
+                this._showUserList();
+        }
     },
 
     _getActorForDefaultButtonWellMode: function(mode) {
@@ -755,6 +770,9 @@ const LoginDialog = new Lang.Class({
     },
 
     _shouldShowSessionMenuButton: function() {
+        if (this._mode != 'gdm')
+          return false;
+
         if (this._verifyingUser)
           return true;
 
@@ -772,12 +790,15 @@ const LoginDialog = new Lang.Class({
         this._promptEntry.show();
         this._promptLoginHint.opacity = 0;
         this._promptLoginHint.show();
-        this._promptBox.opacity = 0;
         this._promptBox.show();
-        Tweener.addTween(this._promptBox,
-                         { opacity: 255,
-                           time: _FADE_ANIMATION_TIME,
-                           transition: 'easeOutQuad' });
+
+        if (this._mode == 'gdm') {
+            this._promptBox.opacity = 0;
+            Tweener.addTween(this._promptBox,
+                             { opacity: 255,
+                               time: _FADE_ANIMATION_TIME,
+                               transition: 'easeOutQuad' });
+        }
 
         if (this._shouldShowSessionMenuButton())
             this._setDefaultButtonWellMode(DefaultButtonWellMode.SESSION_MENU_BUTTON, true);
@@ -863,7 +884,8 @@ const LoginDialog = new Lang.Class({
     _updateSensitivity: function(sensitive) {
         this._promptEntry.reactive = sensitive;
         this._promptEntry.clutter_text.editable = sensitive;
-        this._sessionMenuButton.updateSensitivity(sensitive);
+        if (this._mode == 'gdm')
+            this._sessionMenuButton.updateSensitivity(sensitive);
         this._updateSignInButtonSensitivity(sensitive);
     },
 
@@ -894,7 +916,8 @@ const LoginDialog = new Lang.Class({
         this._updateSensitivity(true);
         this._promptEntry.set_text('');
 
-        this._sessionMenuButton.close();
+        if (this._mode == 'gdm')
+            this._sessionMenuButton.close();
         this._promptLoginHint.opacity = 0;
 
         this._buttonBox.remove_all_children();
@@ -1221,7 +1244,8 @@ const LoginDialog = new Lang.Class({
                                         _("Login Window"),
                                         'dialog-password-symbolic',
                                         { sortGroup: CtrlAltTab.SortGroup.MIDDLE });
-        this._userList.actor.grab_key_focus();
+        if (this._mode == 'gdm')
+            this._userList.actor.grab_key_focus();
         this.actor.show();
 
         return true;
diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js
index 3588547..ec0408f 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -915,7 +915,7 @@ const ScreenShield = new Lang.Class({
                 return;
             }
 
-            this._dialog = new constructor(this._lockDialogGroup);
+            this._dialog = new constructor(this._lockDialogGroup, Main.sessionMode.currentMode);
 
 
             let time = global.get_current_time();


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