network-manager-applet r822 - in branches/mbca: . po src src/connection-editor src/gconf-helpers src/utils



Author: kaijanma
Date: Wed Aug  6 06:38:27 2008
New Revision: 822
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=822&view=rev

Log:
merge from trunk

Added:
   branches/mbca/src/connection-editor/ip4-routes-dialog.c
      - copied unchanged from r821, /trunk/src/connection-editor/ip4-routes-dialog.c
   branches/mbca/src/connection-editor/ip4-routes-dialog.h
      - copied unchanged from r821, /trunk/src/connection-editor/ip4-routes-dialog.h
Modified:
   branches/mbca/ChangeLog
   branches/mbca/po/ChangeLog
   branches/mbca/po/ar.po
   branches/mbca/po/he.po
   branches/mbca/src/applet.c
   branches/mbca/src/connection-editor/Makefile.am
   branches/mbca/src/connection-editor/ce-page-ip4.glade
   branches/mbca/src/connection-editor/page-ip4.c
   branches/mbca/src/gconf-helpers/gconf-helpers.c
   branches/mbca/src/gconf-helpers/gconf-upgrade.c
   branches/mbca/src/gconf-helpers/gconf-upgrade.h
   branches/mbca/src/utils/utils.c

Modified: branches/mbca/src/applet.c
==============================================================================
--- branches/mbca/src/applet.c	(original)
+++ branches/mbca/src/applet.c	Wed Aug  6 06:38:27 2008
@@ -898,7 +898,8 @@
 {
 	const GPtrArray *temp = NULL;
 	GSList *devices = NULL, *iter = NULL;
-	gint n_wireless_devices = 0;
+	gint n_wifi_devices = 0;
+	gint n_usable_wifi_devices = 0;
 	gint n_wired_devices = 0;
 	gint n_cdma_devices = 0;
 	gint n_gsm_devices = 0;
@@ -918,10 +919,10 @@
 			continue;
 
 		if (NM_IS_DEVICE_WIFI (device)) {
+			n_wifi_devices++;
 			if (   nm_client_wireless_get_enabled (applet->nm_client)
-			    && (nm_device_get_state (device) >= NM_DEVICE_STATE_DISCONNECTED)) {
-				n_wireless_devices++;
-			}
+			    && (nm_device_get_state (device) >= NM_DEVICE_STATE_DISCONNECTED))
+				n_usable_wifi_devices++;
 		} else if (NM_IS_DEVICE_ETHERNET (device))
 			n_wired_devices++;
 		else if (NM_IS_CDMA_DEVICE (device))
@@ -930,7 +931,7 @@
 			n_gsm_devices++;
 	}
 
-	if (!n_wired_devices && !n_wireless_devices && !n_cdma_devices && !n_gsm_devices) {
+	if (!n_wired_devices && !n_wifi_devices && !n_cdma_devices && !n_gsm_devices) {
 		nma_menu_add_text_item (menu, _("No network devices available"));
 		goto out;
 	}
@@ -947,7 +948,7 @@
 			continue;
 
 		if (NM_IS_DEVICE_WIFI (device))
-			n_devices = n_wireless_devices;
+			n_devices = n_wifi_devices;
 		else if (NM_IS_DEVICE_ETHERNET (device))
 			n_devices = n_wired_devices;
 		else if (NM_IS_CDMA_DEVICE (device))
@@ -964,7 +965,11 @@
 
  out:
 	g_slist_free (devices);
-	return n_wireless_devices;
+
+	/* Return # of usable wifi devices here for correct enable/disable state
+	 * of things like Enable Wireless, "Connect to other..." and such.
+	 */
+	return n_usable_wifi_devices;
 }
 
 static int

Modified: branches/mbca/src/connection-editor/Makefile.am
==============================================================================
--- branches/mbca/src/connection-editor/Makefile.am	(original)
+++ branches/mbca/src/connection-editor/Makefile.am	Wed Aug  6 06:38:27 2008
@@ -47,7 +47,9 @@
 	page-vpn.h \
 	page-vpn.c \
 	vpn-helpers.h \
-	vpn-helpers.c
+	vpn-helpers.c \
+	ip4-routes-dialog.h \
+	ip4-routes-dialog.c
 
 if NO_POLKIT_GNOME
 nm_connection_editor_SOURCES += \

