[PATCH] Desktop icon placement



Hi all

I've been playing around with nautilus for a while, and noticed a little
glitch -- occasionally when a new file with a long title appears in the
desktop folder, the icon is placed correctly, but the icon label is
partially off the desktop window.  I wasn't sure if it was related to my
font settings or the fact that I'm using nautilus in an FVWM-based
environment, but I started scratching around in the source nonetheless.
After a day or two of hacking I had modified the placement algorithm in
libnautilus-private/nautilus-icon-container.c extensively, ending up
with (IMHO) a more elegant and simple placement method that gives good
results.

Basically, icon placement starts at DESKTOP_INIT_X / DESKTOP_INIT_Y, and
-- if snapping is enabled -- a grid intersection is anchored at this
point as well.  The grid snap size is specified with DESKTOP_SNAP_X /
DESKTOP_SNAP_Y.  Placement of icons is guided by the icon size (i.e.
the bounding rectangle of _both_ icon pixmap and icon label), and icons
can be placed as close to the desktop edge as possible without
overlapping.

It works well for me, but I'd appreciate an opinion or two re the
proposed modification.  And, obviously, it'd be very cool if this patch
is incorporated in nautilus eventually ;-)  Patch is against 2.16.0.




diff -Nurp nautilus-2.16.0/libnautilus-private/nautilus-icon-container.c nautilus-2.16.0-new/libnautilus-private/nautilus-icon-container.c
--- nautilus-2.16.0/libnautilus-private/nautilus-icon-container.c	2006-08-08 15:24:00.000000000 +0200
+++ nautilus-2.16.0-new/libnautilus-private/nautilus-icon-container.c	2006-09-26 22:07:27.000000000 +0200
@@ -103,14 +103,11 @@
 
 #define TEXT_BESIDE_ICON_GRID_WIDTH 205
 
-/* Desktop layout mode defines */
-#define DESKTOP_PAD_HORIZONTAL 	10
-#define DESKTOP_PAD_VERTICAL 	10
-#define SNAP_SIZE_X 		78
-#define SNAP_SIZE_Y 		20
-
-/* Value used to protect against icons being dragged outside of the desktop bounds */
-#define DESKTOP_ICON_SAFETY_PAD 10
+/* Desktop layout values */
+#define DESKTOP_INIT_X	50
+#define DESKTOP_INIT_Y	10
+#define DESKTOP_SNAP_X	40
+#define DESKTOP_SNAP_Y	20
 
 #define DEFAULT_SELECTION_BOX_ALPHA 0x40
 #define DEFAULT_HIGHLIGHT_ALPHA 0xff
@@ -129,14 +126,17 @@
 /* From nautilus-icon-canvas-item.c */
 #define MAX_TEXT_WIDTH_BESIDE 90
 
-#define SNAP_HORIZONTAL(func,x) ((func ((double)((x) - DESKTOP_PAD_HORIZONTAL) / SNAP_SIZE_X) * SNAP_SIZE_X) + DESKTOP_PAD_HORIZONTAL)
-#define SNAP_VERTICAL(func, y) ((func ((double)((y) - DESKTOP_PAD_VERTICAL) / SNAP_SIZE_Y) * SNAP_SIZE_Y) + DESKTOP_PAD_VERTICAL)
+#define SNAP_X(func,x) ((func ((double)((x) - DESKTOP_INIT_X) / DESKTOP_SNAP_X) * DESKTOP_SNAP_X) + DESKTOP_INIT_X)
+#define SNAP_Y(func, y) ((func ((double)((y) - DESKTOP_INIT_Y) / DESKTOP_SNAP_Y) * DESKTOP_SNAP_Y) + DESKTOP_INIT_Y)
+
+#define SNAP_X_NEAREST(x) SNAP_X (eel_round, x)
+#define SNAP_Y_NEAREST(y) SNAP_Y (eel_round, y)
 
-#define SNAP_NEAREST_HORIZONTAL(x) SNAP_HORIZONTAL (eel_round, x)
-#define SNAP_NEAREST_VERTICAL(y) SNAP_VERTICAL (eel_round, y)
+#define SNAP_X_CEIL(x) SNAP_X (ceil, x)
+#define SNAP_Y_CEIL(y) SNAP_Y (ceil, y)
 
