[network-manager-applet] c-e: show error message when --import fails
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet] c-e: show error message when --import fails
- Date: Sat, 4 Feb 2017 19:19:14 +0000 (UTC)
commit 0597513de7d196cce976b26d70f322f739a93c2d
Author: Thomas Haller <thaller redhat com>
Date: Sat Feb 4 19:57:57 2017 +0100
c-e: show error message when --import fails
When --import fails, previously the code would silently proceed and show a dialog
to select a VPN type for creation. Instead an error message should be shown.
The reason the error message was not shown is because at the point when
vpn_connection_from_file() was called, the mainloop was not yet initialized
to show the dialog. Delay the call to vpn_connection_from_file().
It is still broken however, in that nm-c-e would not exit after closing
the error dialog.
src/connection-editor/main.c | 8 ++++----
src/connection-editor/nm-connection-list.c | 10 +++++++++-
src/connection-editor/nm-connection-list.h | 2 +-
3 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/connection-editor/main.c b/src/connection-editor/main.c
index b4eac54..a942369 100644
--- a/src/connection-editor/main.c
+++ b/src/connection-editor/main.c
@@ -55,7 +55,7 @@ typedef struct {
NMConnectionList *list;
GType ctype;
char *detail;
- NMConnection *connection;
+ char *import_filename;
} CreateConnectionInfo;
static gboolean
@@ -73,12 +73,12 @@ idle_create_connection (gpointer user_data)
} else {
/* import */
nm_connection_list_create (info->list, info->ctype,
- info->detail, info->connection);
+ info->detail, info->import_filename);
}
g_object_unref (info->list);
g_free (info->detail);
- nm_g_object_unref (info->connection);
+ g_free (info->import_filename);
g_slice_free (CreateConnectionInfo, info);
return FALSE;
}
@@ -136,7 +136,7 @@ handle_arguments (NMConnectionList *list,
info->ctype = ctype;
else {
info->ctype = NM_TYPE_SETTING_VPN;
- info->connection = vpn_connection_from_file (import);
+ info->import_filename = g_strdup (import);
}
g_idle_add (idle_create_connection, info);
show_list = FALSE;
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index c1d8b11..9368f8b 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -919,7 +919,7 @@ void
nm_connection_list_create (NMConnectionList *self,
GType ctype,
const char *detail,
- NMConnection *connection)
+ const char *import_filename)
{
ConnectionTypeData *types;
int i;
@@ -933,6 +933,7 @@ nm_connection_list_create (NMConnectionList *self,
|| types[i].setting_types[2] == ctype)
break;
}
+
if (!types[i].name) {
if (ctype == NM_TYPE_SETTING_VPN) {
nm_connection_editor_error (NULL, _("Error creating connection"),
@@ -942,6 +943,13 @@ nm_connection_list_create (NMConnectionList *self,
_("Don’t know how to create “%s” connections"),
g_type_name (ctype));
}
} else {
+ gs_unref_object NMConnection *connection = NULL;
+
+ if (import_filename) {
+ connection = vpn_connection_from_file (import_filename);
+ if (!connection)
+ return;
+ }
new_connection_of_type (GTK_WINDOW (self->dialog),
detail,
NULL,
diff --git a/src/connection-editor/nm-connection-list.h b/src/connection-editor/nm-connection-list.h
index 15f38b6..1db3ec8 100644
--- a/src/connection-editor/nm-connection-list.h
+++ b/src/connection-editor/nm-connection-list.h
@@ -65,7 +65,7 @@ NMConnectionList *nm_connection_list_new (void);
void nm_connection_list_set_type (NMConnectionList *list, GType ctype);
void nm_connection_list_present (NMConnectionList *list);
-void nm_connection_list_create (NMConnectionList *list, GType ctype, const char *detail,
NMConnection *connection);
+void nm_connection_list_create (NMConnectionList *list, GType ctype, const char *detail, const
char *import_filename);
void nm_connection_list_edit (NMConnectionList *list, const gchar *uuid);
void nm_connection_list_add (NMConnectionList *list);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]