Modified: branches/mbca/src/connection-editor/ce-page-ip4.glade
==============================================================================
--- branches/mbca/src/connection-editor/ce-page-ip4.glade	(original)
+++ branches/mbca/src/connection-editor/ce-page-ip4.glade	Wed Aug  6 06:38:27 2008
@@ -47,7 +47,7 @@
             <property name="visible">True</property>
             <property name="spacing">6</property>
             <child>
-              <widget class="GtkLabel" id="label37">
+              <widget class="GtkLabel" id="ip4_addr_label">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
                 <property name="label" translatable="yes">&lt;b&gt;Addresses&lt;/b&gt;</property>
@@ -78,6 +78,7 @@
                             <property name="height_request">100</property>
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
+                            <property name="tooltip_text">IP addresses identify your computer on the network.  Click the "Add" button to add an IP address.</property>
                             <property name="rules_hint">True</property>
                           </widget>
                         </child>
@@ -127,6 +128,7 @@
             </child>
           </widget>
           <packing>
+            <property name="expand">False</property>
             <property name="position">1</property>
           </packing>
         </child>
@@ -134,75 +136,75 @@
           <widget class="GtkTable" id="table8">
             <property name="visible">True</property>
             <property name="border_width">6</property>
-            <property name="n_rows">5</property>
+            <property name="n_rows">3</property>
             <property name="n_columns">2</property>
             <property name="column_spacing">6</property>
             <property name="row_spacing">6</property>
             <child>
-              <widget class="GtkEntry" id="dhcp_client_id_entry">
+              <widget class="GtkEntry" id="ip4_dns_servers_entry">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="tooltip_text">Example: 10.0.0.1, 10.0.0.2</property>
               </widget>
               <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="y_options"></property>
               </packing>
             </child>
             <child>
-              <widget class="GtkLabel" id="dhcp_client_id_label">
+              <widget class="GtkLabel" id="ip4_dns_servers_label">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
-                <property name="label" translatable="yes">DHCP Client ID:</property>
+                <property name="label" translatable="yes">DNS Servers:</property>
               </widget>
               <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>
               </packing>
             </child>
             <child>
-              <placeholder/>
-            </child>
-            <child>
-              <placeholder/>
+              <widget class="GtkLabel" id="ip4_dns_searches_label">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Search Domains:</property>
+              </widget>
+              <packing>
+                <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>
             </child>
             <child>
-              <widget class="GtkLabel" id="label44">
+              <widget class="GtkLabel" id="ip4_dhcp_client_id_label">
                 <property name="visible">True</property>
                 <property name="xalign">0</property>
-                <property name="label" translatable="yes">&lt;span style="italic"&gt;Example: lab.gnome.org, gnome.org&lt;/span&gt;</property>
-                <property name="use_markup">True</property>
+                <property name="label" translatable="yes">DHCP Client ID:</property>
               </widget>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</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>
               </packing>
             </child>
             <child>
-              <widget class="GtkLabel" id="ip4_dns_servers_label">
+              <widget class="GtkEntry" id="ip4_dns_searches_entry">
                 <property name="visible">True</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">&lt;span style="italic"&gt;Example: 10.10.10.1, 10.10.10.2&lt;/span&gt;</property>
-                <property name="use_markup">True</property>
+                <property name="can_focus">True</property>
+                <property name="tooltip_text">Example: lab.gnome.org, gnome.org</property>
               </widget>
               <packing>
                 <property name="left_attach">1</property>
                 <property name="right_attach">2</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>
             </child>
             <child>
-              <widget class="GtkEntry" id="ip4_dns_searches_entry">
+              <widget class="GtkEntry" id="ip4_dhcp_client_id_entry">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
               </widget>
@@ -211,48 +213,182 @@
                 <property name="right_attach">2</property>
                 <property name="top_attach">2</property>
                 <property name="bottom_attach">3</property>
-                <property name="y_options"></property>
               </packing>
             </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">2</property>
+          </packing>
+        </child>
+        <child>
+          <widget class="GtkHBox" id="hbox3">
+            <property name="visible">True</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
             <child>
-              <widget class="GtkLabel" id="label40">
+              <widget class="GtkButton" id="ip4_routes_button">
                 <property name="visible">True</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Search Domains:</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="response_id">0</property>
