[gnome-shell/eos3.8: 39/255] Adapt AppSearchProvider to consider Endless's desktop grid
- From: Matthew Leeds <mwleeds src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/eos3.8: 39/255] Adapt AppSearchProvider to consider Endless's desktop grid
- Date: Wed, 10 Jun 2020 19:01:13 +0000 (UTC)
commit 92ab5f089b49662f402b9e851375d2ac9d6c2ab4
Author: Mario Sanchez Prada <mario endlessm com>
Date: Sat May 27 03:02:07 2017 +0100
Adapt AppSearchProvider to consider Endless's desktop grid
We adapt this provided slightly so that search order properly put
prioritized apps first, then apps that are on the desktop, and
finally apps that are installed but not on the desktop.
https://phabricator.endlessm.com/T4008
https://phabricator.endlessm.com/T15929
js/ui/appDisplay.js | 22 ++++++++++++++++++++++
js/ui/remoteSearch.js | 22 +++++++++++++++++++++-
2 files changed, 43 insertions(+), 1 deletion(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 1a1cdfaf0b..f9a985c96e 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -9,6 +9,7 @@ const AppFavorites = imports.ui.appFavorites;
const DND = imports.ui.dnd;
const GrabHelper = imports.ui.grabHelper;
const IconGrid = imports.ui.iconGrid;
+const IconGridLayout = imports.ui.iconGridLayout;
const Main = imports.ui.main;
const PageIndicators = imports.ui.pageIndicators;
const PopupMenu = imports.ui.popupMenu;
@@ -53,6 +54,12 @@ const SwitcherooProxyInterface = loadInterfaceXML('net.hadess.SwitcherooControl'
const SwitcherooProxy = Gio.DBusProxy.makeProxyWrapper(SwitcherooProxyInterface);
let discreteGpuAvailable = false;
+// Endless-specific definitions below this point
+
+const EOS_LINK_PREFIX = 'eos-link-';
+
+const EOS_APP_CENTER_ID = 'org.gnome.Software.desktop';
+
function _getCategories(info) {
let categoriesStr = info.get_categories();
if (!categoriesStr)
@@ -1211,6 +1218,7 @@ var AppSearchProvider = class AppSearchProvider {
this.isRemoteProvider = false;
this.canLaunchSearch = false;
+ this._iconGridLayout = IconGridLayout.getDefault();
this._systemActions = new SystemActions.getDefault();
}
@@ -1252,6 +1260,13 @@ var AppSearchProvider = class AppSearchProvider {
let results = [];
groups.forEach(group => {
group = group.filter(appID => {
+ const isLink = appID.startsWith(EOS_LINK_PREFIX);
+ const isOnDesktop = this._iconGridLayout.hasIcon(appID);
+
+ // exclude links that are not part of the desktop grid
+ if (isLink && !isOnDesktop)
+ return false;
+
const app = this._appSys.lookup_app(appID);
return app && app.app_info.should_show();
});
@@ -1262,6 +1277,13 @@ var AppSearchProvider = class AppSearchProvider {
results = results.concat(this._systemActions.getMatchingActions(terms));
+ // resort to keep results on the desktop grid before the others
+ results = results.sort((a, b) => {
+ let hasA = a === EOS_APP_CENTER_ID || this._iconGridLayout.hasIcon(a);
+ let hasB = b === EOS_APP_CENTER_ID || this._iconGridLayout.hasIcon(b);
+
+ return hasB - hasA;
+ });
callback(results);
}
diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js
index 62933f7ea8..f939a6595c 100644
--- a/js/ui/remoteSearch.js
+++ b/js/ui/remoteSearch.js
@@ -4,8 +4,10 @@
const { GdkPixbuf, Gio, GLib, Shell, St } = imports.gi;
const FileUtils = imports.misc.fileUtils;
+const IconGridLayout = imports.ui.iconGridLayout;
const KEY_FILE_GROUP = 'Shell Search Provider';
+const CONTROL_CENTER_DESKTOP_ID = 'gnome-control-center.desktop';
const SearchProviderIface = `
<node>
@@ -158,14 +160,32 @@ function loadRemoteSearchProviders(searchSettings, callback) {
let idxA, idxB;
let appIdA, appIdB;
+ const iconGridLayout = IconGridLayout.getDefault();
+
appIdA = providerA.appInfo.get_id();
appIdB = providerB.appInfo.get_id();
idxA = sortOrder.indexOf(appIdA);
idxB = sortOrder.indexOf(appIdB);
- // if no provider is found in the order, use alphabetical order
+ // none of the providers are in the list; check if they're on the desktop
if ((idxA == -1) && (idxB == -1)) {
+ // We special case gnome-control-center, since we don't have it on
+ // the desktop but still want to see the results it provides
+ let hasA = iconGridLayout.hasIcon(appIdA) ||
+ appIdA === CONTROL_CENTER_DESKTOP_ID;
+ let hasB = iconGridLayout.hasIcon(appIdB) ||
+ appIdB === CONTROL_CENTER_DESKTOP_ID;
+
+ // if providerA is on the desktop, it's sorted before providerB
+ if (hasA && !hasB)
+ return -1;
+
+ // if providerB is on the desktop, it's sorted before providerA
+ if (hasB && !hasA)
+ return 1;
+
+ // fall back to alphabetical order
let nameA = providerA.appInfo.get_name();
let nameB = providerB.appInfo.get_name();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]