[network-manager-applet] editor: implement IPv4/IPv6 'may-fail' options



commit 4996767ccf70a9cfb7ba2b19a27d2b6e01c857a3
Author: Dan Williams <dcbw redhat com>
Date:   Sun May 2 16:56:54 2010 -0700

    editor: implement IPv4/IPv6 'may-fail' options
    
    Since most of the time the user doesn't really care what type
    of connectivity they have, as long as they have *some* connectivity,
    this allows better "Just Works" behavior as long as the system
    settings plugins and connection editors/applets use the right
    defaults.

 src/connection-editor/ce-page-ip4.glade |   18 ++++++++++++++++--
 src/connection-editor/ce-page-ip6.glade |   19 ++++++++++++++++++-
 src/connection-editor/page-ip4.c        |   22 ++++++++++++++++++++++
 src/connection-editor/page-ip6.c        |   26 +++++++++++++++++++++++++-
 4 files changed, 81 insertions(+), 4 deletions(-)
---
diff --git a/src/connection-editor/ce-page-ip4.glade b/src/connection-editor/ce-page-ip4.glade
index 7257cb2..b40759c 100644
--- a/src/connection-editor/ce-page-ip4.glade
+++ b/src/connection-editor/ce-page-ip4.glade
@@ -249,6 +249,20 @@ Shared to other computers</property>
                       </packing>
                     </child>
                     <child>
+                      <widget class="GtkCheckButton" id="ip4_required_checkbutton">
+                        <property name="label" translatable="yes">Require IPv4 addressing for this connection to complete</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="tooltip" translatable="yes">When connecting to IPv6-capable networks, allows the connection to complete if IPv4 configuration fails but IPv6 configuration succeeds.</property>
+                        <property name="draw_indicator">True</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
                       <widget class="GtkHButtonBox" id="hbuttonbox1">
                         <property name="visible">True</property>
                         <property name="layout_style">end</property>
@@ -273,7 +287,7 @@ Shared to other computers</property>
                                 <child>
                                   <widget class="GtkLabel" id="label1">
                                     <property name="visible">True</property>
-                                    <property name="label" translatable="yes">_Routesâ?¦</property>
+                                    <property name="label" translatable="yes">_Routes&#x2026;</property>
                                     <property name="use_underline">True</property>
                                   </widget>
                                   <packing>
@@ -296,7 +310,7 @@ Shared to other computers</property>
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">False</property>
-                        <property name="position">2</property>
+                        <property name="position">3</property>
                       </packing>
                     </child>
                   </widget>
diff --git a/src/connection-editor/ce-page-ip6.glade b/src/connection-editor/ce-page-ip6.glade
index f3e80d4..aa89f07 100644
--- a/src/connection-editor/ce-page-ip6.glade
+++ b/src/connection-editor/ce-page-ip6.glade
@@ -8,6 +8,7 @@
       <widget class="GtkVBox" id="IP6Page">
         <property name="visible">True</property>
         <property name="border_width">12</property>
+        <property name="orientation">vertical</property>
         <property name="spacing">18</property>
         <child>
           <widget class="GtkHBox" id="hbox1">
@@ -50,6 +51,7 @@ Shared to other computers</property>
         <child>
           <widget class="GtkVBox" id="ip6_addresses_box">
             <property name="visible">True</property>
+            <property name="orientation">vertical</property>
             <property name="spacing">6</property>
             <child>
               <widget class="GtkLabel" id="ip6_addr_label">
@@ -102,6 +104,7 @@ Shared to other computers</property>
                         <child>
                           <widget class="GtkVButtonBox" id="vbuttonbox1">
                             <property name="visible">True</property>
+                            <property name="orientation">vertical</property>
                             <property name="spacing">6</property>
                             <property name="layout_style">start</property>
                             <child>
@@ -217,6 +220,20 @@ Shared to other computers</property>
                       </packing>
                     </child>
                     <child>
