[PATCH] allow to drop URIs, URLs and text to subfolders



The attached patch considers subfolders as drop targets for non-GNOME
Icon List drag data that refers to files.

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-file-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-dnd.c,v
retrieving revision 1.7
diff -u -p -r1.7 nautilus-file-dnd.c
--- libnautilus-private/nautilus-file-dnd.c	12 Dec 2005 16:59:10 -0000	1.7
+++ libnautilus-private/nautilus-file-dnd.c	22 Jun 2006 19:52:31 -0000
@@ -32,19 +32,14 @@
 #include <eel/eel-glib-extensions.h>
 #include <eel/eel-string.h>
 
-gboolean
-nautilus_drag_can_accept_item (NautilusFile *drop_target_item,
-			       const char *item_uri)
+static gboolean
+nautilus_drag_can_accept_files (NautilusFile *drop_target_item)
 {
 	NautilusDirectory *directory;
-	gboolean res;
-	
-	if (nautilus_file_matches_uri (drop_target_item, item_uri)) {
-		/* can't accept itself */
-		return FALSE;
-	}
-	
+
 	if (nautilus_file_is_directory (drop_target_item)) {
+		gboolean res;
+
 		/* target is a directory, accept if editable */
 		directory = nautilus_directory_get_for_file (drop_target_item);
 		res = nautilus_directory_is_editable (directory);
@@ -68,7 +63,19 @@ nautilus_drag_can_accept_item (NautilusF
 	
 	return FALSE;
 }
-					       
+
+gboolean
+nautilus_drag_can_accept_item (NautilusFile *drop_target_item,
+			       const char *item_uri)
+{
+	if (nautilus_file_matches_uri (drop_target_item, item_uri)) {
+		/* can't accept itself */
+		return FALSE;
+	}
+
+	return nautilus_drag_can_accept_files (drop_target_item);
+}
+				       
 gboolean
 nautilus_drag_can_accept_items (NautilusFile *drop_target_item,
 				const GList *items)
@@ -92,6 +99,39 @@ nautilus_drag_can_accept_items (Nautilus
 	}
 	
 	return TRUE;
+}
+
+gboolean
+nautilus_drag_can_accept_info (NautilusFile *drop_target_item,
+			       NautilusIconDndTargetType drag_type,
+			       const GList *items)
+{
+	switch (drag_type) {
+		case NAUTILUS_ICON_DND_GNOME_ICON_LIST:
+			return nautilus_drag_can_accept_items (drop_target_item, items);
+
+		case NAUTILUS_ICON_DND_URI_LIST:
+		case NAUTILUS_ICON_DND_URL:
+		case NAUTILUS_ICON_DND_TEXT:
+			return nautilus_drag_can_accept_files (drop_target_item);
+
+		case NAUTILUS_ICON_DND_KEYWORD:
+			return TRUE;
+
+		case NAUTILUS_ICON_DND_ROOTWINDOW_DROP:
+			return FALSE;
+
+		/* TODO return TRUE for folders as soon as drop handling is implemented */
+		case NAUTILUS_ICON_DND_COLOR:
+		case NAUTILUS_ICON_DND_BGIMAGE:
+		case NAUTILUS_ICON_DND_RESET_BACKGROUND:
+			return FALSE;
+
+		default:
+			g_assert_not_reached ();
+			return FALSE;
+	}
+	
 }
 
 void
Index: libnautilus-private/nautilus-file-dnd.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-dnd.h,v
retrieving revision 1.5
diff -u -p -r1.5 nautilus-file-dnd.h
--- libnautilus-private/nautilus-file-dnd.h	22 Feb 2002 18:54:15 -0000	1.5
+++ libnautilus-private/nautilus-file-dnd.h	22 Jun 2006 19:52:31 -0000
@@ -25,6 +25,7 @@
 #ifndef NAUTILUS_FILE_DND_H
 #define NAUTILUS_FILE_DND_H
 
+#include <libnautilus-private/nautilus-dnd.h>
 #include <libnautilus-private/nautilus-file.h>
 
 #define NAUTILUS_FILE_DND_ERASE_KEYWORD "erase"
@@ -33,6 +34,9 @@ gboolean nautilus_drag_can_accept_item  
 						     const char   *item_uri);
 gboolean nautilus_drag_can_accept_items             (NautilusFile *drop_target_item,
 						     const GList  *items);
