remoteSearch: Do filtering here of providers here
We already do ordering at load time, so why not filtering?
This commit is contained in:
parent
ea2451d882
commit
dc2468b27b
@ -62,7 +62,7 @@ const SearchProvider2Iface = '<node> \
|
|||||||
var SearchProviderProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProviderIface);
|
var SearchProviderProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProviderIface);
|
||||||
var SearchProvider2ProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProvider2Iface);
|
var SearchProvider2ProxyInfo = Gio.DBusInterfaceInfo.new_for_xml(SearchProvider2Iface);
|
||||||
|
|
||||||
function loadRemoteSearchProviders(addProviderCallback) {
|
function loadRemoteSearchProviders(callback) {
|
||||||
let objectPaths = {};
|
let objectPaths = {};
|
||||||
let loadedProviders = [];
|
let loadedProviders = [];
|
||||||
|
|
||||||
@ -116,6 +116,12 @@ function loadRemoteSearchProviders(addProviderCallback) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let searchSettings = new Gio.Settings({ schema: Search.SEARCH_PROVIDERS_SCHEMA });
|
||||||
|
if (searchSettings.get_boolean('disable-external')) {
|
||||||
|
callback([]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let dataDirs = GLib.get_system_data_dirs();
|
let dataDirs = GLib.get_system_data_dirs();
|
||||||
dataDirs.forEach(function(dataDir) {
|
dataDirs.forEach(function(dataDir) {
|
||||||
let path = GLib.build_filenamev([dataDir, 'gnome-shell', 'search-providers']);
|
let path = GLib.build_filenamev([dataDir, 'gnome-shell', 'search-providers']);
|
||||||
@ -134,12 +140,17 @@ function loadRemoteSearchProviders(addProviderCallback) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let searchSettings = new Gio.Settings({ schema: Search.SEARCH_PROVIDERS_SCHEMA });
|
|
||||||
let sortOrder = searchSettings.get_strv('sort-order');
|
let sortOrder = searchSettings.get_strv('sort-order');
|
||||||
|
|
||||||
// Special case gnome-control-center to be always active and always first
|
// Special case gnome-control-center to be always active and always first
|
||||||
sortOrder.unshift('gnome-control-center.desktop');
|
sortOrder.unshift('gnome-control-center.desktop');
|
||||||
|
|
||||||
|
loadedProviders = loadedProviders.filter(function(provider) {
|
||||||
|
let appId = provider.appInfo.get_id();
|
||||||
|
let disabled = searchSettings.get_strv('disabled');
|
||||||
|
return disabled.indexOf(appId) == -1;
|
||||||
|
});
|
||||||
|
|
||||||
loadedProviders.sort(function(providerA, providerB) {
|
loadedProviders.sort(function(providerA, providerB) {
|
||||||
let idxA, idxB;
|
let idxA, idxB;
|
||||||
let appIdA, appIdB;
|
let appIdA, appIdB;
|
||||||
@ -170,7 +181,7 @@ function loadRemoteSearchProviders(addProviderCallback) {
|
|||||||
return (idxA - idxB);
|
return (idxA - idxB);
|
||||||
});
|
});
|
||||||
|
|
||||||
loadedProviders.forEach(addProviderCallback);
|
callback(loadedProviders);
|
||||||
}
|
}
|
||||||
|
|
||||||
const RemoteSearchProvider = new Lang.Class({
|
const RemoteSearchProvider = new Lang.Class({
|
||||||
|
@ -39,19 +39,6 @@ const SearchSystem = new Lang.Class({
|
|||||||
this._reloadRemoteProviders();
|
this._reloadRemoteProviders();
|
||||||
},
|
},
|
||||||
|
|
||||||
_shouldUseSearchProvider: function(provider) {
|
|
||||||
// the disable-external GSetting only affects remote providers
|
|
||||||
if (!provider.isRemoteProvider)
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (this._searchSettings.get_boolean('disable-external'))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
let appId = provider.appInfo.get_id();
|
|
||||||
let disable = this._searchSettings.get_strv('disabled');
|
|
||||||
return disable.indexOf(appId) == -1;
|
|
||||||
},
|
|
||||||
|
|
||||||
addProvider: function(provider) {
|
addProvider: function(provider) {
|
||||||
this._providers.push(provider);
|
this._providers.push(provider);
|
||||||
this.emit('providers-changed');
|
this.emit('providers-changed');
|
||||||
@ -65,12 +52,10 @@ const SearchSystem = new Lang.Class({
|
|||||||
this._unregisterProvider(provider);
|
this._unregisterProvider(provider);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
RemoteSearch.loadRemoteSearchProviders(Lang.bind(this, function(provider) {
|
RemoteSearch.loadRemoteSearchProviders(Lang.bind(this, function(providers) {
|
||||||
if (!this._shouldUseSearchProvider(provider))
|
providers.forEach(Lang.bind(this, this._registerProvider));
|
||||||
return;
|
|
||||||
|
|
||||||
this._registerProvider(provider);
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this.emit('providers-changed');
|
this.emit('providers-changed');
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user