+                      <widget class="GtkCheckButton" id="ip6_required_checkbutton">
+                        <property name="label" translatable="yes">Require IPv6 addressing for this connection to complete</property>
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="receives_default">False</property>
+                        <property name="tooltip" translatable="yes">When connecting to IPv4-capable networks, allows the connection to complete if IPv6 configuration fails but IPv4 configuration succeeds.</property>
+                        <property name="draw_indicator">True</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                    <child>
                       <widget class="GtkHButtonBox" id="hbuttonbox1">
                         <property name="visible">True</property>
                         <property name="layout_style">end</property>
@@ -264,7 +281,7 @@ Shared to other computers</property>
                       <packing>
                         <property name="expand">False</property>
                         <property name="fill">False</property>
-                        <property name="position">2</property>
+                        <property name="position">3</property>
                       </packing>
                     </child>
                   </widget>
diff --git a/src/connection-editor/page-ip4.c b/src/connection-editor/page-ip4.c
index 1dd4e49..1827a15 100644
--- a/src/connection-editor/page-ip4.c
+++ b/src/connection-editor/page-ip4.c
@@ -80,8 +80,12 @@ typedef struct {
 	GtkWidget *dhcp_client_id_label;
 	GtkEntry *dhcp_client_id;
 
+	/* Routes */
 	GtkButton *routes_button;
 
+	/* IPv4 required */
+	GtkCheckButton *ip4_required;
+
 	GtkWindowGroup *window_group;
 	gboolean window_added;
 
@@ -212,6 +216,14 @@ ip4_private_init (CEPageIP4 *self, NMConnection *connection)
 		gtk_widget_hide (GTK_WIDGET (priv->dhcp_client_id));
 	}
 
+	priv->ip4_required = GTK_CHECK_BUTTON (glade_xml_get_widget (xml, "ip4_required_checkbutton"));
+	/* Hide IP4-require button if it'll never be used for a particular method */
+	if (   priv->connection_type == NM_TYPE_SETTING_VPN
+	    || priv->connection_type == NM_TYPE_SETTING_GSM
+	    || priv->connection_type == NM_TYPE_SETTING_CDMA
+	    || priv->connection_type == NM_TYPE_SETTING_PPPOE)
+		gtk_widget_hide (GTK_WIDGET (priv->ip4_required));
+
 	priv->routes_button = GTK_BUTTON (glade_xml_get_widget (xml, "ip4_routes_button"));
 }
 
@@ -410,6 +422,10 @@ populate_ui (CEPageIP4 *self)
 			                    nm_setting_ip4_config_get_dhcp_client_id (setting));
 		}
 	}
+
+	/* IPv4 required */
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->ip4_required),
+	                              !nm_setting_ip4_config_get_may_fail (setting));
 }
 
 static void
@@ -766,6 +782,8 @@ finish_setup (CEPageIP4 *self, gpointer unused, GError *error, gpointer user_dat
 
 	g_signal_connect_swapped (priv->dhcp_client_id, "changed", G_CALLBACK (ce_page_changed), self);
 
+	g_signal_connect_swapped (priv->ip4_required, "toggled", G_CALLBACK (ce_page_changed), self);
+
 	g_signal_connect (priv->routes_button, "clicked", G_CALLBACK (routes_button_clicked_cb), self);
 }
 
@@ -871,6 +889,7 @@ ui_to_setting (CEPageIP4 *self)
 	gboolean ignore_auto_dns = FALSE;
 	const char *dhcp_client_id = NULL;
 	char **items = NULL, **iter;
+	gboolean may_fail = FALSE;
 
 	/* Method */
 	if (gtk_combo_box_get_active_iter (priv->method, &tree_iter)) {
@@ -1009,6 +1028,8 @@ ui_to_setting (CEPageIP4 *self)
 			dhcp_client_id = NULL;
 	}
 
