[gnome-software/wip/hughsie/show-event-on-file-not-supported: 3/3] Show an in-application notification when a local file or URI is not supported
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/wip/hughsie/show-event-on-file-not-supported: 3/3] Show an in-application notification when a local file or URI is not supported
- Date: Wed, 31 Jan 2018 14:50:46 +0000 (UTC)
commit e8c34c4303143784a2266ffd4a6b35a2df1a56ec
Author: Richard Hughes <richard hughsie com>
Date: Tue Jan 30 14:02:38 2018 +0000
Show an in-application notification when a local file or URI is not supported
This can be reproduced doing: xdg-open appstream://this.is.invalid
Fixes https://gitlab.gnome.org/GNOME/gnome-software/issues/236
src/gs-shell.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
---
diff --git a/src/gs-shell.c b/src/gs-shell.c
index ae9eab5f..6e54dd1e 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -1469,6 +1469,10 @@ gs_shell_show_event_file_to_app (GsShell *shell, GsPluginEvent *event)
g_autoptr(GString) str = g_string_new (NULL);
switch (error->code) {
+ case GS_PLUGIN_ERROR_NOT_SUPPORTED:
+ /* TRANSLATORS: failure text for the in-app notification */
+ g_string_append (str, _("Failed to install file: not supported"));
+ break;
case GS_PLUGIN_ERROR_NO_SECURITY:
/* TRANSLATORS: failure text for the in-app notification */
g_string_append (str, _("Failed to install file: "
@@ -1499,6 +1503,48 @@ gs_shell_show_event_file_to_app (GsShell *shell, GsPluginEvent *event)
return TRUE;
}
+static gboolean
+gs_shell_show_event_url_to_app (GsShell *shell, GsPluginEvent *event)
+{
+ GsShellEventButtons buttons = GS_SHELL_EVENT_BUTTON_NONE;
+ const GError *error = gs_plugin_event_get_error (event);
+ g_autoptr(GString) str = g_string_new (NULL);
+
+ switch (error->code) {
+ case GS_PLUGIN_ERROR_NOT_SUPPORTED:
+ /* TRANSLATORS: failure text for the in-app notification */
+ g_string_append (str, _("Failed to install from URI: not supported"));
+ break;
+ case GS_PLUGIN_ERROR_NO_SECURITY:
+ /* TRANSLATORS: failure text for the in-app notification */
+ g_string_append (str, _("Failed to install from URI: "
+ "authentication failed"));
+ break;
+ case GS_PLUGIN_ERROR_NO_SPACE:
+ /* TRANSLATORS: failure text for the in-app notification */
+ g_string_append (str, _("Not enough disk space — free up some space "
+ "and try again"));
+ buttons |= GS_SHELL_EVENT_BUTTON_NO_SPACE;
+ break;
+ case GS_PLUGIN_ERROR_CANCELLED:
+ break;
+ default:
+ /* TRANSLATORS: we failed to get a proper error code */
+ g_string_append (str, _("Sorry, something went wrong"));
+ break;
+ }
+ if (str->len == 0)
+ return FALSE;
+
+ /* add extra debugging for debug builds */
+ if (gs_shell_show_detailed_error (shell, error))
+ g_string_append_printf (str, "\n%s", error->message);
+
+ /* show in-app notification */
+ gs_shell_show_event_app_notify (shell, str->str, buttons);
+ return TRUE;
+}
+
static gboolean
gs_shell_show_event_fallback (GsShell *shell, GsPluginEvent *event)
{
@@ -1610,8 +1656,9 @@ gs_shell_show_event (GsShell *shell, GsPluginEvent *event)
case GS_PLUGIN_ACTION_LAUNCH:
return gs_shell_show_event_launch (shell, event);
case GS_PLUGIN_ACTION_FILE_TO_APP:
- case GS_PLUGIN_ACTION_URL_TO_APP:
return gs_shell_show_event_file_to_app (shell, event);
+ case GS_PLUGIN_ACTION_URL_TO_APP:
+ return gs_shell_show_event_url_to_app (shell, event);
default:
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]