+                <child>
+                  <widget class="GtkHBox" id="hbox4">
+                    <property name="visible">True</property>
+                    <property name="spacing">3</property>
+                    <child>
+                      <widget class="GtkImage" id="image1">
+                        <property name="visible">True</property>
+                        <property name="stock">gtk-preferences</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <widget class="GtkLabel" id="label1">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Routes...</property>
+                      </widget>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </widget>
+                </child>
               </widget>
               <packing>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options"></property>
+                <property name="expand">False</property>
+                <property name="padding">6</property>
+                <property name="pack_type">GTK_PACK_END</property>
+                <property name="position">3</property>
               </packing>
             </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+  <widget class="GtkDialog" id="ip4_routes_dialog">
+    <property name="width_request">450</property>
+    <property name="height_request">250</property>
+    <property name="border_width">5</property>
+    <property name="modal">True</property>
+    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="icon_name">stock-peferences</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="spacing">15</property>
+        <child>
+          <widget class="GtkHBox" id="hbox5">
+            <property name="visible">True</property>
+            <property name="spacing">6</property>
             <child>
-              <widget class="GtkEntry" id="ip4_dns_servers_entry">
+              <widget class="GtkScrolledWindow" id="scrolledwindow2">
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
+                <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
+                <property name="shadow_type">GTK_SHADOW_IN</property>
+                <child>
+                  <widget class="GtkTreeView" id="ip4_routes">
+                    <property name="height_request">100</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="tooltip_text">Routes help determine how traffic leaving your computer flows over the network.  Click the "Add" button to add a new route.</property>
+                    <property name="rules_hint">True</property>
+                  </widget>
+                </child>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkVButtonBox" id="vbuttonbox2">
+                <property name="visible">True</property>
+                <property name="spacing">6</property>
+                <property name="layout_style">GTK_BUTTONBOX_START</property>
+                <child>
+                  <widget class="GtkButton" id="ip4_route_add_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="label">gtk-add</property>
+                    <property name="use_stock">True</property>
+                    <property name="response_id">0</property>
+                  </widget>
+                </child>
+                <child>
+                  <widget class="GtkButton" id="ip4_route_delete_button">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="can_default">True</property>
+                    <property name="label">gtk-delete</property>
+                    <property name="use_stock">True</property>
+                    <property name="response_id">0</property>
+                  </widget>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
               </widget>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="right_attach">2</property>
-                <property name="y_options"></property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">1</property>
               </packing>
             </child>
+          </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="cancel_button">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-6</property>
+              </widget>
+            </child>
             <child>
-              <widget class="GtkLabel" id="label39">
+              <widget class="GtkButton" id="ok_button">
                 <property name="visible">True</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">DNS Servers:</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">-5</property>
               </widget>
               <packing>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options"></property>
+                <property name="position">1</property>
               </packing>
             </child>
           </widget>
           <packing>
             <property name="expand">False</property>
-            <property name="position">2</property>
+            <property name="pack_type">GTK_PACK_END</property>
           </packing>
         </child>
       </widget>

Modified: branches/mbca/src/connection-editor/page-ip4.c
==============================================================================
--- branches/mbca/src/connection-editor/page-ip4.c	(original)
+++ branches/mbca/src/connection-editor/page-ip4.c	Wed Aug  6 06:38:27 2008
@@ -35,6 +35,7 @@
 #include <nm-setting-vpn.h>
 
 #include "page-ip4.h"
+#include "ip4-routes-dialog.h"
 
 G_DEFINE_TYPE (CEPageIP4, ce_page_ip4, CE_TYPE_PAGE)
 
@@ -42,26 +43,33 @@
 
 typedef struct {
 	NMSettingIP4Config *setting;
+	char *connection_id;
 
 	GtkComboBox *method;
 	GtkListStore *method_store;
 
 	/* Addresses */
+	GtkWidget *addr_label;
 	GtkButton *addr_add;
 	GtkButton *addr_delete;
 	GtkTreeView *addr_list;
 
 	/* DNS servers */
+	GtkWidget *dns_servers_label;
 	GtkEntry *dns_servers;
 
 	/* Search domains */
+	GtkWidget *dns_searches_label;
 	GtkEntry *dns_searches;
 
 	/* DHCP stuff */
 	GtkWidget *dhcp_client_id_label;
-	GtkEntry *dhcp_client_id_entry;
+	GtkEntry *dhcp_client_id;
 
-	gboolean disposed;
+	GtkButton *routes_button;
+
+	GtkWindowGroup *window_group;
+	gboolean window_added;
 } CEPageIP4Private;
 
 #define METHOD_COL_NAME 0
