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