nautilus r13815 - in trunk: . libnautilus-private src/file-manager



Author: alexl
Date: Mon Feb 25 14:35:23 2008
New Revision: 13815
URL: http://svn.gnome.org/viewvc/nautilus?rev=13815&view=rev

Log:
2008-02-25  Alexander Larsson  <alexl redhat com>

        * libnautilus-private/nautilus-icon-container.[ch]:
        * src/file-manager/fm-directory-view.[ch]:
        * src/file-manager/fm-icon-view.c:
	Fixes the icon position when creating a new folder,
	and the view is zoomed.
	Patch from Christian Neumair



Modified:
   trunk/ChangeLog
   trunk/libnautilus-private/nautilus-icon-container.c
   trunk/libnautilus-private/nautilus-icon-container.h
   trunk/src/file-manager/fm-directory-view.c
   trunk/src/file-manager/fm-directory-view.h
   trunk/src/file-manager/fm-icon-view.c

Modified: trunk/libnautilus-private/nautilus-icon-container.c
==============================================================================
--- trunk/libnautilus-private/nautilus-icon-container.c	(original)
+++ trunk/libnautilus-private/nautilus-icon-container.c	Mon Feb 25 14:35:23 2008
@@ -7949,6 +7949,27 @@
 	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)
 {

Modified: trunk/libnautilus-private/nautilus-icon-container.h
==============================================================================
--- trunk/libnautilus-private/nautilus-icon-container.h	(original)
+++ trunk/libnautilus-private/nautilus-icon-container.h	Mon Feb 25 14:35:23 2008
@@ -304,6 +304,10 @@
 
 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) \

Modified: trunk/src/file-manager/fm-directory-view.c
==============================================================================
--- trunk/src/file-manager/fm-directory-view.c	(original)
+++ trunk/src/file-manager/fm-directory-view.c	Mon Feb 25 14:35:23 2008
@@ -3819,6 +3819,9 @@
 	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;

Modified: trunk/src/file-manager/fm-directory-view.h
==============================================================================
--- trunk/src/file-manager/fm-directory-view.h	(original)
+++ trunk/src/file-manager/fm-directory-view.h	Mon Feb 25 14:35:23 2008
@@ -297,6 +297,15 @@
 						 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.

Modified: trunk/src/file-manager/fm-icon-view.c
==============================================================================
--- trunk/src/file-manager/fm-icon-view.c	(original)
+++ trunk/src/file-manager/fm-icon-view.c	Mon Feb 25 14:35:23 2008
@@ -1683,6 +1683,16 @@
 }
 
 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 +2610,7 @@
         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;



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