[gnome-control-center] network: Don't save hidden configuration options



commit 33b1858787d03d451bb8a0036fe014d544d90b71
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Aug 13 18:26:19 2014 +0200

    network: Don't save hidden configuration options
    
    When switching from a particular IPv4 or IPv6 "addresses" method to
    another, make sure that "address", "DNS" and "routes" are applied or
    ignored depending on that method's capabilities.
    
    For example, when switching from manual to automatic IPv4 "addresses"
    method, we need to make sure that the old IP address, gateway, etc.
    aren't actually used in the new setting.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=734337

 panels/network/connection-editor/ce-page-ip4.c |   21 +++++++++++++++++----
 panels/network/connection-editor/ce-page-ip6.c |   22 +++++++++++++++++++---
 2 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/panels/network/connection-editor/ce-page-ip4.c b/panels/network/connection-editor/ce-page-ip4.c
index 7972222..a768bc9 100644
--- a/panels/network/connection-editor/ce-page-ip4.c
+++ b/panels/network/connection-editor/ce-page-ip4.c
@@ -704,7 +704,11 @@ ui_to_setting (CEPageIP4 *page)
         }
 
         addresses = g_ptr_array_new_with_free_func (free_addr);
-        children = gtk_container_get_children (GTK_CONTAINER (page->address_list));
+        if (g_str_equal (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
+                children = gtk_container_get_children (GTK_CONTAINER (page->address_list));
+        else
+                children = NULL;
+
         for (l = children; l; l = l->next) {
                 GtkWidget *row = l->data;
                 GtkEntry *entry;
@@ -774,7 +778,12 @@ ui_to_setting (CEPageIP4 *page)
         }
 
         dns_servers = g_array_new (FALSE, FALSE, sizeof (guint));
-        children = gtk_container_get_children (GTK_CONTAINER (page->dns_list));
+        if (g_str_equal (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) ||
+            g_str_equal (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
+                children = gtk_container_get_children (GTK_CONTAINER (page->dns_list));
+        else
+                children = NULL;
+
         for (l = children; l; l = l->next) {
                 GtkWidget *row = l->data;
                 GtkEntry *entry;
@@ -802,9 +811,13 @@ ui_to_setting (CEPageIP4 *page)
         }
         g_list_free (children);
 
-
         routes = g_ptr_array_new_with_free_func (free_addr);
-        children = gtk_container_get_children (GTK_CONTAINER (page->routes_list));
+        if (g_str_equal (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO) ||
+            g_str_equal (method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
+                children = gtk_container_get_children (GTK_CONTAINER (page->routes_list));
+        else
+                children = NULL;
+
         for (l = children; l; l = l->next) {
                 GtkWidget *row = l->data;
                 GtkEntry *entry;
diff --git a/panels/network/connection-editor/ce-page-ip6.c b/panels/network/connection-editor/ce-page-ip6.c
index 5c07290..8084bff 100644
--- a/panels/network/connection-editor/ce-page-ip6.c
+++ b/panels/network/connection-editor/ce-page-ip6.c
@@ -681,7 +681,11 @@ ui_to_setting (CEPageIP6 *page)
         }
 
         nm_setting_ip6_config_clear_addresses (page->setting);
-        children = gtk_container_get_children (GTK_CONTAINER (page->address_list));
+        if (g_str_equal (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL))
+                children = gtk_container_get_children (GTK_CONTAINER (page->address_list));
+        else
+                children = NULL;
+
         for (l = children; l; l = l->next) {
                 GtkWidget *row = l->data;
                 GtkEntry *entry;
@@ -752,7 +756,13 @@ ui_to_setting (CEPageIP6 *page)
         g_list_free (children);
 
         nm_setting_ip6_config_clear_dns (page->setting);
-        children = gtk_container_get_children (GTK_CONTAINER (page->dns_list));
+        if (g_str_equal (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) ||
+            g_str_equal (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) ||
+            g_str_equal (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL))
+                children = gtk_container_get_children (GTK_CONTAINER (page->dns_list));
+        else
+                children = NULL;
+
         for (l = children; l; l = l->next) {
                 GtkWidget *row = l->data;
                 GtkEntry *entry;
@@ -781,7 +791,13 @@ ui_to_setting (CEPageIP6 *page)
         g_list_free (children);
 
         nm_setting_ip6_config_clear_routes (page->setting);
-        children = gtk_container_get_children (GTK_CONTAINER (page->routes_list));
+        if (g_str_equal (method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) ||
+            g_str_equal (method, NM_SETTING_IP6_CONFIG_METHOD_DHCP) ||
+            g_str_equal (method, NM_SETTING_IP6_CONFIG_METHOD_MANUAL))
+                children = gtk_container_get_children (GTK_CONTAINER (page->routes_list));
+        else
+                children = NULL;
+
         for (l = children; l; l = l->next) {
                 GtkWidget *row = l->data;
                 GtkEntry *entry;


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