Skip to content

Commit

Permalink
Merge pull request #8 from LynithDev/master
Browse files Browse the repository at this point in the history
  • Loading branch information
LynithDev authored May 1, 2023
2 parents 7062000 + 1cc491c commit 838a201
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 4 deletions.
2 changes: 1 addition & 1 deletion metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Hide apps in GNOME's app menu",
"uuid": "[email protected]",
"settings-schema": "org.gnome.shell.extensions.app-hider",
"version": 4,
"version": 6,
"url": "https://github.com/LynithDev/gnome-app-hider",
"shell-version": [
"42",
Expand Down
27 changes: 26 additions & 1 deletion patches/appDisplayPatcher.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
const { BaseAppView, AppDisplay, FolderView } = imports.ui.appDisplay;
const { BaseAppView, AppDisplay, FolderView, AppSearchProvider } = imports.ui.appDisplay;
const Main = imports.ui.main;

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;

Expand Down Expand Up @@ -35,10 +58,12 @@ var AppDisplayPatcher = class AppDisplayPatcher {
}

enable() {
this._patchAppSearchProvider();
this._patchAppView();
}

disable() {
this._unpatchAppSearchProvider();
this._unpatchAppView();
}
}
34 changes: 32 additions & 2 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -32,7 +33,7 @@ function fillPreferencesWindow(window) {
});

const button = new Gtk.Button({
icon_name: "list-remove",
icon_name: "edit-delete-symbolic",
tooltip_text: "Unhide",
});

Expand All @@ -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);
}
}
Expand Down
Binary file modified schemas/gschemas.compiled
Binary file not shown.
5 changes: 5 additions & 0 deletions schemas/org.gnome.shell.extensions.app-hider.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,10 @@
<summary>Hidden apps</summary>
<description>Apps that are hidden</description>
</key>
<key name="hidden-search-apps" type="as">
<default>[]</default>
<summary>Hidden search apps</summary>
<description>Apps that are hidden from search</description>
</key>
</schema>
</schemalist>

0 comments on commit 838a201

Please sign in to comment.