[network-manager-applet] connection-editor: pass NMRemoteSettings to PageNewConnectionFunc



commit 5c170840ec1f40fcbd4ee516ca6c03c537230d7b
Author: Dan Winship <danw gnome org>
Date:   Thu Jul 19 15:56:17 2012 -0400

    connection-editor: pass NMRemoteSettings to PageNewConnectionFunc
    
    Rather than passing a PageGetConnectionsFunc that can be called to
    indirectly call nm_remote_settings_list_connection(), just pass the
    NMRemoteSettings object to the new-connection funcs directly, allowing
    them to do other things with it as well.

 src/connection-editor/ce-page.c            |    4 ++--
 src/connection-editor/ce-page.h            |    5 +++--
 src/connection-editor/nm-connection-list.c |   12 ++----------
 src/connection-editor/page-dsl.c           |    4 ++--
 src/connection-editor/page-dsl.h           |    2 +-
 src/connection-editor/page-mobile.c        |   10 ++++++----
 src/connection-editor/page-mobile.h        |    2 +-
 src/connection-editor/page-vpn.c           |   11 ++++++-----
 src/connection-editor/page-vpn.h           |    2 +-
 src/connection-editor/page-wired.c         |    4 ++--
 src/connection-editor/page-wired.h         |    2 +-
 src/connection-editor/page-wireless.c      |    4 ++--
 src/connection-editor/page-wireless.h      |    2 +-
 13 files changed, 30 insertions(+), 34 deletions(-)
