Mercurial > geeqie.yaz
comparison src/metadata.c @ 1392:d1b32a69b40a
dnd in keywords tree
improved dnd in advanced exif
author | nadvornik |
---|---|
date | Sun, 08 Mar 2009 09:56:40 +0000 |
parents | 9e0df7903581 |
children | 58f0b4586c8c |
comparison
equal
deleted
inserted
replaced
1391:9e0df7903581 | 1392:d1b32a69b40a |
---|---|
727 KEYWORD_COLUMN_CASEFOLD, casefold, | 727 KEYWORD_COLUMN_CASEFOLD, casefold, |
728 KEYWORD_COLUMN_IS_KEYWORD, is_keyword, -1); | 728 KEYWORD_COLUMN_IS_KEYWORD, is_keyword, -1); |
729 g_free(casefold); | 729 g_free(casefold); |
730 } | 730 } |
731 | 731 |
732 void keyword_copy(GtkTreeStore *keyword_tree, GtkTreeIter *to, GtkTreeIter *from) | |
733 { | |
734 | |
735 gchar *mark, *name, *casefold; | |
736 gboolean is_keyword; | |
737 | |
738 gtk_tree_model_get(GTK_TREE_MODEL(keyword_tree), from, KEYWORD_COLUMN_MARK, &mark, | |
739 KEYWORD_COLUMN_NAME, &name, | |
740 KEYWORD_COLUMN_CASEFOLD, &casefold, | |
741 KEYWORD_COLUMN_IS_KEYWORD, &is_keyword, -1); | |
742 | |
743 gtk_tree_store_set(keyword_tree, to, KEYWORD_COLUMN_MARK, mark, | |
744 KEYWORD_COLUMN_NAME, name, | |
745 KEYWORD_COLUMN_CASEFOLD, casefold, | |
746 KEYWORD_COLUMN_IS_KEYWORD, is_keyword, -1); | |
747 g_free(mark); | |
748 g_free(name); | |
749 g_free(casefold); | |
750 } | |
751 | |
752 void keyword_copy_recursive(GtkTreeStore *keyword_tree, GtkTreeIter *to, GtkTreeIter *from) | |
753 { | |
754 GtkTreeIter from_child; | |
755 | |
756 keyword_copy(keyword_tree, to, from); | |
757 | |
758 if (!gtk_tree_model_iter_children(GTK_TREE_MODEL(keyword_tree), &from_child, from)) return; | |
759 | |
760 while (TRUE) | |
761 { | |
762 GtkTreeIter to_child; | |
763 gtk_tree_store_append(keyword_tree, &to_child, to); | |
764 keyword_copy_recursive(keyword_tree, &to_child, &from_child); | |
765 if (!gtk_tree_model_iter_next(GTK_TREE_MODEL(keyword_tree), &from_child)) return; | |
766 } | |
767 } | |
768 | |
769 void keyword_move_recursive(GtkTreeStore *keyword_tree, GtkTreeIter *to, GtkTreeIter *from) | |
770 { | |
771 keyword_copy_recursive(keyword_tree, to, from); | |
772 gtk_tree_store_remove(keyword_tree, from); | |
773 } | |
774 | |
775 GList *keyword_tree_get_path(GtkTreeModel *keyword_tree, GtkTreeIter *iter_ptr) | |
776 { | |
777 GList *path = NULL; | |
778 GtkTreeIter iter = *iter_ptr; | |
779 | |
780 while (TRUE) | |
781 { | |
782 GtkTreeIter parent; | |
783 path = g_list_prepend(path, keyword_get_name(keyword_tree, &iter)); | |
784 if (!gtk_tree_model_iter_parent(keyword_tree, &parent, &iter)) break; | |
785 iter = parent; | |
786 } | |
787 return path; | |
788 } | |
789 | |
790 gboolean keyword_tree_get_iter(GtkTreeModel *keyword_tree, GtkTreeIter *iter_ptr, GList *path) | |
791 { | |
792 GtkTreeIter iter; | |
793 | |
794 if (!gtk_tree_model_get_iter_first(keyword_tree, &iter)) return FALSE; | |
795 | |
796 while (TRUE) | |
797 { | |
798 GtkTreeIter children; | |
799 while (TRUE) | |
800 { | |
801 gchar *name = keyword_get_name(keyword_tree, &iter); | |
802 if (strcmp(name, path->data) == 0) break; | |
803 g_free(name); | |
804 if (!gtk_tree_model_iter_next(keyword_tree, &iter)) return FALSE; | |
805 } | |
806 path = path->next; | |
807 if (!path) | |
808 { | |
809 *iter_ptr = iter; | |
810 return TRUE; | |
811 } | |
812 | |
813 if (!gtk_tree_model_iter_children(keyword_tree, &children, &iter)) return FALSE; | |
814 iter = children; | |
815 } | |
816 } | |
817 | |
818 | |
732 static gboolean keyword_tree_is_set_casefold(GtkTreeModel *keyword_tree, GtkTreeIter iter, GList *casefold_list) | 819 static gboolean keyword_tree_is_set_casefold(GtkTreeModel *keyword_tree, GtkTreeIter iter, GList *casefold_list) |
733 { | 820 { |
734 if (!casefold_list) return FALSE; | 821 if (!casefold_list) return FALSE; |
735 | 822 |
736 while (TRUE) | 823 while (TRUE) |
796 { | 883 { |
797 gchar *name = keyword_get_name(keyword_tree, &iter); | 884 gchar *name = keyword_get_name(keyword_tree, &iter); |
798 if (!find_string_in_list_utf8nocase(*kw_list, name)) | 885 if (!find_string_in_list_utf8nocase(*kw_list, name)) |
799 { | 886 { |
800 *kw_list = g_list_append(*kw_list, name); | 887 *kw_list = g_list_append(*kw_list, name); |
801 printf("set %s\n", name); | |
802 } | 888 } |
803 else | 889 else |
804 { | 890 { |
805 g_free(name); | 891 g_free(name); |
806 } | 892 } |
821 found = find_string_in_list_utf8nocase(*kw_list, name); | 907 found = find_string_in_list_utf8nocase(*kw_list, name); |
822 | 908 |
823 if (found) | 909 if (found) |
824 { | 910 { |
825 *kw_list = g_list_remove(*kw_list, found); | 911 *kw_list = g_list_remove(*kw_list, found); |
826 printf("remove %s\n", found); | |
827 g_free(found); | 912 g_free(found); |
828 } | 913 } |
829 g_free(name); | 914 g_free(name); |
830 } | 915 } |
831 | 916 |