@@ -125,15 +133,21 @@
 
 	gtk_combo_box_set_model (priv->method, GTK_TREE_MODEL (priv->method_store));
 
+	priv->addr_label = glade_xml_get_widget (xml, "ip4_addr_label");
 	priv->addr_add = GTK_BUTTON (glade_xml_get_widget (xml, "ip4_addr_add_button"));
 	priv->addr_delete = GTK_BUTTON (glade_xml_get_widget (xml, "ip4_addr_delete_button"));
 	priv->addr_list = GTK_TREE_VIEW (glade_xml_get_widget (xml, "ip4_addresses"));
 
+	priv->dns_servers_label = glade_xml_get_widget (xml, "ip4_dns_servers_label");
 	priv->dns_servers = GTK_ENTRY (glade_xml_get_widget (xml, "ip4_dns_servers_entry"));
+
+	priv->dns_searches_label = glade_xml_get_widget (xml, "ip4_dns_searches_label");
 	priv->dns_searches = GTK_ENTRY (glade_xml_get_widget (xml, "ip4_dns_searches_entry"));
 
-	priv->dhcp_client_id_label = GTK_WIDGET (glade_xml_get_widget (xml, "dhcp_client_id_label"));
-	priv->dhcp_client_id_entry = GTK_ENTRY (glade_xml_get_widget (xml, "dhcp_client_id_entry"));
+	priv->dhcp_client_id_label = glade_xml_get_widget (xml, "ip4_dhcp_client_id_label");
+	priv->dhcp_client_id = GTK_ENTRY (glade_xml_get_widget (xml, "ip4_dhcp_client_id_entry"));
+
+	priv->routes_button = GTK_BUTTON (glade_xml_get_widget (xml, "ip4_routes_button"));
 }
 
 static void
@@ -141,7 +155,10 @@
 {
 	CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (user_data);
 	guint32 method = IP4_METHOD_AUTO;
-	gboolean config_enabled = TRUE;
+	gboolean addr_enabled = FALSE;
+	gboolean dns_enabled = FALSE;
+	gboolean dhcp_enabled = FALSE;
+	gboolean routes_enabled = FALSE;
 	GtkTreeIter iter;
 
 	if (gtk_combo_box_get_active_iter (priv->method, &iter)) {
@@ -149,34 +166,48 @@
 		                    METHOD_COL_NUM, &method, -1);
 	}
 
-	if (method == IP4_METHOD_SHARED || method == IP4_METHOD_LINK_LOCAL)
-		config_enabled = FALSE;
+	switch (method) {
+	case IP4_METHOD_AUTO:
+		dhcp_enabled = routes_enabled = TRUE;
+		break;
+	case IP4_METHOD_AUTO_MANUAL_DNS:
+		addr_enabled = FALSE;
+		dns_enabled = dhcp_enabled = routes_enabled = TRUE;
+		break;
+	case IP4_METHOD_MANUAL:
+		addr_enabled = dns_enabled = routes_enabled = TRUE;
+		break;
+	default:
+		break;
+	}
 
-	gtk_widget_set_sensitive (GTK_WIDGET (priv->addr_add), config_enabled);
-	gtk_widget_set_sensitive (GTK_WIDGET (priv->addr_delete), config_enabled);
-	gtk_widget_set_sensitive (GTK_WIDGET (priv->addr_list), config_enabled);
-	if (!config_enabled) {
+	gtk_widget_set_sensitive (priv->addr_label, addr_enabled);
+	gtk_widget_set_sensitive (GTK_WIDGET (priv->addr_add), addr_enabled);
+	gtk_widget_set_sensitive (GTK_WIDGET (priv->addr_delete), addr_enabled);
+	gtk_widget_set_sensitive (GTK_WIDGET (priv->addr_list), addr_enabled);
+	if (!addr_enabled) {
 		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), config_enabled);
-	if (!config_enabled)
+	gtk_widget_set_sensitive (priv->dns_servers_label, dns_enabled);
+	gtk_widget_set_sensitive (GTK_WIDGET (priv->dns_servers), dns_enabled);
+	if (!dns_enabled)
 		gtk_entry_set_text (priv->dns_servers, "");
 
-	gtk_widget_set_sensitive (GTK_WIDGET (priv->dns_searches), config_enabled);
-	if (!config_enabled)
+	gtk_widget_set_sensitive (priv->dns_searches_label, dns_enabled);
+	gtk_widget_set_sensitive (GTK_WIDGET (priv->dns_searches), dns_enabled);
+	if (!dns_enabled)
 		gtk_entry_set_text (priv->dns_searches, "");
 
