[network-manager-applet] editor: move 'Connect automatically' and 'Available to all users' to General page



commit 648a382fe6aa959e2ed9456922dead25c27dc09d
Author: JiÅÃ KlimeÅ <jklimes redhat com>
Date:   Thu Oct 4 16:03:37 2012 -0400

    editor: move 'Connect automatically' and 'Available to all users' to General page
    
    and rename them to
    "Automatically connect to this network"
    and
    "All users may connect to this network"

 src/connection-editor/ce-page-general.ui      |   63 +++++++++++++++++++++----
 src/connection-editor/nm-connection-editor.c  |   53 ++-------------------
 src/connection-editor/nm-connection-editor.ui |   48 -------------------
 src/connection-editor/page-general.c          |   31 ++++++++++++
 4 files changed, 89 insertions(+), 106 deletions(-)
---
diff --git a/src/connection-editor/ce-page-general.ui b/src/connection-editor/ce-page-general.ui
index 461432e..2014c4b 100644
--- a/src/connection-editor/ce-page-general.ui
+++ b/src/connection-editor/ce-page-general.ui
@@ -13,11 +13,56 @@
     <property name="visible">True</property>
     <property name="can_focus">False</property>
     <property name="border_width">12</property>
-    <property name="n_rows">3</property>
+    <property name="n_rows">4</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</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="top_attach">0</property>
+        <property name="bottom_attach">1</property>
+        <property name="y_options"></property>
+      </packing>
+    </child>
+    <child>
       <object class="GtkLabel" id="firewall_zone_label">
         <property name="visible">True</property>
         <property name="can_focus">False</property>
@@ -27,8 +72,8 @@
       </object>
       <packing>
         <property name="right_attach">1</property>
-        <property name="top_attach">2</property>
-        <property name="bottom_attach">3</property>
+        <property name="top_attach">3</property>
+        <property name="bottom_attach">4</property>
         <property name="x_options">GTK_FILL</property>
         <property name="y_options"></property>
         <property name="y_padding">12</property>
@@ -42,8 +87,8 @@
       <packing>
         <property name="left_attach">1</property>
         <property name="right_attach">2</property>
-        <property name="top_attach">2</property>
-        <property name="bottom_attach">3</property>
+        <property name="top_attach">3</property>
+        <property name="bottom_attach">4</property>
         <property name="x_options">GTK_FILL</property>
         <property name="y_options"></property>
       </packing>
@@ -60,8 +105,8 @@
       </object>
       <packing>
         <property name="right_attach">2</property>
-        <property name="top_attach">0</property>
-        <property name="bottom_attach">1</property>
+        <property name="top_attach">1</property>
+        <property name="bottom_attach">2</property>
         <property name="x_options">GTK_FILL</property>
         <property name="y_options"></property>
       </packing>
@@ -81,8 +126,8 @@
       </object>
       <packing>
         <property name="right_attach">2</property>
-        <property name="top_attach">1</property>
-        <property name="bottom_attach">2</property>
+        <property name="top_attach">2</property>
+        <property name="bottom_attach">3</property>
         <property name="y_options"></property>
       </packing>
     </child>
diff --git a/src/connection-editor/nm-connection-editor.c b/src/connection-editor/nm-connection-editor.c
index 7612567..5c6f8d6 100644
--- a/src/connection-editor/nm-connection-editor.c
+++ b/src/connection-editor/nm-connection-editor.c
@@ -122,7 +122,6 @@ ui_to_setting (NMConnectionEditor *editor)
 	NMSettingConnection *s_con;
 	GtkWidget *widget;
 	const char *name;
-	gboolean autoconnect = FALSE, everyone = FALSE;
 
 	s_con = nm_connection_get_setting_connection (editor->connection);
 	g_assert (s_con);
@@ -136,18 +135,6 @@ ui_to_setting (NMConnectionEditor *editor)
 	if (!name || !strlen (name))
 		return FALSE;
 
-	widget = GTK_WIDGET (gtk_builder_get_object (editor->builder, "connection_autoconnect"));
-	autoconnect = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget));
-	g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_AUTOCONNECT, autoconnect, NULL);
-
-	/* Handle visibility */
-	everyone = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->all_checkbutton));
-	g_object_set (G_OBJECT (s_con), NM_SETTING_CONNECTION_PERMISSIONS, NULL, NULL);
-	if (everyone == FALSE) {
-		/* Only visible to this user */
-		nm_setting_connection_add_permission (s_con, "user", g_get_user_name (), NULL);
-	}
-
 	return TRUE;
 }
 
@@ -183,8 +170,6 @@ update_sensitivity (NMConnectionEditor *editor)
 		sensitive = authorized;
 	}
 