+	may_fail = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->ip4_required));
+
 	/* Update setting */
 	g_object_set (priv->setting,
 				  NM_SETTING_IP4_CONFIG_METHOD, method,
@@ -1017,6 +1038,7 @@ ui_to_setting (CEPageIP4 *self)
 				  NM_SETTING_IP4_CONFIG_DNS_SEARCH, search_domains,
 				  NM_SETTING_IP4_CONFIG_IGNORE_AUTO_DNS, ignore_auto_dns,
 				  NM_SETTING_IP4_CONFIG_DHCP_CLIENT_ID, dhcp_client_id,
+				  NM_SETTING_IP4_CONFIG_MAY_FAIL, may_fail,
 				  NULL);
 	valid = TRUE;
 
diff --git a/src/connection-editor/page-ip6.c b/src/connection-editor/page-ip6.c
index 1348169..fb5cc7f 100644
--- a/src/connection-editor/page-ip6.c
+++ b/src/connection-editor/page-ip6.c
@@ -17,7 +17,7 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  *
- * (C) Copyright 2008 Red Hat, Inc.
+ * (C) Copyright 2008 - 2010 Red Hat, Inc.
  */
 
 #include <string.h>
@@ -76,8 +76,12 @@ typedef struct {
 	GtkWidget *dns_searches_label;
 	GtkEntry *dns_searches;
 
+	/* Routes */
 	GtkButton *routes_button;
 
+	/* IPv6 required */
+	GtkCheckButton *ip6_required;
+
 	GtkWindowGroup *window_group;
 	gboolean window_added;
 
@@ -216,6 +220,14 @@ ip6_private_init (CEPageIP6 *self, NMConnection *connection)
 	priv->dns_searches_label = glade_xml_get_widget (xml, "ip6_dns_searches_label");
 	priv->dns_searches = GTK_ENTRY (glade_xml_get_widget (xml, "ip6_dns_searches_entry"));
 
+	priv->ip6_required = GTK_CHECK_BUTTON (glade_xml_get_widget (xml, "ip6_required_checkbutton"));
+	/* Hide IP6-require button if it'll never be used for a particular method */
+	if (   priv->connection_type == NM_TYPE_SETTING_VPN
+	    || priv->connection_type == NM_TYPE_SETTING_GSM
+	    || priv->connection_type == NM_TYPE_SETTING_CDMA
+	    || priv->connection_type == NM_TYPE_SETTING_PPPOE)
+		gtk_widget_hide (GTK_WIDGET (priv->ip6_required));
+
 	priv->routes_button = GTK_BUTTON (glade_xml_get_widget (xml, "ip6_routes_button"));
 }
 
@@ -400,6 +412,10 @@ populate_ui (CEPageIP6 *self)
 	}
 	gtk_entry_set_text (priv->dns_searches, string->str);
 	g_string_free (string, TRUE);
+
+	/* IPv6 required */
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->ip6_required),
+	                              !nm_setting_ip6_config_get_may_fail (setting));
 }
 
 static void
@@ -746,6 +762,8 @@ finish_setup (CEPageIP6 *self, gpointer unused, GError *error, gpointer user_dat
 	method_changed (priv->method, self);
 	g_signal_connect (priv->method, "changed", G_CALLBACK (method_changed), self);
 
+	g_signal_connect_swapped (priv->ip6_required, "toggled", G_CALLBACK (ce_page_changed), self);
+
 	g_signal_connect (priv->routes_button, "clicked", G_CALLBACK (routes_button_clicked_cb), self);
 }
 
@@ -815,6 +833,7 @@ ui_to_setting (CEPageIP6 *self)
 	const char *text;
 	gboolean ignore_auto_dns = FALSE;
 	char **items = NULL, **iter;
+	gboolean may_fail;
 
 	/* Method */
 	if (gtk_combo_box_get_active_iter (priv->method, &tree_iter)) {
@@ -953,6 +972,11 @@ ui_to_setting (CEPageIP6 *self)
 			g_strfreev (items);
 	}
 
+	may_fail = !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->ip6_required));
+	g_object_set (G_OBJECT (priv->setting),
+	              NM_SETTING_IP6_CONFIG_MAY_FAIL, may_fail,
+	              NULL);
+
 	valid = TRUE;
 
 out:



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