120 lines
3.6 KiB
Diff
120 lines
3.6 KiB
Diff
|
From 39cf97176e2a92506081ee151ea546e2c6cf213a Mon Sep 17 00:00:00 2001
|
||
|
From: Ray Strode <rstrode@redhat.com>
|
||
|
Date: Wed, 21 Aug 2019 15:06:46 -0400
|
||
|
Subject: [PATCH 3/4] 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.
|
||
|
|
||
|
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/687
|
||
|
---
|
||
|
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 603a9c64a..765cede06 100644
|
||
|
--- a/js/ui/shellEntry.js
|
||
|
+++ b/js/ui/shellEntry.js
|
||
|
@@ -14,76 +14,87 @@ var EntryMenu = class extends PopupMenu.PopupMenu {
|
||
|
|
||
|
this._entry = entry;
|
||
|
this._clipboard = St.Clipboard.get_default();
|
||
|
|
||
|
// Populate menu
|
||
|
let item;
|
||
|
item = new PopupMenu.PopupMenuItem(_("Copy"));
|
||
|
item.connect('activate', this._onCopyActivated.bind(this));
|
||
|
this.addMenuItem(item);
|
||
|
this._copyItem = item;
|
||
|
|
||
|
item = new PopupMenu.PopupMenuItem(_("Paste"));
|
||
|
item.connect('activate', this._onPasteActivated.bind(this));
|
||
|
this.addMenuItem(item);
|
||
|
this._pasteItem = item;
|
||
|
|
||
|
this._passwordItem = null;
|
||
|
|
||
|
Main.uiGroup.add_actor(this.actor);
|
||
|
this.actor.hide();
|
||
|
}
|
||
|
|
||
|
_makePasswordItem() {
|
||
|
let item = new PopupMenu.PopupMenuItem('');
|
||
|
item.connect('activate', this._onPasswordActivated.bind(this));
|
||
|
this.addMenuItem(item);
|
||
|
this._passwordItem = item;
|
||
|
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;
|
||
|
}
|
||
|
|
||
|
set isPassword(v) {
|
||
|
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) {
|
||
|
this._updatePasteItem();
|
||
|
this._updateCopyItem();
|
||
|
if (this._passwordItem)
|
||
|
this._updatePasswordItem();
|
||
|
|
||
|
super.open(animate);
|
||
|
this._entry.add_style_pseudo_class('focus');
|
||
|
|
||
|
let direction = St.DirectionType.TAB_FORWARD;
|
||
|
if (!this.actor.navigate_focus(null, direction, false))
|
||
|
this.actor.grab_key_focus();
|
||
|
}
|
||
|
|
||
|
_updateCopyItem() {
|
||
|
let selection = this._entry.clutter_text.get_selection();
|
||
|
this._copyItem.setSensitive(!this._entry.clutter_text.password_char &&
|
||
|
selection && selection != '');
|
||
|
}
|
||
|
|
||
|
_updatePasteItem() {
|
||
|
this._clipboard.get_text(St.ClipboardType.CLIPBOARD,
|
||
|
(clipboard, text) => {
|
||
|
this._pasteItem.setSensitive(text && text != '');
|
||
|
});
|
||
|
}
|
||
|
|
||
|
_updatePasswordItem() {
|
||
|
--
|
||
|
2.27.0
|
||
|
|