Mercurial > gftp.yaz
comparison src/gtk/bookmarks.c @ 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 | af9ecca3568e |
comparison
equal
deleted
inserted
replaced
612:08e7b5186eb8 | 613:45a015044483 |
---|---|
668 | 668 |
669 | 669 |
670 static void | 670 static void |
671 entry_apply_changes (GtkWidget * widget, gftp_bookmarks_var * entry) | 671 entry_apply_changes (GtkWidget * widget, gftp_bookmarks_var * entry) |
672 { | 672 { |
673 gftp_bookmarks_var * tempentry, * nextentry; | 673 gftp_bookmarks_var * tempentry, * nextentry, * bmentry; |
674 char *pos, *newpath, tempchar, *tempstr; | 674 char *pos, *newpath, tempchar, *tempstr; |
675 GtkWidget * tempwid; | 675 GtkWidget * tempwid; |
676 size_t oldpathlen; | 676 size_t oldpathlen; |
677 const char *str; | 677 const char *str; |
678 | 678 |
679 tempstr = g_strdup (gtk_entry_get_text (GTK_ENTRY (bm_pathedit))); | 679 tempstr = g_strdup (gtk_entry_get_text (GTK_ENTRY (bm_pathedit))); |
680 while ((pos = strchr (tempstr, '/')) != NULL) | 680 while ((pos = strchr (tempstr, '/')) != NULL) |
681 *pos = ' '; | 681 *pos = ' '; |
682 | 682 |
683 oldpathlen = strlen (entry->path); | 683 oldpathlen = strlen (entry->path); |
684 if ((pos = strrchr (entry->path, '/')) == NULL) | 684 if ((pos = strrchr (entry->path, '/')) != NULL) |
685 pos = entry->path; | 685 { |
686 | 686 pos = entry->path; |
687 tempchar = *pos; | 687 tempchar = *pos; |
688 *pos = '\0'; | 688 *pos = '\0'; |
689 newpath = gftp_build_path (NULL, entry->path, tempstr, NULL); | 689 newpath = gftp_build_path (NULL, entry->path, tempstr, NULL); |
690 *pos = tempchar; | 690 *pos = tempchar; |
691 | 691 g_free (tempstr); |
692 g_free (tempstr); | 692 } |
693 else | |
694 newpath = tempstr; | |
693 | 695 |
694 str = gtk_entry_get_text (GTK_ENTRY (bm_hostedit)); | 696 str = gtk_entry_get_text (GTK_ENTRY (bm_hostedit)); |
695 if (entry->hostname != NULL) | 697 if (entry->hostname != NULL) |
696 g_free (entry->hostname); | 698 g_free (entry->hostname); |
697 entry->hostname = g_strdup (str); | 699 entry->hostname = g_strdup (str); |
743 if (strcmp (entry->path, newpath) != 0) | 745 if (strcmp (entry->path, newpath) != 0) |
744 { | 746 { |
745 tempentry = entry; | 747 tempentry = entry; |
746 nextentry = entry->next; | 748 nextentry = entry->next; |
747 entry->next = NULL; | 749 entry->next = NULL; |
750 | |
748 while (tempentry != NULL) | 751 while (tempentry != NULL) |
749 { | 752 { |
750 g_hash_table_remove (new_bookmarks_htable, tempentry->path); | 753 g_hash_table_remove (new_bookmarks_htable, tempentry->path); |
751 | 754 |
752 if (tempentry->oldpath == NULL) | 755 bmentry = g_hash_table_lookup (gftp_bookmarks_htable, |
753 tempentry->oldpath = tempentry->path; | 756 tempentry->path); |
757 if (bmentry->oldpath == NULL) | |
758 bmentry->oldpath = tempentry->path; | |
754 else | 759 else |
755 g_free (tempentry->path); | 760 g_free (tempentry->path); |
756 | 761 |
757 if (*(tempentry->path + oldpathlen) == '\0') | 762 if (*(tempentry->path + oldpathlen) == '\0') |
758 tempentry->path = g_strdup (newpath); | 763 tempentry->path = g_strdup (newpath); |
761 tempentry->path + oldpathlen, | 766 tempentry->path + oldpathlen, |
762 NULL); | 767 NULL); |
763 | 768 |
764 g_hash_table_insert (new_bookmarks_htable, tempentry->path, | 769 g_hash_table_insert (new_bookmarks_htable, tempentry->path, |
765 tempentry); | 770 tempentry); |
771 | |
772 gtk_ctree_node_set_text (GTK_CTREE (tree), tempentry->cnode, 0, | |
773 tempentry->path); | |
774 | |
766 if (tempentry->children != NULL) | 775 if (tempentry->children != NULL) |
767 { | 776 tempentry = tempentry->children; |
768 tempentry = tempentry->children; | 777 else |
769 continue; | 778 { |
770 } | 779 while (tempentry->next == NULL && tempentry != entry && |
771 while (tempentry->next == NULL && tempentry != entry && | 780 tempentry->prev != NULL) |
772 tempentry->prev != NULL) | 781 tempentry = tempentry->prev; |
773 tempentry = tempentry->prev; | 782 |
774 | 783 tempentry = tempentry->next; |
775 tempentry = tempentry->next; | 784 } |
776 } | 785 } |
777 | 786 |
778 entry->next = nextentry; | 787 entry->next = nextentry; |
779 } | 788 } |
780 | 789 |