# HG changeset patch # User masneyb # Date 1099479092 0 # Node ID d97e985f5dbeb78cad002a149762734241c2add4 # Parent 7e575601841ace4aad382f5937ed9c1ad49c2a6a 2004-11-3 Brian Masney * lib/config_file.c (gftp_bookmarks_destroy) src/gtk/bookmarks.c (bm_apply_changes) - cleaned up the tree parsing code * lib/gftp.h lib/misc.c lib/config_file.c src/gtk/bookmarks.c - added free_node argument to gftp_free_bookmark() * lib/gftp.h src/gtk/bookmarks.c - added oldpath variable to the gftp_bookmarks structure. diff -r 7e575601841a -r d97e985f5dbe ChangeLog --- a/ChangeLog Tue Nov 02 06:55:01 2004 +0000 +++ b/ChangeLog Wed Nov 03 10:51:32 2004 +0000 @@ -1,3 +1,14 @@ +2004-11-3 Brian Masney + * lib/config_file.c (gftp_bookmarks_destroy) + src/gtk/bookmarks.c (bm_apply_changes) - cleaned up the tree parsing + code + + * lib/gftp.h lib/misc.c lib/config_file.c src/gtk/bookmarks.c - added + free_node argument to gftp_free_bookmark() + + * lib/gftp.h src/gtk/bookmarks.c - added oldpath variable to the + gftp_bookmarks structure. + 2004-11-1 Brian Masney * lib/config_file.c (gftp_write_bookmarks_file) - if a folder has no children, make sure the entry has a / appended to the end of the @@ -3006,7 +3017,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.357 2004/11/02 02:15:14 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.358 2004/11/03 10:51:31 masneyb Exp $ tags * debian/* - updated files from Debian maintainer diff -r 7e575601841a -r d97e985f5dbe lib/config_file.c --- a/lib/config_file.c Tue Nov 02 06:55:01 2004 +0000 +++ b/lib/config_file.c Wed Nov 03 10:51:32 2004 +0000 @@ -1554,27 +1554,21 @@ tempentry = bookmarks; while (tempentry != NULL) { - gftp_free_bookmark (tempentry); - - if (tempentry->path != NULL) - g_free (tempentry->path); - if (tempentry->children != NULL) + tempentry = tempentry->children; + else { - tempentry = tempentry->children; - continue; + while (tempentry->next == NULL && tempentry->prev != NULL) + { + delentry = tempentry; + tempentry = tempentry->prev; + gftp_free_bookmark (delentry, 1); + } + + delentry = tempentry; + tempentry = tempentry->next; + gftp_free_bookmark (delentry, 1); } - - while (tempentry->next == NULL && tempentry->prev != NULL) - { - delentry = tempentry; - tempentry = tempentry->prev; - g_free (delentry); - } - - delentry = tempentry; - tempentry = tempentry->next; - g_free (delentry); } } diff -r 7e575601841a -r d97e985f5dbe lib/gftp.h --- a/lib/gftp.h Tue Nov 02 06:55:01 2004 +0000 +++ b/lib/gftp.h Wed Nov 03 10:51:32 2004 +0000 @@ -579,8 +579,9 @@ struct gftp_bookmarks_tag { - char *path; /* Path */ - char *hostname, /* Our actual internet hostname */ + char *path, /* Path */ + *oldpath, /* Old path name */ + *hostname, /* Our actual internet hostname */ *protocol, /* Protocol we will connect through */ *remote_dir, /* Initial directory */ *local_dir, /* Init local directory */ @@ -771,7 +772,8 @@ char * base64_encode ( char *str ); -void gftp_free_bookmark ( gftp_bookmarks_var * entry ); +void gftp_free_bookmark ( gftp_bookmarks_var * entry, + int free_node ); void gftp_shutdown ( void ); diff -r 7e575601841a -r d97e985f5dbe lib/misc.c --- a/lib/misc.c Tue Nov 02 06:55:01 2004 +0000 +++ b/lib/misc.c Wed Nov 03 10:51:32 2004 +0000 @@ -988,8 +988,10 @@ void -gftp_free_bookmark (gftp_bookmarks_var * entry) +gftp_free_bookmark (gftp_bookmarks_var * entry, int free_node) { + gftp_bookmarks_var * tempentry; + if (entry->hostname) g_free (entry->hostname); if (entry->remote_dir) @@ -1015,6 +1017,15 @@ entry->local_options_hash = NULL; entry->num_local_options_vars = 0; } + + if (free_node) + g_free (entry); + else + { + tempentry = entry->children; + memset (entry, 0, sizeof (*entry)); + entry->children = tempentry; + } } diff -r 7e575601841a -r d97e985f5dbe src/gtk/bookmarks.c --- a/src/gtk/bookmarks.c Tue Nov 02 06:55:01 2004 +0000 +++ b/src/gtk/bookmarks.c Wed Nov 03 10:51:32 2004 +0000 @@ -167,6 +167,7 @@ test.item_type = ""; test.callback = run_bookmark; } + gtk_item_factory_create_item (factory, &test, (gpointer) tempentry->path, 1); g_free (test.path); @@ -281,10 +282,28 @@ static void +_free_menu_entry (gftp_bookmarks_var * entry) +{ + GtkWidget * tempwid; + char *tempstr; + + if (entry->oldpath != NULL) + tempstr = gftp_build_path (NULL, "/Bookmarks", entry->oldpath, NULL); + else + tempstr = gftp_build_path (NULL, "/Bookmarks", entry->path, NULL); + + tempwid = gtk_item_factory_get_item (factory, tempstr); + if (GTK_IS_WIDGET (tempwid)) + gtk_widget_destroy (tempwid); + + g_free (tempstr); +} + + +static void bm_apply_changes (GtkWidget * widget, gpointer backup_data) { gftp_bookmarks_var * tempentry, * delentry; - char *tempstr; if (bm_dialog != NULL) { @@ -297,68 +316,34 @@ tempentry = gftp_bookmarks->children; while (tempentry != NULL) { - if (tempentry->path && !tempentry->isfolder) - { - tempstr = g_strdup_printf ("/Bookmarks/%s", tempentry->path); - gtk_widget_destroy (gtk_item_factory_get_item (factory, tempstr)); - g_free (tempentry->path); - g_free (tempstr); - } - - gftp_free_bookmark (tempentry); - if (tempentry->children != NULL) tempentry = tempentry->children; else { - if (tempentry->next == NULL) - { - while (tempentry->next == NULL && tempentry->prev != NULL) - { - delentry = tempentry; - tempentry = tempentry->prev; - if (delentry->isfolder) - { - tempstr = g_strdup_printf ("/Bookmarks/%s", - delentry->path); - gtk_widget_destroy (gtk_item_factory_get_item (factory, - tempstr)); - g_free (tempstr); - g_free (delentry->path); - } - g_free (delentry); - } - - delentry = tempentry; - tempentry = tempentry->next; - if (delentry->isfolder && tempentry != NULL) - { - tempstr = g_strdup_printf ("/Bookmarks/%s", - delentry->path); - gtk_widget_destroy (gtk_item_factory_get_item (factory, - tempstr)); - g_free (delentry->path); - g_free (tempstr); - g_free (delentry); - } - } - else + while (tempentry->next == NULL && tempentry->prev != NULL) { delentry = tempentry; - tempentry = tempentry->next; - g_free (delentry); + tempentry = tempentry->prev; + _free_menu_entry (delentry); + gftp_free_bookmark (delentry, 1); } + + delentry = tempentry; + tempentry = tempentry->next; + if (tempentry != NULL) + _free_menu_entry (delentry); + + gftp_free_bookmark (delentry, 1); } } - - g_free (gftp_bookmarks); + g_hash_table_destroy (gftp_bookmarks_htable); } if (backup_data) { gftp_bookmarks = copy_bookmarks (new_bookmarks); - gftp_bookmarks_htable = build_bookmarks_hash_table (new_bookmarks); + gftp_bookmarks_htable = build_bookmarks_hash_table (gftp_bookmarks); } else { @@ -475,7 +460,7 @@ newentry->cnode = gtk_ctree_insert_node (GTK_CTREE (tree), new_bookmarks->cnode, NULL, text, 5, NULL, NULL, NULL, NULL, - FALSE, FALSE); + TRUE, FALSE); gtk_ctree_node_set_row_data (GTK_CTREE (tree), newentry->cnode, newentry); g_hash_table_insert (new_bookmarks_htable, newentry->path, newentry); @@ -524,7 +509,7 @@ tempentry = entry; while (tempentry != NULL) { - gftp_free_bookmark (tempentry); + gftp_free_bookmark (tempentry, 0); if (tempentry->children != NULL) { @@ -670,7 +655,7 @@ text[0] = text[1] = pos; tempentry->cnode = gtk_ctree_insert_node (GTK_CTREE (tree), tempentry->prev->cnode, NULL, text, 5, NULL, - NULL, NULL, NULL, FALSE, FALSE); + NULL, NULL, NULL, TRUE, FALSE); gtk_ctree_node_set_row_data (GTK_CTREE (tree), tempentry->cnode, tempentry); } @@ -685,8 +670,8 @@ static void entry_apply_changes (GtkWidget * widget, gftp_bookmarks_var * entry) { - char *pos, *newpath, tempchar, *tempstr, *origpath; gftp_bookmarks_var * tempentry, * nextentry; + char *pos, *newpath, tempchar, *tempstr; GtkWidget * tempwid; size_t oldpathlen; const char *str; @@ -701,7 +686,7 @@ tempchar = *pos; *pos = '\0'; - origpath = newpath = gftp_build_path (NULL, entry->path, tempstr, NULL); + newpath = gftp_build_path (NULL, entry->path, tempstr, NULL); *pos = tempchar; g_free (tempstr); @@ -764,14 +749,18 @@ { g_hash_table_remove (new_bookmarks_htable, tempentry->path); - if (*(tempentry->path + oldpathlen) == '\0') - tempstr = g_strdup (newpath); + if (tempentry->oldpath == NULL) + tempentry->oldpath = tempentry->path; else - tempstr = gftp_build_path (NULL, newpath, - tempentry->path + oldpathlen, NULL); + g_free (tempentry->path); - g_free (tempentry->path); - tempentry->path = tempstr; + if (*(tempentry->path + oldpathlen) == '\0') + tempentry->path = g_strdup (newpath); + else + tempentry->path = gftp_build_path (NULL, newpath, + tempentry->path + oldpathlen, + NULL); + g_hash_table_insert (new_bookmarks_htable, tempentry->path, tempentry); if (tempentry->children != NULL) @@ -789,7 +778,7 @@ entry->next = nextentry; } - g_free (origpath); + g_free (newpath); }