diff --git a/src/gs-application.c b/src/gs-application.c index 9c2676ef3b4908caf1ec71b0e795f9b783b766d3..06f811a08f3b8f383e4a012839340480e69762d0 100644 --- a/src/gs-application.c +++ b/src/gs-application.c @@ -798,9 +798,10 @@ install_resources_activated (GSimpleAction *action, GdkDisplay *display; const gchar *mode; const gchar *startup_id; + const gchar *desktop_id; g_autofree gchar **resources = NULL; - g_variant_get (parameter, "(&s^a&s&s)", &mode, &resources, &startup_id); + g_variant_get (parameter, "(&s^a&s&s&s)", &mode, &resources, &startup_id, &desktop_id); display = gdk_display_get_default (); #ifdef GDK_WINDOWING_X11 @@ -821,7 +822,7 @@ install_resources_activated (GSimpleAction *action, gs_application_present_window (app, startup_id); gs_shell_reset_state (app->shell); - gs_shell_show_extras_search (app->shell, mode, resources); + gs_shell_show_extras_search (app->shell, mode, resources, desktop_id); } static GActionEntry actions[] = { @@ -846,7 +847,7 @@ static GActionEntry actions_after_loading[] = { { "details-url", details_url_activated, "(s)", NULL, NULL }, { "install", install_activated, "(su)", NULL, NULL }, { "filename", filename_activated, "(s)", NULL, NULL }, - { "install-resources", install_resources_activated, "(sass)", NULL, NULL }, + { "install-resources", install_resources_activated, "(sasss)", NULL, NULL }, { "nop", NULL, NULL, NULL } }; diff --git a/src/gs-dbus-helper.c b/src/gs-dbus-helper.c index b90ff98006d33377717c34c366eb91a529a606da..85325a49571ebe4200692bf50f28290d92cb905e 100644 --- a/src/gs-dbus-helper.c +++ b/src/gs-dbus-helper.c @@ -321,7 +321,7 @@ notify_search_resources (GsExtrasPageMode mode, g_notification_set_body (n, body); /* TRANSLATORS: this is a button that launches gnome-software */ g_notification_add_button_with_target (n, _("Find in Software"), "app.install-resources", "(s^ass)", mode_string, resources, ""); - g_notification_set_default_action_and_target (n, "app.install-resources", "(s^ass)", mode_string, resources, ""); + g_notification_set_default_action_and_target (n, "app.install-resources", "(s^asss)", mode_string, resources, "", desktop_id); g_application_send_notification (g_application_get_default (), "install-resources", n); } @@ -349,7 +349,7 @@ install_resources (GsExtrasPageMode mode, app = g_application_get_default (); mode_string = gs_extras_page_mode_to_string (mode); g_action_group_activate_action (G_ACTION_GROUP (app), "install-resources", - g_variant_new ("(s^ass)", mode_string, resources, startup_id)); + g_variant_new ("(s^asss)", mode_string, resources, startup_id, desktop_id)); } static gboolean diff --git a/src/gs-extras-page.c b/src/gs-extras-page.c index 9b9aeece28cc388a79a7717d2ab219d91773eda1..ec1e97a4b9c3f9149b6cedc4ebd9441c0b3cd65b 100644 --- a/src/gs-extras-page.c +++ b/src/gs-extras-page.c @@ -54,6 +54,7 @@ struct _GsExtrasPage GsLanguage *language; GsVendor *vendor; guint pending_search_cnt; + gchar *caller_app_name; GtkWidget *label_failed; GtkWidget *label_no_results; @@ -452,12 +453,23 @@ build_no_results_label (GsExtrasPage *self) url = g_strdup_printf ("%s", gs_app_get_url (app, AS_URL_KIND_MISSING), /* TRANSLATORS: hyperlink title */ - _("this website")); + _("the documentation")); codec_titles = build_comma_separated_list ((gchar **) array->pdata); - /* TRANSLATORS: no codecs were found. First %s will be replaced by actual codec name(s), second %s is a link titled "this website" */ - return g_strdup_printf (ngettext ("Unfortunately, the %s you were searching for could not be found. Please see %s for more information.", - "Unfortunately, the %s you were searching for could not be found. Please see %s for more information.", + if (self->caller_app_name) { + /* TRANSLATORS: no codecs were found. The first %s will be replaced by actual codec name(s), + the second %s is the application name, which requested the codecs, the third %s is a link titled "the documentation" */ + return g_strdup_printf (ngettext ("Unable to find the %s requested by %s. Please see %s for more information.", + "Unable to find the %s requested by %s. Please see %s for more information.", + num), + codec_titles, + self->caller_app_name, + url); + } + + /* TRANSLATORS: no codecs were found. First %s will be replaced by actual codec name(s), second %s is a link titled "the documentation" */ + return g_strdup_printf (ngettext ("Unable to find the %s you were searching for. Please see %s for more information.", + "Unable to find the %s you were searching for. Please see %s for more information.", num), codec_titles, url); @@ -974,12 +986,31 @@ gs_extras_page_search_printer_drivers (GsExtrasPage *self, gchar **device_ids) gs_extras_page_load (self, array_search_data); } +static gchar * +gs_extras_page_get_app_name (const gchar *desktop_id) +{ + g_autoptr(GDesktopAppInfo) app_info = NULL; + + if (!desktop_id || !*desktop_id) + return NULL; + + app_info = g_desktop_app_info_new (desktop_id); + if (!app_info) + return NULL; + + return g_strdup (g_app_info_get_display_name (G_APP_INFO (app_info))); +} + void gs_extras_page_search (GsExtrasPage *self, const gchar *mode_str, - gchar **resources) + gchar **resources, + const gchar *desktop_id) { self->mode = gs_extras_page_mode_from_string (mode_str); + g_clear_pointer (&self->caller_app_name, g_free); + self->caller_app_name = gs_extras_page_get_app_name (desktop_id); + switch (self->mode) { case GS_EXTRAS_PAGE_MODE_INSTALL_PACKAGE_FILES: gs_extras_page_search_package_files (self, resources); @@ -1164,6 +1195,7 @@ gs_extras_page_dispose (GObject *object) g_clear_object (&self->plugin_loader); g_clear_pointer (&self->array_search_data, g_ptr_array_unref); + g_clear_pointer (&self->caller_app_name, g_free); G_OBJECT_CLASS (gs_extras_page_parent_class)->dispose (object); } diff --git a/src/gs-extras-page.h b/src/gs-extras-page.h index e4dc0010b767e3e98f1c92057b013aff62694c82..ad248b50681258d1d2ddd0dbdfe1e7a1b80d0b5f 100644 --- a/src/gs-extras-page.h +++ b/src/gs-extras-page.h @@ -34,6 +34,7 @@ const gchar *gs_extras_page_mode_to_string (GsExtrasPageMode mode); GsExtrasPage *gs_extras_page_new (void); void gs_extras_page_search (GsExtrasPage *self, const gchar *mode, - gchar **resources); + gchar **resources, + const gchar *desktop_id); G_END_DECLS diff --git a/src/gs-shell.c b/src/gs-shell.c index 44663b2ec87448d03d26bad3d85dac7dc9e71c21..7c8cb2d4adcef00def5283e357326950725e7a33 100644 --- a/src/gs-shell.c +++ b/src/gs-shell.c @@ -2402,7 +2402,7 @@ gs_shell_show_category (GsShell *shell, GsCategory *category) gs_shell_change_mode (shell, GS_SHELL_MODE_CATEGORY, category, TRUE); } -void gs_shell_show_extras_search (GsShell *shell, const gchar *mode, gchar **resources) +void gs_shell_show_extras_search (GsShell *shell, const gchar *mode, gchar **resources, const gchar *desktop_id) { GsShellPrivate *priv = gs_shell_get_instance_private (shell); GsPage *page; @@ -2410,7 +2410,7 @@ void gs_shell_show_extras_search (GsShell *shell, const gchar *mode, gchar **res page = GS_PAGE (gtk_builder_get_object (priv->builder, "extras_page")); save_back_entry (shell); - gs_extras_page_search (GS_EXTRAS_PAGE (page), mode, resources); + gs_extras_page_search (GS_EXTRAS_PAGE (page), mode, resources, desktop_id); gs_shell_change_mode (shell, GS_SHELL_MODE_EXTRAS, NULL, TRUE); gs_shell_activate (shell); } diff --git a/src/gs-shell.h b/src/gs-shell.h index a02d24d74cf6705946e92d3445c69842969b6361..7259b722eec35ca2b9dfdcb5980477cd34d26942 100644 --- a/src/gs-shell.h +++ b/src/gs-shell.h @@ -81,7 +81,8 @@ void gs_shell_show_search_result (GsShell *shell, const gchar *search); void gs_shell_show_extras_search (GsShell *shell, const gchar *mode, - gchar **resources); + gchar **resources, + const gchar *desktop_id); void gs_shell_show_uri (GsShell *shell, const gchar *url); void gs_shell_setup (GsShell *shell,