search-entry: Handle find-as-you-type activation internally

To enable find-as-you-type when entering the overview and disabling
it when leaving, we used a chain of functions calls from ViewSelector
over SearchTab to SearchEntry. As find-as-you-type should be enabled
while the overview is shown, the activation/deactivation can be
handled entirely by the SearchEntry itself by tying it to the entry's
visibility.

https://bugzilla.gnome.org/show_bug.cgi?id=642196
This commit is contained in:
Florian Müllner 2011-02-12 23:03:30 +01:00
parent f1c279765b
commit 0ae44f4015

View File

@ -39,6 +39,7 @@ SearchEntry.prototype = {
this.reset(); this.reset();
})); }));
this.actor.connect('destroy', Lang.bind(this, this._onDestroy)); this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
this.actor.connect('notify::mapped', Lang.bind(this, this._onMapped));
global.stage.connect('notify::key-focus', Lang.bind(this, this._updateCursorVisibility)); global.stage.connect('notify::key-focus', Lang.bind(this, this._updateCursorVisibility));
@ -56,16 +57,16 @@ SearchEntry.prototype = {
this.entry.set_cursor_visible(false); this.entry.set_cursor_visible(false);
}, },
show: function() { _onMapped: function() {
if (this._capturedEventId == 0) if (this.actor.mapped) {
// Enable 'find-as-you-type'
this._capturedEventId = global.stage.connect('captured-event', this._capturedEventId = global.stage.connect('captured-event',
Lang.bind(this, this._onCapturedEvent)); Lang.bind(this, this._onCapturedEvent));
this.entry.set_cursor_visible(true); this.entry.set_cursor_visible(true);
this.entry.set_selection(0, 0); this.entry.set_selection(0, 0);
}, } else {
// Disable 'find-as-you-type'
hide: function() { if (this._capturedEventId > 0)
if (this._capturedEventId > 0) {
global.stage.disconnect(this._capturedEventId); global.stage.disconnect(this._capturedEventId);
this._capturedEventId = 0; this._capturedEventId = 0;
} }
@ -266,13 +267,6 @@ SearchTab.prototype = {
})); }));
}, },
setFindAsYouType: function(enabled) {
if (enabled)
this._searchEntry.show();
else
this._searchEntry.hide();
},
show: function() { show: function() {
BaseTab.prototype.show.call(this); BaseTab.prototype.show.call(this);
@ -580,8 +574,6 @@ ViewSelector.prototype = {
}, },
show: function() { show: function() {
this._searchTab.setFindAsYouType(true);
if (this._itemDragBeginId == 0) if (this._itemDragBeginId == 0)
this._itemDragBeginId = Main.overview.connect('item-drag-begin', this._itemDragBeginId = Main.overview.connect('item-drag-begin',
Lang.bind(this, this._switchDefaultTab)); Lang.bind(this, this._switchDefaultTab));
@ -596,8 +588,6 @@ ViewSelector.prototype = {
}, },
hide: function() { hide: function() {
this._searchTab.setFindAsYouType(false);
if (this._keyPressId > 0) { if (this._keyPressId > 0) {
this.actor.disconnect(this._keyPressId); this.actor.disconnect(this._keyPressId);
this._keyPressId = 0; this._keyPressId = 0;