[PATCH] Drop text in Nautilus window, new file created



One thing that bugged me for ages in Nautilus is that one can not drop
text (from gedit, Epiphany) to Nautilus to create a new file. After
applying the attached patch, this works.

-- 
Christian Neumair <chris gnome-de org>
Index: libnautilus-private/nautilus-file-operations.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-operations.c,v
retrieving revision 1.188
diff -u -p -r1.188 nautilus-file-operations.c
--- libnautilus-private/nautilus-file-operations.c	17 May 2005 09:27:06 -0000	1.188
+++ libnautilus-private/nautilus-file-operations.c	2 Jun 2005 09:26:54 -0000
@@ -26,6 +26,7 @@
 
 #include <config.h>
 #include <string.h>
+#include <stdio.h>
 #include "nautilus-file-operations.h"
 
 #include "nautilus-file-operations-progress.h"
@@ -38,6 +39,7 @@
 #include <eel/eel-vfs-extensions.h>
 
 #include <gnome.h>
+#include <gdk/gdkdnd.h>
 #include <gtk/gtklabel.h>
 #include <gtk/gtkmessagedialog.h>
 #include <libgnomevfs/gnome-vfs-async-ops.h>
@@ -2230,7 +2232,8 @@ typedef struct {
 	NautilusNewFileCallback done_callback;
 	gpointer data;
 	GtkWidget *parent_view;
-	char *empty_file;
+	char *source_file;
+	gboolean move_source_file;
 	GHashTable *debuting_uris;
 } NewFileTransferState;
 
