[network-manager-applet/lr/import: 1/3] editor: add connection argument to the new page function



commit 979fc71eeed41431495ad469de130acadaafc635
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Sun Oct 30 15:46:28 2016 +0100

    editor: add connection argument to the new page function
    
    The page can use an already existing connection instead of creating a
    new one. This would be useful for importing the connections.
    
    Currently we let the new page functions handle the imports (for VPN
    connections), but that's not a very good idea -- when we're able to
    import non-VPN connections we might not even know the connection type in
    advance.
    
    The new page functions are still able to construct the connections
    themselves according to details passed and even interact with the user.
    That might be worthwhile streamlining at some point.

 src/connection-editor/ce-page.c            |   41 +++++++++++++--------------
 src/connection-editor/ce-page.h            |   11 ++++---
 src/connection-editor/connection-helpers.c |   15 ++++++++--
 src/connection-editor/connection-helpers.h |    1 +
 src/connection-editor/main.c               |    3 +-
 src/connection-editor/nm-connection-list.c |    3 +-
 src/connection-editor/nm-connection-list.h |    2 +-
 src/connection-editor/page-bluetooth.c     |   14 ++++++---
 src/connection-editor/page-bluetooth.h     |    1 +
 src/connection-editor/page-bond.c          |   15 ++++++----
 src/connection-editor/page-bond.h          |    1 +
 src/connection-editor/page-bridge.c        |   14 +++++----
 src/connection-editor/page-bridge.h        |    1 +
 src/connection-editor/page-dsl.c           |   14 +++++----
 src/connection-editor/page-dsl.h           |    1 +
 src/connection-editor/page-ethernet.c      |   15 +++++-----
 src/connection-editor/page-ethernet.h      |    1 +
 src/connection-editor/page-infiniband.c    |   15 +++++-----
 src/connection-editor/page-infiniband.h    |    1 +
 src/connection-editor/page-mobile.c        |   10 ++++++-
 src/connection-editor/page-mobile.h        |    1 +
 src/connection-editor/page-team.c          |   15 ++++++----
 src/connection-editor/page-team.h          |    1 +
 src/connection-editor/page-vlan.c          |   15 +++++-----
 src/connection-editor/page-vlan.h          |    1 +
 src/connection-editor/page-vpn.c           |   23 ++++++++++-----
 src/connection-editor/page-vpn.h           |    1 +
 src/connection-editor/page-wifi.c          |   14 +++++----
 src/connection-editor/page-wifi.h          |    1 +
 29 files changed, 154 insertions(+), 97 deletions(-)
---
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index 4b17fde..aca0c72 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -808,39 +808,38 @@ ce_page_class_init (CEPageClass *page_class)
 }
 
 
