[network-manager-applet] editor: hide widgets that aren't supported for VPNs on the general page



commit 03760194e54eaeaf493e9b45c4835e84524d8650
Author: Dan Williams <dcbw redhat com>
Date:   Thu Jan 31 12:44:13 2013 -0600

    editor: hide widgets that aren't supported for VPNs on the general page
    
    VPN autoconnect is handled already by the "Automatically connect to VPN
    when using this connection" combo, so we don't need to show the
    autoconnect checkbox.  Second, we don't support multiple VPNs yet so
    we can't show the "Autoconnect VPN when..." combo for VPNs either.

 src/connection-editor/ce-page-general.ui |  145 +++++++++++++-----------------
 src/connection-editor/page-general.c     |   20 ++++
 2 files changed, 84 insertions(+), 81 deletions(-)
---
diff --git a/src/connection-editor/ce-page-general.ui b/src/connection-editor/ce-page-general.ui
index c7fa75c..f505c14 100644
--- a/src/connection-editor/ce-page-general.ui
+++ b/src/connection-editor/ce-page-general.ui
@@ -14,83 +14,9 @@
     <property name="can_focus">False</property>
     <property name="border_width">12</property>
     <property name="n_rows">5</property>
-    <property name="n_columns">2</property>
     <property name="column_spacing">12</property>
     <property name="row_spacing">6</property>
     <child>
-      <object class="GtkVBox" id="vbox1">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <child>
-          <object class="GtkCheckButton" id="connection_autoconnect">
-            <property name="label" translatable="yes">_Automatically connect to this network when it is available</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="use_underline">True</property>
-            <property name="xalign">0</property>
-            <property name="active">True</property>
-            <property name="draw_indicator">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkCheckButton" id="system_checkbutton">
-            <property name="label" translatable="yes">All _users may connect to this network</property>
-            <property name="visible">True</property>
-            <property name="can_focus">True</property>
-            <property name="receives_default">False</property>
-            <property name="use_underline">True</property>
-            <property name="xalign">0</property>
-            <property name="draw_indicator">True</property>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">False</property>
-            <property name="position">1</property>
-          </packing>
-        </child>
-      </object>
-      <packing>
-        <property name="right_attach">2</property>
-        <property name="y_options"/>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkLabel" id="firewall_zone_label">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="xalign">0</property>
-        <property name="label" translatable="yes">Firewall _zone:</property>
-        <property name="use_underline">True</property>
-      </object>
-      <packing>
-        <property name="top_attach">4</property>
-        <property name="bottom_attach">5</property>
-        <property name="x_options">GTK_FILL</property>
-        <property name="y_options"/>
-        <property name="y_padding">12</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkAlignment" id="firewall_zone_alignment">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-      </object>
-      <packing>
-        <property name="left_attach">1</property>
-        <property name="right_attach">2</property>
-        <property name="top_attach">4</property>
-        <property name="bottom_attach">5</property>
-        <property name="x_options">GTK_FILL</property>
-        <property name="y_options"/>
-      </packing>
-    </child>
-    <child>
       <object class="GtkCheckButton" id="dependent_vpn_checkbox">
         <property name="label" translatable="yes">Automatically connect to _VPN when using this connection</property>
         <property name="visible">True</property>
@@ -101,11 +27,10 @@
         <property name="draw_indicator">True</property>
       </object>
       <packing>
-        <property name="right_attach">2</property>
         <property name="top_attach">2</property>
         <property name="bottom_attach">3</property>
         <property name="x_options">GTK_FILL</property>
-        <property name="y_options"/>
+        <property name="y_options"></property>
       </packing>
     </child>
     <child>
@@ -113,6 +38,7 @@
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <property name="margin_left">26</property>
+        <property name="margin_bottom">12</property>
         <property name="model">dependent_vpn_model</property>
         <child>
           <object class="GtkCellRendererText" id="renderer1"/>
@@ -122,23 +48,80 @@
         </child>
       </object>
       <packing>
