|
|
a3db19 |
From 39cf97176e2a92506081ee151ea546e2c6cf213a Mon Sep 17 00:00:00 2001
|
|
|
a3db19 |
From: Ray Strode <rstrode@redhat.com>
|
|
|
a3db19 |
Date: Wed, 21 Aug 2019 15:06:46 -0400
|
|
|
a3db19 |
Subject: [PATCH 3/4] shellEntry: Handle password item from dedication function
|
|
|
a3db19 |
|
|
|
a3db19 |
At the moment, shellEntry handles creating and destroying its
|
|
|
a3db19 |
"Show Text" password menu item directly from its isPassword
|
|
|
a3db19 |
setter function.
|
|
|
a3db19 |
|
|
|
a3db19 |
This commit moves that handling to a dedicated _resetPasswordItem
|
|
|
a3db19 |
function, as prep work for adding lockdown support of the "Show Text"
|
|
|
a3db19 |
menu item.
|
|
|
a3db19 |
|
|
|
a3db19 |
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/687
|
|
|
a3db19 |
---
|
|
|
a3db19 |
js/ui/shellEntry.js | 23 +++++++++++++++++------
|
|
|
a3db19 |
1 file changed, 17 insertions(+), 6 deletions(-)
|
|
|
a3db19 |
|
|
|
a3db19 |
diff --git a/js/ui/shellEntry.js b/js/ui/shellEntry.js
|
|
|
a3db19 |
index 603a9c64a..765cede06 100644
|
|
|
a3db19 |
--- a/js/ui/shellEntry.js
|
|
|
a3db19 |
+++ b/js/ui/shellEntry.js
|
|
|
a3db19 |
@@ -14,76 +14,87 @@ var EntryMenu = class extends PopupMenu.PopupMenu {
|
|
|
a3db19 |
|
|
|
a3db19 |
this._entry = entry;
|
|
|
a3db19 |
this._clipboard = St.Clipboard.get_default();
|
|
|
a3db19 |
|
|
|
a3db19 |
// Populate menu
|
|
|
a3db19 |
let item;
|
|
|
a3db19 |
item = new PopupMenu.PopupMenuItem(_("Copy"));
|
|
|
a3db19 |
item.connect('activate', this._onCopyActivated.bind(this));
|
|
|
a3db19 |
this.addMenuItem(item);
|
|
|
a3db19 |
this._copyItem = item;
|
|
|
a3db19 |
|
|
|
a3db19 |
item = new PopupMenu.PopupMenuItem(_("Paste"));
|
|
|
a3db19 |
item.connect('activate', this._onPasteActivated.bind(this));
|
|
|
a3db19 |
this.addMenuItem(item);
|
|
|
a3db19 |
this._pasteItem = item;
|
|
|
a3db19 |
|
|
|
a3db19 |
this._passwordItem = null;
|
|
|
a3db19 |
|
|
|
a3db19 |
Main.uiGroup.add_actor(this.actor);
|
|
|
a3db19 |
this.actor.hide();
|
|
|
a3db19 |
}
|
|
|
a3db19 |
|
|
|
a3db19 |
_makePasswordItem() {
|
|
|
a3db19 |
let item = new PopupMenu.PopupMenuItem('');
|
|
|
a3db19 |
item.connect('activate', this._onPasswordActivated.bind(this));
|
|
|
a3db19 |
this.addMenuItem(item);
|
|
|
a3db19 |
this._passwordItem = item;
|
|
|
a3db19 |
this._updatePasswordItem();
|
|
|
a3db19 |
}
|
|
|
a3db19 |
|
|
|
a3db19 |
+ _resetPasswordItem() {
|
|
|
a3db19 |
+ if (!this.isPassword) {
|
|
|
a3db19 |
+ if (this._passwordItem) {
|
|
|
a3db19 |
+ this._passwordItem.destroy();
|
|
|
a3db19 |
+ this._passwordItem = null;
|
|
|
a3db19 |
+ }
|
|
|
a3db19 |
+ this._entry.clutter_text.set_password_char('\u25cf');
|
|
|
a3db19 |
+ } else {
|
|
|
a3db19 |
+ if (!this._passwordItem)
|
|
|
a3db19 |
+ this._makePasswordItem();
|
|
|
a3db19 |
+ }
|
|
|
a3db19 |
+ }
|
|
|
a3db19 |
+
|
|
|
a3db19 |
get isPassword() {
|
|
|
a3db19 |
return this._entry.input_purpose == Clutter.InputContentPurpose.PASSWORD;
|
|
|
a3db19 |
}
|
|
|
a3db19 |
|
|
|
a3db19 |
set isPassword(v) {
|
|
|
a3db19 |
if (v == this.isPassword)
|
|
|
a3db19 |
return;
|
|
|
a3db19 |
|
|
|
a3db19 |
- if (v) {
|
|
|
a3db19 |
- this._makePasswordItem();
|
|
|
a3db19 |
+ if (v)
|
|
|
a3db19 |
this._entry.input_purpose = Clutter.InputContentPurpose.PASSWORD;
|
|
|
a3db19 |
- } else {
|
|
|
a3db19 |
- this._passwordItem.destroy();
|
|
|
a3db19 |
- this._passwordItem = null;
|
|
|
a3db19 |
+ else
|
|
|
a3db19 |
this._entry.input_purpose = Clutter.InputContentPurpose.NORMAL;
|
|
|
a3db19 |
- }
|
|
|
a3db19 |
+
|
|
|
a3db19 |
+ this._resetPasswordItem();
|
|
|
a3db19 |
}
|
|
|
a3db19 |
|
|
|
a3db19 |
open(animate) {
|
|
|
a3db19 |
this._updatePasteItem();
|
|
|
a3db19 |
this._updateCopyItem();
|
|
|
a3db19 |
if (this._passwordItem)
|
|
|
a3db19 |
this._updatePasswordItem();
|
|
|
a3db19 |
|
|
|
a3db19 |
super.open(animate);
|
|
|
a3db19 |
this._entry.add_style_pseudo_class('focus');
|
|
|
a3db19 |
|
|
|
a3db19 |
let direction = St.DirectionType.TAB_FORWARD;
|
|
|
a3db19 |
if (!this.actor.navigate_focus(null, direction, false))
|
|
|
a3db19 |
this.actor.grab_key_focus();
|
|
|
a3db19 |
}
|
|
|
a3db19 |
|
|
|
a3db19 |
_updateCopyItem() {
|
|
|
a3db19 |
let selection = this._entry.clutter_text.get_selection();
|
|
|
a3db19 |
this._copyItem.setSensitive(!this._entry.clutter_text.password_char &&
|
|
|
a3db19 |
selection && selection != '');
|
|
|
a3db19 |
}
|
|
|
a3db19 |
|
|
|
a3db19 |
_updatePasteItem() {
|
|
|
a3db19 |
this._clipboard.get_text(St.ClipboardType.CLIPBOARD,
|
|
|
a3db19 |
(clipboard, text) => {
|
|
|
a3db19 |
this._pasteItem.setSensitive(text && text != '');
|
|
|
a3db19 |
});
|
|
|
a3db19 |
}
|
|
|
a3db19 |
|
|
|
a3db19 |
_updatePasswordItem() {
|
|
|
a3db19 |
--
|
|
|
a3db19 |
2.27.0
|
|
|
a3db19 |
|