search: remove SearchProvider base class
This is causing more confusion than anything else these days; the DBus API is properly documented now and that's what people are expected to use, the rest are implementation details we're not interested in exposing. https://bugzilla.gnome.org/show_bug.cgi?id=681797
This commit is contained in:
parent
3aa0d455c9
commit
d0902fa28b
@ -19,7 +19,6 @@ const IconGrid = imports.ui.iconGrid;
|
|||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const Overview = imports.ui.overview;
|
const Overview = imports.ui.overview;
|
||||||
const PopupMenu = imports.ui.popupMenu;
|
const PopupMenu = imports.ui.popupMenu;
|
||||||
const Search = imports.ui.search;
|
|
||||||
const Tweener = imports.ui.tweener;
|
const Tweener = imports.ui.tweener;
|
||||||
const Workspace = imports.ui.workspace;
|
const Workspace = imports.ui.workspace;
|
||||||
const Params = imports.misc.params;
|
const Params = imports.misc.params;
|
||||||
@ -312,10 +311,8 @@ const AllAppDisplay = new Lang.Class({
|
|||||||
|
|
||||||
const AppSearchProvider = new Lang.Class({
|
const AppSearchProvider = new Lang.Class({
|
||||||
Name: 'AppSearchProvider',
|
Name: 'AppSearchProvider',
|
||||||
Extends: Search.SearchProvider,
|
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this.parent();
|
|
||||||
this._appSys = Shell.AppSystem.get_default();
|
this._appSys = Shell.AppSystem.get_default();
|
||||||
this.id = 'applications';
|
this.id = 'applications';
|
||||||
},
|
},
|
||||||
@ -370,10 +367,9 @@ const AppSearchProvider = new Lang.Class({
|
|||||||
|
|
||||||
const SettingsSearchProvider = new Lang.Class({
|
const SettingsSearchProvider = new Lang.Class({
|
||||||
Name: 'SettingsSearchProvider',
|
Name: 'SettingsSearchProvider',
|
||||||
Extends: Search.SearchProvider,
|
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this.parent(Gio.DesktopAppInfo.new('gnome-control-center.desktop'));
|
this.appInfo = Gio.DesktopAppInfo.new('gnome-control-center.desktop');
|
||||||
this._appSys = Shell.AppSystem.get_default();
|
this._appSys = Shell.AppSystem.get_default();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -167,7 +167,6 @@ function remoteProvidersLoaded(loadState) {
|
|||||||
|
|
||||||
const RemoteSearchProvider = new Lang.Class({
|
const RemoteSearchProvider = new Lang.Class({
|
||||||
Name: 'RemoteSearchProvider',
|
Name: 'RemoteSearchProvider',
|
||||||
Extends: Search.SearchProvider,
|
|
||||||
|
|
||||||
_init: function(appInfo, dbusName, dbusPath, proxyType) {
|
_init: function(appInfo, dbusName, dbusPath, proxyType) {
|
||||||
if (!proxyType)
|
if (!proxyType)
|
||||||
@ -176,7 +175,10 @@ const RemoteSearchProvider = new Lang.Class({
|
|||||||
this.proxy = new proxyType(Gio.DBus.session,
|
this.proxy = new proxyType(Gio.DBus.session,
|
||||||
dbusName, dbusPath, Lang.bind(this, this._onProxyConstructed));
|
dbusName, dbusPath, Lang.bind(this, this._onProxyConstructed));
|
||||||
|
|
||||||
this.parent(appInfo, true);
|
this.appInfo = appInfo;
|
||||||
|
this.id = appInfo.get_id();
|
||||||
|
this.isRemoteProvider = true;
|
||||||
|
|
||||||
this._cancellable = new Gio.Cancellable();
|
this._cancellable = new Gio.Cancellable();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
117
js/ui/search.js
117
js/ui/search.js
@ -21,123 +21,6 @@ const MatchType = {
|
|||||||
PREFIX: 2
|
PREFIX: 2
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* SearchProvider:
|
|
||||||
*
|
|
||||||
* Subclass this object to add a new result type
|
|
||||||
* to the search system, then call registerProvider()
|
|
||||||
* in SearchSystem with an instance.
|
|
||||||
* Search is asynchronous and uses the
|
|
||||||
* getInitialResultSet()/getSubsearchResultSet() methods.
|
|
||||||
*/
|
|
||||||
const SearchProvider = new Lang.Class({
|
|
||||||
Name: 'SearchProvider',
|
|
||||||
|
|
||||||
_init: function(appInfo, isRemoteProvider) {
|
|
||||||
this.appInfo = appInfo;
|
|
||||||
this.searchSystem = null;
|
|
||||||
this.isRemoteProvider = !!isRemoteProvider;
|
|
||||||
this.canLaunchSearch = false;
|
|
||||||
|
|
||||||
if (this.appInfo)
|
|
||||||
this.id = this.appInfo.get_id();
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getInitialResultSet:
|
|
||||||
* @terms: Array of search terms, treated as logical AND
|
|
||||||
*
|
|
||||||
* Called when the user first begins a search (most likely
|
|
||||||
* therefore a single term of length one or two), or when
|
|
||||||
* a new term is added.
|
|
||||||
*
|
|
||||||
* Should "return" an array of result identifier strings representing
|
|
||||||
* items which match the given search terms. This
|
|
||||||
* is expected to be a substring match on the metadata for a given
|
|
||||||
* item. Ordering of returned results is up to the discretion of the provider,
|
|
||||||
* but you should follow these heruistics:
|
|
||||||
*
|
|
||||||
* * Put items where the term matches multiple criteria (e.g. name and
|
|
||||||
* description) before single matches
|
|
||||||
* * Put items which match on a prefix before non-prefix substring matches
|
|
||||||
*
|
|
||||||
* We say "return" above, but in order to make the query asynchronous, use
|
|
||||||
* this.searchSystem.pushResults();. The return value should be ignored.
|
|
||||||
*
|
|
||||||
* This function should be fast; do not perform unindexed full-text searches
|
|
||||||
* or network queries.
|
|
||||||
*/
|
|
||||||
getInitialResultSet: function(terms) {
|
|
||||||
throw new Error('Not implemented');
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getSubsearchResultSet:
|
|
||||||
* @previousResults: Array of item identifiers
|
|
||||||
* @newTerms: Updated search terms
|
|
||||||
*
|
|
||||||
* Called when a search is performed which is a "subsearch" of
|
|
||||||
* the previous search; i.e. when every search term has exactly
|
|
||||||
* one corresponding term in the previous search which is a prefix
|
|
||||||
* of the new term.
|
|
||||||
*
|
|
||||||
* This allows search providers to only search through the previous
|
|
||||||
* result set, rather than possibly performing a full re-query.
|
|
||||||
*
|
|
||||||
* Similar to getInitialResultSet, the return value for this will
|
|
||||||
* be ignored; use this.searchSystem.pushResults();.
|
|
||||||
*/
|
|
||||||
getSubsearchResultSet: function(previousResults, newTerms) {
|
|
||||||
throw new Error('Not implemented');
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* getResultMetas:
|
|
||||||
* @ids: Result identifier strings
|
|
||||||
*
|
|
||||||
* Call callback with array of objects with 'id', 'name', (both strings) and
|
|
||||||
* 'createIcon' (function(size) returning a Clutter.Texture) properties
|
|
||||||
* with the same number of members as @ids
|
|
||||||
*/
|
|
||||||
getResultMetas: function(ids, callback) {
|
|
||||||
throw new Error('Not implemented');
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* createResultActor:
|
|
||||||
* @resultMeta: Object with result metadata
|
|
||||||
* @terms: Array of search terms, should be used for highlighting
|
|
||||||
*
|
|
||||||
* Search providers may optionally override this to render a
|
|
||||||
* particular serch result in a custom fashion. The default
|
|
||||||
* implementation will show the icon next to the name.
|
|
||||||
*/
|
|
||||||
createResultActor: function(resultMeta, terms) {
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* activateResult:
|
|
||||||
* @id: Result identifier string
|
|
||||||
*
|
|
||||||
* Called when the user chooses a given result.
|
|
||||||
*/
|
|
||||||
activateResult: function(id) {
|
|
||||||
throw new Error('Not implemented');
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* launchSearch:
|
|
||||||
* @terms: Current search terms
|
|
||||||
*
|
|
||||||
* Called when the user clicks the provider icon.
|
|
||||||
*/
|
|
||||||
launchSearch: function(terms) {
|
|
||||||
throw new Error('Not implemented');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
Signals.addSignalMethods(SearchProvider.prototype);
|
|
||||||
|
|
||||||
const SearchSystem = new Lang.Class({
|
const SearchSystem = new Lang.Class({
|
||||||
Name: 'SearchSystem',
|
Name: 'SearchSystem',
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ const IconGrid = imports.ui.iconGrid;
|
|||||||
const Layout = imports.ui.layout;
|
const Layout = imports.ui.layout;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const Panel = imports.ui.panel;
|
const Panel = imports.ui.panel;
|
||||||
const Search = imports.ui.search;
|
|
||||||
|
|
||||||
// we could make these gsettings
|
// we could make these gsettings
|
||||||
const FISH_NAME = 'wanda';
|
const FISH_NAME = 'wanda';
|
||||||
@ -132,10 +131,8 @@ function capitalize(str) {
|
|||||||
|
|
||||||
const WandaSearchProvider = new Lang.Class({
|
const WandaSearchProvider = new Lang.Class({
|
||||||
Name: 'WandaSearchProvider',
|
Name: 'WandaSearchProvider',
|
||||||
Extends: Search.SearchProvider,
|
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this.parent();
|
|
||||||
this.id = 'wanda';
|
this.id = 'wanda';
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user