[gnome-shell/wip/lockdown-show-password: 3/4] shellEntry: Handle password item from dedication function



commit 62fd2d2ca12500f31ad4a9550758c96987de7044
Author: Ray Strode <rstrode redhat com>
Date:   Wed Aug 21 15:06:46 2019 -0400

    shellEntry: Handle password item from dedication function
    
    At the moment, shellEntry handles creating and destroying its
    "Show Text" password menu item directly from its isPassword
    setter function.
    
    This commit moves that handling to a dedicated _resetPasswordItem
    function, as prep work for adding lockdown support of the "Show Text"
    menu item.

 js/ui/shellEntry.js | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)
---
diff --git a/js/ui/shellEntry.js b/js/ui/shellEntry.js
index e01a53e409..653b581dc4 100644
--- a/js/ui/shellEntry.js
+++ b/js/ui/shellEntry.js
@@ -41,6 +41,19 @@ var EntryMenu = class extends PopupMenu.PopupMenu {
         this._updatePasswordItem();
     }
 
+    _resetPasswordItem() {
+        if (!this.isPassword) {
+            if (this._passwordItem) {
+                this._passwordItem.destroy();
+                this._passwordItem = null;
+            }
+            this._entry.clutter_text.set_password_char('\u25cf');
+        } else {
+            if (!this._passwordItem)
+                this._makePasswordItem();
+        }
+    }
+
     get isPassword() {
         return this._entry.input_purpose == Clutter.InputContentPurpose.PASSWORD;
     }
@@ -49,14 +62,12 @@ var EntryMenu = class extends PopupMenu.PopupMenu {
         if (v == this.isPassword)
             return;
 
-        if (v) {
-            this._makePasswordItem();
+        if (v)
             this._entry.input_purpose = Clutter.InputContentPurpose.PASSWORD;
-        } else {
-            this._passwordItem.destroy();
-            this._passwordItem = null;
+        else
             this._entry.input_purpose = Clutter.InputContentPurpose.NORMAL;
-        }
+
+        this._resetPasswordItem();
     }
 
     open(animate) {


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