[PATCH] Support list view emblem/keyword DND



The attached patch enables list view DND and partially fixes a text dnd
issue, where the user was required to hover over a path to enable text
dropping. Fixes bug 313408 [1].

[1] http://bugzilla.gnome.org/show_bug.cgi?id=313408

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-tree-view-drag-dest.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-tree-view-drag-dest.c,v
retrieving revision 1.11
diff -u -p -r1.11 nautilus-tree-view-drag-dest.c
--- libnautilus-private/nautilus-tree-view-drag-dest.c	6 Jul 2005 12:18:27 -0000	1.11
+++ libnautilus-private/nautilus-tree-view-drag-dest.c	14 Aug 2005 17:49:46 -0000
@@ -82,7 +83,7 @@ static const GtkTargetEntry drag_types [
 	{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
 	{ NAUTILUS_ICON_DND_URI_LIST_TYPE, 0, NAUTILUS_ICON_DND_URI_LIST },
 	{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
-	/* FIXME: Should handle emblems once the list view supports them */
+	{ NAUTILUS_ICON_DND_KEYWORD_TYPE, 0, NAUTILUS_ICON_DND_KEYWORD }
 };
 
 
@@ -387,6 +388,9 @@ get_drop_action (NautilusTreeViewDragDes
 		return context->suggested_action;
 
 	case NAUTILUS_ICON_DND_TEXT:
+		return GDK_ACTION_COPY;
+
+	case NAUTILUS_ICON_DND_KEYWORD:
 		drop_target = get_drop_target (dest, path);
 
 		if (!drop_target) {
@@ -626,6 +626,36 @@ receive_dropped_url (NautilusTreeViewDra
 		       x, y);
 }
 
+static void
+receive_dropped_keyword (NautilusTreeViewDragDest *dest,
+			 GdkDragContext *context,
+			 int x, int y)
+{
+	char *drop_target_uri;
+	GtkTreePath *path, *drop_path;
+	NautilusFile *drop_target_file;
+
+	gtk_tree_view_get_dest_row_at_pos (dest->details->tree_view, x, y, 
+					   &path, NULL);
+
+	drop_path = get_drop_path (dest, path);
+	g_return_if_fail (drop_path != NULL);
+
+	drop_target_uri = get_drop_target (dest, drop_path);
+	g_return_if_fail (drop_target_uri != NULL);
+
+	drop_target_file = nautilus_file_get (drop_target_uri);
+	g_return_if_fail (drop_target_file != NULL);
+
+	nautilus_drag_file_receive_dropped_keyword (drop_target_file,
+						    (char *) dest->details->drag_data->data);
+
+	g_free (drop_target_uri);
+	nautilus_file_unref (drop_target_file);
+	gtk_tree_path_free (drop_path);
+	gtk_tree_path_free (path);
+}
+
 static gboolean
 drag_data_received_callback (GtkWidget *widget,
 			     GdkDragContext *context,
@@ -669,6 +699,10 @@ drag_data_received_callback (GtkWidget *
 			break;
 		case NAUTILUS_ICON_DND_TEXT:
 			receive_dropped_text (dest, context, x, y);
+			success = TRUE;
+			break;
+		case NAUTILUS_ICON_DND_KEYWORD:
+			receive_dropped_keyword (dest, context, x, y);
 			success = TRUE;
 			break;
 		}

Attachment: signature.asc
Description: This is a digitally signed message part



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]