[gnome-software/wip/hughsie/search-launchable: 8/9] Use the launchable when processing 'details-activated' from the shell
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/search-launchable: 8/9] Use the launchable when processing 'details-activated' from the shell
- Date: Tue, 16 Jul 2019 17:19:20 +0000 (UTC)
commit d6001f794fb4844152a0233d9909758b93ea093e
Author: Richard Hughes <richard hughsie com>
Date: Tue Jul 16 11:40:42 2019 +0100
Use the launchable when processing 'details-activated' from the shell
If the app-id in AppStream is different to the launchable then this is never
going to match. Fixes https://gitlab.gnome.org/GNOME/gnome-software/issues/577
plugins/core/gs-appstream.c | 1 +
src/gs-application.c | 49 ++++++++++++++++++++++++++++++++++++++-------
2 files changed, 43 insertions(+), 7 deletions(-)
---
diff --git a/plugins/core/gs-appstream.c b/plugins/core/gs-appstream.c
index 2999ab44..d582cbef 100644
--- a/plugins/core/gs-appstream.c
+++ b/plugins/core/gs-appstream.c
@@ -1074,6 +1074,7 @@ gs_appstream_search (GsPlugin *plugin,
{ AS_APP_SEARCH_MATCH_NAME, "name[text()~=stem(?)]" },
{ AS_APP_SEARCH_MATCH_KEYWORD, "keywords/keyword[text()~=stem(?)]" },
{ AS_APP_SEARCH_MATCH_ID, "id[text()~=stem(?)]" },
+ { AS_APP_SEARCH_MATCH_ID, "launchable[text()~=stem(?)]" },
{ AS_APP_SEARCH_MATCH_ORIGIN, "../components[@origin~=stem(?)]" },
{ AS_APP_SEARCH_MATCH_NONE, NULL }
};
diff --git a/src/gs-application.c b/src/gs-application.c
index c1d359ae..eec15ad0 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -547,6 +547,28 @@ search_activated (GSimpleAction *action,
gs_shell_show_search (app->shell, search);
}
+static void
+_search_launchable_details_cb (GObject *source, GAsyncResult *res, gpointer user_data)
+{
+ GsApp *a;
+ GsApplication *app = GS_APPLICATION (user_data);
+ g_autoptr(GError) error = NULL;
+ g_autoptr(GsAppList) list = NULL;
+
+ list = gs_plugin_loader_job_process_finish (app->plugin_loader, res, &error);
+ if (list == NULL) {
+ g_warning ("failed to find application: %s", error->message);
+ return;
+ }
+ if (gs_app_list_length (list) == 0) {
+ g_warning ("failed to find application");
+ return;
+ }
+ a = gs_app_list_index (list, 0);
+ gs_shell_reset_state (app->shell);
+ gs_shell_show_app (app->shell, a);
+}
+
static void
details_activated (GSimpleAction *action,
GVariant *parameter,
@@ -559,17 +581,30 @@ details_activated (GSimpleAction *action,
gs_application_present_window (app, NULL);
g_variant_get (parameter, "(&s&s)", &id, &search);
+ g_debug ("trying to activate %s:%s for details", id, search);
if (search != NULL && search[0] != '\0') {
gs_shell_reset_state (app->shell);
gs_shell_show_search_result (app->shell, id, search);
} else {
- g_autoptr (GsApp) a = NULL;
- if (as_utils_unique_id_valid (id))
- a = gs_plugin_loader_app_create (app->plugin_loader, id);
- else
- a = gs_app_new (id);
- gs_shell_reset_state (app->shell);
- gs_shell_show_app (app->shell, a);
+ g_autoptr(GsPluginJob) plugin_job = NULL;
+ if (as_utils_unique_id_valid (id)) {
+ g_autoptr(GsApp) a = gs_plugin_loader_app_create (app->plugin_loader, id);
+ gs_shell_reset_state (app->shell);
+ gs_shell_show_app (app->shell, a);
+ return;
+ }
+
+ /* find by launchable */
+ plugin_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_SEARCH,
+ "search", id,
+ "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_ICON,
+ "dedupe-flags", GS_APP_LIST_FILTER_FLAG_PREFER_INSTALLED |
+ GS_APP_LIST_FILTER_FLAG_KEY_ID_PROVIDES,
+ NULL);
+ gs_plugin_loader_job_process_async (app->plugin_loader, plugin_job,
+ app->cancellable,
+ _search_launchable_details_cb,
+ app);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]