# HG changeset patch
# User nadvornik
# Date 1236516143 0
# Node ID 58f0b4586c8c161acae7e91c942018e5d2eea267
# Parent  e86d8facbdae604239505e1e08f475c922a5f882
dnd fixes

diff -r e86d8facbdae -r 58f0b4586c8c src/bar_keywords.c
--- a/src/bar_keywords.c	Sun Mar 08 11:32:12 2009 +0000
+++ b/src/bar_keywords.c	Sun Mar 08 12:42:23 2009 +0000
@@ -527,6 +527,7 @@
 					  GtkSelectionData *selection_data, guint info,
 					  guint time, gpointer data)
 {
+	PaneKeywordsData *pkd = data;
 	GtkTreePath *tpath = NULL;
         GtkTreeViewDropPosition pos;
 	GtkTreeModel *model;
@@ -578,6 +579,12 @@
 			return;
 			}
 
+		if (src_valid && keyword_compare(keyword_tree, &src_kw_iter, &dest_kw_iter) == 0)
+			{
+			/* can't move to itself */
+			return;
+			}
+
 		if ((pos == GTK_TREE_VIEW_DROP_INTO_OR_BEFORE || pos == GTK_TREE_VIEW_DROP_INTO_OR_AFTER) &&
 		    !gtk_tree_model_iter_has_child(keyword_tree, &dest_kw_iter))
 			{
@@ -622,6 +629,7 @@
 			}
 		}
 	string_list_free(new_keywords);
+	bar_keyword_tree_sync(pkd);
 }
 
 static gint bar_pane_keywords_dnd_motion(GtkWidget *tree_view, GdkDragContext *context,
diff -r e86d8facbdae -r 58f0b4586c8c src/metadata.c
--- a/src/metadata.c	Sun Mar 08 11:32:12 2009 +0000
+++ b/src/metadata.c	Sun Mar 08 12:42:23 2009 +0000
@@ -729,6 +729,16 @@
 	g_free(casefold);
 }
 
+gboolean keyword_compare(GtkTreeModel *keyword_tree, GtkTreeIter *a, GtkTreeIter *b)
+{
+	GtkTreePath *pa = gtk_tree_model_get_path(keyword_tree, a);
+	GtkTreePath *pb = gtk_tree_model_get_path(keyword_tree, b);
+	gint ret = gtk_tree_path_compare(pa, pb);
+	gtk_tree_path_free(pa);
+	gtk_tree_path_free(pb);
+	return ret;
+}
+
 void keyword_copy(GtkTreeStore *keyword_tree, GtkTreeIter *to, GtkTreeIter *from)
 {
 
diff -r e86d8facbdae -r 58f0b4586c8c src/metadata.h
--- a/src/metadata.h	Sun Mar 08 11:32:12 2009 +0000
+++ b/src/metadata.h	Sun Mar 08 12:42:23 2009 +0000
@@ -55,6 +55,8 @@
 gchar *keyword_get_casefold(GtkTreeModel *keyword_tree, GtkTreeIter *iter);
 gboolean keyword_get_is_keyword(GtkTreeModel *keyword_tree, GtkTreeIter *iter);
 
+gboolean keyword_compare(GtkTreeModel *keyword_tree, GtkTreeIter *a, GtkTreeIter *b);
+
 void keyword_copy(GtkTreeStore *keyword_tree, GtkTreeIter *to, GtkTreeIter *from);
 void keyword_copy_recursive(GtkTreeStore *keyword_tree, GtkTreeIter *to, GtkTreeIter *from);
 void keyword_move_recursive(GtkTreeStore *keyword_tree, GtkTreeIter *to, GtkTreeIter *from);