shellEntry: Set the input-purpose property for password entries

This way input methods can disable themselves automatically for
entries holding passwords.

https://bugzilla.gnome.org/show_bug.cgi?id=700043
This commit is contained in:
Rui Matos 2013-05-10 03:35:05 +02:00
parent 08599afdd4
commit 1290c98c9b

View File

@ -14,9 +14,7 @@ const EntryMenu = new Lang.Class({
Name: 'ShellEntryMenu', Name: 'ShellEntryMenu',
Extends: PopupMenu.PopupMenu, Extends: PopupMenu.PopupMenu,
_init: function(entry, params) { _init: function(entry) {
params = Params.parse (params, { isPassword: false });
this.parent(entry, 0, St.Side.TOP); this.parent(entry, 0, St.Side.TOP);
this.actor.add_style_class_name('entry-context-menu'); this.actor.add_style_class_name('entry-context-menu');
@ -37,8 +35,6 @@ const EntryMenu = new Lang.Class({
this._pasteItem = item; this._pasteItem = item;
this._passwordItem = null; this._passwordItem = null;
if (params.isPassword)
this._makePasswordItem();
Main.uiGroup.add_actor(this.actor); Main.uiGroup.add_actor(this.actor);
this.actor.hide(); this.actor.hide();
@ -53,19 +49,21 @@ const EntryMenu = new Lang.Class({
}, },
get isPassword() { get isPassword() {
return this._passwordItem != null; return this._passwordItem != null;
}, },
set isPassword(v) { set isPassword(v) {
if (v == this.isPassword) if (v == this.isPassword)
return; return;
if (v) if (v) {
this._makePasswordItem(); this._makePasswordItem();
else { this._entry.input_purpose = Gtk.InputPurpose.PASSWORD;
this._passwordItem.destroy(); } else {
this._passwordItem = null; this._passwordItem.destroy();
} this._passwordItem = null;
this._entry.input_purpose = Gtk.InputPurpose.FREE_FORM;
}
}, },
open: function(animate) { open: function(animate) {
@ -155,7 +153,10 @@ function addContextMenu(entry, params) {
if (entry.menu) if (entry.menu)
return; return;
entry.menu = new EntryMenu(entry, params); params = Params.parse (params, { isPassword: false });
entry.menu = new EntryMenu(entry);
entry.menu.isPassword = params.isPassword;
entry._menuManager = new PopupMenu.PopupMenuManager({ actor: entry }); entry._menuManager = new PopupMenu.PopupMenuManager({ actor: entry });
entry._menuManager.addMenu(entry.menu); entry._menuManager.addMenu(entry.menu);