From c7883e596b1b7037ae2bb97d1902189c9061fbe8 Mon Sep 17 00:00:00 2001 From: kramo Date: Mon, 1 Dec 2025 15:11:24 +0100 Subject: [PATCH] window: Implement search on action --- cartridges/ui/window.blp | 52 ++++++++++++++++++++++++++++++++++++++++ cartridges/ui/window.py | 8 +++++++ 2 files changed, 60 insertions(+) diff --git a/cartridges/ui/window.blp b/cartridges/ui/window.blp index 67a9971..7f42da0 100644 --- a/cartridges/ui/window.blp +++ b/cartridges/ui/window.blp @@ -368,6 +368,58 @@ template $Window: Adw.ApplicationWindow { "circular", ] } + + MenuButton { + icon-name: "edit-find-symbolic"; + tooltip-text: _("Search On"); + valign: center; + + menu-model: menu { + section { + label: _("Search On"); + + item { + label: _("HowLongToBeat"); + action: "win.search-on"; + target: "https://howlongtobeat.com/?q={}"; + } + + item { + label: _("IGDB"); + action: "win.search-on"; + target: "https://www.igdb.com/search?type=1&q={}"; + } + + item { + label: _("Lutris"); + action: "win.search-on"; + target: "https://lutris.net/games?q={}"; + } + + item { + label: _("PCGamingWiki"); + action: "win.search-on"; + target: "https://www.pcgamingwiki.com/w/index.php?search={}"; + } + + item { + label: _("ProtonDB"); + action: "win.search-on"; + target: "https://www.protondb.com/search?q={}"; + } + + item { + label: _("SteamGridDB"); + action: "win.search-on"; + target: "https://www.steamgriddb.com/search/grids?term={}"; + } + } + }; + + styles [ + "circular", + ] + } } } } diff --git a/cartridges/ui/window.py b/cartridges/ui/window.py index afb33c5..f350b45 100644 --- a/cartridges/ui/window.py +++ b/cartridges/ui/window.py @@ -7,6 +7,7 @@ from collections.abc import Generator from datetime import UTC, datetime from gettext import gettext as _ from typing import Any, TypeVar +from urllib.parse import quote from gi.repository import Adw, Gdk, Gio, GLib, GObject, Gtk @@ -83,6 +84,13 @@ class Window(Adw.ApplicationWindow): "s", state_settings.get_value("sort-mode").print_(False), ), + ( + "search-on", + lambda _action, param, *_: Gio.AppInfo.launch_default_for_uri( + param.get_string().format(quote(self.active_game.name)) + ), + "s", + ), )) @Gtk.Template.Callback()