-#define SNAP_CEIL_HORIZONTAL(x) SNAP_HORIZONTAL (ceil, x)
-#define SNAP_CEIL_VERTICAL(y) SNAP_VERTICAL (ceil, y)
+#define SNAP_X_FLOOR(x) SNAP_X (floor, x)
+#define SNAP_Y_FLOOR(y) SNAP_Y (floor, y)
 
 /* Copied from NautilusIconContainer */
 #define NAUTILUS_ICON_CONTAINER_SEARCH_DIALOG_TIMEOUT 5000
@@ -282,10 +282,6 @@ icon_set_position (NautilusIcon *icon,
 {	
 	NautilusIconContainer *container;
 	double pixels_per_unit;	
-	int left, top, right, bottom;
-	int width, height;
-	int x1, y1, x2, y2;
-	int container_x, container_y, container_width, container_height;
 
 	if (icon->x == x && icon->y == y) {
 		return;
@@ -298,47 +294,38 @@ icon_set_position (NautilusIcon *icon,
 	}
 
 	if (nautilus_icon_container_get_is_fixed_size (container)) {
-		/*  FIXME: This should be:
-		    
-		container_x = GTK_WIDGET (container)->allocation.x;
-		container_y = GTK_WIDGET (container)->allocation.y;
-		container_width = GTK_WIDGET (container)->allocation.width;
-		container_height = GTK_WIDGET (container)->allocation.height;
-
-		But for some reason the widget allocation is sometimes not done
-		at startup, and the allocation is then only 45x60. which is
-		really bad.
-
-		For now, we have a cheesy workaround:
-		*/
-		container_x = 0;
-		container_y = 0;
-		container_width = gdk_screen_width ();
-		container_height = gdk_screen_height ();
-		pixels_per_unit = EEL_CANVAS (container)->pixels_per_unit;
-		/* Clip the position of the icon within our desktop bounds */
-		left = container_x / pixels_per_unit;
-		top =  container_y / pixels_per_unit;
-		right = left + container_width / pixels_per_unit;
-		bottom = top + container_height / pixels_per_unit;
-
-		icon_get_bounding_box (icon, &x1, &y1, &x2, &y2);
-		width = x2 - x1;
-		height = y2 - y1;
-				
-		if (x > right - DESKTOP_ICON_SAFETY_PAD) {
-			x = right - DESKTOP_ICON_SAFETY_PAD;
+
+		/* Calculate desktop bounds */
+		ArtIRect desktop_rect;
+		desktop_rect.x0		= GTK_WIDGET (container)->allocation.x / EEL_CANVAS (container)->pixels_per_unit;
+		desktop_rect.y0		= GTK_WIDGET (container)->allocation.y / EEL_CANVAS (container)->pixels_per_unit;
+		desktop_rect.x1		= desktop_rect.x0 + GTK_WIDGET (container)->allocation.width / EEL_CANVAS (container)->pixels_per_unit;
+		desktop_rect.y1		= desktop_rect.y0 + GTK_WIDGET (container)->allocation.height / EEL_CANVAS (container)->pixels_per_unit;
+
+		/* Calculate icon bounds */
+		ArtIRect icon_rect;
+		icon_get_bounding_box (icon, &icon_rect.x0, &icon_rect.y0, &icon_rect.x1, &icon_rect.y1);
+
+		/* Adjust icon bounds relative to pixmap bounds */
+		ArtDRect pixmap_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
+		icon_rect.x0 -= pixmap_rect.x0;
+		icon_rect.x1 -= pixmap_rect.x0;
+		icon_rect.y0 -= pixmap_rect.y0;
+		icon_rect.y1 -= pixmap_rect.y0;
+
+		/* Clip icon to desktop */
+		if (x + icon_rect.x0 < desktop_rect.x0) {
+			x = SNAP_X_CEIL (desktop_rect.x0 - icon_rect.x0);
 		}
-		
-		if (x < left) {
-			x = left;
+		if (x + icon_rect.x1 > desktop_rect.x1) {
+			x = SNAP_X_FLOOR (desktop_rect.x1 - icon_rect.x1);
 		}
-		if (y > bottom - DESKTOP_ICON_SAFETY_PAD) {
-			y = bottom - DESKTOP_ICON_SAFETY_PAD;
+		if (y + icon_rect.y0 < desktop_rect.y0) {
+			y = SNAP_Y_CEIL (desktop_rect.y0 - icon_rect.y0);
+		}
+		if (y + icon_rect.y1 > desktop_rect.y1) {
+			y = SNAP_Y_FLOOR (desktop_rect.y1 - icon_rect.y1);
 		}
-		if (y < top) {
-			y = top;
-		}		
 	}
 
 	if (icon->x == ICON_UNPOSITIONED_VALUE) {
@@ -1134,35 +1121,10 @@ lay_down_icons_horizontal (NautilusIconC
 }
 
 static void
-snap_position (NautilusIconContainer *container,
-	       NautilusIcon *icon,
-	       int *x, int *y)
+desktop_snap_grid (int *x, int *y)
 {
-	int center_x;
-	int baseline_y;
-	int icon_width;
-	int icon_height;
-	ArtDRect icon_position;
-	
-	icon_position = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
-	icon_width = icon_position.x1 - icon_position.x0;
-	icon_height = icon_position.y1 - icon_position.y0;
-
-	if (*x + icon_width / 2 < DESKTOP_PAD_HORIZONTAL + SNAP_SIZE_X) {
-		*x = DESKTOP_PAD_HORIZONTAL + SNAP_SIZE_X - icon_width / 2;
-	}
-
-	if (*y + icon_height < DESKTOP_PAD_VERTICAL + SNAP_SIZE_Y) {
-		*y = DESKTOP_PAD_VERTICAL + SNAP_SIZE_Y - icon_height;
-	}
-
-	center_x = *x + icon_width / 2;
-	*x = SNAP_NEAREST_HORIZONTAL (center_x) - (icon_width / 2);
-
-	/* Find the grid position vertically and place on the proper baseline */
-	baseline_y = *y + icon_height;
-	baseline_y = SNAP_NEAREST_VERTICAL (baseline_y);
-	*y = baseline_y - icon_height;
+	*x = SNAP_X_NEAREST (*x);
+	*y = SNAP_Y_NEAREST (*y);
 }
 
 static int
@@ -1205,8 +1167,8 @@ placement_grid_new (NautilusIconContaine
 		  - container->details->bottom_margin) /
 		EEL_CANVAS (container)->pixels_per_unit;
 
-	num_columns = width / SNAP_SIZE_X;
-	num_rows = height / SNAP_SIZE_Y;
+	num_columns = width / DESKTOP_SNAP_X;
+	num_rows = height / DESKTOP_SNAP_Y;
 	
 	if (num_columns == 0 || num_rows == 0) {
 		return NULL;
@@ -1274,8 +1236,8 @@ placement_grid_mark (PlacementGrid *grid
 }
 
 static void
-canvas_position_to_grid_position (PlacementGrid *grid,
-				  ArtIRect canvas_position,
+desktop_position_to_grid_position (PlacementGrid *grid,
+				  ArtIRect desktop_position,
 				  ArtIRect *grid_position)
 {
 	/* The first causes minimal moving around during a snap, but
@@ -1283,15 +1245,15 @@ canvas_position_to_grid_position (Placem
 	 * allow any overlapping, but can cause more movement to happen 
 	 * during a snap. */
 	if (grid->tight) {
-		grid_position->x0 = ceil ((double)(canvas_position.x0 - DESKTOP_PAD_HORIZONTAL) / SNAP_SIZE_X);
-		grid_position->y0 = ceil ((double)(canvas_position.y0 - DESKTOP_PAD_VERTICAL) / SNAP_SIZE_Y);
-		grid_position->x1 = floor ((double)(canvas_position.x1 - DESKTOP_PAD_HORIZONTAL) / SNAP_SIZE_X);
-		grid_position->y1 = floor ((double)(canvas_position.y1 - DESKTOP_PAD_VERTICAL) / SNAP_SIZE_Y);
+		grid_position->x0 = ceil  ((double)(desktop_position.x0 - DESKTOP_INIT_X) / DESKTOP_SNAP_X);
+		grid_position->y0 = ceil  ((double)(desktop_position.y0 - DESKTOP_INIT_Y) / DESKTOP_SNAP_Y);
+		grid_position->x1 = floor ((double)(desktop_position.x1 - DESKTOP_INIT_X) / DESKTOP_SNAP_X);
+		grid_position->y1 = floor ((double)(desktop_position.y1 - DESKTOP_INIT_Y) / DESKTOP_SNAP_Y);
 	} else {
-		grid_position->x0 = floor ((double)(canvas_position.x0 - DESKTOP_PAD_HORIZONTAL) / SNAP_SIZE_X);
-		grid_position->y0 = floor ((double)(canvas_position.y0 - DESKTOP_PAD_VERTICAL) / SNAP_SIZE_Y);
-		grid_position->x1 = floor ((double)(canvas_position.x1 - DESKTOP_PAD_HORIZONTAL) / SNAP_SIZE_X);
-		grid_position->y1 = floor ((double)(canvas_position.y1 - DESKTOP_PAD_VERTICAL) / SNAP_SIZE_Y);
+		grid_position->x0 = floor ((double)(desktop_position.x0 - DESKTOP_INIT_X) / DESKTOP_SNAP_X);
+		grid_position->y0 = floor ((double)(desktop_position.y0 - DESKTOP_INIT_Y) / DESKTOP_SNAP_Y);
+		grid_position->x1 = floor ((double)(desktop_position.x1 - DESKTOP_INIT_X) / DESKTOP_SNAP_X);
+		grid_position->y1 = floor ((double)(desktop_position.y1 - DESKTOP_INIT_Y) / DESKTOP_SNAP_Y);
 	}
 
 	grid_position->x0 = CLAMP (grid_position->x0, 0, grid->num_columns - 1);
@@ -1309,85 +1271,75 @@ placement_grid_mark_icon (PlacementGrid 
 	icon_get_bounding_box (icon, 
 			       &icon_pos.x0, &icon_pos.y0,
 			       &icon_pos.x1, &icon_pos.y1);
-	canvas_position_to_grid_position (grid, 
+	desktop_position_to_grid_position (grid, 
 					  icon_pos,
 					  &grid_pos);
 	placement_grid_mark (grid, grid_pos);
 }
 
 static void
-find_empty_location (NautilusIconContainer *container,
-		     PlacementGrid *grid,
-		     NautilusIcon *icon,
-		     int start_x,
-		     int start_y,
-		     int *x, 
-		     int *y)
-{
-	double icon_width, icon_height;
-	int canvas_width;
-	int canvas_height;
-	ArtIRect icon_position;
-	ArtDRect pixbuf_rect;
-	gboolean collision;
-
-	/* Get container dimensions */
-	canvas_width  = (GTK_WIDGET (container)->allocation.width
-			 - container->details->left_margin
-			 - container->details->right_margin) /
-		EEL_CANVAS (container)->pixels_per_unit;
-	canvas_height = (GTK_WIDGET (container)->allocation.height
-			 - container->details->top_margin
-			 - container->details->bottom_margin) /
-		EEL_CANVAS (container)->pixels_per_unit;
-
-	icon_get_bounding_box (icon, 
-			       &icon_position.x0, &icon_position.y0, 
-			       &icon_position.x1, &icon_position.y1);
-	icon_width = icon_position.x1 - icon_position.x0;
-	icon_height = icon_position.y1 - icon_position.y0;
-	
-	pixbuf_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
-	
-	/* Start the icon on a grid location */
-	snap_position (container, icon, &start_x, &start_y);
-
-	icon_position.x0 = start_x;
-	icon_position.y0 = start_y;
-	icon_position.x1 = icon_position.x0 + icon_width;
-	icon_position.y1 = icon_position.y0 + icon_height;
-
-	do {
-		ArtIRect grid_position;
-
+desktop_find_empty_location (NautilusIconContainer *container,
+			     PlacementGrid *grid,
+			     NautilusIcon *icon,
+			     int x,
+			     int y,
+			     int *new_x, 
+			     int *new_y)
+{
+	/* Calculate desktop bounds */
+	ArtIRect desktop_rect;
+	desktop_rect.x0		= GTK_WIDGET (container)->allocation.x / EEL_CANVAS (container)->pixels_per_unit;
+	desktop_rect.y0		= GTK_WIDGET (container)->allocation.y / EEL_CANVAS (container)->pixels_per_unit;
+	desktop_rect.x1		= desktop_rect.x0 + GTK_WIDGET (container)->allocation.width / EEL_CANVAS (container)->pixels_per_unit;
+	desktop_rect.y1		= desktop_rect.y0 + GTK_WIDGET (container)->allocation.height / EEL_CANVAS (container)->pixels_per_unit;
+
+	/* Calculate icon bounds */
+	ArtIRect icon_rect;
+	icon_get_bounding_box (icon, &icon_rect.x0, &icon_rect.y0, &icon_rect.x1, &icon_rect.y1);
+
+	/* Adjust icon bounds relative to pixmap bounds */
+	ArtDRect pixmap_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
+	icon_rect.x0 -= pixmap_rect.x0;
+	icon_rect.x1 -= pixmap_rect.x0;
+	icon_rect.y0 -= pixmap_rect.y0;
+	icon_rect.y1 -= pixmap_rect.y0;
+
+	/* Snap the coordinates to a grid location */
+	desktop_snap_grid (&x, &y);
+
+	/* Create our new icon rectangle */
+	ArtIRect new_rect;
+	new_rect.x0 = x + icon_rect.x0;
+	new_rect.x1 = x + icon_rect.x1;
+	new_rect.y0 = y + icon_rect.y0;
+	new_rect.y1 = y + icon_rect.y1;
+
+	/* Try to find somewhere to place the icon */
+	gboolean collision = TRUE;
+	while (collision && (new_rect.x1 < desktop_rect.x1)) {
 		collision = FALSE;
-		
-		canvas_position_to_grid_position (grid,
-						  icon_position,
-						  &grid_position);
-
+		ArtIRect grid_position;
+		desktop_position_to_grid_position (grid, new_rect, &grid_position);
 		if (!placement_grid_position_is_free (grid, grid_position)) {
-			icon_position.y0 += SNAP_SIZE_Y;
-			icon_position.y1 = icon_position.y0 + icon_height;
-			
-			if (icon_position.y1 + DESKTOP_PAD_VERTICAL > canvas_height) {
-				/* Move to the next column */
-				icon_position.y0 = DESKTOP_PAD_VERTICAL + SNAP_SIZE_Y - (pixbuf_rect.y1 - pixbuf_rect.y0);
-				while (icon_position.y0 < DESKTOP_PAD_VERTICAL) {
-					icon_position.y0 += SNAP_SIZE_Y;
-				}
-				icon_position.y1 = icon_position.y0 + icon_height;
-				
-				icon_position.x0 += SNAP_SIZE_X;
-				icon_position.x1 = icon_position.x0 + icon_width;
-			}
-				
 			collision = TRUE;
+			new_rect.y0 += DESKTOP_SNAP_Y;
+			new_rect.y1 += DESKTOP_SNAP_Y;
+			if (new_rect.y1 > desktop_rect.y1) {
+				new_rect.y0 = desktop_rect.y0 + DESKTOP_INIT_Y + icon_rect.y0;
+				new_rect.y1 = desktop_rect.y0 + DESKTOP_INIT_Y + icon_rect.y1;
+				new_rect.x0 += DESKTOP_SNAP_X;
+				new_rect.x1 += DESKTOP_SNAP_X;
+			}
 		}
-	} while (collision && (icon_position.x1 < canvas_width));
+	}
 
-	*x = icon_position.x0;
-	*y = icon_position.y0;
+	if (!collision) {
+		*new_x = new_rect.x0 - icon_rect.x0;
+		*new_y = new_rect.y0 - icon_rect.y0;
+	} else {
+		*new_x = x;
+		*new_y = y;
+	}
 }
 
 static void
@@ -1416,8 +1368,7 @@ align_icons (NautilusIconContainer *cont
 		x = icon->x;
 		y = icon->y;
 
-		find_empty_location (container, grid, 
-				     icon, x, y, &x, &y);
+		desktop_find_empty_location (container, grid, icon, x, y, &x, &y);
 
 		icon_set_position (icon, x, y);
 
@@ -1487,14 +1438,10 @@ lay_down_icons_tblr (NautilusIconContain
 				icon_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
 				
 				/* Start the icon in the first column */
-				x = DESKTOP_PAD_HORIZONTAL + (SNAP_SIZE_X / 2) - ((icon_rect.x1 - icon_rect.x0) / 2);
-				y = DESKTOP_PAD_VERTICAL + SNAP_SIZE_Y - (icon_rect.y1 - icon_rect.y0);
+				x = DESKTOP_INIT_X;
+				y = DESKTOP_INIT_Y;
 
-				find_empty_location (container,
-						     grid,
-						     icon,
-						     x, y,
-						     &x, &y);
+				desktop_find_empty_location (container, grid, icon, x, y, &x, &y);
 				
 				icon_set_position (icon, x, y);
 				placement_grid_mark_icon (grid, icon);
@@ -1507,7 +1454,7 @@ lay_down_icons_tblr (NautilusIconContain
 		g_list_free (unplaced_icons);
 	} else {
 		/* There are no placed icons.  Just lay them down using our rules */		
-		x = DESKTOP_PAD_HORIZONTAL;
+		x = DESKTOP_INIT_X;
 
 		while (icons != NULL) {
 			int center_x;
@@ -1516,7 +1463,7 @@ lay_down_icons_tblr (NautilusIconContain
 			
 			should_snap = !(container->details->tighter_layout && !container->details->keep_aligned);
 			
-			y = DESKTOP_PAD_VERTICAL;
+			y = DESKTOP_INIT_Y;
 
 			max_width = 0;
 			
@@ -1532,12 +1479,12 @@ lay_down_icons_tblr (NautilusIconContain
 					/* Snap the baseline to a grid position */
 					icon_rect = nautilus_icon_canvas_item_get_icon_rectangle (icon->item);
 					baseline = y + (icon_rect.y1 - icon_rect.y0);
-					baseline = SNAP_CEIL_VERTICAL (baseline);
+					baseline = SNAP_Y_CEIL (baseline);
 					y = baseline - (icon_rect.y1 - icon_rect.y0);
 				}
 				    
 				/* Check and see if we need to move to a new column */
-				if (y != DESKTOP_PAD_VERTICAL && y > height - icon_height) {
+				if (y != DESKTOP_INIT_Y && y > height - icon_height) {
 					break;
 				}
 
@@ -1545,16 +1492,16 @@ lay_down_icons_tblr (NautilusIconContain
 					max_width = icon_width;
 				}
 				
-				y += icon_height + DESKTOP_PAD_VERTICAL;
+				y += icon_height + DESKTOP_INIT_Y;
 			}
 
-			y = DESKTOP_PAD_VERTICAL;
+			y = DESKTOP_INIT_Y;
 
 			center_x = x + max_width / 2;
 			column_width = max_width;
 			if (should_snap) {
 				/* Find the grid column to center on */
-				center_x = SNAP_CEIL_HORIZONTAL (center_x);
+				center_x = SNAP_X_CEIL (center_x);
 				column_width = (center_x - x) + (max_width / 2);
 			}
 			
@@ -1569,15 +1516,15 @@ lay_down_icons_tblr (NautilusIconContain
 
 				if (should_snap) {
 					baseline = y + (icon_rect.y1 - icon_rect.y0);
-					baseline = SNAP_CEIL_VERTICAL (baseline);
+					baseline = SNAP_Y_CEIL (baseline);
 					y = baseline - (icon_rect.y1 - icon_rect.y0);
 				}
 				
 				/* Check and see if we need to move to a new column */
-				if (y != DESKTOP_PAD_VERTICAL && y > height - icon_height &&
+				if (y != DESKTOP_INIT_Y && y > height - icon_height &&
 				    /* Make sure we lay out at least one icon per column, to make progress */
 				    p != icons) {
-					x += column_width + DESKTOP_PAD_HORIZONTAL;
+					x += column_width + DESKTOP_INIT_X;
 					break;
 				}
 				
@@ -1585,7 +1532,7 @@ lay_down_icons_tblr (NautilusIconContain
 						   center_x - (icon_rect.x1 - icon_rect.x0) / 2,
 						   y);
 				
-				y += icon_height + DESKTOP_PAD_VERTICAL;
+				y += icon_height + DESKTOP_INIT_Y;
 			}
 			icons = p;
 		}
@@ -1870,7 +1817,7 @@ nautilus_icon_container_move_icon (Nauti
 
 	if (!details->auto_layout) {
 		if (details->keep_aligned && snap) {
-			snap_position (container, icon, &x, &y);
+			desktop_snap_grid (&x, &y);
 		}
 
 		if (x != icon->x || y != icon->y) {
@@ -5743,9 +5690,7 @@ finish_adding_new_icons (NautilusIconCon
 			x = icon->x;
 			y = icon->y;
 
-			find_empty_location (container, grid, 
-					     icon, x, y, &x, &y);
-
+			desktop_find_empty_location (container, grid, icon, x, y, &x, &y);
 			icon_set_position (icon, x, y);
 
 			placement_grid_mark_icon (grid, icon);



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