diff options
author | Thomas Haller <thaller@redhat.com> | 2017-02-04 19:57:57 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2017-02-04 20:17:44 +0100 |
commit | 0597513de7d196cce976b26d70f322f739a93c2d (patch) | |
tree | e349f6521a588112713771455fe1afe8728e6f19 | |
parent | 2e3d3351a7208aba55954b2ad25b83843f4c6af7 (diff) | |
download | network-manager-applet-0597513de7d196cce976b26d70f322f739a93c2d.tar.gz |
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.
-rw-r--r-- | src/connection-editor/main.c | 8 | ||||
-rw-r--r-- | src/connection-editor/nm-connection-list.c | 10 | ||||
-rw-r--r-- | 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 b4eac54f..a942369d 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 c1d8b11c..9368f8bf 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 15f38b62..1db3ec8d 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); |