-        <property name="right_attach">2</property>
         <property name="top_attach">3</property>
         <property name="bottom_attach">4</property>
-        <property name="y_options"/>
+        <property name="y_options"></property>
       </packing>
     </child>
     <child>
-      <object class="GtkLabel" id="gap">
+      <object class="GtkCheckButton" id="system_checkbutton">
+        <property name="label" translatable="yes">All _users may connect to this network</property>
         <property name="visible">True</property>
-        <property name="can_focus">False</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">False</property>
+        <property name="margin_bottom">12</property>
+        <property name="use_underline">True</property>
+        <property name="xalign">0</property>
+        <property name="draw_indicator">True</property>
       </object>
       <packing>
-        <property name="right_attach">2</property>
         <property name="top_attach">1</property>
         <property name="bottom_attach">2</property>
         <property name="y_options">GTK_FILL</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkCheckButton" id="connection_autoconnect">
+        <property name="label" translatable="yes">_Automatically connect to this network when it is available</property>
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">False</property>
+        <property name="use_underline">True</property>
+        <property name="xalign">0</property>
+        <property name="active">True</property>
+        <property name="draw_indicator">True</property>
+      </object>
+      <packing>
+        <property name="y_options">GTK_FILL</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkBox" id="box2">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="valign">start</property>
+        <property name="vexpand">True</property>
+        <property name="spacing">6</property>
+        <child>
+          <object class="GtkLabel" id="firewall_zone_label">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="xalign">0</property>
+            <property name="label" translatable="yes">Firewall _zone:</property>
+            <property name="use_underline">True</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkAlignment" id="firewall_zone_alignment">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+      </object>
+      <packing>
+        <property name="top_attach">4</property>
+        <property name="bottom_attach">5</property>
+      </packing>
+    </child>
   </object>
 </interface>
diff --git a/src/connection-editor/page-general.c b/src/connection-editor/page-general.c
index 2597971..607e21c 100644
--- a/src/connection-editor/page-general.c
+++ b/src/connection-editor/page-general.c
@@ -35,6 +35,8 @@ typedef struct {
 	NMRemoteSettings *remote_settings;
 	NMSettingConnection *setting;
 
+	gboolean is_vpn;
+
 #if GTK_CHECK_VERSION(2,24,0)
 	GtkComboBoxText *firewall_zone;
 #else
@@ -269,10 +271,26 @@ populate_ui (CEPageGeneral *self)
 	g_slist_free (con_list);
 	gtk_combo_box_set_active (GTK_COMBO_BOX (priv->dependent_vpn), combo_idx);
 
+	/* We don't support multiple VPNs at the moment, so hide secondary
+	 * stuff for VPN connections.  We'll revisit this later when we support
+	 * multiple VPNs.
+	 */
+	if (priv->is_vpn) {
+		gtk_widget_hide (GTK_WIDGET (priv->dependent_vpn_checkbox));
+		gtk_widget_hide (GTK_WIDGET (priv->dependent_vpn));
+	}
+
 	/* 'Automatically connect to this network' checkbox */
 	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->autoconnect),
 	                              nm_setting_connection_get_autoconnect (priv->setting));
 
+	/* VPN connections don't have a blanket "autoconnect" as that is too coarse
+	 * a behavior, instead the user configures another connection to start the
+	 * VPN on success.
+	 */
+	if (priv->is_vpn)
+		gtk_widget_hide (priv->autoconnect);
+
 	/* 'All users may connect to this network' checkbox */
 	if (nm_setting_connection_get_num_permissions (priv->setting))
 		global_connection = FALSE;
@@ -342,6 +360,8 @@ ce_page_general_new (NMConnection *connection,
 		nm_connection_add_setting (connection, NM_SETTING (priv->setting));
 	}
 
+	priv->is_vpn = nm_connection_is_type (connection, NM_SETTING_VPN_SETTING_NAME);
+
 	g_signal_connect (self, "initialized", G_CALLBACK (finish_setup), NULL);
 
 	return CE_PAGE (self);



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