-NMConnection *
-ce_page_new_connection (const char *format,
-                        const char *ctype,
-                        gboolean autoconnect,
-                        NMClient *client,
-                        gpointer user_data)
-{
-       NMConnection *connection;
+void
+ce_page_complete_connection (NMConnection *connection,
+                             const char *format,
+                             const char *ctype,
+                             gboolean autoconnect,
+                             NMClient *client)
+{
        NMSettingConnection *s_con;
-       char *uuid, *id;
+       char *uuid;
+       const char *id;
        const GPtrArray *connections;
 
-       connection = nm_simple_connection_new ();
+       s_con = nm_connection_get_setting_connection (connection);
+       if (!s_con) {
+               s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
+               nm_connection_add_setting (connection, NM_SETTING (s_con));
+       }
 
-       s_con = NM_SETTING_CONNECTION (nm_setting_connection_new ());
-       nm_connection_add_setting (connection, NM_SETTING (s_con));
+       id = nm_setting_connection_get_id (s_con);
+       if (!id) {
+               connections = nm_client_get_connections (client);
+               id = ce_page_get_next_available_name (connections, format);
+               g_object_set (s_con, NM_SETTING_CONNECTION_ID, id, NULL);
+       }
 
        uuid = nm_utils_uuid_generate ();
-
-       connections = nm_client_get_connections (client);
-       id = ce_page_get_next_available_name (connections, format);
-
        g_object_set (s_con,
                      NM_SETTING_CONNECTION_UUID, uuid,
-                     NM_SETTING_CONNECTION_ID, id,
                      NM_SETTING_CONNECTION_TYPE, ctype,
                      NM_SETTING_CONNECTION_AUTOCONNECT, autoconnect,
                      NULL);
-
        g_free (uuid);
-       g_free (id);
-
-       return connection;
 }
 
 CEPage *
diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h
index f375ed4..7f21816 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -46,6 +46,7 @@ typedef GSList * (*PageGetConnectionsFunc) (gpointer user_data);
 typedef void (*PageNewConnectionFunc) (GtkWindow *parent,
                                        const char *detail,
                                        gpointer detail_data,
+                                       NMConnection *connection,
                                        NMClient *client,
                                        PageNewConnectionResultFunc result_func,
                                        gpointer user_data);
@@ -160,11 +161,11 @@ gboolean ce_page_get_initialized (CEPage *self);
 char *ce_page_get_next_available_name (const GPtrArray *connections, const char *format);
 
 /* Only for subclasses */
-NMConnection *ce_page_new_connection (const char *format,
-                                      const char *ctype,
-                                      gboolean autoconnect,
-                                      NMClient *client,
-                                      gpointer user_data);
+void ce_page_complete_connection (NMConnection *connection,
+                                  const char *format,
+                                  const char *ctype,
+                                  gboolean autoconnect,
+                                  NMClient *client);
 
 CEPage *ce_page_new (GType page_type,
                      NMConnectionEditor *editor,
diff --git a/src/connection-editor/connection-helpers.c b/src/connection-editor/connection-helpers.c
index 85261ef..936fbcd 100644
--- a/src/connection-editor/connection-helpers.c
+++ b/src/connection-editor/connection-helpers.c
@@ -419,6 +419,7 @@ void
 new_connection_of_type (GtkWindow *parent_window,
                         const char *detail,
                         gpointer detail_data,
+                        NMConnection *connection,
                         NMClient *client,
                         PageNewConnectionFunc new_func,
                         NewConnectionResultFunc result_func,
@@ -435,6 +436,7 @@ new_connection_of_type (GtkWindow *parent_window,
        new_func (parent_window,
                  detail,
                  detail_data,
+                 connection,
                  client,
                  new_connection_result,
                  ncd);
@@ -535,9 +537,16 @@ new_connection_dialog_full (GtkWindow *parent_window,
        gtk_widget_destroy (GTK_WIDGET (type_dialog));
        g_object_unref (gui);
 
-       if (new_func)
-               new_connection_of_type (parent_window, detail, detail_data, client, new_func, result_func, 
user_data);
-       else
+       if (new_func) {
+               new_connection_of_type (parent_window,
+                                       detail,
+                                       detail_data,
+                                       NULL,
+                                       client,
+                                       new_func,
+                                       result_func,
+                                       user_data);
+       } else
                result_func (NULL, user_data);
 }
 
diff --git a/src/connection-editor/connection-helpers.h b/src/connection-editor/connection-helpers.h
index 0ddb2d3..014bbb3 100644
--- a/src/connection-editor/connection-helpers.h
+++ b/src/connection-editor/connection-helpers.h
@@ -55,6 +55,7 @@ void new_connection_dialog_full (GtkWindow *parent_window,
 void new_connection_of_type (GtkWindow *parent_window,
                              const char *detail,
                              gpointer detail_data,
+                             NMConnection *connection,
                              NMClient *client,
                              PageNewConnectionFunc new_func,
                              NewConnectionResultFunc result_func,
diff --git a/src/connection-editor/main.c b/src/connection-editor/main.c
index 8218601..745a367 100644
--- a/src/connection-editor/main.c
+++ b/src/connection-editor/main.c
@@ -53,8 +53,9 @@ idle_create_connection (gpointer user_data)
        NMConnectionList *list = user_data;
        GType ctype = (GType) GPOINTER_TO_SIZE (g_object_get_data (G_OBJECT (list), 
"nm-connection-editor-ctype"));
        char *detail = g_object_get_data (G_OBJECT (list), "nm-connection-editor-detail");
+       NMConnection *connection = g_object_get_data (G_OBJECT (list), "nm-connection-editor-connection");
 
-       nm_connection_list_create (list, ctype, detail);
+       nm_connection_list_create (list, ctype, detail, connection);
        return FALSE;
 }
 
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index bdd4bc1..25c9d03 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -901,7 +901,7 @@ nm_connection_list_set_type (NMConnectionList *self, GType ctype)
 }
 
 void
-nm_connection_list_create (NMConnectionList *self, GType ctype, const char *detail)
+nm_connection_list_create (NMConnectionList *self, GType ctype, const char *detail, NMConnection *connection)
 {
        ConnectionTypeData *types;
        int i;
@@ -927,6 +927,7 @@ nm_connection_list_create (NMConnectionList *self, GType ctype, const char *deta
                new_connection_of_type (GTK_WINDOW (self->dialog),
                                        detail,
                                        NULL,
+                                       connection,
                                        self->client,
                                        types[i].new_connection_func,
                                        really_add_connection,
diff --git a/src/connection-editor/nm-connection-list.h b/src/connection-editor/nm-connection-list.h
index 6d382bc..15f38b6 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);
+void              nm_connection_list_create (NMConnectionList *list, GType ctype, const char *detail, 
NMConnection *connection);
 void              nm_connection_list_edit (NMConnectionList *list, const gchar *uuid);
 void              nm_connection_list_add (NMConnectionList *list);
 
diff --git a/src/connection-editor/page-bluetooth.c b/src/connection-editor/page-bluetooth.c
index 2d36c57..587536e 100644
--- a/src/connection-editor/page-bluetooth.c
+++ b/src/connection-editor/page-bluetooth.c
@@ -256,11 +256,12 @@ new_connection_mobile_wizard_done (NMAMobileWizard *wizard,
 
        if (!detail)
                detail = g_strdup (_("Bluetooth connection %d"));
-       connection = ce_page_new_connection (detail,
-                                            NM_SETTING_BLUETOOTH_SETTING_NAME,
-                                            FALSE,
-                                            info->client,
-                                            user_data);
+       connection = nm_simple_connection_new ();
+       ce_page_complete_connection (connection,
+                                    detail,
+                                    NM_SETTING_BLUETOOTH_SETTING_NAME,
+                                    FALSE,
+                                    info->client);
        g_free (detail);
        nm_connection_add_setting (connection, nm_setting_bluetooth_new ());
        g_object_set (nm_connection_get_setting_bluetooth (connection),
@@ -285,6 +286,7 @@ void
 bluetooth_connection_new (GtkWindow *parent,
                           const char *detail,
                           gpointer detail_data,
+                          NMConnection *connection,
                           NMClient *client,
                           PageNewConnectionResultFunc result_func,
                           gpointer user_data)
@@ -294,6 +296,8 @@ bluetooth_connection_new (GtkWindow *parent,
        WizardInfo *info;
        GtkWidget *dialog, *content, *alignment, *vbox, *label, *dun_radio, *panu_radio;
 
+       g_return_if_fail (!connection);
+
        info = g_malloc0 (sizeof (WizardInfo));
        info->result_func = result_func;
        info->client = g_object_ref (client);
diff --git a/src/connection-editor/page-bluetooth.h b/src/connection-editor/page-bluetooth.h
index 20f4d31..ed82331 100644
--- a/src/connection-editor/page-bluetooth.h
+++ b/src/connection-editor/page-bluetooth.h
@@ -57,6 +57,7 @@ CEPage *ce_page_bluetooth_new (NMConnectionEditor *edit,
 void bluetooth_connection_new (GtkWindow *parent,
                                const char *detail,
                                gpointer detail_data,
+                               NMConnection *connection,
                                NMClient *client,
                                PageNewConnectionResultFunc result_func,
                                gpointer user_data);
diff --git a/src/connection-editor/page-bond.c b/src/connection-editor/page-bond.c
index e43940c..8b10e38 100644
--- a/src/connection-editor/page-bond.c
+++ b/src/connection-editor/page-bond.c
@@ -389,6 +389,7 @@ add_slave (CEPageMaster *master, NewConnectionResultFunc result_func)
                new_connection_of_type (priv->toplevel,
                                        NULL,
                                        NULL,
+                                       NULL,
                                        CE_PAGE (self)->client,
                                        infiniband_connection_new,
                                        result_func,
@@ -601,11 +602,11 @@ void
 bond_connection_new (GtkWindow *parent,
                      const char *detail,
                      gpointer detail_data,
+                     NMConnection *connection,
                      NMClient *client,
                      PageNewConnectionResultFunc result_func,
                      gpointer user_data)
 {
-       NMConnection *connection;
        NMSettingConnection *s_con;
        int bond_num = 0, num, i;
        const GPtrArray *connections;
@@ -613,11 +614,13 @@ bond_connection_new (GtkWindow *parent,
        const char *iface;
        char *my_iface;
 
-       connection = ce_page_new_connection (_("Bond connection %d"),
-                                            NM_SETTING_BOND_SETTING_NAME,
-                                            TRUE,
-                                            client,
-                                            user_data);
+       if (!connection)
+               connection = nm_simple_connection_new ();
+       ce_page_complete_connection (connection,
+                                    _("Bond connection %d"),
+                                    NM_SETTING_BOND_SETTING_NAME,
+                                    TRUE,
+                                    client);
        nm_connection_add_setting (connection, nm_setting_bond_new ());
 
        /* Find an available interface name */
diff --git a/src/connection-editor/page-bond.h b/src/connection-editor/page-bond.h
index abdee47..2644563 100644
--- a/src/connection-editor/page-bond.h
+++ b/src/connection-editor/page-bond.h
@@ -53,6 +53,7 @@ CEPage *ce_page_bond_new (NMConnectionEditor *editor,
 void bond_connection_new (GtkWindow *parent,
                           const char *detail,
                           gpointer detail_data,
+                          NMConnection *connection,
                           NMClient *client,
                           PageNewConnectionResultFunc result_func,
                           gpointer user_data);
diff --git a/src/connection-editor/page-bridge.c b/src/connection-editor/page-bridge.c
index 136c97c..8774a81 100644
--- a/src/connection-editor/page-bridge.c
+++ b/src/connection-editor/page-bridge.c
@@ -296,11 +296,11 @@ void
 bridge_connection_new (GtkWindow *parent,
                        const char *detail,
                        gpointer detail_data,
+                       NMConnection *connection,
                        NMClient *client,
                        PageNewConnectionResultFunc result_func,
                        gpointer user_data)
 {
-       NMConnection *connection;
        NMSettingConnection *s_con;
        int bridge_num = 0, num, i;
        const GPtrArray *connections;
@@ -308,11 +308,13 @@ bridge_connection_new (GtkWindow *parent,
        const char *iface;
        char *my_iface;
 
-       connection = ce_page_new_connection (_("Bridge connection %d"),
-                                            NM_SETTING_BRIDGE_SETTING_NAME,
-                                            TRUE,
-                                            client,
-                                            user_data);
+       if (!connection)
+               connection = nm_simple_connection_new ();
+       ce_page_complete_connection (connection,
+                                    _("Bridge connection %d"),
+                                    NM_SETTING_BRIDGE_SETTING_NAME,
+                                    TRUE,
+                                    client);
        nm_connection_add_setting (connection, nm_setting_bridge_new ());
 
        /* Find an available interface name */
diff --git a/src/connection-editor/page-bridge.h b/src/connection-editor/page-bridge.h
index 79dee1c..b104ad5 100644
--- a/src/connection-editor/page-bridge.h
+++ b/src/connection-editor/page-bridge.h
@@ -53,6 +53,7 @@ CEPage *ce_page_bridge_new (NMConnectionEditor *editor,
 void bridge_connection_new (GtkWindow *parent,
                             const char *detail,
                             gpointer detail_data,
+                            NMConnection *connection,
                             NMClient *client,
                             PageNewConnectionResultFunc result_func,
                             gpointer user_data);
diff --git a/src/connection-editor/page-dsl.c b/src/connection-editor/page-dsl.c
index 6419fa0..12f24d5 100644
--- a/src/connection-editor/page-dsl.c
+++ b/src/connection-editor/page-dsl.c
@@ -205,18 +205,20 @@ void
 dsl_connection_new (GtkWindow *parent,
                     const char *detail,
                     gpointer detail_data,
+                    NMConnection *connection,
                     NMClient *client,
                     PageNewConnectionResultFunc result_func,
                     gpointer user_data)
 {
-       NMConnection *connection;
        NMSetting *setting;
 
-       connection = ce_page_new_connection (_("DSL connection %d"),
-                                            NM_SETTING_PPPOE_SETTING_NAME,
-                                            FALSE,
-                                            client,
-                                            user_data);
+       if (!connection)
+               connection = nm_simple_connection_new ();
+       ce_page_complete_connection (connection,
+                                    _("DSL connection %d"),
+                                    NM_SETTING_PPPOE_SETTING_NAME,
+                                    FALSE,
+                                    client);
        nm_connection_add_setting (connection, nm_setting_pppoe_new ());
        nm_connection_add_setting (connection, nm_setting_wired_new ());
        setting = nm_setting_ppp_new ();
diff --git a/src/connection-editor/page-dsl.h b/src/connection-editor/page-dsl.h
index b789285..853e42b 100644
--- a/src/connection-editor/page-dsl.h
+++ b/src/connection-editor/page-dsl.h
@@ -55,6 +55,7 @@ CEPage *ce_page_dsl_new (NMConnectionEditor *editor,
 void dsl_connection_new (GtkWindow *parent,
                          const char *detail,
                          gpointer detail_data,
+                         NMConnection *connection,
                          NMClient *client,
                          PageNewConnectionResultFunc callback,
                          gpointer user_data);
diff --git a/src/connection-editor/page-ethernet.c b/src/connection-editor/page-ethernet.c
index 54b0353..ee8bf2e 100644
--- a/src/connection-editor/page-ethernet.c
+++ b/src/connection-editor/page-ethernet.c
@@ -490,17 +490,18 @@ void
 ethernet_connection_new (GtkWindow *parent,
                          const char *detail,
                          gpointer detail_data,
+                         NMConnection *connection,
                          NMClient *client,
                          PageNewConnectionResultFunc result_func,
                          gpointer user_data)
 {
-       NMConnection *connection;
-
-       connection = ce_page_new_connection (_("Ethernet connection %d"),
-                                            NM_SETTING_WIRED_SETTING_NAME,
-                                            TRUE,
-                                            client,
-                                            user_data);
+       if (!connection)
+               connection = nm_simple_connection_new ();
+       ce_page_complete_connection (connection,
+                                    _("Ethernet connection %d"),
+                                    NM_SETTING_WIRED_SETTING_NAME,
+                                    TRUE,
+                                    client);
        nm_connection_add_setting (connection, nm_setting_wired_new ());
 
        (*result_func) (connection, FALSE, NULL, user_data);
diff --git a/src/connection-editor/page-ethernet.h b/src/connection-editor/page-ethernet.h
index 0bee841..e88b717 100644
--- a/src/connection-editor/page-ethernet.h
+++ b/src/connection-editor/page-ethernet.h
@@ -55,6 +55,7 @@ CEPage *ce_page_ethernet_new (NMConnectionEditor *editor,
 void ethernet_connection_new (GtkWindow *parent,
                               const char *detail,
                               gpointer detail_data,
+                              NMConnection *connection,
                               NMClient *client,
                               PageNewConnectionResultFunc result_func,
                               gpointer user_data);
diff --git a/src/connection-editor/page-infiniband.c b/src/connection-editor/page-infiniband.c
index 1441737..a5e52af 100644
--- a/src/connection-editor/page-infiniband.c
+++ b/src/connection-editor/page-infiniband.c
@@ -241,17 +241,18 @@ void
 infiniband_connection_new (GtkWindow *parent,
                            const char *detail,
                            gpointer detail_data,
+                           NMConnection *connection,
                            NMClient *client,
                            PageNewConnectionResultFunc result_func,
                            gpointer user_data)
 {
-       NMConnection *connection;
-
-       connection = ce_page_new_connection (_("InfiniBand connection %d"),
-                                            NM_SETTING_INFINIBAND_SETTING_NAME,
-                                            TRUE,
-                                            client,
-                                            user_data);
+       if (!connection)
+               connection = nm_simple_connection_new ();
+       ce_page_complete_connection (connection,
+                                    _("InfiniBand connection %d"),
+                                    NM_SETTING_INFINIBAND_SETTING_NAME,
+                                    TRUE,
+                                    client);
        nm_connection_add_setting (connection, nm_setting_infiniband_new ());
 
        (*result_func) (connection, FALSE, NULL, user_data);
diff --git a/src/connection-editor/page-infiniband.h b/src/connection-editor/page-infiniband.h
index d095e3c..f2079d1 100644
--- a/src/connection-editor/page-infiniband.h
+++ b/src/connection-editor/page-infiniband.h
@@ -53,6 +53,7 @@ CEPage *ce_page_infiniband_new (NMConnectionEditor *editor,
 void infiniband_connection_new (GtkWindow *parent,
                                 const char *detail,
                                 gpointer detail_data,
+                                NMConnection *connection,
                                 NMClient *client,
                                 PageNewConnectionResultFunc result_func,
                                 gpointer user_data);
diff --git a/src/connection-editor/page-mobile.c b/src/connection-editor/page-mobile.c
index 572d386..efb6ffe 100644
--- a/src/connection-editor/page-mobile.c
+++ b/src/connection-editor/page-mobile.c
@@ -477,7 +477,12 @@ new_connection_mobile_wizard_done (NMAMobileWizard *wizard,
                        detail = g_strdup_printf ("%s %s %%d", method->provider_name, method->plan_name);
                else
                        detail = g_strdup_printf ("%s connection %%d", method->provider_name);
-               connection = ce_page_new_connection (detail, ctype, FALSE, info->client, info->user_data);
+               connection = nm_simple_connection_new ();
+               ce_page_complete_connection (connection,
+                                            detail,
+                                             ctype,
+                                             FALSE,
+                                             info->client);
                g_free (detail);
 
                nm_connection_add_setting (connection, type_setting);
@@ -503,6 +508,7 @@ void
 mobile_connection_new (GtkWindow *parent,
                        const char *detail,
                        gpointer detail_data,
+                       NMConnection *connection,
                        NMClient *client,
                        PageNewConnectionResultFunc result_func,
                        gpointer user_data)
@@ -514,6 +520,8 @@ mobile_connection_new (GtkWindow *parent,
        gint response;
        NMAMobileWizardAccessMethod method;
 
+       g_return_if_fail (!connection);
+
        info = g_malloc0 (sizeof (WizardInfo));
        info->result_func = result_func;
        info->client = g_object_ref (client);
diff --git a/src/connection-editor/page-mobile.h b/src/connection-editor/page-mobile.h
index e8d71f5..ebe318c 100644
--- a/src/connection-editor/page-mobile.h
+++ b/src/connection-editor/page-mobile.h
@@ -55,6 +55,7 @@ CEPage *ce_page_mobile_new (NMConnectionEditor *editor,
 void mobile_connection_new (GtkWindow *parent,
                             const char *detail,
                             gpointer detail_data,
+                            NMConnection *connection,
                             NMClient *client,
                             PageNewConnectionResultFunc result_func,
                             gpointer user_data);
diff --git a/src/connection-editor/page-team.c b/src/connection-editor/page-team.c
index 9be28be..c7ab6ae 100644
--- a/src/connection-editor/page-team.c
+++ b/src/connection-editor/page-team.c
@@ -1103,6 +1103,7 @@ add_slave (CEPageMaster *master, NewConnectionResultFunc result_func)
                new_connection_of_type (GTK_WINDOW (toplevel),
                                        NULL,
                                        NULL,
+                                       NULL,
                                        CE_PAGE (self)->client,
                                        infiniband_connection_new,
                                        result_func,
@@ -1231,11 +1232,11 @@ void
 team_connection_new (GtkWindow *parent,
                      const char *detail,
                      gpointer detail_data,
+                     NMConnection *connection,
                      NMClient *client,
                      PageNewConnectionResultFunc result_func,
                      gpointer user_data)
 {
-       NMConnection *connection;
        NMSettingConnection *s_con;
        int team_num, num, i;
        const GPtrArray *connections;
@@ -1243,11 +1244,13 @@ team_connection_new (GtkWindow *parent,
        const char *iface;
        char *my_iface;
 
-       connection = ce_page_new_connection (_("Team connection %d"),
-                                            NM_SETTING_TEAM_SETTING_NAME,
-                                            TRUE,
-                                            client,
-                                            user_data);
+       if (!connection)
+               connection = nm_simple_connection_new ();
+       ce_page_complete_connection (connection,
+                                    _("Team connection %d"),
+                                    NM_SETTING_TEAM_SETTING_NAME,
+                                    TRUE,
+                                    client);
        nm_connection_add_setting (connection, nm_setting_team_new ());
 
        /* Find an available interface name */
diff --git a/src/connection-editor/page-team.h b/src/connection-editor/page-team.h
index b9daf3b..ec61e63 100644
--- a/src/connection-editor/page-team.h
+++ b/src/connection-editor/page-team.h
@@ -53,6 +53,7 @@ CEPage *ce_page_team_new (NMConnectionEditor *editor,
 void team_connection_new (GtkWindow *parent,
                           const char *detail,
                           gpointer detail_data,
+                          NMConnection *connection,
                           NMClient *client,
                           PageNewConnectionResultFunc result_func,
                           gpointer user_data);
diff --git a/src/connection-editor/page-vlan.c b/src/connection-editor/page-vlan.c
index ef39a7d..b1563b6 100644
--- a/src/connection-editor/page-vlan.c
+++ b/src/connection-editor/page-vlan.c
@@ -787,17 +787,18 @@ void
 vlan_connection_new (GtkWindow *parent,
                      const char *detail,
                      gpointer detail_data,
+                     NMConnection *connection,
                      NMClient *client,
                      PageNewConnectionResultFunc result_func,
                      gpointer user_data)
 {
-       NMConnection *connection;
-
-       connection = ce_page_new_connection (_("VLAN connection %d"),
-                                            NM_SETTING_VLAN_SETTING_NAME,
-                                            TRUE,
-                                            client,
-                                            user_data);
+       if (!connection)
+               connection = nm_simple_connection_new ();
+       ce_page_complete_connection (connection,
+                                    _("VLAN connection %d"),
+                                    NM_SETTING_VLAN_SETTING_NAME,
+                                    TRUE,
+                                    client);
        nm_connection_add_setting (connection, nm_setting_vlan_new ());
 
        (*result_func) (connection, FALSE, NULL, user_data);
diff --git a/src/connection-editor/page-vlan.h b/src/connection-editor/page-vlan.h
index dde01bc..427a644 100644
--- a/src/connection-editor/page-vlan.h
+++ b/src/connection-editor/page-vlan.h
@@ -53,6 +53,7 @@ CEPage *ce_page_vlan_new (NMConnectionEditor *editor,
 void vlan_connection_new (GtkWindow *parent,
                           const char *detail,
                           gpointer detail_data,
+                          NMConnection *connection,
                           NMClient *client,
                           PageNewConnectionResultFunc result_func,
                           gpointer user_data);
diff --git a/src/connection-editor/page-vpn.c b/src/connection-editor/page-vpn.c
index 90fda53..6212fc3 100644
--- a/src/connection-editor/page-vpn.c
+++ b/src/connection-editor/page-vpn.c
@@ -263,6 +263,16 @@ vpn_connection_import (GtkWindow *parent,
        vpn_import (import_cb, info);
 }
 
+static void
+complete_vpn_connection (NMConnection *connection, NMClient *client)
+{
+       ce_page_complete_connection (connection,
+                                    _("VPN connection %d"),
+                                    NM_SETTING_VPN_SETTING_NAME,
+                                    FALSE,
+                                    client);
+}
+
 #define NEW_VPN_CONNECTION_PRIMARY_LABEL _("Choose a VPN Connection Type")
 #define NEW_VPN_CONNECTION_SECONDARY_LABEL _("Select the type of VPN you wish to use for the new connection. 
If the type of VPN connection you wish to create does not appear in the list, you may not have the correct 
VPN plugin installed.")
 
@@ -285,11 +295,11 @@ void
 vpn_connection_new (GtkWindow *parent,
                     const char *detail,
                     gpointer detail_data,
+                    NMConnection *connection,
                     NMClient *client,
                     PageNewConnectionResultFunc result_func,
                     gpointer user_data)
 {
-       NMConnection *connection;
        NMSetting *s_vpn;
        const char *service_type;
        gs_free char *service_type_free = NULL;
@@ -361,11 +371,10 @@ vpn_connection_new (GtkWindow *parent,
        if (!service_type)
                service_type = detail;
 
-       connection = ce_page_new_connection (_("VPN connection %d"),
-                                            NM_SETTING_VPN_SETTING_NAME,
-                                            FALSE,
-                                            client,
-                                            user_data);
+       if (!connection)
+               connection = nm_simple_connection_new ();
+       complete_vpn_connection (connection, client);
+
        s_vpn = nm_setting_vpn_new ();
        g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, service_type, NULL);
 
@@ -376,5 +385,3 @@ vpn_connection_new (GtkWindow *parent,
 
        (*result_func) (connection, FALSE, NULL, user_data);
 }
-
-
diff --git a/src/connection-editor/page-vpn.h b/src/connection-editor/page-vpn.h
index 18994c9..cad7d24 100644
--- a/src/connection-editor/page-vpn.h
+++ b/src/connection-editor/page-vpn.h
@@ -62,6 +62,7 @@ gboolean ce_page_vpn_can_export (CEPageVpn *page);
 void vpn_connection_new (GtkWindow *parent,
                          const char *detail,
                          gpointer detail_data,
+                         NMConnection *connection,
                          NMClient *client,
                          PageNewConnectionResultFunc result_func,
                          gpointer user_data);
diff --git a/src/connection-editor/page-wifi.c b/src/connection-editor/page-wifi.c
index 8f7c6c1..e2b4933 100644
--- a/src/connection-editor/page-wifi.c
+++ b/src/connection-editor/page-wifi.c
@@ -603,18 +603,20 @@ void
 wifi_connection_new (GtkWindow *parent,
                      const char *detail,
                      gpointer detail_data,
+                     NMConnection *connection,
                      NMClient *client,
                      PageNewConnectionResultFunc result_func,
                      gpointer user_data)
 {
-       NMConnection *connection;
        NMSetting *s_wifi;
 
-       connection = ce_page_new_connection (_("Wi-Fi connection %d"),
-                                            NM_SETTING_WIRELESS_SETTING_NAME,
-                                            TRUE,
-                                            client,
-                                            user_data);
+       if (!connection)
+               connection = nm_simple_connection_new ();
+       ce_page_complete_connection (connection,
+                                    _("Wi-Fi connection %d"),
+                                    NM_SETTING_WIRELESS_SETTING_NAME,
+                                    TRUE,
+                                    client);
        s_wifi = nm_setting_wireless_new ();
        g_object_set (s_wifi, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL);
        nm_connection_add_setting (connection, s_wifi);
diff --git a/src/connection-editor/page-wifi.h b/src/connection-editor/page-wifi.h
index 90b25c4..9bf4ff7 100644
--- a/src/connection-editor/page-wifi.h
+++ b/src/connection-editor/page-wifi.h
@@ -59,6 +59,7 @@ GBytes *ce_page_wifi_get_ssid (CEPageWifi *self);
 void wifi_connection_new (GtkWindow *parent,
                           const char *detail,
                           gpointer detail_data,
+                          NMConnection *connection,
                           NMClient *client,
                           PageNewConnectionResultFunc result_func,
                           gpointer user_data);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]