search: Activate SearchResult from the result itself

Search result views can include also objects that are not inheriting from
SearchResults (such as the AppIcon) that has not any 'activate' signal, to
connect to. Since we want to enforce a more formal interface, we want to
have just a simpler requirement as an activate() method.

So, instead using the 'activate' signal in SearchResult to activate a result
via SearchResultsBase just implement activate() in the result.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/765
This commit is contained in:
Marco Trevisan (Treviño) 2019-10-16 02:23:22 +02:00
parent d0d1845bb6
commit 6533690fff

View File

@ -50,7 +50,12 @@ var SearchResult = class {
}
activate() {
this.emit('activate', this.metaInfo.id);
this.provider.activateResult(this.metaInfo.id, this._resultsView.terms);
if (this.metaInfo.clipboardText)
St.Clipboard.get_default().set_text(
St.ClipboardType.CLIPBOARD, this.metaInfo.clipboardText);
Main.overview.toggle();
}
};
Signals.addSignalMethods(SearchResult.prototype);
@ -156,8 +161,6 @@ var SearchResultsBase = class {
this._resultDisplays = {};
this._clipboard = St.Clipboard.get_default();
this._cancellable = new Gio.Cancellable();
this.actor.connect('destroy', this._onDestroy.bind(this));
@ -191,13 +194,6 @@ var SearchResultsBase = class {
this.emit('key-focus-in', actor);
}
_activateResult(result, id) {
this.provider.activateResult(id, this._terms);
if (result.metaInfo.clipboardText)
this._clipboard.set_text(St.ClipboardType.CLIPBOARD, result.metaInfo.clipboardText);
Main.overview.toggle();
}
_setMoreCount(_count) {
}
@ -234,7 +230,6 @@ var SearchResultsBase = class {
metasNeeded.forEach((resultId, i) => {
let meta = metas[i];
let display = this._createResultDisplay(meta);
display.connect('activate', this._activateResult.bind(this));
display.actor.connect('key-focus-in', this._keyFocusIn.bind(this));
this._resultDisplays[resultId] = display;
});
@ -468,6 +463,10 @@ var SearchResultsView = class {
this._reloadRemoteProviders();
}
get terms() {
return this._terms;
}
_reloadRemoteProviders() {
let remoteProviders = this._providers.filter(p => p.isRemoteProvider);
remoteProviders.forEach(provider => {