The patch adds a functionality to present a user with an error dialog (in
addition to writting a message to console), when there is a connection
failure.
Using the notifications would be an option, but I think a dialog is more
appropriate in this case, because notifications can be disabled and we really
want to alert the user.
Jirka
>From d947c6366be6e13d3eaf5aea0f874fb494a22b73 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?=
Date: Mon, 19 Mar 2012 11:02:45 +0100
Subject: [PATCH] applet: show an error dialog on connection failures
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Show the user an error dialog, when connection activation failed, so that
he knows what's the problem. This is useful mainly for situations when
user is not allowed to perform an action, PolicyKit is misconfigured or
something.
Signed-off-by: Jiří Klimeš
---
src/applet-device-wifi.c| 22 +---
src/applet.c| 33 +++---
src/gconf-helpers/tests/Makefile.am |2 +
src/utils/utils.c | 37 +++
src/utils/utils.h |7 ++
5 files changed, 89 insertions(+), 12 deletions(-)
diff --git a/src/applet-device-wifi.c b/src/applet-device-wifi.c
index f17324c..15fcf7b 100644
--- a/src/applet-device-wifi.c
+++ b/src/applet-device-wifi.c
@@ -1377,8 +1377,15 @@ activate_existing_cb (NMClient *client,
GError *error,
gpointer user_data)
{
- if (error)
- g_warning ("Failed to activate connection: (%d) %s", error->code, error->message);
+ if (error) {
+ const char *text = _("Failed to activate connection");
+ char *err_text = g_strdup_printf ("(%d) %s", error->code,
+ error->message ? error->message : _("Unknown error"));
+
+ g_warning ("%s: %s", text, err_text);
+ utils_show_error_dialog (_("Connection failure"), text, err_text, FALSE, NULL);
+ g_free (err_text);
+ }
applet_schedule_update_icon (NM_APPLET (user_data));
}
@@ -1389,8 +1396,15 @@ activate_new_cb (NMClient *client,
GError *error,
gpointer user_data)
{
- if (error)
- g_warning ("Failed to add new connection: (%d) %s", error->code, error->message);
+ if (error) {
+ const char *text = _("Failed to add new connection");
+ char *err_text = g_strdup_printf ("(%d) %s", error->code,
+ error->message ? error->message : _("Unknown error"));
+
+ g_warning ("%s: %s", text, err_text);
+ utils_show_error_dialog (_("Connection failure"), text, err_text, FALSE, NULL);
+ g_free (err_text);
+ }
applet_schedule_update_icon (NM_APPLET (user_data));
}
diff --git a/src/applet.c b/src/applet.c
index cb5b5e4..c7a362e 100644
--- a/src/applet.c
+++ b/src/applet.c
@@ -483,8 +483,15 @@ add_and_activate_cb (NMClient *client,
GError *error,
gpointer user_data)
{
- if (error)
- g_warning ("Failed to add/activate connection: (%d) %s", error->code, error->message);
+ if (error) {
+ const char *text = _("Failed to add/activate connection");
+ char *err_text = g_strdup_printf ("(%d) %s", error->code,
+ error->message ? error->message : _("Unknown error"));
+
+ g_warning ("%s: %s", text, err_text);
+ utils_show_error_dialog (_("Connection failure"), text, err_text, FALSE, NULL);
+ g_free (err_text);
+ }
applet_schedule_update_icon (NM_APPLET (user_data));
}
@@ -521,10 +528,13 @@ static void
disconnect_cb (NMDevice *device, GError *error, gpointer user_data)
{
if (error) {
- g_warning ("%s: device disconnect failed: (%d) %s",
- __func__,
- error ? error->code : -1,
- error && error->message ? error->message : "(unknown)");
+ const char *text = _("Device disconnect failed");
+ char *err_text = g_strdup_printf ("(%d) %s", error->code,
+ error->message ? error->message : _("Unknown error"));
+
+ g_warning ("%s: %s: %s", __func__, text, err_text);
+ utils_show_error_dialog (_("Disconnect failure"), text, err_text, FALSE, NULL);
+ g_free (err_text);
}
}
@@ -543,8 +553,15 @@ activate_connection_cb (NMClient *client,
GError *error,
gpointer user_data)
{
- if (error)
- g_warning ("Connection activation failed: %s", error->message);
+ if (error) {
+ const char *text = _("Connection activation failed");
+ char *err_text = g_strdup_printf ("(%d) %s", error