[PATCH] Use correct icon position when creating new folder



The attached patch fixes the icon position when creating a new folder,
which used to have an offset depending on the zoom level.

It looks like the gio merge broke the file creation from templates.

best regards,
 Christian Neumair

-- 
Christian Neumair <cneumair gnome org>

Index: src/file-manager/fm-icon-view.c
===================================================================
--- src/file-manager/fm-icon-view.c	(Revision 13797)
+++ src/file-manager/fm-icon-view.c	(Arbeitskopie)
@@ -1683,6 +1687,16 @@ fm_icon_view_using_manual_layout (FMDire
 }
 
 static void
+fm_icon_view_widget_to_file_operation_position (FMDirectoryView *view,
+						GdkPoint *position)
+{
+	g_assert (FM_IS_ICON_VIEW (view));
+
+	nautilus_icon_container_widget_to_file_operation_position
+		(get_icon_container (FM_ICON_VIEW (view)), position);
+}
+
+static void
 icon_container_activate_callback (NautilusIconContainer *container,
 				  GList *file_list,
 				  FMIconView *icon_view)
@@ -2600,6 +2614,7 @@ fm_icon_view_class_init (FMIconViewClass
         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;
+	fm_directory_view_class->widget_to_file_operation_position = fm_icon_view_widget_to_file_operation_position;
 
 	klass->clean_up = fm_icon_view_real_clean_up;
 	klass->supports_auto_layout = real_supports_auto_layout;
Index: src/file-manager/fm-directory-view.c
===================================================================
--- src/file-manager/fm-directory-view.c	(Revision 13797)
+++ src/file-manager/fm-directory-view.c	(Arbeitskopie)
@@ -3819,6 +3819,9 @@ context_menu_to_file_operation_position 
 	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) {
+		EEL_CALL_METHOD (FM_DIRECTORY_VIEW_CLASS, directory_view,
+				 widget_to_file_operation_position,
+				 (directory_view, &directory_view->details->context_menu_position));
 		return &directory_view->details->context_menu_position;
 	} else {
 		return NULL;
Index: src/file-manager/fm-directory-view.h
===================================================================
--- src/file-manager/fm-directory-view.h	(Revision 13797)
+++ src/file-manager/fm-directory-view.h	(Arbeitskopie)
@@ -297,6 +297,15 @@ struct FMDirectoryViewClass {
 						 NautilusFile	 *file,
 						 NautilusDirectory *directory);
 
+	/* convert *point from widget's coordinate system to a coordinate
+	 * system used for specifying file operation positions, which is view-specific.
+	 *
+	 * This is used by the the icon view, which converts the screen position to a zoom
+	 * level-independent coordinate system.
+	 */
+	void (* widget_to_file_operation_position) (FMDirectoryView *view,
+						    GdkPoint        *position);
+
 	/* Preference change callbacks, overriden by icon and list views. 
 	 * Icon and list views respond by synchronizing to the new preference
 	 * values and forcing an update if appropriate.
Index: libnautilus-private/nautilus-icon-container.c
===================================================================
--- libnautilus-private/nautilus-icon-container.c	(Revision 13797)
+++ libnautilus-private/nautilus-icon-container.c	(Arbeitskopie)
@@ -7928,6 +7928,27 @@ nautilus_icon_container_accessible_selec
 	return TRUE;
 }
 
+void
+nautilus_icon_container_widget_to_file_operation_position (NautilusIconContainer *container,
+							   GdkPoint              *position)
+{
+	double x, y;
+
+	g_return_if_fail (position != NULL);
+
+	x = position->x;
+	y = position->y;
+
+	eel_canvas_window_to_world (EEL_CANVAS (container), x, y, &x, &y);
+
+	position->x = (int) x;
+	position->y = (int) y;
+
+	/* ensure that we end up in the middle of the icon */
+	position->x -= nautilus_get_icon_size_for_zoom_level (container->details->zoom_level) / 2;
+	position->y -= nautilus_get_icon_size_for_zoom_level (container->details->zoom_level) / 2;
+}
+
 static void 
 nautilus_icon_container_accessible_selection_interface_init (AtkSelectionIface *iface)
 {
Index: libnautilus-private/nautilus-icon-container.h
===================================================================
--- libnautilus-private/nautilus-icon-container.h	(Revision 13797)
+++ libnautilus-private/nautilus-icon-container.h	(Arbeitskopie)
@@ -304,6 +304,10 @@ void              nautilus_icon_containe
 
 gboolean	  nautilus_icon_container_is_layout_rtl			(NautilusIconContainer  *container);
 
+void              nautilus_icon_container_widget_to_file_operation_position (NautilusIconContainer *container,
+									     GdkPoint              *position);
+
+
 #define CANVAS_WIDTH(container) ((GTK_WIDGET (container)->allocation.width \
 				- container->details->left_margin \
 				- container->details->right_margin) \


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