[PATCH] Paste newly-created folder/file below cursors



The attached patch partially fixes bug 47944 [1] by checking whether a
file/folder creation was triggered from a popup menu and - if that is
true - places them below the popup menu. It still lacks move/copy
integration, but is IMHO in a good enough shape to be included.

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

-- 
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.195
diff -u -p -r1.195 nautilus-file-operations.c
--- libnautilus-private/nautilus-file-operations.c	8 Aug 2005 21:12:52 -0000	1.195
+++ libnautilus-private/nautilus-file-operations.c	21 Aug 2005 14:41:38 -0000
@@ -42,6 +42,7 @@
 #include <gdk/gdkdnd.h>
 #include <gtk/gtklabel.h>
 #include <gtk/gtkmessagedialog.h>
+#include <gtk/gtkwidget.h>
 #include <libgnomevfs/gnome-vfs-async-ops.h>
 #include <libgnomevfs/gnome-vfs-find-directory.h>
 #include <libgnomevfs/gnome-vfs-ops.h>
@@ -56,7 +57,11 @@
 #include "nautilus-link.h"
 #include "nautilus-trash-monitor.h"
 
-typedef enum {
+typedef enum   TransferKind         TransferKind;
+typedef struct TransferInfo         TransferInfo;
+typedef struct IconPositionIterator IconPositionIterator;
+
+enum TransferKind {
 	TRANSFER_MOVE,
 	TRANSFER_COPY,
 	TRANSFER_DUPLICATE,
@@ -64,10 +69,10 @@ typedef enum {
 	TRANSFER_EMPTY_TRASH,
 	TRANSFER_DELETE,
 	TRANSFER_LINK
-} TransferKind;
+};
 
 /* Copy engine callback state */
-typedef struct {
+struct TransferInfo {
 	GnomeVFSAsyncHandle *handle;
 	NautilusFileOperationsProgress *progress_dialog;
 	const char *operation_title;	/* "Copying files" */
@@ -83,7 +88,8 @@ typedef struct {
 	gpointer done_callback_data;
 	GHashTable *debuting_uris;
 	gboolean cancelled;	
-} TransferInfo;
+	IconPositionIterator *iterator;
+};
 
 static TransferInfo *
 transfer_info_new (GtkWidget *parent_view)
@@ -118,17 +124,20 @@ transfer_info_destroy (TransferInfo *tra
  * top level items during a copy, drag, new folder creation and
  * link creation
  */
-typedef struct {
+struct IconPositionIterator {
 	GdkPoint *icon_positions;
 	int last_icon_position_index;
 	GList *uris;
 	const GList *last_uri;
 	int screen;
-} IconPositionIterator;
+	gboolean is_source_iterator;
+};
 
 static IconPositionIterator *
-icon_position_iterator_new (GArray *icon_positions, const GList *uris,
-			    int screen)
+icon_position_iterator_new (GArray *icon_positions,
+			    const GList *uris,
+			    int screen,
+			    gboolean is_source_iterator)
 {
 	IconPositionIterator *result;
 	guint index;
@@ -146,10 +155,38 @@ icon_position_iterator_new (GArray *icon
 	result->uris = eel_g_str_list_copy ((GList *)uris);
 	result->last_uri = result->uris;
 	result->screen = screen;
+	result->is_source_iterator = is_source_iterator;
 
 	return result;
 }
 
+static IconPositionIterator *
+icon_position_iterator_new_single (GdkPoint *icon_position,
+				   const char *uri,
+				   int screen,
+				   gboolean is_source_iterator)
+{
+	IconPositionIterator *iterator;
+	GArray *icon_positions;
+	GList *uris;
+
+	if (icon_position == NULL || uri == NULL) {
+		return NULL;
+	}
+
+	icon_positions = g_array_sized_new (FALSE, FALSE, sizeof (GdkPoint), 1);
+	g_array_insert_val (icon_positions, 0, *icon_position);
+
+	uris = g_list_append (NULL, (char *) uri);
+
+	iterator = icon_position_iterator_new (icon_positions, uris, screen, is_source_iterator);
+
+	g_list_free (uris);
+	g_array_free (icon_positions, TRUE);
+
+	return iterator;
+}
+
 static void
 icon_position_iterator_free (IconPositionIterator *position_iterator)
 {
@@ -164,13 +201,22 @@ icon_position_iterator_free (IconPositio
 
 static gboolean
 icon_position_iterator_get_next (IconPositionIterator *position_iterator,
-				 const char *next_uri,
+				 const char *next_source_uri,
+				 const char *next_target_uri,
 				 GdkPoint *point)
 {
+	const char *next_uri;
+
 	if (position_iterator == NULL) {
 		return FALSE;
 	}
-		
+
+	if (position_iterator->is_source_iterator) {
+		next_uri = next_source_uri;
+	} else {
+		next_uri = next_target_uri;
+	}
+
 	for (;;) {
 		if (position_iterator->last_uri == NULL) {
 			/* we are done, no more points left */
@@ -204,6 +250,38 @@ icon_position_iterator_get_next (IconPos
 	return TRUE;
 }
 
+static void
+icon_position_iterator_update_uri (IconPositionIterator *position_iterator,
+				   const char *old_uri,
+				   const char *new_uri_fragment)
+{
+	GnomeVFSURI *uri, *parent_uri;
+	GList *l;
+
+	if (position_iterator == NULL) {
+		return;
+	}
+
+	l = g_list_find_custom (position_iterator->uris,
+			        old_uri,
+				(GCompareFunc) strcmp);
+	if (l == NULL) {
+		return;
+	}
+
+	uri = gnome_vfs_uri_new (old_uri);
+	parent_uri = gnome_vfs_uri_get_parent (uri);
+	gnome_vfs_uri_unref (uri);
+
+	uri = gnome_vfs_uri_append_string (parent_uri, new_uri_fragment);
+
+	g_free (l->data);
+	l->data = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
+
+	gnome_vfs_uri_unref (uri);
+	gnome_vfs_uri_unref (parent_uri);
+}
+
 static char *
 ellipsize_string_for_dialog (PangoContext *context, const char *str)
 {
@@ -1620,7 +1698,7 @@ apply_one_position (IconPositionIterator
 {
 	GdkPoint point;
 
-	if (icon_position_iterator_get_next (position_iterator, source_name, &point)) {
+	if (icon_position_iterator_get_next (position_iterator, source_name, target_name, &point)) {
 		nautilus_file_changes_queue_schedule_position_set (target_name, point, position_iterator->screen);
 	} else {
 		nautilus_file_changes_queue_schedule_position_remove (target_name);
@@ -1665,10 +1743,12 @@ sync_transfer_callback (GnomeVFSXferProg
 					nautilus_file_changes_queue_schedule_metadata_copy 
 						(progress_info->source_name, progress_info->target_name);
 
-					apply_one_position (position_iterator,
-							    progress_info->source_name,
-							    progress_info->target_name);
 				}
+
+				apply_one_position (position_iterator,
+						    progress_info->source_name,
+						    progress_info->target_name);
+
 				if (debuting_uris != NULL) {
 					g_hash_table_replace (debuting_uris,
 							      g_strdup (progress_info->target_name),
@@ -1696,12 +1776,12 @@ sync_transfer_callback (GnomeVFSXferProg
 				if (really_moved) {
 					nautilus_file_changes_queue_schedule_metadata_move 
 						(progress_info->source_name, progress_info->target_name);
-					
-					apply_one_position (position_iterator,
-							    progress_info->source_name,
-							    progress_info->target_name);
 				}
-				
+
+				apply_one_position (position_iterator,
+						    progress_info->source_name,
+						    progress_info->target_name);
+
 				if (debuting_uris != NULL) {
 					g_hash_table_replace (debuting_uris,
 							      g_strdup (progress_info->target_name),
@@ -1935,7 +2015,7 @@ nautilus_file_operations_copy_move (cons
 		 * here at all.
 		 */
 		icon_position_iterator = icon_position_iterator_new
-			(relative_item_points, item_uris, screen_num);
+			(relative_item_points, item_uris, screen_num, TRUE);
 	} else {
 		icon_position_iterator = NULL;
 	}
@@ -2098,6 +2178,8 @@ nautilus_file_operations_copy_move (cons
 	sync_transfer_info->iterator = icon_position_iterator;
 	sync_transfer_info->debuting_uris = transfer_info->debuting_uris;
 
+	transfer_info->iterator = sync_transfer_info->iterator;
+
 	if (result == GNOME_VFS_OK) {
 		gnome_vfs_async_xfer (&transfer_info->handle, source_uri_list, target_uri_list,
 		      		      move_options, GNOME_VFS_XFER_ERROR_MODE_QUERY, 
@@ -2120,6 +2202,7 @@ typedef struct {
 	NautilusNewFolderCallback done_callback;
 	gpointer data;
 	GtkWidget *parent_view;
+	IconPositionIterator *iterator;
 } NewFolderTransferState;
 
 static int
@@ -2199,6 +2282,12 @@ new_folder_transfer_callback (GnomeVFSAs
 					 progress_info->duplicate_count);
 			}
 			g_free (temp_string);
+
+			icon_position_iterator_update_uri
+				(state->iterator,
+				 progress_info->target_name,
+				 progress_info->duplicate_name);
+
 			return GNOME_VFS_XFER_ERROR_ACTION_SKIP;
 	
 		case GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR:
@@ -2216,20 +2305,16 @@ new_folder_transfer_callback (GnomeVFSAs
 
 void 
 nautilus_file_operations_new_folder (GtkWidget *parent_view, 
+				     GdkPoint *target_point,
 				     const char *parent_dir,
 				     NautilusNewFolderCallback done_callback,
 				     gpointer data)
 {
 	GList *target_uri_list;
 	GnomeVFSURI *uri, *parent_uri;
-	char *dirname;
+	char *text_uri, *dirname;
 	NewFolderTransferState *state;
-
-	state = g_new (NewFolderTransferState, 1);
-	state->done_callback = done_callback;
-	state->data = data;
-	state->parent_view = parent_view;
-	eel_add_weak_pointer (&state->parent_view);
+	SyncTransferInfo *sync_transfer_info;
 
 	/* pass in the target directory and the new folder name as a destination URI */
 	parent_uri = gnome_vfs_uri_new (parent_dir);
@@ -2239,14 +2324,32 @@ nautilus_file_operations_new_folder (Gtk
 	uri = gnome_vfs_uri_append_file_name (parent_uri, dirname);
 	g_free (dirname);
 	target_uri_list = g_list_prepend (NULL, uri);
-	
+
+	text_uri = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_NONE);
+
+	sync_transfer_info = g_new (SyncTransferInfo, 1);
+	sync_transfer_info->iterator = icon_position_iterator_new_single
+		(target_point, text_uri,
+		 gdk_screen_get_number (gtk_widget_get_screen (parent_view)),
+		 FALSE);
+	sync_transfer_info->debuting_uris = NULL;
+
+	g_free (text_uri);
+
+	state = g_new (NewFolderTransferState, 1);
+	state->done_callback = done_callback;
+	state->data = data;
+	state->parent_view = parent_view;
+	state->iterator = sync_transfer_info->iterator;
+	eel_add_weak_pointer (&state->parent_view);
+
 	gnome_vfs_async_xfer (&state->handle, NULL, target_uri_list,
 	      		      GNOME_VFS_XFER_NEW_UNIQUE_DIRECTORY,
 	      		      GNOME_VFS_XFER_ERROR_MODE_QUERY, 
 	      		      GNOME_VFS_XFER_OVERWRITE_MODE_QUERY,
 			      GNOME_VFS_PRIORITY_DEFAULT,
 	      		      new_folder_transfer_callback, state,
-	      		      sync_transfer_callback, NULL);
+	      		      sync_transfer_callback, sync_transfer_info);
 
 	gnome_vfs_uri_list_free (target_uri_list);
 	gnome_vfs_uri_unref (parent_uri);
@@ -2258,6 +2361,7 @@ typedef struct {
 	gpointer data;
 	GtkWidget *parent_view;
 	GHashTable *debuting_uris;
+	IconPositionIterator *iterator;
 } NewFileTransferState;
 
 
@@ -2366,6 +2470,7 @@ new_file_transfer_callback (GnomeVFSAsyn
 				g_strfreev (temp_strings);
 			}
 			g_free (temp_string);
+
 			return GNOME_VFS_XFER_ERROR_ACTION_SKIP;
 	
 		case GNOME_VFS_XFER_PROGRESS_STATUS_VFSERROR:
@@ -2383,6 +2488,7 @@ new_file_transfer_callback (GnomeVFSAsyn
 
 void 
 nautilus_file_operations_new_file_from_template (GtkWidget *parent_view, 
+						 GdkPoint *target_point,
 						 const char *parent_dir,
 						 const char *target_filename,
 						 const char *template_uri,
@@ -2401,18 +2507,12 @@ nautilus_file_operations_new_file_from_t
 	g_assert (parent_dir != NULL);
 	g_assert (template_uri != NULL);
 
-	state = g_new (NewFileTransferState, 1);
-	state->done_callback = done_callback;
-	state->data = data;
-	state->parent_view = parent_view;
-
 	/* pass in the target directory and the new folder name as a destination URI */
 	parent_uri = gnome_vfs_uri_new (parent_dir);
 
 	source_uri = gnome_vfs_uri_new (template_uri);
 	if (source_uri == NULL) {
 		(*done_callback) (NULL, data);
-		g_free (state);
 		return;
 	}
 
@@ -2424,16 +2524,24 @@ nautilus_file_operations_new_file_from_t
 		g_free (tmp);
 	}
 
-	state->debuting_uris = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+	sync_transfer_info = g_new (SyncTransferInfo, 1);
+	sync_transfer_info->iterator = icon_position_iterator_new_single
+		(target_point, template_uri,
+		 gdk_screen_get_number (gtk_widget_get_screen (parent_view)),
+		 TRUE);
+	sync_transfer_info->debuting_uris = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
+
+	state = g_new (NewFileTransferState, 1);
+	state->done_callback = done_callback;
+	state->data = data;
+	state->parent_view = parent_view;
+	state->iterator = sync_transfer_info->iterator;
+	state->debuting_uris = sync_transfer_info->debuting_uris;
 	eel_add_weak_pointer (&state->parent_view);
 
 	target_uri_list = g_list_prepend (NULL, target_uri);
 	source_uri_list = g_list_prepend (NULL, source_uri);
 
-	sync_transfer_info = g_new (SyncTransferInfo, 1);
-	sync_transfer_info->iterator = NULL;
-	sync_transfer_info->debuting_uris = state->debuting_uris;
-
 	options = GNOME_VFS_XFER_USE_UNIQUE_NAMES;
 	if (move_template) {
 		options |= GNOME_VFS_XFER_REMOVESOURCE;
@@ -2454,6 +2562,7 @@ nautilus_file_operations_new_file_from_t
 
 void 
 nautilus_file_operations_new_file (GtkWidget *parent_view, 
+				   GdkPoint *target_point,
 				   const char *parent_dir,
 				   const char *initial_contents,
 				   NautilusNewFileCallback done_callback,
@@ -2485,6 +2594,7 @@ nautilus_file_operations_new_file (GtkWi
 	source_file_uri = gnome_vfs_get_uri_from_local_path (source_file_str);
 
 	nautilus_file_operations_new_file_from_template (parent_view, 
+							 target_point,
 							 parent_dir,
 							 target_filename,
 							 source_file_uri,
Index: libnautilus-private/nautilus-file-operations.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-operations.h,v
retrieving revision 1.20
diff -u -p -r1.20 nautilus-file-operations.h
--- libnautilus-private/nautilus-file-operations.h	5 Jul 2005 12:23:34 -0000	1.20
+++ libnautilus-private/nautilus-file-operations.h	21 Aug 2005 14:41:38 -0000
@@ -41,7 +41,7 @@ typedef void (* NautilusNewFileCallback)
 /* FIXME: int copy_action should be an enum */
 
 void nautilus_file_operations_copy_move   (const GList               *item_uris,
-					   GArray                    *target_item_points,
+					   GArray                    *relative_item_points,
 					   const char                *target_dir_uri,
 					   GdkDragAction              copy_action,
 					   GtkWidget                 *parent_view,
@@ -49,15 +49,18 @@ void nautilus_file_operations_copy_move 
 					   gpointer                   done_callback_data);
 void nautilus_file_operations_empty_trash (GtkWidget                 *parent_view);
 void nautilus_file_operations_new_folder  (GtkWidget                 *parent_view,
+					   GdkPoint                  *target_point,
 					   const char                *parent_dir_uri,
 					   NautilusNewFolderCallback  done_callback,
 					   gpointer                   done_callback_data);
 void nautilus_file_operations_new_file    (GtkWidget                 *parent_view,
+					   GdkPoint                  *target_point,
 					   const char                *parent_dir,
 					   const char                *initial_contents,
 					   NautilusNewFileCallback    done_callback,
 					   gpointer                   data);
 void nautilus_file_operations_new_file_from_template (GtkWidget               *parent_view,
+					   	      GdkPoint                *target_point,
 						      const char              *parent_dir,
 						      const char              *target_filename,
 						      const char              *template_uri,
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.703
diff -u -p -r1.703 fm-directory-view.c
--- src/file-manager/fm-directory-view.c	1 Aug 2005 22:08:55 -0000	1.703
+++ src/file-manager/fm-directory-view.c	21 Aug 2005 14:10:15 -0000
@@ -253,6 +253,8 @@ struct FMDirectoryViewDetails
 	guint open_with_merge_id;
 
 	GList *subdirectory_list;
+
+	GdkPoint context_menu_position;
 };
 
 typedef enum {
@@ -3655,11 +3657,41 @@ new_folder_data_new (FMDirectoryView *di
 	return data;
 }
 
+static GdkPoint *
+context_menu_to_file_operation_position (FMDirectoryView *directory_view)
+{
+	g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (directory_view), NULL);
+
+	if (fm_directory_view_using_manual_layout (directory_view)
+	    && directory_view->details->context_menu_position.x >= 0
+	    && directory_view->details->context_menu_position.y >= 0) {
+		return &directory_view->details->context_menu_position;
+	} else {
+		return NULL;
+	}
+}
+
+static void
+update_context_menu_position_from_event (FMDirectoryView *view,
+					 GdkEventButton  *event)
+{
+	g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
+
+	if (event != NULL) {
+		view->details->context_menu_position.x = event->x;
+		view->details->context_menu_position.y = event->y;
+	} else {
+		view->details->context_menu_position.x = -1;
+		view->details->context_menu_position.y = -1;
+	}
+}
+
 void
 fm_directory_view_new_folder (FMDirectoryView *directory_view)
 {
 	char *parent_uri;
 	NewFolderData *data;
+	GdkPoint *pos;
 
 	data = new_folder_data_new (directory_view);
 
@@ -3670,9 +3702,11 @@ fm_directory_view_new_folder (FMDirector
 			       (GClosureNotify)NULL,
 			       G_CONNECT_AFTER);
 
+	pos = context_menu_to_file_operation_position (directory_view);
+
 	parent_uri = fm_directory_view_get_backing_uri (directory_view);
 	nautilus_file_operations_new_folder (GTK_WIDGET (directory_view),
-					     parent_uri,
+					     pos, parent_uri,
 					     new_folder_done, data);
 
 	g_free (parent_uri);
@@ -3699,15 +3733,17 @@ static void
 fm_directory_view_new_file_with_initial_contents (FMDirectoryView *directory_view,
 						  const char *initial_contents)
 {
+	GdkPoint *pos;
 	NewFolderData *data;
 	char *parent_uri;
 
 	data = setup_new_folder_data (directory_view);
 
-	parent_uri = fm_directory_view_get_backing_uri (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),
-					   parent_uri,
+					   pos, parent_uri,
 					   initial_contents,
 					   new_folder_done, data);
 
@@ -3718,6 +3754,7 @@ void
 fm_directory_view_new_file (FMDirectoryView *directory_view,
 			    NautilusFile *source)
 {
+	GdkPoint *pos;
 	NewFolderData *data;
 	char *parent_uri;
 	char *source_uri;
@@ -3729,12 +3766,15 @@ fm_directory_view_new_file (FMDirectoryV
 
 	g_return_if_fail (nautilus_file_is_local (source));
 
+	pos = context_menu_to_file_operation_position (directory_view);
+
 	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,
 							 NULL,
 							 source_uri,
@@ -6278,6 +6318,44 @@ connect_proxy (FMDirectoryView *view,
 }
 
 static void
+pre_activate (FMDirectoryView *view,
+	      GtkAction *action,
+	      GtkActionGroup *action_group)
+{
+	GdkEvent *event;
+	GtkWidget *proxy, *shell;
+	gboolean unset_pos;
+
+	/* check whether action was activated through a popup menu.
+	 * If not, unset the last stored context menu popup position */
+	unset_pos = TRUE;
+
+	event = gtk_get_current_event ();
+	proxy = gtk_get_event_widget (event);
+
+	if (proxy != NULL && GTK_IS_MENU_ITEM (proxy)) {
+		shell = proxy->parent;
+
+		unset_pos = FALSE;
+
+		do {
+			if (!GTK_IS_MENU (shell)) {
+				/* popup menus are GtkMenu-only menu shell hierarchies */
+				unset_pos = TRUE;
+				break;
+			}
+
+			shell = GTK_MENU_SHELL (shell)->parent_menu_shell;
+		} while (GTK_IS_MENU_SHELL (shell)
+			 && GTK_MENU_SHELL (shell)->parent_menu_shell != NULL);
+	}
+
+	if (unset_pos) {
+		update_context_menu_position_from_event (view, NULL);
+	}
+}
+
+static void
 real_merge_menus (FMDirectoryView *view)
 {
 	GtkActionGroup *action_group;
@@ -6311,6 +6389,9 @@ real_merge_menus (FMDirectoryView *view)
 	g_signal_connect_object (action_group, "connect-proxy",
 				 G_CALLBACK (connect_proxy), G_OBJECT (view),
 				 G_CONNECT_SWAPPED);
+	g_signal_connect_object (action_group, "pre-activate",
+				 G_CALLBACK (pre_activate), G_OBJECT (view),
+				 G_CONNECT_SWAPPED);
 
 	/* Insert action group at end so clipboard action group ends up before it */
 	gtk_ui_manager_insert_action_group (ui_manager, action_group, -1);
@@ -6881,6 +6962,8 @@ fm_directory_view_pop_up_selection_conte
 	 */
 	update_menus_if_pending (view);
 
+	update_context_menu_position_from_event (view, event);
+
 	eel_pop_up_context_menu (create_popup_menu 
 				      	(view, FM_DIRECTORY_VIEW_POPUP_PATH_SELECTION),
 				      EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
@@ -6908,6 +6991,8 @@ fm_directory_view_pop_up_background_cont
 	 */
 	update_menus_if_pending (view);
 
+	update_context_menu_position_from_event (view, event);
+
 	eel_pop_up_context_menu (create_popup_menu 
 				      (view, FM_DIRECTORY_VIEW_POPUP_PATH_BACKGROUND),
 				      EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
@@ -6932,6 +7017,8 @@ fm_directory_view_pop_up_location_contex
 	/* always update the menu before showing it. Shouldn't be too expensive. */
 	real_update_location_menu (view);
 
+	update_context_menu_position_from_event (view, event);
+
 	eel_pop_up_context_menu (create_popup_menu 
 				      (view, FM_DIRECTORY_VIEW_POPUP_PATH_LOCATION),
 				      EEL_DEFAULT_POPUP_MENU_DISPLACEMENT,
@@ -8035,6 +8122,24 @@ real_supports_zooming (FMDirectoryView *
 	return TRUE;
 }
 
+gboolean
+fm_directory_view_using_manual_layout (FMDirectoryView  *view)
+{
+	g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE);
+
+	return EEL_CALL_METHOD_WITH_RETURN_VALUE
+		(FM_DIRECTORY_VIEW_CLASS, view,
+		 using_manual_layout, (view));
+}
+
+static gboolean
+real_using_manual_layout (FMDirectoryView *view)
+{
+	g_return_val_if_fail (FM_IS_DIRECTORY_VIEW (view), FALSE);
+
+	return FALSE;
+}
+
 /**
  * fm_directory_view_update_menus:
  * 
@@ -8794,6 +8899,7 @@ fm_directory_view_class_init (FMDirector
 	klass->supports_creating_files = real_supports_creating_files;
 	klass->supports_properties = real_supports_properties;
 	klass->supports_zooming = real_supports_zooming;
+	klass->using_manual_layout = real_using_manual_layout;
         klass->merge_menus = real_merge_menus;
         klass->update_menus = real_update_menus;
 
Index: src/file-manager/fm-directory-view.h
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.h,v
retrieving revision 1.141
diff -u -p -r1.141 fm-directory-view.h
--- src/file-manager/fm-directory-view.h	5 Jul 2005 12:23:35 -0000	1.141
+++ src/file-manager/fm-directory-view.h	21 Aug 2005 14:10:15 -0000
@@ -246,6 +246,13 @@ struct FMDirectoryViewClass {
 	 */
 	gboolean (* supports_zooming)		(FMDirectoryView *view);
 
+	/* using_manual_layout is a function pointer that subclasses may
+	 * override to control whether or not items can be freely positioned
+	 * on the user-visible area.
+	 * Note that this value is not guaranteed to be constant within the
+	 * view's lifecycle. */
+	gboolean (* using_manual_layout)     (FMDirectoryView *view);
+
 	/* is_read_only is a function pointer that subclasses may
 	 * override to control whether or not the user is allowed to
 	 * change the contents of the currently viewed directory. The
@@ -338,6 +345,7 @@ gboolean            fm_directory_view_su
 gboolean            fm_directory_view_accepts_dragged_files            (FMDirectoryView  *view);
 gboolean            fm_directory_view_supports_properties              (FMDirectoryView  *view);
 gboolean            fm_directory_view_supports_zooming                 (FMDirectoryView  *view);
+gboolean            fm_directory_view_using_manual_layout              (FMDirectoryView  *view);
 void                fm_directory_view_move_copy_items                  (const GList      *item_uris,
 									GArray           *relative_item_points,
 									const char       *target_uri,
Index: src/file-manager/fm-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.c,v
retrieving revision 1.313
diff -u -p -r1.313 fm-icon-view.c
--- src/file-manager/fm-icon-view.c	12 Aug 2005 18:11:30 -0000	1.313
+++ src/file-manager/fm-icon-view.c	21 Aug 2005 14:10:16 -0000
@@ -1641,6 +1641,14 @@ fm_icon_view_set_selection (FMDirectoryV
 		(get_icon_container (FM_ICON_VIEW (view)), selection);
 }
 
+static gboolean
+fm_icon_view_using_manual_layout (FMDirectoryView *view)
+{
+	g_return_val_if_fail (FM_IS_ICON_VIEW (view), FALSE);
+
+	return !fm_icon_view_using_auto_layout (FM_ICON_VIEW (view));
+}
+
 static void
 icon_container_activate_callback (NautilusIconContainer *container,
 				  GList *file_list,
@@ -2604,6 +2612,7 @@ fm_icon_view_class_init (FMIconViewClass
         fm_directory_view_class->start_renaming_file = fm_icon_view_start_renaming_file;
         fm_directory_view_class->text_attribute_names_changed = fm_icon_view_text_attribute_names_changed;
         fm_directory_view_class->update_menus = fm_icon_view_update_menus;
+	fm_directory_view_class->using_manual_layout = fm_icon_view_using_manual_layout;
 
 	klass->clean_up = fm_icon_view_real_clean_up;
 	klass->supports_auto_layout = real_supports_auto_layout;
Index: src/file-manager/fm-list-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-list-view.c,v
retrieving revision 1.256
diff -u -p -r1.256 fm-list-view.c
--- src/file-manager/fm-list-view.c	12 Aug 2005 18:11:30 -0000	1.256
+++ src/file-manager/fm-list-view.c	21 Aug 2005 14:10:18 -0000
@@ -2449,6 +2449,14 @@ fm_list_view_sort_files (FMDirectoryView
 	fm_list_model_sort_files (list_view->details->model, files);
 }
 
+static gboolean
+fm_list_view_using_manual_layout (FMDirectoryView *view)
+{
+	g_return_val_if_fail (FM_IS_LIST_VIEW (view), FALSE);
+
+	return FALSE;
+}
+
 static void
 fm_list_view_dispose (GObject *object)
 {
@@ -2629,6 +2637,7 @@ fm_list_view_class_init (FMListViewClass
 	fm_directory_view_class->zoom_to_level = fm_list_view_zoom_to_level;
         fm_directory_view_class->emblems_changed = fm_list_view_emblems_changed;
 	fm_directory_view_class->end_file_changes = fm_list_view_end_file_changes;
+	fm_directory_view_class->using_manual_layout = fm_list_view_using_manual_layout;
 
 	eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_CLICK_POLICY,
 				       &click_policy_auto_value);
Index: src/file-manager/fm-tree-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-tree-view.c,v
retrieving revision 1.17
diff -u -p -r1.17 fm-tree-view.c
--- src/file-manager/fm-tree-view.c	11 Jul 2005 10:12:47 -0000	1.17
+++ src/file-manager/fm-tree-view.c	21 Aug 2005 14:10:18 -0000
@@ -832,6 +832,7 @@ fm_tree_view_create_folder_cb (GtkWidget
 
 	parent_uri = nautilus_file_get_uri (view->details->popup_file);
 	nautilus_file_operations_new_folder (GTK_WIDGET (view->details->tree_widget),
+					     NULL,
 					     parent_uri,
 					     new_folder_done, view->details->tree_widget);
 

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]