[gnome-software/1103-gs-application-search-for-the-installed-application-in-app-launch] gs-application: Search for the installed application in app.launch
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/1103-gs-application-search-for-the-installed-application-in-app-launch] gs-application: Search for the installed application in app.launch
- Date: Tue, 1 Dec 2020 18:17:46 +0000 (UTC)
commit ad0e68b45af5287ad5e609674a3747b649fc18c4
Author: Milan Crha <mcrha redhat com>
Date: Tue Dec 1 19:14:49 2020 +0100
gs-application: Search for the installed application in app.launch
Clicking 'Launch' button in the "application was installed" bubble doesn't
launch just installed flatpak application. The problem is that the app.launch
is called only with the application ID, and then a GsApp instance is just
created from this ID, which is not enough to even refine the internal things,
because the app doesn't know what plugin it belongs to.
The fix is to:
* pass both management plugin and the application ID to app.launch
* search for the application by its ID
* traverse returned list of found applications and find a matched installed application from the given
plugin
* launch the found application
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/issues/1103
Closes https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/555
src/gs-application.c | 42 +++++++++++++++++++++++++++++++-----------
src/gs-common.c | 5 +++--
2 files changed, 34 insertions(+), 13 deletions(-)
---
diff --git a/src/gs-application.c b/src/gs-application.c
index 06f811a0..cfd32478 100644
--- a/src/gs-application.c
+++ b/src/gs-application.c
@@ -741,22 +741,42 @@ launch_activated (GSimpleAction *action,
gpointer data)
{
GsApplication *self = GS_APPLICATION (data);
- const gchar *id;
- g_autoptr(GsApp) app = NULL;
- g_autoptr(GsPluginJob) refine_job = NULL;
+ GsApp *app = NULL;
+ const gchar *id, *management_plugin;
+ g_autoptr(GsAppList) list = NULL;
+ g_autoptr(GsPluginJob) search_job = NULL;
g_autoptr(GsPluginJob) launch_job = NULL;
g_autoptr(GError) error = NULL;
+ guint ii, len;
- id = g_variant_get_string (parameter, NULL);
- app = gs_app_new (id);
- refine_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_REFINE,
- "app", app,
- "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION,
+ g_variant_get (parameter, "(&s&s)", &id, &management_plugin);
+
+ search_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_SEARCH,
+ "search", id,
+ "refine-flags", GS_PLUGIN_REFINE_FLAGS_REQUIRE_DESCRIPTION |
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_PERMISSIONS |
+ GS_PLUGIN_REFINE_FLAGS_REQUIRE_RUNTIME,
NULL);
- if (!gs_plugin_loader_job_action (self->plugin_loader, refine_job, self->cancellable, &error)) {
- g_warning ("Failed to refine app: %s", error->message);
+ list = gs_plugin_loader_job_process (self->plugin_loader, search_job, self->cancellable, &error);
+ if (!list) {
+ g_warning ("Failed to search for application '%s' (from '%s'): %s", id, management_plugin,
error ? error->message : "Unknown error");
return;
}
+
+ len = gs_app_list_length (list);
+ for (ii = 0; ii < len && !app; ii++) {
+ GsApp *list_app = gs_app_list_index (list, ii);
+
+ if (gs_app_is_installed (list_app) &&
+ g_strcmp0 (gs_app_get_management_plugin (list_app), management_plugin) == 0)
+ app = list_app;
+ }
+
+ if (!app) {
+ g_warning ("Did not find application '%s' from '%s'", id, management_plugin);
+ return;
+ }
+
launch_job = gs_plugin_job_newv (GS_PLUGIN_ACTION_LAUNCH,
"app", app,
NULL);
@@ -831,7 +851,7 @@ static GActionEntry actions[] = {
{ "reboot-and-install", reboot_and_install, NULL, NULL, NULL },
{ "reboot", reboot_activated, NULL, NULL, NULL },
{ "shutdown", shutdown_activated, NULL, NULL, NULL },
- { "launch", launch_activated, "s", NULL, NULL },
+ { "launch", launch_activated, "(ss)", NULL, NULL },
{ "show-offline-update-error", show_offline_updates_error, NULL, NULL, NULL },
{ "autoupdate", autoupdate_activated, NULL, NULL, NULL },
{ "nop", NULL, NULL, NULL }
diff --git a/src/gs-common.c b/src/gs-common.c
index 1d616e7c..1e5358bf 100644
--- a/src/gs-common.c
+++ b/src/gs-common.c
@@ -162,8 +162,9 @@ gs_app_notify_installed (GsApp *app)
} else if (gs_app_get_kind (app) == AS_APP_KIND_DESKTOP) {
/* TRANSLATORS: this is button that opens the newly installed application */
g_notification_add_button_with_target (n, _("Launch"),
- "app.launch", "s",
- gs_app_get_id (app));
+ "app.launch", "(ss)",
+ gs_app_get_id (app),
+ gs_app_get_management_plugin (app));
}
g_notification_set_default_action_and_target (n, "app.details", "(ss)",
gs_app_get_unique_id (app), "");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]