-	if ((method == IP4_METHOD_AUTO) || (method == IP4_METHOD_AUTO_MANUAL_DNS)) {
-		gtk_widget_show (priv->dhcp_client_id_label);
-		gtk_widget_show (GTK_WIDGET (priv->dhcp_client_id_entry));
-	} else {
-		gtk_widget_hide (priv->dhcp_client_id_label);
-		gtk_widget_hide (GTK_WIDGET (priv->dhcp_client_id_entry));
-	}
+	gtk_widget_set_sensitive (priv->dhcp_client_id_label, dhcp_enabled);
+	gtk_widget_set_sensitive (GTK_WIDGET (priv->dhcp_client_id), dhcp_enabled);
+	if (!dhcp_enabled)
+		gtk_entry_set_text (priv->dhcp_client_id, "");
+
+	gtk_widget_set_sensitive (GTK_WIDGET (priv->routes_button), routes_enabled);
 
 	ce_page_changed (CE_PAGE (user_data));
 }
@@ -215,7 +246,7 @@
 	/* Method */
 	gtk_combo_box_set_active (priv->method, 0);
 	if (setting->method) {
-		if (!strcmp (setting->method, NM_SETTING_IP4_CONFIG_METHOD_AUTOIP))
+		if (!strcmp (setting->method, NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL))
 			method = IP4_METHOD_LINK_LOCAL;
 		else if (!strcmp (setting->method, NM_SETTING_IP4_CONFIG_METHOD_MANUAL))
 			method = IP4_METHOD_MANUAL;
@@ -295,7 +326,7 @@
 
 	if ((method == IP4_METHOD_AUTO) || (method = IP4_METHOD_AUTO_MANUAL_DNS)) {
 		if (setting->dhcp_client_id)
-			gtk_entry_set_text (priv->dhcp_client_id_entry, setting->dhcp_client_id);
+			gtk_entry_set_text (priv->dhcp_client_id, setting->dhcp_client_id);
 	}
 }
 
@@ -442,6 +473,57 @@
 	                  data);
 }
 
+static void
+routes_dialog_close_cb (GtkWidget *dialog, gpointer user_data)
+{
+	gtk_widget_hide (dialog);
+	/* gtk_widget_destroy() will remove the window from the window group */
+	gtk_widget_destroy (dialog);
+}
+
+static void
+routes_dialog_response_cb (GtkWidget *dialog, gint response, gpointer user_data)
+{
+	CEPageIP4 *self = CE_PAGE_IP4 (user_data);
+	CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
+
+	if (response == GTK_RESPONSE_OK)
+		ip4_routes_dialog_update_setting (dialog, priv->setting);
+
+	routes_dialog_close_cb (dialog, NULL);
+}
+
+static void
+routes_button_clicked_cb (GtkWidget *button, gpointer user_data)
+{
+	CEPageIP4 *self = CE_PAGE_IP4 (user_data);
+	CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
+	GtkWidget *dialog, *toplevel;
+
+	toplevel = gtk_widget_get_toplevel (CE_PAGE (self)->page);
+	g_return_if_fail (GTK_WIDGET_TOPLEVEL (toplevel));
+
+	dialog = ip4_routes_dialog_new (priv->setting->routes);
+	if (!dialog) {
+		g_warning ("%s: failed to create the routes dialog!", __func__);
+		return;
+	}
+
+	gtk_window_group_add_window (priv->window_group, GTK_WINDOW (dialog));
+	if (!priv->window_added) {
+		gtk_window_group_add_window (priv->window_group, GTK_WINDOW (toplevel));
+		priv->window_added = TRUE;
+	}
+
+	gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (toplevel));
+	gtk_window_set_title (GTK_WINDOW (dialog), g_strdup_printf (_("Editing IPv4 routes for %s"), priv->connection_id));
+
+	g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (routes_dialog_response_cb), self);
+	g_signal_connect (G_OBJECT (dialog), "close", G_CALLBACK (routes_dialog_close_cb), self);
+
+	gtk_widget_show_all (dialog);
+}
+
 CEPageIP4 *
 ce_page_ip4_new (NMConnection *connection)
 {
@@ -478,12 +560,16 @@
 
 	s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (connection, NM_TYPE_SETTING_CONNECTION));
 	g_assert (s_con && s_con->type);