-	gtk_widget_set_sensitive (GTK_WIDGET (editor->all_checkbutton), actionable && authorized);
-
 	/* Cancel button is always sensitive */
 	gtk_widget_set_sensitive (GTK_WIDGET (editor->cancel_button), TRUE);
 
@@ -194,12 +179,6 @@ update_sensitivity (NMConnectionEditor *editor)
 	widget = GTK_WIDGET (gtk_builder_get_object (editor->builder, "connection_name"));
 	gtk_widget_set_sensitive (widget, sensitive);
 
-	widget = GTK_WIDGET (gtk_builder_get_object (editor->builder, "connection_autoconnect"));
-	gtk_widget_set_sensitive (widget, sensitive && !nm_setting_connection_get_master (s_con));
-
-	widget = GTK_WIDGET (gtk_builder_get_object (editor->builder, "connection_name"));
-	gtk_widget_set_sensitive (widget, sensitive);
-
 	for (iter = editor->pages; iter; iter = g_slist_next (iter)) {
 		widget = ce_page_get_page (CE_PAGE (iter->data));
 		gtk_widget_set_sensitive (widget, sensitive);
@@ -275,12 +254,6 @@ permissions_changed_cb (NMClient *client,
 }
 
 static void
-all_checkbutton_toggled_cb (GtkWidget *widget, NMConnectionEditor *editor)
-{
-	connection_editor_validate (editor);
-}
-
-static void
 nm_connection_editor_init (NMConnectionEditor *editor)
 {
 	GtkWidget *dialog;
@@ -310,7 +283,6 @@ nm_connection_editor_init (NMConnectionEditor *editor)
 	editor->window = GTK_WIDGET (gtk_builder_get_object (editor->builder, "nm-connection-editor"));
 	editor->cancel_button = GTK_WIDGET (gtk_builder_get_object (editor->builder, "cancel_button"));
 	editor->export_button = GTK_WIDGET (gtk_builder_get_object (editor->builder, "export_button"));
-	editor->all_checkbutton = GTK_WIDGET (gtk_builder_get_object (editor->builder, "system_checkbutton"));
 }
 
 static void
@@ -543,6 +515,7 @@ update_secret_flags (NMSetting *setting,
 gboolean
 nm_connection_editor_update_connection (NMConnectionEditor *editor)
 {
+	NMSettingConnection *s_con;
 	GHashTable *settings;
 	gboolean everyone = FALSE;
 	GError *error = NULL;
@@ -566,7 +539,8 @@ nm_connection_editor_update_connection (NMConnectionEditor *editor)
 	 * otherwise the secret flags we set here might be overwritten during
 	 * setting validation.
 	 */
-	everyone = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (editor->all_checkbutton));
+	s_con = nm_connection_get_setting_connection (editor->connection);
+	everyone = !nm_setting_connection_get_num_permissions (s_con);
 	nm_connection_for_each_setting_value (editor->connection, update_secret_flags, GUINT_TO_POINTER (everyone));
 
 	/* Copy the modified connection to the original connection */
@@ -582,32 +556,13 @@ populate_connection_ui (NMConnectionEditor *editor)
 {
 	NMSettingConnection *s_con;
 	GtkWidget *name;
-	GtkWidget *autoconnect;
-	gboolean system_connection = TRUE;
 
 	name = GTK_WIDGET (gtk_builder_get_object (editor->builder, "connection_name"));
-	autoconnect = GTK_WIDGET (gtk_builder_get_object (editor->builder, "connection_autoconnect"));
 
 	s_con = nm_connection_get_setting_connection (editor->connection);
-	if (s_con) {
-		const char *id = nm_setting_connection_get_id (s_con);
-
-		gtk_entry_set_text (GTK_ENTRY (name), id);
-		gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (autoconnect),
-		                              nm_setting_connection_get_autoconnect (s_con));
-
-		if (nm_setting_connection_get_num_permissions (s_con))
-			system_connection = FALSE;
-	} else {
-		gtk_entry_set_text (GTK_ENTRY (name), NULL);
-	}
+	gtk_entry_set_text (GTK_ENTRY (name), s_con ? nm_setting_connection_get_id (s_con) : NULL);
 
 	g_signal_connect_swapped (name, "changed", G_CALLBACK (connection_editor_validate), editor);
-	g_signal_connect_swapped (autoconnect, "toggled", G_CALLBACK (connection_editor_validate), editor);
-
-	g_signal_connect (editor->all_checkbutton, "toggled", G_CALLBACK (all_checkbutton_toggled_cb), editor);
-
-	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->all_checkbutton), system_connection);
 
 	connection_editor_validate (editor);
 }
diff --git a/src/connection-editor/nm-connection-editor.ui b/src/connection-editor/nm-connection-editor.ui
index a3f9b02..74ee266 100644
--- a/src/connection-editor/nm-connection-editor.ui
+++ b/src/connection-editor/nm-connection-editor.ui
@@ -179,54 +179,6 @@
               </packing>
             </child>
             <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">Connect _automatically</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">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">True</property>
