From 5da02874f10c1a747ea44c377872e114c13fb1e3 Mon Sep 17 00:00:00 2001 From: Robert Love Date: Wed, 27 Sep 2006 20:17:54 +0000 Subject: [PATCH] 2006-09-27 Robert Love Patch by Tambet Ingo : * gnome/vpn-properties/nm-vpn-properties.c: Make Renaming a VPN entry actually work. git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@2039 4912f4e0-d625-0410-9fb7-b9a5a253dbdc --- ChangeLog | 6 ++ gnome/vpn-properties/nm-vpn-properties.c | 78 +++++++++++------------- 2 files changed, 43 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index a47886048..f65b92891 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-09-27 Robert Love + + Patch by Tambet Ingo : + * gnome/vpn-properties/nm-vpn-properties.c: Make Renaming a VPN entry + actually work. + 2006-09-07 Dan Williams * test/Makefile.am diff --git a/gnome/vpn-properties/nm-vpn-properties.c b/gnome/vpn-properties/nm-vpn-properties.c index 0a7a5a64f..16d6109a4 100644 --- a/gnome/vpn-properties/nm-vpn-properties.c +++ b/gnome/vpn-properties/nm-vpn-properties.c @@ -198,6 +198,36 @@ out: return ret; } +static void +remove_vpn_connection (const char *gconf_path, GtkTreeIter *iter) +{ + char key[PATH_MAX]; + + g_snprintf (key, sizeof (key), "%s/name", gconf_path); + gconf_client_unset (gconf_client, key, NULL); + g_snprintf (key, sizeof (key), "%s/service_name", gconf_path); + gconf_client_unset (gconf_client, key, NULL); + g_snprintf (key, sizeof (key), "%s/vpn_data", gconf_path); + gconf_client_unset (gconf_client, key, NULL); + g_snprintf (key, sizeof (key), "%s/routes", gconf_path); + gconf_client_unset (gconf_client, key, NULL); + g_snprintf (key, sizeof (key), "%s/user_name", gconf_path); + gconf_client_unset (gconf_client, key, NULL); + + g_snprintf (key, sizeof (key), "%s/last_attempt_success", gconf_path); + gconf_client_unset (gconf_client, key, NULL); + + gconf_client_unset (gconf_client, gconf_path, NULL); + gconf_client_suggest_sync (gconf_client, NULL); + + if (gtk_list_store_remove (vpn_conn_list, iter)) { + GtkTreeSelection *selection; + + selection = gtk_tree_view_get_selection (vpn_conn_view); + gtk_tree_selection_select_iter (selection, iter); + } +} + static void vpn_druid_vpn_validity_changed (NetworkManagerVpnUI *vpn_ui, gboolean is_valid, @@ -605,7 +635,6 @@ edit_cb (GtkButton *button, gpointer user_data) const char *conn_name; char key[PATH_MAX]; char *conn_gconf_path; - GtkTreeIter iter; /*printf ("edit_cb\n");*/ @@ -650,23 +679,12 @@ edit_cb (GtkButton *button, gpointer user_data) gconf_client_suggest_sync (gconf_client, NULL); } else { - /* remove old entry */ - g_snprintf (key, sizeof (key), "%s/name", conn_gconf_path); - gconf_client_unset (gconf_client, key, NULL); - g_snprintf (key, sizeof (key), "%s/service_name", conn_gconf_path); - gconf_client_unset (gconf_client, key, NULL); - g_snprintf (key, sizeof (key), "%s/vpn_data", conn_gconf_path); - gconf_client_unset (gconf_client, key, NULL); - /* TODO: at some point remove routes and user_name */ - g_snprintf (key, sizeof (key), "%s/routes", conn_gconf_path); - gconf_client_unset (gconf_client, key, NULL); - g_snprintf (key, sizeof (key), "%s/user_name", conn_gconf_path); - gconf_client_unset (gconf_client, key, NULL); - gconf_client_unset (gconf_client, conn_gconf_path, NULL); - gconf_client_suggest_sync (gconf_client, NULL); - gtk_list_store_remove (vpn_conn_list, &iter); + GtkTreeSelection *selection; + GtkTreeIter iter; - /* add new entry */ + selection = gtk_tree_view_get_selection (vpn_conn_view); + gtk_tree_selection_get_selected (selection, NULL, &iter); + remove_vpn_connection (conn_gconf_path, &iter); add_vpn_connection (new_conn_name, current_vpn_ui->get_service_name (current_vpn_ui), new_conn_data, new_conn_routes); } @@ -723,30 +741,8 @@ delete_cb (GtkButton *button, gpointer user_data) gtk_tree_model_get (GTK_TREE_MODEL (vpn_conn_list), &iter, VPNCONN_GCONF_COLUMN, &conn_gconf_path, -1); - if (conn_gconf_path != NULL) { - char key[PATH_MAX]; - - g_snprintf (key, sizeof (key), "%s/name", conn_gconf_path); - gconf_client_unset (gconf_client, key, NULL); - g_snprintf (key, sizeof (key), "%s/service_name", conn_gconf_path); - gconf_client_unset (gconf_client, key, NULL); - g_snprintf (key, sizeof (key), "%s/vpn_data", conn_gconf_path); - gconf_client_unset (gconf_client, key, NULL); - g_snprintf (key, sizeof (key), "%s/routes", conn_gconf_path); - gconf_client_unset (gconf_client, key, NULL); - /* TODO: remove user_name */ - g_snprintf (key, sizeof (key), "%s/user_name", conn_gconf_path); - gconf_client_unset (gconf_client, key, NULL); - g_snprintf (key, sizeof (key), "%s/last_attempt_success", conn_gconf_path); - gconf_client_unset (gconf_client, key, NULL); - - gconf_client_unset (gconf_client, conn_gconf_path, NULL); - - gconf_client_suggest_sync (gconf_client, NULL); - - if (gtk_list_store_remove (vpn_conn_list, &iter)) - gtk_tree_selection_select_iter (selection, &iter); - } + if (conn_gconf_path != NULL) + remove_vpn_connection (conn_gconf_path, &iter); update_edit_del_sensitivity ();