+
 	if (!strcmp (s_con->type, NM_SETTING_VPN_SETTING_NAME))
 		is_vpn = TRUE;
 
 	ip4_private_init (self, is_vpn);
 	priv = CE_PAGE_IP4_GET_PRIVATE (self);
 
+	priv->window_group = gtk_window_group_new ();
+	priv->connection_id = g_strdup (s_con->id);
+
 	priv->setting = (NMSettingIP4Config *) nm_connection_get_setting (connection, NM_TYPE_SETTING_IP4_CONFIG);
 	if (!priv->setting) {
 		priv->setting = NM_SETTING_IP4_CONFIG (nm_setting_ip4_config_new ());
@@ -554,7 +640,9 @@
 	method_changed (priv->method, self);
 	g_signal_connect (priv->method, "changed", G_CALLBACK (method_changed), self);
 
-	g_signal_connect_swapped (priv->dhcp_client_id_entry, "changed", G_CALLBACK (ce_page_changed), self);
+	g_signal_connect_swapped (priv->dhcp_client_id, "changed", G_CALLBACK (ce_page_changed), self);
+
+	g_signal_connect (priv->routes_button, "clicked", G_CALLBACK (routes_button_clicked_cb), self);
 
 	return self;
 }
@@ -590,7 +678,7 @@
 
 	switch (int_method) {
 	case IP4_METHOD_LINK_LOCAL:
-		method = NM_SETTING_IP4_CONFIG_METHOD_AUTOIP;
+		method = NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL;
 		break;
 	case IP4_METHOD_MANUAL:
 		method = NM_SETTING_IP4_CONFIG_METHOD_MANUAL;
@@ -602,7 +690,7 @@
 		ignore_dhcp_dns = TRUE;
 		/* fall through */
 	default:
-		method = NM_SETTING_IP4_CONFIG_METHOD_DHCP;
+		method = NM_SETTING_IP4_CONFIG_METHOD_AUTO;
 		break;
 	}
 
@@ -706,8 +794,8 @@
 	search_domains = g_slist_reverse (search_domains);
 
 	/* DHCP client ID */
-	if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_DHCP)) {
-		dhcp_client_id = gtk_entry_get_text (priv->dhcp_client_id_entry);
+	if (!strcmp (method, NM_SETTING_IP4_CONFIG_METHOD_AUTO)) {
+		dhcp_client_id = gtk_entry_get_text (priv->dhcp_client_id);
 		if (dhcp_client_id && !strlen (dhcp_client_id))
 			dhcp_client_id = NULL;
 	}
@@ -755,6 +843,20 @@
 }
 
 static void
+dispose (GObject *object)
+{
+	CEPageIP4 *self = CE_PAGE_IP4 (object);
+	CEPageIP4Private *priv = CE_PAGE_IP4_GET_PRIVATE (self);
+
+	if (priv->window_group)
+		g_object_unref (priv->window_group);
+
+	g_free (priv->connection_id);
+
+	G_OBJECT_CLASS (ce_page_ip4_parent_class)->dispose (object);
+}
+
+static void
 ce_page_ip4_class_init (CEPageIP4Class *ip4_class)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (ip4_class);
@@ -764,4 +866,5 @@
 
 	/* virtual methods */
 	parent_class->validate = validate;
+	object_class->dispose = dispose;
 }

Modified: branches/mbca/src/gconf-helpers/gconf-helpers.c
==============================================================================
--- branches/mbca/src/gconf-helpers/gconf-helpers.c	(original)
+++ branches/mbca/src/gconf-helpers/gconf-helpers.c	Wed Aug  6 06:38:27 2008
@@ -752,6 +752,7 @@
 	nm_gconf_migrate_0_7_vpn_connections (client);
 	nm_gconf_migrate_0_7_wireless_security (client);
 	nm_gconf_migrate_0_7_netmask_to_prefix (client);
+	nm_gconf_migrate_0_7_ip4_method (client);
 
 	connections = gconf_client_all_dirs (client, GCONF_PATH_CONNECTIONS, NULL);
 	if (!connections) {

Modified: branches/mbca/src/gconf-helpers/gconf-upgrade.c
==============================================================================
--- branches/mbca/src/gconf-helpers/gconf-upgrade.c	(original)
+++ branches/mbca/src/gconf-helpers/gconf-upgrade.c	Wed Aug  6 06:38:27 2008
@@ -1063,3 +1063,41 @@
 	gconf_client_suggest_sync (client, NULL);
 }
 
