changeset 1396:58f0b4586c8c

dnd fixes
author nadvornik
date Sun, 08 Mar 2009 12:42:23 +0000
parents e86d8facbdae
children a0bd58a6535f
files src/bar_keywords.c src/metadata.c src/metadata.h
diffstat 3 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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,
--- 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)
 {
 
--- 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);