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