+void
+nm_gconf_migrate_0_7_ip4_method (GConfClient *client)
+{
+	GSList *connections, *iter;
+
+	connections = gconf_client_all_dirs (client, GCONF_PATH_CONNECTIONS, NULL);
+	for (iter = connections; iter; iter = iter->next) {
+		char *id = g_path_get_basename ((const char *) iter->data);
+		char *method = NULL;
+
+		if (!nm_gconf_get_string_helper (client, iter->data,
+		                                 NM_SETTING_IP4_CONFIG_METHOD,
+		                                 NM_SETTING_IP4_CONFIG_SETTING_NAME,
+		                                 &method))
+			goto next;
+
+		if (!strcmp (method, "autoip")) {
+			nm_gconf_set_string_helper (client, iter->data,
+			                            NM_SETTING_IP4_CONFIG_METHOD,
+			                            NM_SETTING_IP4_CONFIG_SETTING_NAME,
+			                            NM_SETTING_IP4_CONFIG_METHOD_LINK_LOCAL);
+		} else if (!strcmp (method, "dhcp")) {
+			nm_gconf_set_string_helper (client, iter->data,
+			                            NM_SETTING_IP4_CONFIG_METHOD,
+			                            NM_SETTING_IP4_CONFIG_SETTING_NAME,
+			                            NM_SETTING_IP4_CONFIG_METHOD_AUTO);
+		}
+
+		g_free (method);
+
+next:
+		g_free (id);
+	}
+	free_slist (connections);
+
+	gconf_client_suggest_sync (client, NULL);
+}
+

Modified: branches/mbca/src/gconf-helpers/gconf-upgrade.h
==============================================================================
--- branches/mbca/src/gconf-helpers/gconf-upgrade.h	(original)
+++ branches/mbca/src/gconf-helpers/gconf-upgrade.h	Wed Aug  6 06:38:27 2008
@@ -36,5 +36,7 @@
 
 void nm_gconf_migrate_0_7_netmask_to_prefix (GConfClient *client);
 
+void nm_gconf_migrate_0_7_ip4_method (GConfClient *client);
+
 #endif	/* GCONF_UPGRADE_H */
 

Modified: branches/mbca/src/utils/utils.c
==============================================================================
--- branches/mbca/src/utils/utils.c	(original)
+++ branches/mbca/src/utils/utils.c	Wed Aug  6 06:38:27 2008
@@ -77,19 +77,38 @@
 	return result;
 }
 
-static char * ignored_words[] = {
+static char *ignored_words[] = {
 	"Semiconductor",
 	"Components",
 	"Corporation",
+	"Communications",
 	"Corp.",
 	"Corp",
 	"Co.",
 	"Inc.",
 	"Inc",
 	"Ltd.",
-	"Multiprotocol",
-	"MAC/baseband",
-	"processor",
+	"chipset",
+	"adapter",
+	"[hex]",
+	"NDIS",
+	NULL
+};
+
+static char *ignored_phrases[] = {
+	"Multiprotocol MAC/baseband processor",
+	"Wireless LAN Controller",
+	"Wireless LAN Adapter",
+	"Wireless Adapter",
+	"Network Connection",
+	"Wireless Cardbus Adapter",
+	"Wireless CardBus Adapter",
+	"54 Mbps Wireless PC Card",
+	"Wireless PC Card",
+	"Wireless PC",
+	"PC Card with XJACK(r) Antenna",
+	"Wireless cardbus",
+	"Wireless LAN PC Card",
 	NULL
 };
 
@@ -107,7 +126,17 @@
 		p++;
 	}
 
-	/* Attmept to shorted ID by ignoring certain words */
+	/* Attempt to shorten ID by ignoring certain phrases */
+	for (item = ignored_phrases; *item; item++) {
+		guint32 temp_len = strlen (temp);
+		guint32 ignored_len = strlen (*item);
+
+		p = strstr (temp, *item);
+		if (p)
+			memmove (p, p + ignored_len, temp_len - (p - temp));
+	}
+
+	/* Attmept to shorten ID by ignoring certain individual words */
 	words = g_strsplit (temp, " ", 0);
 	str = g_string_new_len (NULL, strlen (temp));
 	g_free (temp);



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