From 22d2097943ae4c795d8ec53b8977158460128771 Mon Sep 17 00:00:00 2001 From: LynithDev <61880709+LynithDev@users.noreply.github.com> Date: Mon, 1 May 2023 12:55:17 +0200 Subject: [PATCH 1/2] Hide app from search --- metadata.json | 2 +- patches/appDisplayPatcher.js | 28 ++++++++++++++- prefs.js | 34 ++++++++++++++++-- schemas/gschemas.compiled | Bin 300 -> 357 bytes ...ome.shell.extensions.app-hider.gschema.xml | 5 +++ 5 files changed, 65 insertions(+), 4 deletions(-) diff --git a/metadata.json b/metadata.json index bada199..f1bc887 100644 --- a/metadata.json +++ b/metadata.json @@ -3,7 +3,7 @@ "description": "Hide apps in GNOME's app menu", "uuid": "app-hider-dev@lynith.dev", "settings-schema": "org.gnome.shell.extensions.app-hider", - "version": 4, + "version": 6, "url": "https://github.com/LynithDev/gnome-app-hider", "shell-version": [ "42", diff --git a/patches/appDisplayPatcher.js b/patches/appDisplayPatcher.js index 05928c5..0683d3f 100644 --- a/patches/appDisplayPatcher.js +++ b/patches/appDisplayPatcher.js @@ -1,11 +1,35 @@ -const { BaseAppView, AppDisplay, FolderView } = imports.ui.appDisplay; +const { BaseAppView, AppDisplay, FolderView, AppSearchProvider } = imports.ui.appDisplay; const Main = imports.ui.main; +const { Shell } = imports.gi; var AppDisplayPatcher = class AppDisplayPatcher { constructor(settings) { this.settings = settings; } + _patchAppSearchProvider() { + AppSearchProvider.prototype._original_getInitialResultSet = AppSearchProvider.prototype.getInitialResultSet; + + let SETTINGS = this.settings; + AppSearchProvider.prototype.getInitialResultSet = async function(terms, cancellable) { + try { + let resultSet = await this._original_getInitialResultSet(terms, cancellable); + + let hiddenSearchApps = SETTINGS.get_strv("hidden-search-apps"); + resultSet = resultSet.filter(app => !hiddenSearchApps.includes(app)); + + return new Promise((resolve) => resolve(resultSet)); + } catch (e) { + return this._original_getInitialResultSet(terms, cancellable); + } + } + } + + _unpatchAppSearchProvider() { + AppSearchProvider.prototype.getInitialResultSet = AppSearchProvider.prototype._original_getInitialResultSet; + delete AppSearchProvider.prototype._original_getInitialResultSet; + } + _patchAppView() { let SETTINGS = this.settings; @@ -35,10 +59,12 @@ var AppDisplayPatcher = class AppDisplayPatcher { } enable() { + this._patchAppSearchProvider(); this._patchAppView(); } disable() { + this._unpatchAppSearchProvider(); this._unpatchAppView(); } } \ No newline at end of file diff --git a/prefs.js b/prefs.js index 7ab5d60..c8fd65e 100644 --- a/prefs.js +++ b/prefs.js @@ -17,6 +17,7 @@ function fillPreferencesWindow(window) { page.add(group); const hiddenApps = settings.get_strv("hidden-apps"); + let hiddenSearchApps = settings.get_strv("hidden-search-apps"); if (hiddenApps.length === 0) { group.add(getNoAppsRow()); @@ -32,7 +33,7 @@ function fillPreferencesWindow(window) { }); const button = new Gtk.Button({ - icon_name: "list-remove", + icon_name: "edit-delete-symbolic", tooltip_text: "Unhide", }); @@ -48,8 +49,37 @@ function fillPreferencesWindow(window) { group.add(getNoAppsRow()); } }); + + const hideSearchButton = new Gtk.Button({ + icon_name: hiddenSearchApps.includes(appId) ? "edit-clear-symbolic" : "system-search-symbolic", + tooltip_text: hiddenSearchApps.includes(appId) ? "Unhide from search" : "Hide from search", + }); + + hideSearchButton.connect("clicked", (self) => { + const index = hiddenSearchApps.indexOf(appId); + if (index > -1) { + hiddenSearchApps.splice(index, 1); + } else { + hiddenSearchApps.push(appId); + } + + settings.set_strv("hidden-search-apps", hiddenSearchApps); + hideSearchButton.set_icon_name(hiddenSearchApps.includes(appId) ? "edit-clear-symbolic" : "system-search-symbolic"); + hideSearchButton.set_tooltip_text(hiddenSearchApps.includes(appId) ? "Unhide from search" : "Hide from search"); + }); + + const buttonBox = new Gtk.Box({ + orientation: Gtk.Orientation.HORIZONTAL, + spacing: 6, + margin_top: 8, + margin_bottom: 8, + }); + + buttonBox.append(hideSearchButton); + buttonBox.append(button); - row.add_suffix(button); + row.add_suffix(buttonBox); + group.add(row); } } diff --git a/schemas/gschemas.compiled b/schemas/gschemas.compiled index fd6c29f9eca66ebd6091a01b0e0f2746bf54392e..b99559f0ca783ace90195f8eea50051142a2d20d 100644 GIT binary patch delta 196 zcmZ3(^pt5r2;+~5q5AbK3=qHwq?myi#6M75$Ne7&egN653}p-qKuJv?{@S>vlL;sW zVhaJq9e}he5VMLhFo4v9*bEFl3?4u_0Emr5i{F9NgV@|a^$9>a6^Qi;5=%0G;`;eT q6JP6^7N;f_C1>a+78DeN^fNGMBo=D|DUfr3su?meQ&Lj%(BuIRcqo|w delta 133 zcmaFLw1#Oy2;-fJq56r;3<$skWFDxkcYthGhBAg1Kw6NIfx$?$_#H?d#O4Ny zD*$O#AZ8V1U;wEHu^AYA7&L&i4iM`VB$i}=geLwq7D+59CHidden apps Apps that are hidden + + [] + Hidden search apps + Apps that are hidden from search + From 1cc491cc85eb8dca6e514a67332c259b24db501f Mon Sep 17 00:00:00 2001 From: LynithDev <61880709+LynithDev@users.noreply.github.com> Date: Mon, 1 May 2023 12:56:24 +0200 Subject: [PATCH 2/2] Removed unused import --- patches/appDisplayPatcher.js | 1 - 1 file changed, 1 deletion(-) diff --git a/patches/appDisplayPatcher.js b/patches/appDisplayPatcher.js index 0683d3f..2c797de 100644 --- a/patches/appDisplayPatcher.js +++ b/patches/appDisplayPatcher.js @@ -1,6 +1,5 @@ const { BaseAppView, AppDisplay, FolderView, AppSearchProvider } = imports.ui.appDisplay; const Main = imports.ui.main; -const { Shell } = imports.gi; var AppDisplayPatcher = class AppDisplayPatcher { constructor(settings) {