network-manager-applet r739 - in trunk: . src src/connection-editor



Author: dcbw
Date: Thu May 29 21:39:35 2008
New Revision: 739
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=739&view=rev

Log:
2008-05-29  Dan Williams  <dcbw redhat com>

	* src/wireless-dialog.c
		- (connection_combo_init): when creating a new adhoc network, only show
			existing Ad-Hoc 'shared' connections
		- (nma_wireless_dialog_get_connection): when creating a new adhoc
			network, set the connection's ip4 method to 'shared'

	* src/connection-editor/ce-page-ip4.glade
		- Add a new IPv4 method "Shared to other computers"

	* src/connection-editor/page-ip4.c
		- (method_changed): enable/disable DNS stuff as appropriate when the
			method changes
		- (populate_ui, ui_to_setting): handle the 'shared' method
		- (ce_page_ip4_new): call method_changed() to update widget sensitivity



Modified:
   trunk/ChangeLog
   trunk/src/connection-editor/ce-page-ip4.glade
   trunk/src/connection-editor/page-ip4.c
   trunk/src/wireless-dialog.c

Modified: trunk/src/connection-editor/ce-page-ip4.glade
==============================================================================
--- trunk/src/connection-editor/ce-page-ip4.glade	(original)
+++ trunk/src/connection-editor/ce-page-ip4.glade	Thu May 29 21:39:35 2008
@@ -62,7 +62,8 @@
 	      <property name="items" translatable="yes">DHCP
 Auto IP
 Manual
-DHCP with manual DNS settings</property>
+DHCP with manual DNS settings
+Shared to other computers</property>
 	      <property name="add_tearoffs">False</property>
 	      <property name="focus_on_click">True</property>
 	    </widget>

Modified: trunk/src/connection-editor/page-ip4.c
==============================================================================
--- trunk/src/connection-editor/page-ip4.c	(original)
+++ trunk/src/connection-editor/page-ip4.c	Thu May 29 21:39:35 2008
@@ -60,6 +60,7 @@
 #define IP4_METHOD_AUTOIP          1
 #define IP4_METHOD_MANUAL          2
 #define IP4_METHOD_DHCP_MANUAL_DNS 3
+#define IP4_METHOD_SHARED          4
 
 #define COL_ADDRESS 0
 #define COL_NETMASK 1
@@ -86,6 +87,29 @@
 static void
 method_changed (GtkComboBox *combo, gpointer user_data)
 {
+	CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (user_data);
+	gboolean is_shared;
+
+	is_shared = (gtk_combo_box_get_active (priv->method) == IP4_METHOD_SHARED);
+
+	gtk_widget_set_sensitive (GTK_WIDGET (priv->addr_add), !is_shared);
+	gtk_widget_set_sensitive (GTK_WIDGET (priv->addr_delete), !is_shared);
+	gtk_widget_set_sensitive (GTK_WIDGET (priv->addr_list), !is_shared);
+	if (is_shared) {
+		GtkListStore *store;
+
+		store = GTK_LIST_STORE (gtk_tree_view_get_model (priv->addr_list));
+		gtk_list_store_clear (store);
+	}
+
+	gtk_widget_set_sensitive (GTK_WIDGET (priv->dns_servers), !is_shared);
+	if (is_shared)
+		gtk_entry_set_text (priv->dns_servers, "");
+
+	gtk_widget_set_sensitive (GTK_WIDGET (priv->dns_searches), !is_shared);
+	if (is_shared)
+		gtk_entry_set_text (priv->dns_searches, "");
+
 	ce_page_changed (CE_PAGE (user_data));
 }
 
@@ -123,13 +147,14 @@
 			method = IP4_METHOD_AUTOIP;
 		else if (!strcmp (setting->method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
 			method = IP4_METHOD_MANUAL;
+		else if (!strcmp (setting->method, NM_SETTING_IP4_CONFIG_METHOD_SHARED))
+			method = IP4_METHOD_SHARED;
 	}
 
 	if (method == IP4_METHOD_DHCP && setting->ignore_dhcp_dns)
 		method = IP4_METHOD_DHCP_MANUAL_DNS;
 
 	gtk_combo_box_set_active (priv->method, method);
-	g_signal_connect (priv->method, "changed", G_CALLBACK (method_changed), self);
 
 	/* Addresses */
 	store = gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING);
@@ -500,6 +525,9 @@
 	g_signal_connect (priv->dns_servers, "changed", G_CALLBACK (dns_servers_changed), self);
 	g_signal_connect (priv->dns_searches, "changed", G_CALLBACK (dns_searches_changed), self);
 
+	method_changed (priv->method, self);
+	g_signal_connect (priv->method, "changed", G_CALLBACK (method_changed), self);
+
 	return self;
 }
 
@@ -532,6 +560,9 @@
 	case IP4_METHOD_MANUAL:
 		method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
 		break;
+	case IP4_METHOD_SHARED:
+		method = NM_SETTING_IP4_CONFIG_METHOD_SHARED;
+		break;
 	case IP4_METHOD_DHCP_MANUAL_DNS:
 		ignore_dhcp_dns = TRUE;
 		/* fall through */

Modified: trunk/src/wireless-dialog.c
==============================================================================
--- trunk/src/wireless-dialog.c	(original)
+++ trunk/src/wireless-dialog.c	Thu May 29 21:39:35 2008
@@ -36,6 +36,7 @@
 #include <nm-device-802-11-wireless.h>
 #include <nm-setting-connection.h>
 #include <nm-setting-wireless.h>
+#include <nm-setting-ip4-config.h>
 
 #include "applet.h"
 #include "applet-dialogs.h"
@@ -422,13 +423,23 @@
 			if (strcmp (s_con->type, NM_SETTING_WIRELESS_SETTING_NAME))
 				continue;
 
-			/* If creating a new Ad-Hoc network, only show adhoc networks
-			 * with adhoc-create = TRUE.
-			 */
 			s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (candidate, NM_TYPE_SETTING_WIRELESS));
-			if (!s_wireless || (priv->adhoc_create != s_wireless->adhoc_create))
+			if (!s_wireless)
 				continue;
 
+			/* If creating a new Ad-Hoc network, only show shared network connections */
+			if (priv->adhoc_create) {
+				NMSettingIP4Config *s_ip4;
+
+				s_ip4 = (NMSettingIP4Config *) nm_connection_get_setting (candidate, NM_TYPE_SETTING_IP4_CONFIG);
+				if (!s_ip4 || strcmp (s_ip4->method, "shared"))
+					continue;
+
+				/* Ignore non-Ad-Hoc connections too */
+				if (!s_wireless->mode || strcmp (s_wireless->mode, "adhoc"))
+					continue;
+			}
+
 			/* Ignore connections that don't apply to the selected device */
 			if (s_wireless->mac_address) {
 				const char *hw_addr;
@@ -969,8 +980,13 @@
 		g_assert (s_wireless->ssid);
 
 		if (priv->adhoc_create) {
+			NMSettingIP4Config *s_ip4;
+
 			s_wireless->mode = g_strdup ("adhoc");
-			s_wireless->adhoc_create = TRUE;
+
+			s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
+			s_ip4->method = g_strdup ("shared");
+			nm_connection_add_setting (connection, (NMSetting *) s_ip4);
 		}
 
 		nm_connection_add_setting (connection, (NMSetting *) s_wireless);



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