changeset 613:45a015044483

2004-11-4 Brian Masney <masneyb@gftp.org> * src/gtk/bookmarks.c (entry_apply_changes) - more cleanups to this function. Fixes for renaming bookmark entries
author masneyb
date Fri, 05 Nov 2004 02:11:59 +0000
parents 08e7b5186eb8
children 04aff709924a
files ChangeLog src/gtk/bookmarks.c
diffstat 2 files changed, 33 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Nov 05 02:05:22 2004 +0000
+++ b/ChangeLog	Fri Nov 05 02:11:59 2004 +0000
@@ -1,4 +1,7 @@
 2004-11-4 Brian Masney <masneyb@gftp.org>
+	* src/gtk/bookmarks.c (entry_apply_changes) - more cleanups to this
+	function. Fixes for renaming bookmark entries
+
 	* src/gtk/bookmarks.c (build_bookmarks_tree) - greatly simplified
 	this function. Added helper function _add_tree_node()
 
@@ -3026,7 +3029,7 @@
 
 	* cvsclean - added this script
 
-	* *.[ch] - added $Id: ChangeLog,v 1.360 2004/11/05 02:05:22 masneyb Exp $ tags
+	* *.[ch] - added $Id: ChangeLog,v 1.361 2004/11/05 02:11:58 masneyb Exp $ tags
 
 	* debian/* - updated files from Debian maintainer
 
--- a/src/gtk/bookmarks.c	Fri Nov 05 02:05:22 2004 +0000
+++ b/src/gtk/bookmarks.c	Fri Nov 05 02:11:59 2004 +0000
@@ -670,7 +670,7 @@
 static void
 entry_apply_changes (GtkWidget * widget, gftp_bookmarks_var * entry)
 {
-  gftp_bookmarks_var * tempentry, * nextentry;
+  gftp_bookmarks_var * tempentry, * nextentry, * bmentry;
   char *pos, *newpath, tempchar, *tempstr;
   GtkWidget * tempwid;
   size_t oldpathlen;
@@ -681,15 +681,17 @@
     *pos = ' ';
 
   oldpathlen = strlen (entry->path);
-  if ((pos = strrchr (entry->path, '/')) == NULL)
-    pos = entry->path;
-
-  tempchar = *pos;
-  *pos = '\0';
-  newpath = gftp_build_path (NULL, entry->path, tempstr, NULL);
-  *pos = tempchar;
-
-  g_free (tempstr);
+  if ((pos = strrchr (entry->path, '/')) != NULL)
+    {
+      pos = entry->path;
+      tempchar = *pos;
+      *pos = '\0';
+      newpath = gftp_build_path (NULL, entry->path, tempstr, NULL);
+      *pos = tempchar;
+      g_free (tempstr);
+    }
+  else
+    newpath = tempstr;
 
   str = gtk_entry_get_text (GTK_ENTRY (bm_hostedit));
   if (entry->hostname != NULL)
@@ -745,12 +747,15 @@
       tempentry = entry;
       nextentry = entry->next;
       entry->next = NULL;
+
       while (tempentry != NULL)
 	{
 	  g_hash_table_remove (new_bookmarks_htable, tempentry->path);
 
-          if (tempentry->oldpath == NULL)
-            tempentry->oldpath = tempentry->path;
+          bmentry = g_hash_table_lookup (gftp_bookmarks_htable,
+                                         tempentry->path);
+          if (bmentry->oldpath == NULL)
+            bmentry->oldpath = tempentry->path;
           else
             g_free (tempentry->path);
 
@@ -763,16 +768,20 @@
 
 	  g_hash_table_insert (new_bookmarks_htable, tempentry->path,
                                tempentry);
+
+          gtk_ctree_node_set_text (GTK_CTREE (tree), tempentry->cnode, 0,
+                                   tempentry->path);
+
 	  if (tempentry->children != NULL)
-	    {
-	      tempentry = tempentry->children;
-	      continue;
-	    }
-	  while (tempentry->next == NULL && tempentry != entry &&
-		 tempentry->prev != NULL)
-	    tempentry = tempentry->prev;
+	    tempentry = tempentry->children;
+          else
+            {
+	      while (tempentry->next == NULL && tempentry != entry &&
+                     tempentry->prev != NULL)
+                tempentry = tempentry->prev;
 
-	  tempentry = tempentry->next;
+	      tempentry = tempentry->next;
+            }
 	}
 
       entry->next = nextentry;