Skip to content

Commit

Permalink
AppsPlugin: add switch to ignore XDG OnlyShowIn Desktop Attr
Browse files Browse the repository at this point in the history
  • Loading branch information
UffeJakobsen committed Aug 29, 2024
1 parent 56350ed commit 3267a8c
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion catapult/plugins/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,38 @@
import re

from catapult.api import Plugin
from catapult.api import PreferencesItem
from catapult.api import SearchResult
from catapult.i18n import _
from gi.repository import Gio
from gi.repository import Gtk


class AppsPluginPrefs(PreferencesItem):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.label = Gtk.Label(label=_("Ignore OnlyShowIn Attr"))
self.widget = Gtk.Switch()
self.widget.connect("notify::active", self._on_widget_notify_active)

def _on_widget_notify_active(self, *args, **kwargs):
return

def dump(self, window):
value = self.conf.ignore_only_show_in
self.widget.set_active(value)

def load(self, window):
value = self.widget.get_active()
self.conf.ignore_only_show_in = value


class AppsPlugin(Plugin):

title = _("Apps")
conf_defaults = {"ignore_only_show_in": False}
preferences_items = [AppsPluginPrefs]

def __init__(self):
super().__init__()
Expand Down Expand Up @@ -54,7 +79,8 @@ def launch(self, window, id):
def _list_apps(self):
key = lambda x: x.get_filename().lower()
for app in sorted(Gio.AppInfo.get_all(), key=key):
if not app.should_show(): continue
if not self.conf.ignore_only_show_in:
if not app.should_show(): continue
id = app.get_id()
if id == "io.otsaloma.catapult.desktop": continue
yield id, app
Expand Down

0 comments on commit 3267a8c

Please sign in to comment.