Add ability to search for games
This commit is contained in:
@@ -159,9 +159,7 @@ template CartridgesWindow : Adw.ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Box {
|
Box {
|
||||||
hexpand: true;
|
|
||||||
halign: start;
|
halign: start;
|
||||||
vexpand: true;
|
|
||||||
valign: center;
|
valign: center;
|
||||||
margin-top: 24;
|
margin-top: 24;
|
||||||
margin-start: 12;
|
margin-start: 12;
|
||||||
@@ -191,11 +189,25 @@ template CartridgesWindow : Adw.ApplicationWindow {
|
|||||||
"circular",
|
"circular",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
styles [
|
styles [
|
||||||
"linked",
|
"linked",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MenuButton {
|
||||||
|
halign: start;
|
||||||
|
valign: center;
|
||||||
|
margin-top: 24;
|
||||||
|
margin-start: 12;
|
||||||
|
icon-name: "system-search-symbolic";
|
||||||
|
menu-model: search;
|
||||||
|
tooltip-text: _("Search");
|
||||||
|
|
||||||
|
styles [
|
||||||
|
"circular",
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -417,3 +429,29 @@ menu add_games {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menu search {
|
||||||
|
section {
|
||||||
|
label: "Search on…";
|
||||||
|
item {
|
||||||
|
label: "IGDB";
|
||||||
|
action: "app.igdb_search";
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
label: "SteamGridDB";
|
||||||
|
action: "app.sgdb_search";
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
label: "ProtonDB";
|
||||||
|
action: "app.protondb_search";
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
label: "Lutris";
|
||||||
|
action: "app.lutris_search";
|
||||||
|
}
|
||||||
|
item {
|
||||||
|
label: "HowLongToBeat";
|
||||||
|
action: "app.hltb_search";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
src/main.py
25
src/main.py
@@ -60,6 +60,11 @@ class CartridgesApplication(Adw.Application):
|
|||||||
"remove_game_overview", self.on_remove_game_overview_action, ["Delete"]
|
"remove_game_overview", self.on_remove_game_overview_action, ["Delete"]
|
||||||
)
|
)
|
||||||
self.create_action("remove_game", self.on_remove_game_action)
|
self.create_action("remove_game", self.on_remove_game_action)
|
||||||
|
self.create_action("igdb_search", self.on_igdb_search_action)
|
||||||
|
self.create_action("sgdb_search", self.on_sgdb_search_action)
|
||||||
|
self.create_action("protondb_search", self.on_protondb_search_action)
|
||||||
|
self.create_action("lutris_search", self.on_lutris_search_action)
|
||||||
|
self.create_action("hltb_search", self.on_hltb_search_action)
|
||||||
|
|
||||||
self.win = None
|
self.win = None
|
||||||
|
|
||||||
@@ -243,6 +248,26 @@ class CartridgesApplication(Adw.Application):
|
|||||||
def on_quit_action(self, _widget, _callback=None):
|
def on_quit_action(self, _widget, _callback=None):
|
||||||
self.quit()
|
self.quit()
|
||||||
|
|
||||||
|
def search(self, uri):
|
||||||
|
Gio.AppInfo.launch_default_for_uri(
|
||||||
|
f"{uri}{self.win.games[self.win.active_game_id].name}"
|
||||||
|
)
|
||||||
|
|
||||||
|
def on_igdb_search_action(self, _widget, _callback=None):
|
||||||
|
self.search("https://www.igdb.com/search?type=1&q=")
|
||||||
|
|
||||||
|
def on_sgdb_search_action(self, _widget, _callback=None):
|
||||||
|
self.search("https://www.steamgriddb.com/search/grids?term=")
|
||||||
|
|
||||||
|
def on_protondb_search_action(self, _widget, _callback=None):
|
||||||
|
self.search("https://www.protondb.com/search?q=")
|
||||||
|
|
||||||
|
def on_lutris_search_action(self, _widget, _callback=None):
|
||||||
|
self.search("https://lutris.net/games?q=")
|
||||||
|
|
||||||
|
def on_hltb_search_action(self, _widget, _callback=None):
|
||||||
|
self.search("https://howlongtobeat.com/?q=")
|
||||||
|
|
||||||
def create_action(self, name, callback, shortcuts=None, win=None):
|
def create_action(self, name, callback, shortcuts=None, win=None):
|
||||||
action = Gio.SimpleAction.new(name, None)
|
action = Gio.SimpleAction.new(name, None)
|
||||||
action.connect("activate", callback)
|
action.connect("activate", callback)
|
||||||
|
|||||||
Reference in New Issue
Block a user