-                    <property name="fill">True</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkCheckButton" id="system_checkbutton">
-                    <property name="label" translatable="yes">A_vailable to all users</property>
-                    <property name="use_action_appearance">False</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="receives_default">False</property>
-                    <property name="use_action_appearance">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="expand">False</property>
-                <property name="fill">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
               <object class="GtkNotebook" id="notebook">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
diff --git a/src/connection-editor/page-general.c b/src/connection-editor/page-general.c
index 57f6261..921981c 100644
--- a/src/connection-editor/page-general.c
+++ b/src/connection-editor/page-general.c
@@ -44,6 +44,9 @@ typedef struct {
 	GtkToggleButton *dependent_vpn_checkbox;
 	GtkComboBox *dependent_vpn;
 	GtkListStore *dependent_vpn_store;
+
+	GtkWidget *autoconnect;
+	GtkWidget *all_checkbutton;
 } CEPageGeneralPrivate;
 
 /* TRANSLATORS: Default zone set for firewall, when no zone is selected */
@@ -86,6 +89,9 @@ general_private_init (CEPageGeneral *self)
 	priv->dependent_vpn_checkbox = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "dependent_vpn_checkbox"));
 	priv->dependent_vpn = GTK_COMBO_BOX (gtk_builder_get_object (builder, "dependent_vpn_combo"));
 	priv->dependent_vpn_store = GTK_LIST_STORE (gtk_builder_get_object (builder, "dependent_vpn_model"));
+
+	priv->autoconnect = GTK_WIDGET (gtk_builder_get_object (builder, "connection_autoconnect"));
+	priv->all_checkbutton = GTK_WIDGET (gtk_builder_get_object (builder, "system_checkbutton"));
 }
 
 static void
@@ -165,6 +171,7 @@ populate_ui (CEPageGeneral *self)
 	guint32 combo_idx = 0, idx;
 	GSList *con_list, *l;
 	GtkTreeIter iter;
+	gboolean global_connection = TRUE;
 
 	s_zone = nm_setting_connection_get_zone (setting);
 	
@@ -228,6 +235,15 @@ populate_ui (CEPageGeneral *self)
 	g_slist_free (con_list);
 	gtk_combo_box_set_active (GTK_COMBO_BOX (priv->dependent_vpn), combo_idx);
 
+	/* 'Automatically connect to this network' checkbox */
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->autoconnect),
+	                              nm_setting_connection_get_autoconnect (priv->setting));
+
+	/* 'All users may connect to this network' checkbox */
+	if (nm_setting_connection_get_num_permissions (priv->setting))
+		global_connection = FALSE;
+	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->all_checkbutton), global_connection);
+
 	stuff_changed (NULL, self);
 }
 
@@ -249,6 +265,9 @@ finish_setup (CEPageGeneral *self, gpointer unused, GError *error, gpointer user
 	g_signal_connect (priv->dependent_vpn_checkbox, "toggled", G_CALLBACK (vpn_checkbox_toggled), self);
 	gtk_widget_set_sensitive (GTK_WIDGET (priv->dependent_vpn), any_dependent_vpn);
 	g_signal_connect (priv->dependent_vpn, "changed", G_CALLBACK (stuff_changed), self);
+
+	g_signal_connect (priv->autoconnect, "toggled", G_CALLBACK (stuff_changed), self);
+	g_signal_connect (priv->all_checkbutton, "toggled", G_CALLBACK (stuff_changed), self);
 }
 
 CEPage *
@@ -299,6 +318,7 @@ ui_to_setting (CEPageGeneral *self)
 	char *zone;
 	char *uuid = NULL;
 	GtkTreeIter iter;
+	gboolean autoconnect = FALSE, everyone = FALSE;
 
 #if GTK_CHECK_VERSION (2,24,0)
 	zone = gtk_combo_box_text_get_active_text (priv->firewall_zone);
@@ -321,6 +341,17 @@ ui_to_setting (CEPageGeneral *self)
 	if (uuid)
 		nm_setting_connection_add_secondary (priv->setting, uuid);
 	g_free (uuid);
+
+	autoconnect = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->autoconnect));
+	g_object_set (G_OBJECT (priv->setting), NM_SETTING_CONNECTION_AUTOCONNECT, autoconnect, NULL);
+
+	/* Handle visibility */
+	everyone = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (priv->all_checkbutton));
+	g_object_set (G_OBJECT (priv->setting), NM_SETTING_CONNECTION_PERMISSIONS, NULL, NULL);
+	if (everyone == FALSE) {
+		/* Only visible to this user */
+		nm_setting_connection_add_permission (priv->setting, "user", g_get_user_name (), NULL);
+	}
 }
 
 static gboolean



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