@@ -2298,9 +2301,12 @@ new_file_transfer_callback (GnomeVFSAsyn
 		(* state->done_callback) (uri, state->data);
 		/* uri is owned by hashtable, don't free */
 
-		if (state->empty_file != NULL) {
-			unlink (state->empty_file);
-			g_free (state->empty_file);
+		if (state->source_file != NULL) {
+			if (state->move_source_file) {
+				unlink (state->source_file);
+			}
+
+			g_free (state->source_file);
 		}
 		eel_remove_weak_pointer (&state->parent_view);
 		g_hash_table_destroy (state->debuting_uris);
@@ -2350,61 +2356,52 @@ new_file_transfer_callback (GnomeVFSAsyn
 }
 
 void 
-nautilus_file_operations_new_file (GtkWidget *parent_view, 
-				   const char *parent_dir,
-				   const char *source_uri_text,
-				   NautilusNewFileCallback done_callback,
-				   gpointer data)
+nautilus_file_operations_new_file_from_template (GtkWidget *parent_view, 
+						 const char *parent_dir,
+						 const char *target_filename,
+						 const char *template_file,
+						 GdkDragAction copy_action,
+						 NautilusNewFileCallback done_callback,
+						 gpointer data)
 {
 	GList *target_uri_list;
 	GList *source_uri_list;
+	char *source_uri_text;
 	GnomeVFSURI *target_uri, *parent_uri, *source_uri;
-	char *filename;
 	NewFileTransferState *state;
 	SyncTransferInfo *sync_transfer_info;
 
+	g_assert (parent_dir != NULL);
+	g_assert (template_file != NULL);
+
 	state = g_new (NewFileTransferState, 1);
 	state->done_callback = done_callback;
 	state->data = data;
 	state->parent_view = parent_view;
-	state->empty_file = NULL;
 
 	/* pass in the target directory and the new folder name as a destination URI */
 	parent_uri = gnome_vfs_uri_new (parent_dir);
 
-	if (source_uri_text != NULL) {
-		source_uri = gnome_vfs_uri_new (source_uri_text);
-		if (source_uri == NULL) {
-			(*done_callback) (NULL, data);
-			g_free (state);
-			return;
-		}
-		filename = gnome_vfs_uri_extract_short_path_name (source_uri);
-		target_uri = gnome_vfs_uri_append_string (parent_uri, filename);
-		g_free (filename);
+	source_uri_text = g_filename_to_uri (template_file, NULL, NULL);
+	source_uri = gnome_vfs_uri_new (source_uri_text);
+	if (source_uri == NULL) {
+		(*done_callback) (NULL, data);
+		g_free (state);
+		g_free (source_uri_text);
+		return;
+	}
+
+	state->source_file = g_strdup (template_file);
+	state->move_source_file = (copy_action == GDK_ACTION_MOVE);
+
+	if (target_filename != NULL) {
+		target_uri = gnome_vfs_uri_append_file_name (parent_uri, target_filename);
 	} else {
-		char empty_file[] = "/tmp/emptyXXXXXX";
-		char *empty_uri;
-		int fd;
-
-		fd = mkstemp (empty_file);
-		if (fd == -1) {
-			(*done_callback) (NULL, data);
-			g_free (state);
-		}
-		close (fd);
-
-		empty_uri = gnome_vfs_get_uri_from_local_path (empty_file);
-		source_uri = gnome_vfs_uri_new (empty_uri);
-		g_free (empty_uri);
-		
-		state->empty_file = g_strdup (empty_file);
-		
-		filename = g_filename_from_utf8 (_("new file"), -1, NULL, NULL, NULL);
-		target_uri = gnome_vfs_uri_append_file_name (parent_uri, filename);
-		g_free (filename);
+		target_filename = gnome_vfs_uri_extract_short_path_name (source_uri);
+		target_uri = gnome_vfs_uri_append_file_name (parent_uri, target_filename);
+		g_free ((char *) target_filename);
 	}
-	
+
 	state->debuting_uris = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
 	eel_add_weak_pointer (&state->parent_view);
 
@@ -2426,6 +2423,47 @@ nautilus_file_operations_new_file (GtkWi
 	gnome_vfs_uri_list_free (target_uri_list);
 	gnome_vfs_uri_list_free (source_uri_list);
 	gnome_vfs_uri_unref (parent_uri);
+	g_free (source_uri_text);
+}
+
+void 
+nautilus_file_operations_new_file (GtkWidget *parent_view, 
+				   const char *parent_dir,
+				   const char *initial_contents,
+				   NautilusNewFileCallback done_callback,
+				   gpointer data)
+{
+	char source_file_str[] = "/tmp/nautilus-sourceXXXXXX";
+	FILE *source_file;
+	char *target_filename;
+	int fd;
+
+	fd = mkstemp (source_file_str);
+	if (fd == -1) {
+		(*done_callback) (NULL, data);
+		return;
+	}
+
+	if (initial_contents != NULL) {
+		source_file = fdopen (fd, "a+");
+
+		fprintf (source_file, initial_contents);
+		fclose (source_file);
+	}
+
+	close (fd);
+
+	target_filename = g_filename_from_utf8 (_("new file"), -1, NULL, NULL, NULL);
+
+	nautilus_file_operations_new_file_from_template (parent_view, 
+							 parent_dir,
+							 target_filename,
+							 source_file_str,
+							 GDK_ACTION_MOVE,
+							 done_callback,
+							 data);
+
+	g_free (target_filename);
 }
 
 void 
Index: libnautilus-private/nautilus-file-operations.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-operations.h,v
retrieving revision 1.19
diff -u -p -r1.19 nautilus-file-operations.h
--- libnautilus-private/nautilus-file-operations.h	12 Dec 2003 17:55:45 -0000	1.19
+++ libnautilus-private/nautilus-file-operations.h	2 Jun 2005 09:26:54 -0000
@@ -27,6 +27,7 @@
 #ifndef NAUTILUS_FILE_OPERATIONS_H
 #define NAUTILUS_FILE_OPERATIONS_H
 
+#include <gdk/gdkdnd.h>
 #include <gtk/gtkwidget.h>
 #include <libgnomevfs/gnome-vfs-types.h>
 
@@ -53,9 +54,17 @@ void nautilus_file_operations_new_folder
 					   gpointer                   done_callback_data);
 void nautilus_file_operations_new_file    (GtkWidget                 *parent_view,
 					   const char                *parent_dir,
-					   const char                *source_uri_text,
+					   const char                *initial_contents,
 					   NautilusNewFileCallback    done_callback,
 					   gpointer                   data);
+void nautilus_file_operations_new_file_from_template (GtkWidget               *parent_view,
+						      const char              *parent_dir,
+						      const char              *target_filename,
+						      const char              *template_file,
+						      GdkDragAction            copy_action,
+						      NautilusNewFileCallback  done_callback,
+						      gpointer                 data);
+
 void nautilus_file_operations_delete      (const GList               *item_uris,
 					   GtkWidget                 *parent_view);
 
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.c,v
retrieving revision 1.385
diff -u -p -r1.385 nautilus-icon-container.c
--- libnautilus-private/nautilus-icon-container.c	2 May 2005 20:50:06 -0000	1.385
+++ libnautilus-private/nautilus-icon-container.c	2 Jun 2005 09:26:56 -0000
@@ -229,6 +229,7 @@ enum {
 	MOVE_COPY_ITEMS,
 	HANDLE_URL,
 	HANDLE_URI_LIST,
+	HANDLE_TEXT,
 	PREVIEW,
 	SELECTION_CHANGED,
 	ICON_ADDED,
@@ -4148,7 +4149,19 @@ nautilus_icon_container_class_init (Naut
 				G_TYPE_INT,
 				G_TYPE_INT,
 				G_TYPE_INT);
-
+	signals[HANDLE_TEXT]
+		= g_signal_new ("handle_text",
+		                G_TYPE_FROM_CLASS (class),
+		                G_SIGNAL_RUN_LAST,
+		                G_STRUCT_OFFSET (NautilusIconContainerClass, 
+						 handle_text),
+		                NULL, NULL,
+		                nautilus_marshal_VOID__STRING_INT_INT_INT,
+		                G_TYPE_NONE, 4,
+				G_TYPE_STRING,
+				G_TYPE_INT,
+				G_TYPE_INT,
+				G_TYPE_INT);
 	signals[GET_CONTAINER_URI] 
 		= g_signal_new ("get_container_uri",
 		                G_TYPE_FROM_CLASS (class),
Index: libnautilus-private/nautilus-icon-container.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-container.h,v
retrieving revision 1.85
diff -u -p -r1.85 nautilus-icon-container.h
--- libnautilus-private/nautilus-icon-container.h	13 Jan 2005 13:27:51 -0000	1.85
+++ libnautilus-private/nautilus-icon-container.h	2 Jun 2005 09:26:56 -0000
@@ -108,6 +108,10 @@ typedef struct {
 						   char *uri_list,
 						   int x,
 						   int y);
+	void	     (* handle_text)		  (NautilusIconContainer *container,
+						   char *text,
+						   int x,
+						   int y);
 
 	/* Queries on the container for subclass/client.
 	 * These must be implemented. The default "do nothing" is not good enough.
Index: libnautilus-private/nautilus-icon-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-dnd.c,v
retrieving revision 1.142
diff -u -p -r1.142 nautilus-icon-dnd.c
--- libnautilus-private/nautilus-icon-dnd.c	16 Mar 2005 08:32:20 -0000	1.142
+++ libnautilus-private/nautilus-icon-dnd.c	2 Jun 2005 09:26:57 -0000
@@ -64,14 +64,14 @@
 static 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 },
-	{ NAUTILUS_ICON_DND_TEXT_TYPE, 0, NAUTILUS_ICON_DND_TEXT }
+	{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL }
 };
 
 static GtkTargetEntry drop_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 },
+	{ NAUTILUS_ICON_DND_TEXT_TYPE, 0, NAUTILUS_ICON_DND_TEXT },
 	{ NAUTILUS_ICON_DND_COLOR_TYPE, 0, NAUTILUS_ICON_DND_COLOR },
 	{ NAUTILUS_ICON_DND_BGIMAGE_TYPE, 0, NAUTILUS_ICON_DND_BGIMAGE },
 	{ NAUTILUS_ICON_DND_KEYWORD_TYPE, 0, NAUTILUS_ICON_DND_KEYWORD },
@@ -643,6 +643,20 @@ receive_dropped_uri_list (NautilusIconCo
 				 x, y);
 }
 
+/* handle dropped text */
+static void
+receive_dropped_text (NautilusIconContainer *container, const char *text, GdkDragAction action, int x, int y)
+{	
+	if (text == NULL) {
+		return;
+	}
+	
+	g_signal_emit_by_name (container, "handle_text",
+			       text,
+			       action,
+			       x, y);
+}
+
 static int
 auto_scroll_timeout_callback (gpointer data)
 {
@@ -1131,6 +1145,7 @@ nautilus_icon_container_get_drop_action 
 		break;
 
 	case NAUTILUS_ICON_DND_TEXT:
+		*action = GDK_ACTION_COPY;
 		break;
 	}
 }
@@ -1557,6 +1572,7 @@ drag_data_received_callback (GtkWidget *
 	case NAUTILUS_ICON_DND_BGIMAGE:	
 	case NAUTILUS_ICON_DND_KEYWORD:
 	case NAUTILUS_ICON_DND_URI_LIST:
+	case NAUTILUS_ICON_DND_TEXT:
 	case NAUTILUS_ICON_DND_RESET_BACKGROUND:
 		/* Save the data so we can do the actual work on drop. */
 		if (drag_info->selection_data != NULL) {
@@ -1615,6 +1631,12 @@ drag_data_received_callback (GtkWidget *
 			break;
 		case NAUTILUS_ICON_DND_URI_LIST:
 			receive_dropped_uri_list
+				(NAUTILUS_ICON_CONTAINER (widget),
+				 (char *) data->data, context->action, x, y);
+			success = TRUE;
+			break;
+		case NAUTILUS_ICON_DND_TEXT:
+			receive_dropped_text
 				(NAUTILUS_ICON_CONTAINER (widget),
 				 (char *) data->data, context->action, x, y);
 			success = TRUE;
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.6
diff -u -p -r1.6 nautilus-tree-view-drag-dest.c
--- libnautilus-private/nautilus-tree-view-drag-dest.c	13 Jan 2005 13:27:51 -0000	1.6
+++ libnautilus-private/nautilus-tree-view-drag-dest.c	2 Jun 2005 09:27:01 -0000
@@ -62,6 +62,7 @@ enum {
 	MOVE_COPY_ITEMS,
 	HANDLE_URL,
 	HANDLE_URI_LIST,
+	HANDLE_TEXT,
 	LAST_SIGNAL
 };
 
@@ -77,7 +78,8 @@ GNOME_CLASS_BOILERPLATE (NautilusTreeVie
 static 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 }
+	{ NAUTILUS_ICON_DND_URL_TYPE, 0, NAUTILUS_ICON_DND_URL },
+	{ NAUTILUS_ICON_DND_TEXT_TYPE, 0, NAUTILUS_ICON_DND_TEXT }
 	/* FIXME: Should handle emblems once the list view supports them */
 };
 
@@ -354,6 +356,17 @@ get_drop_action (NautilusTreeViewDragDes
 		
 	case NAUTILUS_ICON_DND_URI_LIST :
 		return context->suggested_action;
+
+	case NAUTILUS_ICON_DND_TEXT:
+		drop_target = get_drop_target (dest, path);
+
+		if (!drop_target) {
+			return 0;
+		}
+
+		g_free (drop_target);
+
+		return GDK_ACTION_COPY;
 	}
 
 	return 0;
@@ -526,6 +539,22 @@ receive_dropped_uri_list (NautilusTreeVi
 }
 
 static void
+receive_dropped_text (NautilusTreeViewDragDest *dest,
+		      GdkDragContext *context,
+		      int x, int y)
+{
+	if (!dest->details->drag_data) {
+		return;
+	}
+
+	g_signal_emit (dest, signals[HANDLE_TEXT], 0,
+		       (char*)dest->details->drag_data->data,
+		       context->action,
+		       x, y);
+}
+
+
+static void
 receive_dropped_url (NautilusTreeViewDragDest *dest,
 		     GdkDragContext *context,
 		     int x, int y)
@@ -581,6 +610,10 @@ drag_data_received_callback (GtkWidget *
 			receive_dropped_uri_list (dest, context, x, y);
 			success = TRUE;
 			break;
+		case NAUTILUS_ICON_DND_TEXT:
+			receive_dropped_text (dest, context, x, y);
+			success = TRUE;
+			break;
 		}
 
 		dest->details->drop_occurred = FALSE;
@@ -731,6 +764,19 @@ nautilus_tree_view_drag_dest_class_init 
 			      G_SIGNAL_RUN_LAST,
 			      G_STRUCT_OFFSET (NautilusTreeViewDragDestClass, 
 					       handle_uri_list),
+			      NULL, NULL,
+			      nautilus_marshal_VOID__STRING_INT_INT_INT,
+			      G_TYPE_NONE, 4,
+			      G_TYPE_STRING,
+			      G_TYPE_INT,
+			      G_TYPE_INT,
+			      G_TYPE_INT);
+	signals[HANDLE_TEXT] =
+		g_signal_new ("handle_text",
+			      G_TYPE_FROM_CLASS (class),
+			      G_SIGNAL_RUN_LAST,
+			      G_STRUCT_OFFSET (NautilusTreeViewDragDestClass, 
+					       handle_text),
 			      NULL, NULL,
 			      nautilus_marshal_VOID__STRING_INT_INT_INT,
 			      G_TYPE_NONE, 4,
Index: libnautilus-private/nautilus-tree-view-drag-dest.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-tree-view-drag-dest.h,v
retrieving revision 1.2
diff -u -p -r1.2 nautilus-tree-view-drag-dest.h
--- libnautilus-private/nautilus-tree-view-drag-dest.h	13 Jan 2005 13:27:51 -0000	1.2
+++ libnautilus-private/nautilus-tree-view-drag-dest.h	2 Jun 2005 09:27:01 -0000
@@ -72,6 +72,10 @@ struct _NautilusTreeViewDragDestClass {
 				  char *uri_list,
 				  int x,
 				  int y);
+	void (* handle_text)    (NautilusTreeViewDragDest *dest,
+				  char *uri_list,
+				  int x,
+				  int y);
 };
 
 GType                     nautilus_tree_view_drag_dest_get_type (void);
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.679
diff -u -p -r1.679 fm-directory-view.c
--- src/file-manager/fm-directory-view.c	27 May 2005 21:06:49 -0000	1.679
+++ src/file-manager/fm-directory-view.c	2 Jun 2005 09:27:03 -0000
@@ -3562,12 +3562,9 @@ fm_directory_view_new_folder (FMDirector
 	g_free (parent_uri);
 }
 
-void
-fm_directory_view_new_file (FMDirectoryView *directory_view,
-			    NautilusFile *source)
+static NewFolderData *
+setup_new_folder_data (FMDirectoryView *directory_view)
 {
-	char *parent_uri;
-	char *source_uri;
 	NewFolderData *data;
 
 	data = g_new (NewFolderData, 1);
@@ -3582,20 +3579,58 @@ fm_directory_view_new_file (FMDirectoryV
 			       (GClosureNotify)NULL,
 			       G_CONNECT_AFTER);
 
-	
-	source_uri = NULL;
-	if (source != NULL) {
-		source_uri = nautilus_file_get_uri (source);
-	}
+	return data;
+}
+
+static void
+fm_directory_view_new_file_with_initial_contents (FMDirectoryView *directory_view,
+						  const char *initial_contents)
+{
+	NewFolderData *data;
+	char *parent_uri;
+
+	data = setup_new_folder_data (directory_view);
+
 	parent_uri = fm_directory_view_get_backing_uri (directory_view);
 	nautilus_file_operations_new_file (GTK_WIDGET (directory_view),
 					   parent_uri,
-					   source_uri,
+					   initial_contents,
 					   new_folder_done, data);
 	g_free (parent_uri);
-	g_free (source_uri);
 }
 
+void
+fm_directory_view_new_file (FMDirectoryView *directory_view,
+			    NautilusFile *source)
+{
+	NewFolderData *data;
+	char *parent_uri;
+	char *source_uri;
+	char *source_file;
+
+	if (source == NULL) {
+		fm_directory_view_new_file_with_initial_contents (directory_view, NULL);
+		return;
+	}
+
+	g_return_if_fail (nautilus_file_is_local (source));
+
+	data = setup_new_folder_data (directory_view);
+
+	source_uri = nautilus_file_get_uri (source);
+	source_file = g_filename_from_uri (source_uri, NULL, NULL);
+
+	parent_uri = fm_directory_view_get_backing_uri (directory_view);
+	nautilus_file_operations_new_file_from_template (GTK_WIDGET (directory_view),
+							 parent_uri,
+							 NULL,
+							 source_file,
+							 GDK_ACTION_COPY,
+							 new_folder_done, data);
+	g_free (parent_uri);
+	g_free (source_uri);
+	g_free (source_file);
+}
 
 /* handle the open command */
 
@@ -8384,6 +8419,31 @@ fm_directory_view_handle_uri_list_drop (
 
 	g_free (container_uri);
 }
+
+void
+fm_directory_view_handle_text_drop (FMDirectoryView  *view,
+				    const char       *text,
+				    GdkDragAction     action,
+				    int               x,
+				    int               y)
+{
+	char *container_uri;
+
+	if (text == NULL) {
+		return;
+	}
+
+	g_return_if_fail (action == GDK_ACTION_COPY);
+
+	container_uri = fm_directory_view_get_backing_uri (view);
+	g_return_if_fail (container_uri != NULL);
+
+	fm_directory_view_new_file_with_initial_contents (
+		view, text);
+
+	g_free (container_uri);
+}
+
 
 static void
 real_sort_files (FMDirectoryView *view, GList **files)
Index: src/file-manager/fm-directory-view.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.h,v
retrieving revision 1.137
diff -u -p -r1.137 fm-directory-view.h
--- src/file-manager/fm-directory-view.h	17 May 2005 13:27:36 -0000	1.137
+++ src/file-manager/fm-directory-view.h	2 Jun 2005 09:27:03 -0000
@@ -386,6 +386,11 @@ void                fm_directory_view_ha
 									GdkDragAction     action,
 									int               x,
 									int               y);
+void                fm_directory_view_handle_text_drop                 (FMDirectoryView  *view,
+									const char       *text,
+									GdkDragAction     action,
+									int               x,
+									int               y);
 void                fm_directory_view_freeze_updates                   (FMDirectoryView  *view);
 void                fm_directory_view_unfreeze_updates                 (FMDirectoryView  *view);
 
Index: src/file-manager/fm-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.c,v
retrieving revision 1.306
diff -u -p -r1.306 fm-icon-view.c
--- src/file-manager/fm-icon-view.c	19 Apr 2005 12:01:17 -0000	1.306
+++ src/file-manager/fm-icon-view.c	2 Jun 2005 09:27:05 -0000
@@ -2475,6 +2475,14 @@ icon_view_handle_uri_list (NautilusIconC
 						item_uris, action, x, y);
 }
 
+static void
+icon_view_handle_text (NautilusIconContainer *container, const char *text,
+		       GdkDragAction action, int x, int y, FMIconView *view)
+{
+	fm_directory_view_handle_text_drop (FM_DIRECTORY_VIEW (view),
+					    text, action, x, y);
+}
+
 static char *
 icon_view_get_first_visible_file (NautilusView *view)
 {
@@ -2640,6 +2648,8 @@ fm_icon_view_init (FMIconView *icon_view
 				 G_CALLBACK (icon_view_handle_url), icon_view, 0);
 	g_signal_connect_object (get_icon_container (icon_view), "handle_uri_list",
 				 G_CALLBACK (icon_view_handle_uri_list), icon_view, 0);
+	g_signal_connect_object (get_icon_container (icon_view), "handle_text",
+				 G_CALLBACK (icon_view_handle_text), icon_view, 0);
 }
 
 static NautilusView *
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.242
diff -u -p -r1.242 fm-list-view.c
--- src/file-manager/fm-list-view.c	3 May 2005 01:00:50 -0000	1.242
+++ src/file-manager/fm-list-view.c	2 Jun 2005 09:27:05 -0000
@@ -936,6 +936,13 @@ list_view_handle_uri_list (NautilusTreeV
 						item_uris, action, x, y);
 }
 
+static void
+list_view_handle_text (NautilusTreeViewDragDest *dest, const char *text,
+		       GdkDragAction action, int x, int y, FMListView *view)
+{
+	fm_directory_view_handle_text_drop (FM_DIRECTORY_VIEW (view),
+					    text, action, x, y);
+}
 
 static void
 move_copy_items_callback (NautilusTreeViewDragDest *dest,
@@ -1052,6 +1059,8 @@ create_and_set_up_tree_view (FMListView 
 				 G_CALLBACK (list_view_handle_url), view, 0);
 	g_signal_connect_object (view->details->drag_dest, "handle_uri_list",
 				 G_CALLBACK (list_view_handle_uri_list), view, 0);
+	g_signal_connect_object (view->details->drag_dest, "handle_text",
+				 G_CALLBACK (list_view_handle_text), view, 0);
 
 	g_signal_connect_object (gtk_tree_view_get_selection (view->details->tree_view),
 				 "changed",


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