[gnome-shell/wip/rstrode/list-extension: 2/2] wip! gdmUtil: start to hook up choice list interface



commit d537988a28e7ccbf9f95dd46f94507ab12bfe7e3
Author: Ray Strode <rstrode redhat com>
Date:   Mon Jul 17 16:48:03 2017 -0400

    wip! gdmUtil: start to hook up choice list interface

 js/gdm/authPrompt.js |   42 ++++++++++++++++++++++++++++++++++++++++++
 js/gdm/util.js       |   16 ++++++++++++++++
 2 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/js/gdm/authPrompt.js b/js/gdm/authPrompt.js
index 4b2509a..434a87e 100644
--- a/js/gdm/authPrompt.js
+++ b/js/gdm/authPrompt.js
@@ -8,6 +8,7 @@ const Signals = imports.signals;
 const St = imports.gi.St;
 
 const Animation = imports.ui.animation;
+const AuthList = imports.gdm.authList;
 const Batch = imports.gdm.batch;
 const GdmUtil = imports.gdm.util;
 const Params = imports.misc.params;
@@ -57,6 +58,7 @@ const AuthPrompt = new Lang.Class({
 
         this._userVerifier.connect('ask-question', Lang.bind(this, this._onAskQuestion));
         this._userVerifier.connect('show-message', Lang.bind(this, this._onShowMessage));
+        this._userVerifier.connect('show-choice-list', Lang.bind(this, this._onShowChoiceList));
         this._userVerifier.connect('verification-failed', Lang.bind(this, this._onVerificationFailed));
         this._userVerifier.connect('verification-complete', Lang.bind(this, this._onVerificationComplete));
         this._userVerifier.connect('reset', Lang.bind(this, this._onReset));
@@ -117,6 +119,14 @@ const AuthPrompt = new Lang.Class({
         this._message.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
         this.actor.add(this._message, { x_fill: false, x_align: St.Align.START, y_align: St.Align.START });
 
+        this._authList = new AuthList.AuthList();
+        this._authList.actor.hide();
+        this.actor.add(this._authList.actor,
+                       { expand: true,
+                         x_fill: true,
+                         y_fill: false,
+                         x_align: St.Align.START });
+
         this._buttonBox = new St.BoxLayout({ style_class: 'login-dialog-button-box',
                                              vertical: false });
         this.actor.add(this._buttonBox,
@@ -222,6 +232,21 @@ const AuthPrompt = new Lang.Class({
         this.emit('prompted');
     },
 
+    _onShowChoiceList: function(userVerifier, serviceName, choiceList) {
+        if (this._queryingService)
+            this.clear();
+
+        this._queryingService = serviceName;
+
+        if (this._preemptiveAnswer)
+            this._preemptiveAnswer = null;
+
+        this.nextButton.label = _("Next");
+        this.setChoiceList(choiceList);
+        this.updateSensitivity(true);
+        this.emit('prompted');
+    },
+
     _onOVirtUserAuthenticated: function() {
         if (this.verificationStatus != AuthPromptStatus.VERIFICATION_SUCCEEDED)
             this.reset();
@@ -360,12 +385,29 @@ const AuthPrompt = new Lang.Class({
     setQuestion: function(question) {
         this._label.set_text(question);
 
+        this._authList.actor.hide();
         this._label.show();
         this._entry.show();
 
         this._entry.grab_key_focus();
     },
 
+    setChoiceList: function(choiceList) {
+        this._label.hide();
+        this._entry.hide();
+
+        this._authList.clear();
+        for (let key in choiceList) {
+            let text = choiceList[key];
+            this._authList.addItem(key, text);
+        }
+        this._authList.actor.show();
+
+        this._authList.connect('activate', (list, key) => {
+            this._userVerifier.selectChoice(this._queryingService, key);
+        });
+    },
+
     getAnswer: function() {
         let text;
 
diff --git a/js/gdm/util.js b/js/gdm/util.js
index 667bbf1..5c48911 100644
--- a/js/gdm/util.js
+++ b/js/gdm/util.js
@@ -226,6 +226,10 @@ const ShellUserVerifier = new Lang.Class({
         this._oVirtCredentialsManager = null;
     },
 
+    selectChoice: function(serviceName, key) {
+        this._userVerifierChoiceList.call_select_choice(serviceName, key, this._cancellable, null);
+    },
+
     answerQuery: function(serviceName, answer) {
         if (!this.hasPendingMessages) {
             this._userVerifier.call_answer_query(serviceName, answer, this._cancellable, null);
@@ -382,6 +386,8 @@ const ShellUserVerifier = new Lang.Class({
             return;
         }
 
+        this._userVerifierChoiceList = client.get_user_verifier_choice_list();
+
         this._connectSignals();
         this._beginVerification();
         this._hold.release();
@@ -395,6 +401,9 @@ const ShellUserVerifier = new Lang.Class({
         this._userVerifier.connect('conversation-stopped', Lang.bind(this, this._onConversationStopped));
         this._userVerifier.connect('reset', Lang.bind(this, this._onReset));
         this._userVerifier.connect('verification-complete', Lang.bind(this, this._onVerificationComplete));
+
+        if (this._userVerifierChoiceList)
+            this._userVerifierChoiceList.connect('choice-query', Lang.bind(this, this._onChoiceListQuery));
     },
 
     _getForegroundService: function() {
@@ -464,6 +473,13 @@ const ShellUserVerifier = new Lang.Class({
             this._startService(FINGERPRINT_SERVICE_NAME);
     },
 
+    _onChoiceListQuery: function(client, serviceName, list) {
+        if (!this.serviceIsForeground(serviceName))
+            return;
+
+        this.emit('show-choice-list', serviceName, list.deep_unpack());
+    },
+
     _onInfo: function(client, serviceName, info) {
         if (this.serviceIsForeground(serviceName)) {
             this._queueMessage(info, MessageType.INFO);


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