---
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index c0d8eb4..44806d7 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -495,7 +495,7 @@ NMConnection *
 ce_page_new_connection (const char *format,
                         const char *ctype,
                         gboolean autoconnect,
-                        PageGetConnectionsFunc get_connections_func,
+                        NMRemoteSettings *settings,
                         gpointer user_data)
 {
 	NMConnection *connection;
@@ -510,7 +510,7 @@ ce_page_new_connection (const char *format,
 
 	uuid = nm_utils_uuid_generate ();
 
-	connections = (*get_connections_func) (user_data);
+	connections = nm_remote_settings_list_connections (settings);
 	id = ce_page_get_next_available_name (connections, format);
 	g_slist_free (connections);
 
diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h
index b5ec497..c3f2f15 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -31,6 +31,7 @@
 #include <dbus/dbus-glib.h>
 #include <nm-connection.h>
 #include <nm-client.h>
+#include <nm-remote-settings.h>
 #include "utils.h"
 
 typedef void (*PageNewConnectionResultFunc) (NMConnection *connection,
@@ -41,8 +42,8 @@ typedef void (*PageNewConnectionResultFunc) (NMConnection *connection,
 typedef GSList * (*PageGetConnectionsFunc) (gpointer user_data);
 
 typedef void (*PageNewConnectionFunc) (GtkWindow *parent,
+                                       NMRemoteSettings *settings,
                                        PageNewConnectionResultFunc result_func,
-                                       PageGetConnectionsFunc get_connections_func,
                                        gpointer user_data);
 
 #define CE_TYPE_PAGE            (ce_page_get_type ())
@@ -131,7 +132,7 @@ GtkWidget *ce_page_nag_user (CEPage *self);
 NMConnection *ce_page_new_connection (const char *format,
                                       const char *ctype,
                                       gboolean autoconnect,
-                                      PageGetConnectionsFunc get_connections_func,
+                                      NMRemoteSettings *settings,
                                       gpointer user_data);
 
 CEPage *ce_page_new (GType page_type,
diff --git a/src/connection-editor/nm-connection-list.c b/src/connection-editor/nm-connection-list.c
index c9a0929..4f36e09 100644
--- a/src/connection-editor/nm-connection-list.c
+++ b/src/connection-editor/nm-connection-list.c
@@ -585,14 +585,6 @@ really_add_connection (NMConnection *connection,
 	nm_connection_editor_run (editor);
 }
 
-static GSList *
-page_get_connections (gpointer user_data)
-{
-	ActionInfo *info = (ActionInfo *) user_data;
-
-	return nm_remote_settings_list_connections (info->list->settings);
-}
-
 static void
 add_clicked (GtkButton *button, gpointer user_data)
 {
@@ -608,8 +600,8 @@ add_clicked (GtkButton *button, gpointer user_data)
 	}
 
 	info->new_func (GTK_WINDOW (list->dialog),
+	                list->settings,
 	                really_add_connection,
-	                page_get_connections,
 	                info);
 }
 
@@ -1376,8 +1368,8 @@ nm_connection_list_create (NMConnectionList *self, GType ctype)
 		              _("Don't know how to create '%s' connections"), g_type_name (ctype));
 	} else {
 		info->new_func (GTK_WINDOW (info->list->dialog),
+		                info->list->settings,
 		                really_add_connection,
-		                page_get_connections,
 		                info);
 	}
 }
diff --git a/src/connection-editor/page-dsl.c b/src/connection-editor/page-dsl.c
index 52dac57..40b2a72 100644
--- a/src/connection-editor/page-dsl.c
+++ b/src/connection-editor/page-dsl.c
@@ -222,8 +222,8 @@ ce_page_dsl_class_init (CEPageDslClass *dsl_class)
 
 void
 dsl_connection_new (GtkWindow *parent,
+                    NMRemoteSettings *settings,
                     PageNewConnectionResultFunc result_func,
-                    PageGetConnectionsFunc get_connections_func,
                     gpointer user_data)
 {
 	NMConnection *connection;
@@ -232,7 +232,7 @@ dsl_connection_new (GtkWindow *parent,
 	connection = ce_page_new_connection (_("DSL connection %d"),
 	                                     NM_SETTING_PPPOE_SETTING_NAME,
 	                                     FALSE,
-	                                     get_connections_func,
+	                                     settings,
 	                                     user_data);
 	nm_connection_add_setting (connection, nm_setting_pppoe_new ());
 	nm_connection_add_setting (connection, nm_setting_wired_new ());
diff --git a/src/connection-editor/page-dsl.h b/src/connection-editor/page-dsl.h
index 2679939..04f2b09 100644
--- a/src/connection-editor/page-dsl.h
+++ b/src/connection-editor/page-dsl.h
@@ -54,8 +54,8 @@ CEPage *ce_page_dsl_new (NMConnection *connection,
                          GError **error);
 
 void dsl_connection_new (GtkWindow *parent,
+                         NMRemoteSettings *settings,
                          PageNewConnectionResultFunc callback,
-                         PageGetConnectionsFunc get_connections_func,
                          gpointer user_data);
 
 #endif  /* __PAGE_DSL_H__ */
diff --git a/src/connection-editor/page-mobile.c b/src/connection-editor/page-mobile.c
index 517ebb9..e59c07d 100644
--- a/src/connection-editor/page-mobile.c
+++ b/src/connection-editor/page-mobile.c
@@ -539,8 +539,8 @@ add_default_serial_setting (NMConnection *connection)
 }
 
 typedef struct {
+    NMRemoteSettings *settings;
     PageNewConnectionResultFunc result_func;
-    PageGetConnectionsFunc get_connections_func;
     gpointer user_data;
 } WizardInfo;
 
@@ -589,7 +589,7 @@ 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->get_connections_func, info->user_data);
+		connection = ce_page_new_connection (detail, ctype, FALSE, info->settings, info->user_data);
 		g_free (detail);
 
 		nm_connection_add_setting (connection, type_setting);
@@ -601,6 +601,8 @@ new_connection_mobile_wizard_done (NMAMobileWizard *wizard,
 
 	if (wizard)
 		nma_mobile_wizard_destroy (wizard);
+
+	g_object_unref (info->settings);
 	g_free (info);
 }
 
@@ -612,8 +614,8 @@ cancel_dialog (GtkDialog *dialog)
 
 void
 mobile_connection_new (GtkWindow *parent,
+                       NMRemoteSettings *settings,
                        PageNewConnectionResultFunc result_func,
-                       PageGetConnectionsFunc get_connections_func,
                        gpointer user_data)
 {
 	NMAMobileWizard *wizard;
@@ -625,7 +627,7 @@ mobile_connection_new (GtkWindow *parent,
 
 	info = g_malloc0 (sizeof (WizardInfo));
 	info->result_func = result_func;
-	info->get_connections_func = get_connections_func;
+	info->settings = g_object_ref (settings);
 	info->user_data = user_data;
 
 	wizard = nma_mobile_wizard_new (parent, NULL, NM_DEVICE_MODEM_CAPABILITY_NONE, FALSE,
diff --git a/src/connection-editor/page-mobile.h b/src/connection-editor/page-mobile.h
index 19d449e..b5c27d0 100644
--- a/src/connection-editor/page-mobile.h
+++ b/src/connection-editor/page-mobile.h
@@ -54,8 +54,8 @@ CEPage *ce_page_mobile_new (NMConnection *connection,
                             GError **error);
 
 void mobile_connection_new (GtkWindow *parent,
+                            NMRemoteSettings *settings,
                             PageNewConnectionResultFunc result_func,
-                            PageGetConnectionsFunc get_connections_func,
                             gpointer user_data);
 
 #endif  /* __PAGE_MOBILE_H__ */
diff --git a/src/connection-editor/page-vpn.c b/src/connection-editor/page-vpn.c
index 8e9f1a9..d5604b4 100644
--- a/src/connection-editor/page-vpn.c
+++ b/src/connection-editor/page-vpn.c
@@ -191,8 +191,8 @@ ce_page_vpn_class_init (CEPageVpnClass *vpn_class)
 }
 
 typedef struct {
+	NMRemoteSettings *settings;
 	PageNewConnectionResultFunc result_func;
-	PageGetConnectionsFunc get_connections_func;
 	gpointer user_data;
 } NewVpnInfo;
 
@@ -217,7 +217,7 @@ import_cb (NMConnection *connection, gpointer user_data)
 	if (!s) {
 		GSList *connections;
 
-		connections = info->get_connections_func (info->user_data);
+		connections = nm_remote_settings_list_connections (info->settings);
 		s = ce_page_get_next_available_name (connections, _("VPN connection %d"));
 		g_object_set (s_con, NM_SETTING_CONNECTION_ID, s, NULL);
 		g_free (s);
@@ -249,13 +249,14 @@ import_cb (NMConnection *connection, gpointer user_data)
 
 	info->result_func (connection, FALSE, error, info->user_data);
 	g_clear_error (&error);
+	g_object_unref (info->settings);
 	g_slice_free (NewVpnInfo, info);
 }
 
 void
 vpn_connection_new (GtkWindow *parent,
+                    NMRemoteSettings *settings,
                     PageNewConnectionResultFunc result_func,
-                    PageGetConnectionsFunc get_connections_func,
                     gpointer user_data)
 {
 	char *service = NULL;
@@ -274,7 +275,7 @@ vpn_connection_new (GtkWindow *parent,
 		g_free (service);
 		info = g_slice_new (NewVpnInfo);
 		info->result_func = result_func;
-		info->get_connections_func = get_connections_func;
+		info->settings = g_object_ref (settings);
 		info->user_data = user_data;
 		vpn_import (import_cb, info);
 		return;
@@ -283,7 +284,7 @@ vpn_connection_new (GtkWindow *parent,
 	connection = ce_page_new_connection (_("VPN connection %d"),
 	                                     NM_SETTING_VPN_SETTING_NAME,
 	                                     FALSE,
-	                                     get_connections_func,
+	                                     settings,
 	                                     user_data);
 	s_vpn = nm_setting_vpn_new ();
 	g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, service, NULL);
diff --git a/src/connection-editor/page-vpn.h b/src/connection-editor/page-vpn.h
index d9a4106..66c1c81 100644
--- a/src/connection-editor/page-vpn.h
+++ b/src/connection-editor/page-vpn.h
@@ -56,8 +56,8 @@ CEPage *ce_page_vpn_new (NMConnection *connection,
 gboolean ce_page_vpn_can_export (CEPageVpn *page);
 
 void vpn_connection_new (GtkWindow *parent,
+                         NMRemoteSettings *settings,
                          PageNewConnectionResultFunc result_func,
-                         PageGetConnectionsFunc get_connections_func,
                          gpointer user_data);
 
 #endif  /* __PAGE_VPN_H__ */
diff --git a/src/connection-editor/page-wired.c b/src/connection-editor/page-wired.c
index 2d1ad0f..e95dfc2 100644
--- a/src/connection-editor/page-wired.c
+++ b/src/connection-editor/page-wired.c
@@ -440,8 +440,8 @@ ce_page_wired_class_init (CEPageWiredClass *wired_class)
 
 void
 wired_connection_new (GtkWindow *parent,
+                      NMRemoteSettings *settings,
                       PageNewConnectionResultFunc result_func,
-                      PageGetConnectionsFunc get_connections_func,
                       gpointer user_data)
 {
 	NMConnection *connection;
@@ -449,7 +449,7 @@ wired_connection_new (GtkWindow *parent,
 	connection = ce_page_new_connection (_("Wired connection %d"),
 	                                     NM_SETTING_WIRED_SETTING_NAME,
 	                                     TRUE,
-	                                     get_connections_func,
+	                                     settings,
 	                                     user_data);
 	nm_connection_add_setting (connection, nm_setting_wired_new ());
 
diff --git a/src/connection-editor/page-wired.h b/src/connection-editor/page-wired.h
index 4a38568..b257d0e 100644
--- a/src/connection-editor/page-wired.h
+++ b/src/connection-editor/page-wired.h
@@ -54,8 +54,8 @@ CEPage *ce_page_wired_new (NMConnection *connection,
                            GError **error);
 
 void wired_connection_new (GtkWindow *parent,
+                           NMRemoteSettings *settings,
                            PageNewConnectionResultFunc result_func,
-                           PageGetConnectionsFunc get_connections_func,
                            gpointer user_data);
 
 #endif  /* __PAGE_WIRED_H__ */
diff --git a/src/connection-editor/page-wireless.c b/src/connection-editor/page-wireless.c
index 3b1b57e..b317ac6 100644
--- a/src/connection-editor/page-wireless.c
+++ b/src/connection-editor/page-wireless.c
@@ -656,8 +656,8 @@ ce_page_wireless_class_init (CEPageWirelessClass *wireless_class)
 
 void
 wifi_connection_new (GtkWindow *parent,
+                     NMRemoteSettings *settings,
                      PageNewConnectionResultFunc result_func,
-                     PageGetConnectionsFunc get_connections_func,
                      gpointer user_data)
 {
 	NMConnection *connection;
@@ -666,7 +666,7 @@ wifi_connection_new (GtkWindow *parent,
 	connection = ce_page_new_connection (_("Wireless connection %d"),
 	                                     NM_SETTING_WIRELESS_SETTING_NAME,
 	                                     TRUE,
-	                                     get_connections_func,
+	                                     settings,
 	                                     user_data);
 	s_wifi = nm_setting_wireless_new ();
 	g_object_set (s_wifi, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL);
diff --git a/src/connection-editor/page-wireless.h b/src/connection-editor/page-wireless.h
index 5ddb696..5ab782e 100644
--- a/src/connection-editor/page-wireless.h
+++ b/src/connection-editor/page-wireless.h
@@ -58,8 +58,8 @@ GByteArray *ce_page_wireless_get_ssid (CEPageWireless *self);
 
 
 void wifi_connection_new (GtkWindow *parent,
+                          NMRemoteSettings *settings,
                           PageNewConnectionResultFunc result_func,
-                          PageGetConnectionsFunc get_connections_func,
                           gpointer user_data);
 
 #endif  /* __PAGE_WIRELESS_H__ */



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