summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-10-19 19:17:40 +0200
committerThomas Haller <thaller@redhat.com>2016-10-19 19:54:36 +0200
commit6e5046d12290fe31c7eef5bf2a5874926096a8e5 (patch)
treeb702a92064f6e7db715c1137d5d7f34d9d45cb74
parent64f69435f650774477740278ddaa9fd91815ab38 (diff)
downloadnetwork-manager-applet-6e5046d12290fe31c7eef5bf2a5874926096a8e5.tar.gz
nm-c-e: let --create show the "Add" connection dialog
Previously, `nm-connection-editor --create` without explicit --type argument would directly create an ethernet connection. Now, open instead the list of connection types, as if the user clicks "Add" in the main menu. It also changes behavior for `nm-connection-editor --show`, which previously behaved like `nm-connection-editor --show --type 802-3-ethernet`. Now it behaves like `nm-connection-editor` without arguments.
-rw-r--r--src/connection-editor/main.c44
-rw-r--r--src/connection-editor/nm-connection-list.c8
-rw-r--r--src/connection-editor/nm-connection-list.h1
3 files changed, 26 insertions, 27 deletions
diff --git a/src/connection-editor/main.c b/src/connection-editor/main.c
index 185e95ee..82186011 100644
--- a/src/connection-editor/main.c
+++ b/src/connection-editor/main.c
@@ -67,8 +67,8 @@ handle_arguments (NMConnectionList *list,
gboolean quit_after)
{
gboolean show_list = TRUE;
- GType ctype;
- char *type_tmp = NULL;
+ GType ctype = 0;
+ gs_free char *type_tmp = NULL;
const char *p, *detail = NULL;
if (type) {
@@ -77,36 +77,29 @@ handle_arguments (NMConnectionList *list,
type = type_tmp = g_strndup (type, p - type);
detail = p + 1;
}
- } else
- type = NM_SETTING_WIRED_SETTING_NAME;
-
- /* Grab type to create or show */
- ctype = nm_setting_lookup_type (type);
- if (ctype == 0) {
- g_warning ("Unknown connection type '%s'", type);
- g_free (type_tmp);
- return TRUE;
+ ctype = nm_setting_lookup_type (type);
+ if (ctype == 0) {
+ g_warning ("Unknown connection type '%s'", type);
+ return TRUE;
+ }
}
if (show) {
/* Just show the given connection type page */
nm_connection_list_set_type (list, ctype);
} else if (create) {
- if (!type) {
- g_warning ("'create' requested but no connection type given.");
- g_free (type_tmp);
- return TRUE;
+ if (!ctype)
+ nm_connection_list_add (list);
+ else {
+ /* If type is "vpn" and the user cancels the "vpn type" dialog, we need
+ * to quit. But we haven't even started yet. So postpone this to an idle.
+ */
+ g_idle_add (idle_create_connection, list);
+ g_object_set_data (G_OBJECT (list), "nm-connection-editor-ctype",
+ GSIZE_TO_POINTER (ctype));
+ g_object_set_data_full (G_OBJECT (list), "nm-connection-editor-detail",
+ g_strdup (detail), g_free);
}
-
- /* If type is "vpn" and the user cancels the "vpn type" dialog, we need
- * to quit. But we haven't even started yet. So postpone this to an idle.
- */
- g_idle_add (idle_create_connection, list);
- g_object_set_data (G_OBJECT (list), "nm-connection-editor-ctype",
- GSIZE_TO_POINTER (ctype));
- g_object_set_data_full (G_OBJECT (list), "nm-connection-editor-detail",
- g_strdup (detail), g_free);
-
show_list = FALSE;
} else if (edit_uuid) {
/* Show the edit dialog for the given UUID */
@@ -118,7 +111,6 @@ handle_arguments (NMConnectionList *list,
if (show_list == FALSE && quit_after == TRUE)
g_signal_connect_swapped (list, "editing-done", G_CALLBACK (g_main_loop_quit), loop);
- g_free (type_tmp);
return show_list;
}
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index 32101689..bdd4bc18 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -296,7 +296,13 @@ really_add_connection (NMConnection *connection,
static void
add_clicked (GtkButton *button, gpointer user_data)
{
- NMConnectionList *list = user_data;
+ nm_connection_list_add (user_data);
+}
+
+void
+nm_connection_list_add (NMConnectionList *list)
+{
+ g_return_if_fail (NM_IS_CONNECTION_LIST (list));
new_connection_dialog (GTK_WINDOW (list->dialog),
list->client,
diff --git a/src/connection-editor/nm-connection-list.h b/src/connection-editor/nm-connection-list.h
index 046f2e3f..6d382bc5 100644
--- a/src/connection-editor/nm-connection-list.h
+++ b/src/connection-editor/nm-connection-list.h
@@ -67,5 +67,6 @@ void nm_connection_list_set_type (NMConnectionList *list, GType cty
void nm_connection_list_present (NMConnectionList *list);
void nm_connection_list_create (NMConnectionList *list, GType ctype, const char *detail);
void nm_connection_list_edit (NMConnectionList *list, const gchar *uuid);
+void nm_connection_list_add (NMConnectionList *list);
#endif