+gboolean nautilus_drag_can_accept_info              (NautilusFile *drop_target_item,
+						     NautilusIconDndTargetType drag_type,
+						     const GList *items);
 void     nautilus_drag_file_receive_dropped_keyword (NautilusFile *file,
 						     const char   *keyword);
 
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.415
diff -u -p -r1.415 nautilus-icon-container.c
--- libnautilus-private/nautilus-icon-container.c	15 May 2006 22:55:24 -0000	1.415
+++ libnautilus-private/nautilus-icon-container.c	22 Jun 2006 19:53:16 -0000
@@ -4596,8 +4604,9 @@ nautilus_icon_container_class_init (Naut
 		                G_STRUCT_OFFSET (NautilusIconContainerClass, 
 						     handle_url),
 		                NULL, NULL,
-		                nautilus_marshal_VOID__STRING_ENUM_INT_INT,
-		                G_TYPE_NONE, 4,
+		                nautilus_marshal_VOID__STRING_STRING_ENUM_INT_INT,
+		                G_TYPE_NONE, 5,
+				G_TYPE_STRING,
 				G_TYPE_STRING,
 				GDK_TYPE_DRAG_ACTION,
 				G_TYPE_INT,
@@ -4609,8 +4618,9 @@ nautilus_icon_container_class_init (Naut
 		                G_STRUCT_OFFSET (NautilusIconContainerClass, 
 						     handle_uri_list),
 		                NULL, NULL,
-		                nautilus_marshal_VOID__STRING_ENUM_INT_INT,
-		                G_TYPE_NONE, 4,
+		                nautilus_marshal_VOID__STRING_STRING_ENUM_INT_INT,
+		                G_TYPE_NONE, 5,
+				G_TYPE_STRING,
 				G_TYPE_STRING,
 				GDK_TYPE_DRAG_ACTION,
 				G_TYPE_INT,
@@ -4622,8 +4632,9 @@ nautilus_icon_container_class_init (Naut
 		                G_STRUCT_OFFSET (NautilusIconContainerClass, 
 						 handle_text),
 		                NULL, NULL,
-		                nautilus_marshal_VOID__STRING_ENUM_INT_INT,
-		                G_TYPE_NONE, 4,
+		                nautilus_marshal_VOID__STRING_STRING_ENUM_INT_INT,
+		                G_TYPE_NONE, 5,
+				G_TYPE_STRING,
 				G_TYPE_STRING,
 				GDK_TYPE_DRAG_ACTION,
 				G_TYPE_INT,
Index: libnautilus-private/nautilus-icon-container.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.h,v
retrieving revision 1.92
diff -u -p -r1.92 nautilus-icon-container.h
--- libnautilus-private/nautilus-icon-container.h	15 May 2006 22:55:24 -0000	1.92
+++ libnautilus-private/nautilus-icon-container.h	22 Jun 2006 19:53:18 -0000
Index: libnautilus-private/nautilus-icon-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-dnd.c,v
retrieving revision 1.154
diff -u -p -r1.154 nautilus-icon-dnd.c
--- libnautilus-private/nautilus-icon-dnd.c	15 May 2006 22:55:24 -0000	1.154
+++ libnautilus-private/nautilus-icon-dnd.c	22 Jun 2006 19:53:21 -0000
@@ -84,6 +84,10 @@ static void     dnd_highlight_queue_redr
 static GtkTargetList *drop_types_list = NULL;
 static GtkTargetList *drop_types_list_root = NULL;
 
+static char * nautilus_icon_container_find_drop_target (NautilusIconContainer *container,
+							GdkDragContext *context,
+							int x, int y, gboolean *icon_hit);
+
 static EelCanvasItem *
 create_selection_shadow (NautilusIconContainer *container,
 			 GList *list)
@@ -618,44 +622,65 @@ receive_dropped_keyword (NautilusIconCon
 
 /* handle dropped url */
 static void
-receive_dropped_url (NautilusIconContainer *container, const char *encoded_url, GdkDragAction action, int x, int y)
+receive_dropped_url (NautilusIconContainer *container, const char *encoded_url, GdkDragContext *context, int x, int y)
 {
+	char *drop_target;
+
 	if (encoded_url == NULL) {
 		return;
 	}
 
+	drop_target = nautilus_icon_container_find_drop_target (container, context, x, y, NULL);
+
 	g_signal_emit_by_name (container, "handle_url",
 			       encoded_url,
-			       action,
+			       drop_target,
+			       context->action,
 			       x, y);
+
+	g_free (drop_target);
 }
 
 /* handle dropped uri list */
 static void
-receive_dropped_uri_list (NautilusIconContainer *container, const char *uri_list, GdkDragAction action, int x, int y)
+receive_dropped_uri_list (NautilusIconContainer *container, const char *uri_list, GdkDragContext *context, int x, int y)
 {	
+	char *drop_target;
+
 	if (uri_list == NULL) {
 		return;
 	}
-	
+
+	drop_target = nautilus_icon_container_find_drop_target (container, context, x, y, NULL);
+
 	g_signal_emit_by_name (container, "handle_uri_list",
 				 uri_list,
-				 action,
+				 drop_target,
+				 context->action,
 				 x, y);
+
+	g_free (drop_target);
 }
 
 /* handle dropped text */
 static void
-receive_dropped_text (NautilusIconContainer *container, const char *text, GdkDragAction action, int x, int y)
+receive_dropped_text (NautilusIconContainer *container, const char *text, GdkDragContext *context, int x, int y)
 {	
+	char *drop_target;
+
 	if (text == NULL) {
 		return;
 	}
+
+	drop_target = nautilus_icon_container_find_drop_target (container, context, x, y, NULL);
 	
 	g_signal_emit_by_name (container, "handle_text",
 			       text,
-			       action,
+			       drop_target,
+			       context->action,
 			       x, y);
+
+	g_free (drop_target);
 }
 
 static int
@@ -843,7 +868,7 @@ handle_local_move (NautilusIconContainer
 
 			nautilus_icon_container_add (container,
 					NAUTILUS_ICON_CONTAINER_ICON_DATA (file),
-					FALSE);
+					FALSE, FALSE);
 			
 			icon = nautilus_icon_container_get_icon_by_uri
 				(container, item->uri);
@@ -939,8 +964,11 @@ nautilus_icon_container_find_drop_target
 	NautilusFile *file;
 	char *icon_uri;
 
-	*icon_hit = FALSE;
-	if (container->details->dnd_info->drag_info.selection_list == NULL) {
+	if (icon_hit) {
+		*icon_hit = FALSE;
+	}
+
+	if (!container->details->dnd_info->drag_info.got_drop_data_type) {
 		return NULL;
 	}
 
@@ -959,8 +987,9 @@ nautilus_icon_container_find_drop_target
 		if (icon_uri != NULL) {
 			file = nautilus_file_get (icon_uri);
 
-			if (!nautilus_drag_can_accept_items (file, 
-					container->details->dnd_info->drag_info.selection_list)) {
+			if (!nautilus_drag_can_accept_info (file,
+							    container->details->dnd_info->drag_info.data_type,
+							    container->details->dnd_info->drag_info.selection_list)) {
 			 	/* the item we dropped our selection on cannot accept the items,
 			 	 * do the same thing as if we just dropped the items on the canvas
 				 */
@@ -973,11 +1002,16 @@ nautilus_icon_container_find_drop_target
 	}
 
 	if (drop_target_icon == NULL) {
-		*icon_hit = FALSE;
+		if (icon_hit) {
+			*icon_hit = FALSE;
+		}
+
 		return get_container_uri (container);
 	}
 	
-	*icon_hit = TRUE;
+	if (icon_hit) {
+		*icon_hit = TRUE;
+	}
 	return nautilus_icon_container_get_icon_drop_target_uri (container, drop_target_icon);
 }
 
@@ -1177,10 +1211,6 @@ nautilus_icon_dnd_update_drop_target (Na
 	char *uri;
 	
 	g_assert (NAUTILUS_IS_ICON_CONTAINER (container));
-	if ((container->details->dnd_info->drag_info.selection_list == NULL) 
-	   && (container->details->dnd_info->drag_info.data_type != NAUTILUS_ICON_DND_KEYWORD)) {
-		return;
-	}
 
 	canvas_widget_to_world (EEL_CANVAS (container), x, y, &world_x, &world_y);
 
@@ -1199,8 +1229,9 @@ nautilus_icon_dnd_update_drop_target (Na
 		    file = nautilus_file_get (uri);
 		    g_free (uri);
 		
-		    if (!nautilus_drag_can_accept_items (file,
-							 container->details->dnd_info->drag_info.selection_list)) {
+		    if (!nautilus_drag_can_accept_info (file,
+					    		container->details->dnd_info->drag_info.data_type,
+							container->details->dnd_info->drag_info.selection_list)) {
 			    icon = NULL;
 		    }
 
@@ -1642,20 +1673,20 @@ drag_data_received_callback (GtkWidget *
 		case NAUTILUS_ICON_DND_URL:
 			receive_dropped_url
 				(NAUTILUS_ICON_CONTAINER (widget),
-				 (char *) data->data, context->action, x, y);
+				 (char *) data->data, context, x, y);
 			success = TRUE;
 			break;
 		case NAUTILUS_ICON_DND_URI_LIST:
 			receive_dropped_uri_list
 				(NAUTILUS_ICON_CONTAINER (widget),
-				 (char *) data->data, context->action, x, y);
+				 (char *) data->data, context, x, y);
 			success = TRUE;
 			break;
 		case NAUTILUS_ICON_DND_TEXT:
 			tmp = gtk_selection_data_get_text (data);
 			receive_dropped_text
 				(NAUTILUS_ICON_CONTAINER (widget),
-				 (char *) tmp, context->action, x, y);
+				 (char *) tmp, context, x, y);
 			success = TRUE;
 			g_free (tmp);
 			break;
Index: libnautilus-private/nautilus-marshal.list
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-marshal.list,v
retrieving revision 1.11
diff -u -p -r1.11 nautilus-marshal.list
--- libnautilus-private/nautilus-marshal.list	12 Dec 2005 16:59:10 -0000	1.11
+++ libnautilus-private/nautilus-marshal.list	22 Jun 2006 19:53:27 -0000
@@ -16,5 +16,6 @@ VOID:POINTER,POINTER
 VOID:POINTER,POINTER,POINTER,ENUM,INT,INT
 VOID:POINTER,STRING
 VOID:POINTER,STRING,ENUM,INT,INT
+VOID:STRING,STRING,ENUM,INT,INT
 VOID:STRING,ENUM,INT,INT
 VOID:STRING,STRING
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.14
diff -u -p -r1.14 nautilus-tree-view-drag-dest.c
--- libnautilus-private/nautilus-tree-view-drag-dest.c	27 Feb 2006 21:54:58 -0000	1.14
+++ libnautilus-private/nautilus-tree-view-drag-dest.c	22 Jun 2006 19:53:31 -0000
@@ -306,7 +306,7 @@ get_drop_path (NautilusTreeViewDragDest 
 	NautilusFile *file;
 	GtkTreePath *ret;
 	
-	if (!path) {
+	if (!path || !dest->details->have_drag_data) {
 		return NULL;
 	}
 
@@ -315,7 +315,9 @@ get_drop_path (NautilusTreeViewDragDest 
 
 	/* Go up the tree until we find a file that can accept a drop */
 	while (file == NULL /* dummy row */ ||
-	       !nautilus_drag_can_accept_items (file, dest->details->drag_list)) {
+	       !nautilus_drag_can_accept_info (file,
+		       			       dest->details->drag_type,
+					       dest->details->drag_list)) {
 		if (gtk_tree_path_get_depth (ret) == 1) {
 			gtk_tree_path_free (ret);
 			ret = NULL;
@@ -333,8 +335,8 @@ get_drop_path (NautilusTreeViewDragDest 
 }
 
 static char *
-get_drop_target (NautilusTreeViewDragDest *dest, 
-		 GtkTreePath *path)
+get_drop_target_uri_for_path (NautilusTreeViewDragDest *dest,
+			      GtkTreePath *path)
 {
 	NautilusFile *file;
 	char *target;
@@ -366,7 +368,7 @@ get_drop_action (NautilusTreeViewDragDes
 
 	switch (dest->details->drag_type) {
 	case NAUTILUS_ICON_DND_GNOME_ICON_LIST :
-		drop_target = get_drop_target (dest, path);
+		drop_target = get_drop_target_uri_for_path (dest, path);
 		
 		if (!drop_target) {
 			return 0;
@@ -383,9 +385,27 @@ get_drop_action (NautilusTreeViewDragDes
 		return action;
 		
 	case NAUTILUS_ICON_DND_URL:
-		return nautilus_drag_default_drop_action_for_url (context);
+		drop_target = get_drop_target_uri_for_path (dest, path);
+
+		if (drop_target == NULL) {
+			return 0;
+		}
+
+		action = nautilus_drag_default_drop_action_for_url (context);
+
+		g_free (drop_target);
+
+		return action;
 		
 	case NAUTILUS_ICON_DND_URI_LIST :
+		drop_target = get_drop_target_uri_for_path (dest, path);
+
+		if (drop_target == NULL) {
+			return 0;
+		}
+
+		g_free (drop_target);
+
 		return context->suggested_action;
 
 	case NAUTILUS_ICON_DND_TEXT:
@@ -497,24 +517,43 @@ drag_leave_callback (GtkWidget *widget,
 	remove_expand_timeout (dest);
 }
 
-static void
-receive_uris (NautilusTreeViewDragDest *dest,
-	      GdkDragContext *context,
-	      GList *source_uris,
-	      int x, int y)
+static char *
+get_drop_target_uri_at_pos (NautilusTreeViewDragDest *dest, int x, int y)
 {
 	char *drop_target;
 	GtkTreePath *path;
 	GtkTreePath *drop_path;
 	GtkTreeViewDropPosition pos;
-	GdkDragAction action;
 
 	gtk_tree_view_get_dest_row_at_pos (dest->details->tree_view, x, y, 
 					   &path, &pos);
 
 	drop_path = get_drop_path (dest, path);
 
-	drop_target = get_drop_target (dest, drop_path);
+	drop_target = get_drop_target_uri_for_path (dest, drop_path);
+
+	if (path != NULL) {
+		gtk_tree_path_free (path);
+	}
+
+	if (drop_path != NULL) {
+		gtk_tree_path_free (drop_path);
+	}
+
+	return drop_target;
+}
+
+static void
+receive_uris (NautilusTreeViewDragDest *dest,
+	      GdkDragContext *context,
+	      GList *source_uris,
+	      int x, int y)
+{
+	char *drop_target;
+	GdkDragAction action;
+
+	drop_target = get_drop_target_uri_at_pos (dest, x, y);
+	g_assert (drop_target != NULL);
 
 	if (context->action == GDK_ACTION_ASK) {
 		if (nautilus_drag_selection_includes_special_link (dest->details->drag_list)) {
@@ -540,14 +579,6 @@ receive_uris (NautilusTreeViewDragDest *
 			       x, y);
 	}
 
-	if (path) {
-		gtk_tree_path_free (path);
-	}
-
-	if (drop_path) {
-		gtk_tree_path_free (drop_path);
-	}
-
 	g_free (drop_target);
 }
 
@@ -583,14 +614,22 @@ receive_dropped_uri_list (NautilusTreeVi
 			  GdkDragContext *context,
 			  int x, int y)
 {
+	char *drop_target;
+
 	if (!dest->details->drag_data) {
 		return;
 	}
 
+	drop_target = get_drop_target_uri_at_pos (dest, x, y);
+	g_assert (drop_target != NULL);
+
 	g_signal_emit (dest, signals[HANDLE_URI_LIST], 0,
 		       (char*)dest->details->drag_data->data,
+		       drop_target,
 		       context->action,
 		       x, y);
+
+	g_free (drop_target);
 }
 
 static void
@@ -598,18 +637,24 @@ receive_dropped_text (NautilusTreeViewDr
 		      GdkDragContext *context,
 		      int x, int y)
 {
+	char *drop_target;
 	char *text;
 
 	if (!dest->details->drag_data) {
 		return;
 	}
 
+	drop_target = get_drop_target_uri_at_pos (dest, x, y);
+	g_assert (drop_target != NULL);
+
 	text = gtk_selection_data_get_text (dest->details->drag_data);
 	g_signal_emit (dest, signals[HANDLE_TEXT], 0,
-		       (char *) text,
+		       (char *) text, drop_target,
 		       context->action,
 		       x, y);
+
 	g_free (text);
+	g_free (drop_target);
 }
 
 
@@ -618,14 +663,22 @@ receive_dropped_url (NautilusTreeViewDra
 		     GdkDragContext *context,
 		     int x, int y)
 {
+	char *drop_target;
+
 	if (!dest->details->drag_data) {
 		return;
 	}
 
+	drop_target = get_drop_target_uri_at_pos (dest, x, y);
+	g_assert (drop_target != NULL);
+
 	g_signal_emit (dest, signals[HANDLE_URL], 0,
 		       (char*)dest->details->drag_data->data,
+		       drop_target,
 		       context->action,
 		       x, y);
+
+	g_free (drop_target);
 }
 
 static void
@@ -634,15 +687,14 @@ receive_dropped_keyword (NautilusTreeVie
 			 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);
+	if (!dest->details->drag_data) {
+		return;
+	}
 
-	drop_target_uri = get_drop_target (dest, drop_path);
+	drop_target_uri = get_drop_target_uri_at_pos (dest, x, y);
+	g_assert (drop_target_uri != NULL);
 
 	drop_target_file = nautilus_file_get (drop_target_uri);
 
@@ -652,15 +704,6 @@ receive_dropped_keyword (NautilusTreeVie
 		nautilus_file_unref (drop_target_file);
 	}
 
-
-	if (path) {
-		gtk_tree_path_free (path);
-	}
-
-	if (drop_path) {
-		gtk_tree_path_free (drop_path);
-	}
-
 	g_free (drop_target_uri);
 }
 
@@ -854,8 +897,9 @@ nautilus_tree_view_drag_dest_class_init 
 			      G_STRUCT_OFFSET (NautilusTreeViewDragDestClass, 
 					       handle_url),
 			      NULL, NULL,
-			      nautilus_marshal_VOID__STRING_ENUM_INT_INT,
-			      G_TYPE_NONE, 4,
+			      nautilus_marshal_VOID__STRING_STRING_ENUM_INT_INT,
+			      G_TYPE_NONE, 5,
+			      G_TYPE_STRING,
 			      G_TYPE_STRING,
 			      GDK_TYPE_DRAG_ACTION,
 			      G_TYPE_INT,
@@ -867,8 +911,9 @@ nautilus_tree_view_drag_dest_class_init 
 			      G_STRUCT_OFFSET (NautilusTreeViewDragDestClass, 
 					       handle_uri_list),
 			      NULL, NULL,
-			      nautilus_marshal_VOID__STRING_ENUM_INT_INT,
-			      G_TYPE_NONE, 4,
+			      nautilus_marshal_VOID__STRING_STRING_ENUM_INT_INT,
+			      G_TYPE_NONE, 5,
+			      G_TYPE_STRING,
 			      G_TYPE_STRING,
 			      GDK_TYPE_DRAG_ACTION,
 			      G_TYPE_INT,
@@ -880,8 +925,9 @@ nautilus_tree_view_drag_dest_class_init 
 			      G_STRUCT_OFFSET (NautilusTreeViewDragDestClass, 
 					       handle_text),
 			      NULL, NULL,
-			      nautilus_marshal_VOID__STRING_ENUM_INT_INT,
-			      G_TYPE_NONE, 4,
+			      nautilus_marshal_VOID__STRING_STRING_ENUM_INT_INT,
+			      G_TYPE_NONE, 5,
+			      G_TYPE_STRING,
 			      G_TYPE_STRING,
 			      GDK_TYPE_DRAG_ACTION,
 			      G_TYPE_INT,
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.745
diff -u -p -r1.745 fm-directory-view.c
--- src/file-manager/fm-directory-view.c	16 Jun 2006 15:40:18 -0000	1.745
+++ src/file-manager/fm-directory-view.c	22 Jun 2006 20:08:33 -0000
@@ -1415,7 +1415,7 @@ action_new_empty_file_callback (GtkActio
 {                
         g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
 
-	fm_directory_view_new_file (FM_DIRECTORY_VIEW (callback_data), NULL);
+	fm_directory_view_new_file (FM_DIRECTORY_VIEW (callback_data), NULL, NULL);
 }
 
 static void
@@ -4217,36 +4217,45 @@ setup_new_folder_data (FMDirectoryView *
 
 static void
 fm_directory_view_new_file_with_initial_contents (FMDirectoryView *directory_view,
+						  const char *parent_uri,
 						  const char *initial_contents)
 {
 	GdkPoint *pos;
 	NewFolderData *data;
-	char *parent_uri;
+
+	g_assert (parent_uri != NULL);
 
 	data = setup_new_folder_data (directory_view);
 
 	pos = context_menu_to_file_operation_position (directory_view);
 
-	parent_uri = fm_directory_view_get_backing_uri (directory_view);
 	nautilus_file_operations_new_file (GTK_WIDGET (directory_view),
 					   pos, parent_uri,
 					   initial_contents,
 					   new_folder_done, data);
-
-	g_free (parent_uri);
 }
 
 void
 fm_directory_view_new_file (FMDirectoryView *directory_view,
+			    const char *parent_uri,
 			    NautilusFile *source)
 {
 	GdkPoint *pos;
 	NewFolderData *data;
-	char *parent_uri;
 	char *source_uri;
+	char *container_uri;
+
+	container_uri = NULL;
+	if (parent_uri == NULL) {
+		container_uri = fm_directory_view_get_backing_uri (directory_view);
+		g_assert (container_uri != NULL);
+	}
 
 	if (source == NULL) {
-		fm_directory_view_new_file_with_initial_contents (directory_view, NULL);
+		fm_directory_view_new_file_with_initial_contents (directory_view,
+								  parent_uri != NULL ? parent_uri : container_uri,
+								  NULL);
+		g_free (container_uri);
 		return;
 	}
 
@@ -4257,17 +4266,16 @@ fm_directory_view_new_file (FMDirectoryV
 	data = setup_new_folder_data (directory_view);
 
 	source_uri = nautilus_file_get_uri (source);
-	parent_uri = fm_directory_view_get_backing_uri (directory_view);
 
 	nautilus_file_operations_new_file_from_template (GTK_WIDGET (directory_view),
 							 pos,
-							 parent_uri,
+							 parent_uri != NULL ? parent_uri : container_uri,
 							 NULL,
 							 source_uri,
 							 new_folder_done, data);
 
-	g_free (parent_uri);
 	g_free (source_uri);
+	g_free (container_uri);
 }
 
 /* handle the open command */
@@ -4782,7 +4790,8 @@ extension_action_callback_data_free (Ext
 {
 	g_object_unref (data->item);
 	nautilus_file_list_free (data->selection);
-	
+	g_object_unref (data->view);
+
 	g_free (data);
 }
 
@@ -4826,6 +4835,12 @@ extension_action_slow_mime_types_ready_c
 	g_free (item_name);
 
 	if (is_valid) {
+		char *display;
+
+		display = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (data->view)));
+		g_setenv ("DISPLAY", display, TRUE);
+		g_free (display);
+
 		nautilus_menu_item_activate (data->item);
 	}
 
@@ -4890,7 +4905,7 @@ add_extension_action_for_files (FMDirect
 
 	data = g_new0 (ExtensionActionCallbackData, 1);
 	data->item = g_object_ref (item);
-	data->view = view;
+	data->view = g_object_ref (view);
 	data->selection = nautilus_file_list_copy (files);
 	data->action = action;
 
@@ -5567,7 +5582,7 @@ create_template_callback (GtkAction *act
 
 	parameters = callback_data;
 	
-	fm_directory_view_new_file (parameters->directory_view, parameters->file);
+	fm_directory_view_new_file (parameters->directory_view, NULL, parameters->file);
 }
 
 static void
@@ -9632,6 +9647,7 @@ ask_link_action (FMDirectoryView *view)
 void
 fm_directory_view_handle_url_drop (FMDirectoryView  *view,
 				   const char       *encoded_url,
+				   const char       *target_uri,
 				   GdkDragAction     action,
 				   int               x,
 				   int               y)
@@ -9652,10 +9668,13 @@ fm_directory_view_handle_url_drop (FMDir
 		return;
 	}
 
-	container_uri = fm_directory_view_get_backing_uri (view);
-	g_return_if_fail (container_uri != NULL);
+	container_uri = NULL;
+	if (target_uri == NULL) {
+		container_uri = fm_directory_view_get_backing_uri (view);
+		g_assert (container_uri != NULL);
+	}
 
-	if (eel_vfs_has_capability (container_uri,
+	if (eel_vfs_has_capability (target_uri != NULL ? target_uri : container_uri,
 				    EEL_VFS_CAPABILITY_IS_REMOTE_AND_SLOW)) {
 		eel_show_warning_dialog (_("Drag and drop is not supported."),
 					 _("Drag and drop is only supported on local file systems."),
@@ -9736,7 +9755,7 @@ fm_directory_view_handle_url_drop (FMDir
 			screen = gtk_widget_get_screen (GTK_WIDGET (view));
 			screen_num = gdk_screen_get_number (screen);
 
-			nautilus_link_local_create (container_uri,
+			nautilus_link_local_create (target_uri != NULL ? target_uri : container_uri,
 						    link_name,
 						    link_display_name,
 						    "gnome-fs-bookmark",
@@ -9758,7 +9777,7 @@ fm_directory_view_handle_url_drop (FMDir
 		uri_list = g_list_append (uri_list, url);
 
 		fm_directory_view_move_copy_items (uri_list, points,
-						   container_uri,
+						   target_uri != NULL ? target_uri : container_uri,
 						   action, x, y, view);
 
 		g_list_free (uri_list);
@@ -9773,6 +9792,7 @@ fm_directory_view_handle_url_drop (FMDir
 void
 fm_directory_view_handle_uri_list_drop (FMDirectoryView  *view,
 					const char       *item_uris,
+					const char       *target_uri,
 					GdkDragAction     action,
 					int               x,
 					int               y)
@@ -9787,8 +9807,11 @@ fm_directory_view_handle_uri_list_drop (
 		return;
 	}
 
-	container_uri = fm_directory_view_get_backing_uri (view);
-	g_return_if_fail (container_uri != NULL);
+	container_uri = NULL;
+	if (target_uri == NULL) {
+		container_uri = fm_directory_view_get_backing_uri (view);
+		g_assert (container_uri != NULL);
+	}
 
 	if (action == GDK_ACTION_ASK) {
 		action = nautilus_drag_drop_action_ask
@@ -9847,7 +9870,7 @@ fm_directory_view_handle_uri_list_drop (
 	}
 
 	fm_directory_view_move_copy_items (real_uri_list, points,
-					   container_uri,
+					   target_uri != NULL ? target_uri : container_uri,
 					   action, x, y, view);
 
 	eel_g_list_free_deep (real_uri_list);
@@ -9861,6 +9884,7 @@ fm_directory_view_handle_uri_list_drop (
 void
 fm_directory_view_handle_text_drop (FMDirectoryView  *view,
 				    const char       *text,
+				    const char       *target_uri,
 				    GdkDragAction     action,
 				    int               x,
 				    int               y)
@@ -9873,11 +9897,14 @@ fm_directory_view_handle_text_drop (FMDi
 
 	g_return_if_fail (action == GDK_ACTION_COPY);
 
-	container_uri = fm_directory_view_get_backing_uri (view);
-	g_return_if_fail (container_uri != NULL);
+	container_uri = NULL;
+	if (target_uri == NULL) {
+		container_uri = fm_directory_view_get_backing_uri (view);
+		g_assert (container_uri != NULL);
+	}
 
 	fm_directory_view_new_file_with_initial_contents (
-		view, text);
+		view, target_uri != NULL ? target_uri : container_uri, text);
 
 	g_free (container_uri);
 }
Index: src/file-manager/fm-directory-view.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.h,v
retrieving revision 1.144
diff -u -p -r1.144 fm-directory-view.h
--- src/file-manager/fm-directory-view.h	30 Mar 2006 19:37:22 -0000	1.144
+++ src/file-manager/fm-directory-view.h	22 Jun 2006 20:08:34 -0000
@@ -404,21 +404,25 @@ gboolean	    fm_directory_view_should_so
 void                fm_directory_view_update_menus                     (FMDirectoryView  *view);
 void                fm_directory_view_new_folder                       (FMDirectoryView  *view);
 void                fm_directory_view_new_file                         (FMDirectoryView  *view,
+									const char       *parent_uri,
 									NautilusFile     *source);
 void                fm_directory_view_ignore_hidden_file_preferences   (FMDirectoryView  *view);
 void                fm_directory_view_init_view_iface                  (NautilusViewIface *iface);
 void                fm_directory_view_handle_url_drop                  (FMDirectoryView  *view,
 									const char       *encoded_url,
+									const char       *target_uri,
 									GdkDragAction     action,
 									int               x,
 									int               y);
 void                fm_directory_view_handle_uri_list_drop             (FMDirectoryView  *view,
 									const char       *item_uris,
+									const char       *target_uri,
 									GdkDragAction     action,
 									int               x,
 									int               y);
 void                fm_directory_view_handle_text_drop                 (FMDirectoryView  *view,
 									const char       *text,
+									const char       *target_uri,
 									GdkDragAction     action,
 									int               x,
 									int               y);
Index: src/file-manager/fm-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.c,v
retrieving revision 1.323
diff -u -p -r1.323 fm-icon-view.c
--- src/file-manager/fm-icon-view.c	15 May 2006 22:55:25 -0000	1.323
+++ src/file-manager/fm-icon-view.c	22 Jun 2006 20:08:41 -0000
@@ -553,7 +553,8 @@ fm_icon_view_add_file (FMDirectoryView *
 
 	if (nautilus_icon_container_add (icon_container,
 					 NAUTILUS_ICON_CONTAINER_ICON_DATA (file),
-					 file_has_lazy_position (view, file)))  {
+					 file_has_lazy_position (view, file),
+					 nautilus_icon_factory_can_thumbnail (file))) {
 		nautilus_file_ref (file);
 	}
 }
@@ -2077,7 +2078,8 @@ fm_icon_view_screen_changed (GtkWidget *
 			} else {
 				if (nautilus_icon_container_add (icon_container,
 								 NAUTILUS_ICON_CONTAINER_ICON_DATA (file),
-								 file_has_lazy_position (view, file))) {
+								 file_has_lazy_position (view, file),
+								 nautilus_icon_factory_can_thumbnail (file))) {
 					nautilus_file_ref (file);
 				}
 			}
@@ -2527,26 +2529,29 @@ create_icon_container (FMIconView *icon_
 /* Handles an URL received from Mozilla */
 static void
 icon_view_handle_url (NautilusIconContainer *container, const char *encoded_url,
+		      const char *target_uri,
 		      GdkDragAction action, int x, int y, FMIconView *view)
 {
 	fm_directory_view_handle_url_drop (FM_DIRECTORY_VIEW (view),
-					   encoded_url, action, x, y);
+					   encoded_url, target_uri, action, x, y);
 }
 
 static void
 icon_view_handle_uri_list (NautilusIconContainer *container, const char *item_uris,
+			   const char *target_uri,
 			   GdkDragAction action, int x, int y, FMIconView *view)
 {
 	fm_directory_view_handle_uri_list_drop (FM_DIRECTORY_VIEW (view),
-						item_uris, action, x, y);
+						item_uris, target_uri, action, x, y);
 }
 
 static void
 icon_view_handle_text (NautilusIconContainer *container, const char *text,
+		       const char *target_uri,
 		       GdkDragAction action, int x, int y, FMIconView *view)
 {
 	fm_directory_view_handle_text_drop (FM_DIRECTORY_VIEW (view),
-					    text, action, x, y);
+					    text, target_uri, action, x, y);
 }
 
 static char *
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.270
diff -u -p -r1.270 fm-list-view.c
--- src/file-manager/fm-list-view.c	24 May 2006 13:20:42 -0000	1.270
+++ src/file-manager/fm-list-view.c	22 Jun 2006 20:08:47 -0000
@@ -1044,26 +1044,28 @@ get_file_for_path_callback (NautilusTree
 /* Handles an URL received from Mozilla */
 static void
 list_view_handle_url (NautilusTreeViewDragDest *dest, const char *encoded_url,
-		      GdkDragAction action, int x, int y, FMListView *view)
+		      const char *target_uri, GdkDragAction action, int x, int y, FMListView *view)
 {
 	fm_directory_view_handle_url_drop (FM_DIRECTORY_VIEW (view),
-					   encoded_url, action, x, y);
+					   encoded_url, target_uri, action, x, y);
 }
 
 static void
 list_view_handle_uri_list (NautilusTreeViewDragDest *dest, const char *item_uris,
+			   const char *target_uri,
 			   GdkDragAction action, int x, int y, FMListView *view)
 {
 	fm_directory_view_handle_uri_list_drop (FM_DIRECTORY_VIEW (view),
-						item_uris, action, x, y);
+						item_uris, target_uri, action, x, y);
 }
 
 static void
 list_view_handle_text (NautilusTreeViewDragDest *dest, const char *text,
+		       const char *target_uri,
 		       GdkDragAction action, int x, int y, FMListView *view)
 {
 	fm_directory_view_handle_text_drop (FM_DIRECTORY_VIEW (view),
-					    text, action, x, y);
+					    text, target_uri, action, x, y);
 }
 
 static void


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