diff -rub --exclude 'Makefile.*' nautilus-2.2.3.1-original/libnautilus-private/apps_nautilus_preferences.schemas nautilus-2.2.3.1/libnautilus-private/apps_nautilus_preferences.schemas
--- nautilus-2.2.3.1-original/libnautilus-private/apps_nautilus_preferences.schemas	Mon Mar 17 16:52:27 2003
+++ nautilus-2.2.3.1/libnautilus-private/apps_nautilus_preferences.schemas	Tue Apr  8 16:15:05 2003
@@ -507,6 +507,20 @@
     </schema>
 
     <schema>
+      <key>/schemas/apps/nautilus/icon_view/desktop_auto_layout</key>
+      <applyto>/apps/nautilus/icon_view/desktop_auto_layout</applyto>
+      <owner>nautilus</owner>
+      <type>bool</type>
+      <default>true</default>
+      <locale name="C">
+         <short>Automatically lay out icons on the desktop by their position</short>
+         <long>
+           If true, icons on the desktop will be layed out by their position automatically.
+         </long>
+      </locale>
+    </schema>
+
+    <schema>
       <key>/schemas/apps/nautilus/icon_view/default_zoom_level</key>
       <applyto>/apps/nautilus/icon_view/default_zoom_level</applyto>
       <owner>nautilus</owner>
diff -rub --exclude 'Makefile.*' nautilus-2.2.3.1-original/libnautilus-private/nautilus-global-preferences.c nautilus-2.2.3.1/libnautilus-private/nautilus-global-preferences.c
--- nautilus-2.2.3.1-original/libnautilus-private/nautilus-global-preferences.c	Fri Mar 14 18:48:44 2003
+++ nautilus-2.2.3.1/libnautilus-private/nautilus-global-preferences.c	Tue Apr  8 16:13:19 2003
@@ -462,6 +462,10 @@
 	  PREFERENCE_BOOLEAN,
 	  GINT_TO_POINTER (FALSE)
 	},
+	{ NAUTILUS_PREFERENCES_ICON_VIEW_DESKTOP_AUTO_LAYOUT,
+	  PREFERENCE_BOOLEAN,
+	  GINT_TO_POINTER (TRUE)
+	},
 	{ NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT,
 	  PREFERENCE_BOOLEAN,
 	  GINT_TO_POINTER (FALSE)
diff -rub --exclude 'Makefile.*' nautilus-2.2.3.1-original/libnautilus-private/nautilus-global-preferences.h nautilus-2.2.3.1/libnautilus-private/nautilus-global-preferences.h
--- nautilus-2.2.3.1-original/libnautilus-private/nautilus-global-preferences.h	Sun Mar  2 03:34:52 2003
+++ nautilus-2.2.3.1/libnautilus-private/nautilus-global-preferences.h	Tue Apr  8 16:12:34 2003
@@ -107,6 +107,7 @@
 #define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_TIGHTER_LAYOUT	"icon_view/default_use_tighter_layout"
 #define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL		"icon_view/default_zoom_level"
 #define NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_USE_MANUAL_LAYOUT	"icon_view/default_use_manual_layout"
+#define NAUTILUS_PREFERENCES_ICON_VIEW_DESKTOP_AUTO_LAYOUT		"icon_view/desktop_auto_layout"
 
 /* The icon view uses 2 variables to store the sort order and
  * whether to use manual layout.  However, the UI for these
diff -rub --exclude 'Makefile.*' nautilus-2.2.3.1-original/libnautilus-private/nautilus-icon-container.c nautilus-2.2.3.1/libnautilus-private/nautilus-icon-container.c
--- nautilus-2.2.3.1-original/libnautilus-private/nautilus-icon-container.c	Fri Mar 28 13:31:36 2003
+++ nautilus-2.2.3.1/libnautilus-private/nautilus-icon-container.c	Wed Apr 16 14:18:52 2003
@@ -313,6 +313,84 @@
 }
 
 static void
+icon_set_position2 (NautilusIcon *icon,
+		   double x, double y)
+{	
+	NautilusIconContainer *container;
+	double pixels_per_unit;	
+	int left, top, right, bottom;
+	int x1, y1, x2, y2;
+	int container_x, container_y, container_width, container_height;
+
+	if (icon->x == x && icon->y == y) {
+		return;
+	}
+
+	container = NAUTILUS_ICON_CONTAINER (EEL_CANVAS_ITEM (icon->item)->canvas);
+
+	if (icon == get_icon_being_renamed (container)) {
+		end_renaming_mode (container, TRUE);
+	}
+
+	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;
+
+		if (x > right - DESKTOP_ICON_SAFETY_PAD) {
+			x = right - DESKTOP_ICON_SAFETY_PAD;
+		}
+
+		if (x < left) {
+			x = left;
+		}
+		if (y > bottom - DESKTOP_ICON_SAFETY_PAD) {
+			y = bottom - DESKTOP_ICON_SAFETY_PAD;
+		}
+		if (y < top) {
+			y = top;
+		}
+	}
+
+	eel_canvas_item_move (EEL_CANVAS_ITEM (icon->item),
+				x - icon->x,
+				y - icon->y);
+	icon->x = x;
+	icon->y = y;
+
+	icon_get_bounding_box (icon, &x1, &y1, &x2, &y2);
+	x -= x1 - x;
+	y -= y1 - y;
+
+	eel_canvas_item_move (EEL_CANVAS_ITEM (icon->item),
+				x - icon->x,
+				y - icon->y);
+	icon->x = x;
+	icon->y = y;
+}
+
+static void
 icon_get_size (NautilusIconContainer *container,
 	       NautilusIcon *icon,
 	       guint *size)
@@ -1182,6 +1260,16 @@
 		placed_icons = g_list_reverse (placed_icons);
 		unplaced_icons = g_list_reverse (unplaced_icons);
 					
+      /* Get container dimensions */
+      width  = GTK_WIDGET (container)->allocation.width /
+         EEL_CANVAS (container)->pixels_per_unit
+         - container->details->left_margin
+         - container->details->right_margin;
+      height = GTK_WIDGET (container)->allocation.height /
+         EEL_CANVAS (container)->pixels_per_unit
+         - container->details->top_margin
+         - container->details->bottom_margin;
+					
 		/* Allocate grid array */
 		num_rows = width / CELL_SIZE;
 		num_columns = height / CELL_SIZE;
@@ -1296,7 +1384,6 @@
 	nautilus_icon_container_freeze_icon_positions (container);
 }
 
-
 static void
 lay_down_icons (NautilusIconContainer *container, GList *icons, double start_y)
 {
@@ -5297,6 +5384,11 @@
 {
 	gboolean changed;
 
+	if (container->details->sorting) {
+		return;
+	}
+
+	container->details->sorting = TRUE;
 	changed = !container->details->auto_layout;
 	container->details->auto_layout = TRUE;
 
@@ -5306,6 +5398,138 @@
 	if (changed) {
 		g_signal_emit (container, signals[LAYOUT_CHANGED], 0);
 	}
+	container->details->sorting = FALSE;
+}
+
+static gint
+compare_for_snap_to_grid (gconstpointer a, gconstpointer b)
+{
+	const NautilusIcon *icon1, *icon2;
+
+	icon1 = a;
+	icon2 = b;
+	if (icon1->x > (icon2->x + CELL_SIZE)) {
+		return 1;
+	}
+	if (icon1->x < (icon2->x - (CELL_SIZE / 2))) {
+		return -1;
+	}
+	if (icon1->y > icon2->y) {
+		return 1;
+	}
+	return -1;
+}
+
+static void
+basic_lay_down_icons (NautilusIconContainer *container, GList *icons)
+{
+	int container_width, container_height;
+	GList *p;
+	int icon_width, icon_height, x1, x2, y1, y2;
+	int grid_width, grid_height;
+	NautilusIcon *icon;
+
+	container_width = GTK_WIDGET (container)->allocation.width /
+		EEL_CANVAS (container)->pixels_per_unit - container->details->left_margin
+		- container->details->right_margin;
+	container_height = GTK_WIDGET (container)->allocation.height /
+		EEL_CANVAS (container)->pixels_per_unit - container->details->top_margin
+		- container->details->bottom_margin;
+
+	grid_width = 0;
+	grid_height = 0;
+
+	/* Find the biggest icon; that will determine the grid size */
+	for (p = icons; p != NULL; p = p->next) {
+		icon = p->data;
+		icon_get_bounding_box (icon, &x1, &y1, &x2, &y2);
+
+		icon_width = x2 - x1;
+		icon_height = y2 - y1;
+
+		/* Check for increase in column width & height */
+		if (grid_width < icon_width) {
+			grid_width = icon_width;
+		}
+		if (grid_height < icon_height) {
+			grid_height = icon_height;
+		}
+	}
+	grid_width += DESKTOP_PAD_HORIZONTAL / 3;
+	grid_height += DESKTOP_PAD_VERTICAL / 2;
+
+
+	for (p = icons; p != NULL; p = p->next) {
+		int icon_x, icon_y, x_middle, y_middle, hn, vn;
+
+		icon = p->data;
+		icon_get_bounding_box (icon, &x1, &y1, &x2, &y2);
+		x_middle = x1 + (x2 - x1) / 2;
+		y_middle = y1 + (y2 - y1) / 2;
+		hn = x_middle / grid_width;
+		vn = y_middle / grid_height;
+
+		icon_x = (DESKTOP_PAD_HORIZONTAL / 3) + hn * grid_width + grid_width / 2 - (x2 - x1) / 2;
+		icon_y = DESKTOP_PAD_VERTICAL + vn * grid_height + grid_height / 2 - (y2 - y1) / 2;
+		icon_set_position2 (icon, icon_x, icon_y);
+	}
+}
+
+/* try and arrange icons so that they stay in the sam order but are put in
+ * a top/down left/right grid
+ * */
+void
+nautilus_icon_container_snap_to_grid (NautilusIconContainer *container)
+{
+	GList *icon_list;
+
+	icon_list = g_list_copy(container->details->icons);
+	icon_list = g_list_sort(icon_list, compare_for_snap_to_grid);
+	reset_scroll_region_if_not_empty (container);
+	basic_lay_down_icons (container, icon_list);
+
+	/* We should check to see if the icons have overflowed the desktop.
+	 * A solution is to decrease the zoom level of the desktop if this happens.
+	 * The only problem is that the desktop always returns to the default zoom level
+	 * on startup. Right now the behavior is to stack the icons on the edge of the
+	 * desktop.  We can put this code in when the desktop can remember its zoom level
+	 * or we can have a setting.
+	 *
+	 * 
+	icon_list = g_list_last(icon_list);
+	icon = icon_list->data;
+	container_width = GTK_WIDGET (container)->allocation.width /
+		EEL_CANVAS (container)->pixels_per_unit - container->details->left_margin
+		- container->details->right_margin;
+	container_height = GTK_WIDGET (container)->allocation.height /
+		EEL_CANVAS (container)->pixels_per_unit - container->details->top_margin
+		- container->details->bottom_margin;
+	if (icon->x < container_width && icon->y < container_height) {
+		return;
+	}
+	zoom_level = nautilus_icon_container_get_zoom_level(container);
+	nautilus_icon_container_set_zoom_level(container, zoom_level/2);
+	basic_lay_down_icons (container, icon_list);
+	*/
+
+	nautilus_icon_container_update_scroll_region (container);
+	g_signal_emit (container, signals[LAYOUT_CHANGED], 0);
+	g_list_free(icon_list);
+}
+
+void
+nautilus_icon_container_lay_down_icons (NautilusIconContainer *container)
+{
+	GList *icon_list;
+
+	icon_list = g_list_copy(container->details->icons);
+	icon_list = g_list_sort(icon_list, compare_for_snap_to_grid);
+	reset_scroll_region_if_not_empty (container);
+	lay_down_icons_tblr (container, icon_list);
+
+	nautilus_icon_container_update_scroll_region (container);
+	g_signal_emit (container, signals[LAYOUT_CHANGED], 0);
+	g_list_free(icon_list);
 }
 
 gboolean
diff -rub --exclude 'Makefile.*' nautilus-2.2.3.1-original/libnautilus-private/nautilus-icon-container.h nautilus-2.2.3.1/libnautilus-private/nautilus-icon-container.h
--- nautilus-2.2.3.1-original/libnautilus-private/nautilus-icon-container.h	Wed Mar 12 15:29:00 2003
+++ nautilus-2.2.3.1/libnautilus-private/nautilus-icon-container.h	Sun Apr  6 14:37:40 2003
@@ -207,6 +207,8 @@
 void              nautilus_icon_container_set_layout_mode               (NautilusIconContainer  *container,
 									 NautilusIconLayoutMode  mode);
 void              nautilus_icon_container_sort                          (NautilusIconContainer  *container);
+void              nautilus_icon_container_snap_to_grid                  (NautilusIconContainer  *container);
+void              nautilus_icon_container_lay_down_icons                (NautilusIconContainer  *container);
 void              nautilus_icon_container_freeze_icon_positions         (NautilusIconContainer  *container);
 
 
diff -rub --exclude 'Makefile.*' nautilus-2.2.3.1-original/libnautilus-private/nautilus-icon-private.h nautilus-2.2.3.1/libnautilus-private/nautilus-icon-private.h
--- nautilus-2.2.3.1-original/libnautilus-private/nautilus-icon-private.h	Thu Mar 27 13:53:07 2003
+++ nautilus-2.2.3.1/libnautilus-private/nautilus-icon-private.h	Sun Apr  6 15:49:29 2003
@@ -240,6 +240,9 @@
 	/* Whether we should use drop shadows for the icon labels or not */
 	gboolean use_drop_shadows;
 	gboolean drop_shadows_requested;
+
+	/* Sorting details */
+	gboolean sorting;
 };
 
 /* Private functions shared by mutiple files. */
diff -rub --exclude 'Makefile.*' nautilus-2.2.3.1-original/src/file-manager/fm-desktop-icon-view.c nautilus-2.2.3.1/src/file-manager/fm-desktop-icon-view.c
--- nautilus-2.2.3.1-original/src/file-manager/fm-desktop-icon-view.c	Tue Mar  4 16:07:25 2003
+++ nautilus-2.2.3.1/src/file-manager/fm-desktop-icon-view.c	Sun Apr 13 19:38:57 2003
@@ -226,6 +226,10 @@
 
 		icon_container_set_workarea (
 			icon_container, screen, workareas, length_returned / sizeof (long));
+		if (fm_icon_view_get_desktop_auto_layout (icon_view)) {
+			EEL_CALL_METHOD (FM_ICON_VIEW_CLASS, icon_view,
+				clean_up_by_pos, (icon_view));
+		}
 	}
 
 	if (workareas != NULL)
diff -rub --exclude 'Makefile.*' nautilus-2.2.3.1-original/src/file-manager/fm-icon-view.c nautilus-2.2.3.1/src/file-manager/fm-icon-view.c
--- nautilus-2.2.3.1-original/src/file-manager/fm-icon-view.c	Fri Mar 28 10:39:03 2003
+++ nautilus-2.2.3.1/src/file-manager/fm-icon-view.c	Sun Apr 13 19:38:17 2003
@@ -88,7 +88,10 @@
 #define MENU_PATH_MANUAL_LAYOUT 		"/menu/View/View Items Placeholder/Arrange Items/Manual Layout"
 #define MENU_PATH_TIGHTER_LAYOUT 		"/menu/View/View Items Placeholder/Arrange Items/Tighter Layout"
 #define MENU_PATH_SORT_REVERSED			"/menu/View/View Items Placeholder/Arrange Items/Reversed Order"
+#define MENU_PATH_AUTOMATIC_LAYOUT		"/menu/View/View Items Placeholder/Automatic Layout"
 #define MENU_PATH_CLEAN_UP			"/menu/View/View Items Placeholder/Clean Up"
+#define MENU_PATH_CLEAN_UP_BY_POSITION		"/menu/View/View Items Placeholder/Clean Up by Position"
+#define MENU_PATH_SNAP_TO_GRID			"/menu/View/View Items Placeholder/Snap to Grid"
 
 #define POPUP_PATH_LAY_OUT			"/popups/background/Before Zoom Items/View Items/Arrange Items"
 
@@ -97,11 +100,15 @@
 #define COMMAND_UNSTRETCH_ICONS 		"/commands/Unstretch"
 #define COMMAND_TIGHTER_LAYOUT 			"/commands/Tighter Layout"
 #define COMMAND_SORT_REVERSED			"/commands/Reversed Order"
+#define COMMAND_AUTOMATIC_LAYOUT		"/commands/Automatic Layout"
 #define COMMAND_CLEAN_UP			"/commands/Clean Up"
+#define COMMAND_CLEAN_UP_BY_POSITION		"/commands/Clean Up by Position"
+#define COMMAND_SNAP_TO_GRID			"/commands/Snap to Grid"
 
 #define ID_MANUAL_LAYOUT                        "Manual Layout"
 #define ID_TIGHTER_LAYOUT                       "Tighter Layout"
 #define ID_SORT_REVERSED                        "Reversed Order"
+#define ID_AUTOMATIC_LAYOUT                     "Automatic Layout"
 
 typedef struct {
 	NautilusFileSortType sort_type;
@@ -140,6 +147,9 @@
 
 	gboolean filter_by_screen;
 	int num_screens;
+	
+	gboolean desktop_snapping;
+	gboolean automatic_layout;
 };
 
 
@@ -394,6 +404,65 @@
 }
 
 static void
+fm_icon_view_clean_up_by_pos (FMIconView *icon_view)
+{
+	EEL_CALL_METHOD (FM_ICON_VIEW_CLASS, icon_view, clean_up_by_pos, (icon_view));
+}
+
+static void
+fm_icon_view_real_clean_up_by_pos (FMIconView *icon_view)
+{
+	NautilusIconContainer *icon_container;
+	gboolean saved_sort_reversed;
+
+	if (icon_view->details->desktop_snapping) {
+		return;
+	}
+
+	icon_view->details->desktop_snapping = TRUE;
+	icon_container = get_icon_container (icon_view);
+
+	nautilus_icon_container_lay_down_icons (icon_container);
+	nautilus_icon_container_freeze_icon_positions (icon_container);
+	icon_view->details->desktop_snapping = FALSE;
+}
+
+static void
+clean_up_by_pos_callback (BonoboUIComponent *component, gpointer callback_data, const char *verb)
+{
+	fm_icon_view_clean_up_by_pos (FM_ICON_VIEW (callback_data));
+}
+
+static void
+fm_icon_view_snap_to_grid (FMIconView *icon_view)
+{
+	if (icon_view->details->desktop_snapping) {
+		return;
+	}
+
+	icon_view->details->desktop_snapping = TRUE;
+	EEL_CALL_METHOD (FM_ICON_VIEW_CLASS, icon_view, snap_to_grid, (icon_view));
+	icon_view->details->desktop_snapping = FALSE;
+}
+
+static void
+fm_icon_view_real_snap_to_grid (FMIconView *icon_view)
+{
+	NautilusIconContainer *icon_container;
+
+	icon_container = get_icon_container (icon_view);
+
+	nautilus_icon_container_snap_to_grid (icon_container);
+	nautilus_icon_container_freeze_icon_positions (icon_container);
+}
+
+static void
+snap_to_grid_callback (BonoboUIComponent *component, gpointer callback_data, const char *verb)
+{
+	fm_icon_view_snap_to_grid (FM_ICON_VIEW (callback_data));
+}
+
+static void
 set_tighter_layout (FMIconView *icon_view, gboolean new_value)
 {
 	fm_icon_view_set_directory_tighter_layout (icon_view,  
@@ -437,6 +506,13 @@
 		(get_icon_container (icon_view));
 }
 
+static gboolean
+fm_icon_view_using_automatic_layout (FMIconView *icon_view)
+{
+	return nautilus_icon_container_get_is_desktop (get_icon_container (icon_view))
+		&& icon_view->details->automatic_layout;
+}
+
 static void
 handle_radio_item (FMIconView *view,
 		   const char *id)
@@ -593,7 +669,8 @@
 		return;
 	}
 
-	is_auto_layout = fm_icon_view_using_auto_layout (view);
+	is_auto_layout = fm_icon_view_using_auto_layout (view)
+		|| fm_icon_view_using_automatic_layout (view);
 
 	bonobo_ui_component_freeze (view->details->ui, NULL);
 
@@ -619,8 +696,21 @@
 	}
 
 	/* Clean Up is only relevant for manual layout */
+	if (nautilus_icon_container_get_is_desktop (get_icon_container (view))) {
+		nautilus_bonobo_set_sensitive
+			(view->details->ui, COMMAND_CLEAN_UP, TRUE);
+	} else {
 	nautilus_bonobo_set_sensitive
 		(view->details->ui, COMMAND_CLEAN_UP, !is_auto_layout);	
+	}
+	nautilus_bonobo_set_sensitive
+		(view->details->ui, COMMAND_CLEAN_UP_BY_POSITION, !is_auto_layout);
+	nautilus_bonobo_set_sensitive
+		(view->details->ui, COMMAND_SNAP_TO_GRID, !is_auto_layout);
+
+	/* Set the checkmark for the "automatic layout" item */
+	nautilus_bonobo_set_toggle_state 
+		(view->details->ui, COMMAND_AUTOMATIC_LAYOUT, fm_icon_view_using_automatic_layout (view));
 
 	bonobo_ui_component_thaw (view->details->ui, NULL);
 }
@@ -1292,6 +1382,35 @@
 }
 
 static void
+automatic_layout_state_changed_callback (BonoboUIComponent *component,
+					 const char        *path,
+					 Bonobo_UIComponent_EventType type,
+					 const char        *state,
+					 gpointer          user_data)
+{
+	FMIconView *icon_view;
+
+	g_assert (strcmp (path, ID_AUTOMATIC_LAYOUT) == 0);
+
+	icon_view = FM_ICON_VIEW (user_data);
+
+	if (strcmp (state, "") == 0) {
+		/* State goes blank when component is removed; ignore this. */
+		return;
+	}
+
+	if (strcmp (state, "1") == 0) {
+		icon_view->details->automatic_layout = TRUE;
+		fm_icon_view_clean_up_by_pos (icon_view);
+	} else {
+		icon_view->details->automatic_layout = FALSE;
+	}
+
+	eel_preferences_set_boolean (NAUTILUS_PREFERENCES_ICON_VIEW_DESKTOP_AUTO_LAYOUT,
+		icon_view->details->automatic_layout);
+}
+
+static void
 switch_to_manual_layout (FMIconView *icon_view)
 {
 	if (!fm_icon_view_using_auto_layout (icon_view)) {
@@ -1373,6 +1492,8 @@
 		BONOBO_UI_VERB ("Stretch", show_stretch_handles_callback),
 		BONOBO_UI_VERB ("Unstretch", unstretch_icons_callback),
 		BONOBO_UI_VERB ("Clean Up", clean_up_callback),
+		BONOBO_UI_VERB ("Clean Up by Position", clean_up_by_pos_callback),
+		BONOBO_UI_VERB ("Snap to Grid", snap_to_grid_callback),
 		BONOBO_UI_VERB_END
 	};
 	
@@ -1398,6 +1519,8 @@
 	
 	bonobo_ui_component_add_listener (icon_view->details->ui, ID_TIGHTER_LAYOUT, tighter_layout_state_changed_callback, view);
 	bonobo_ui_component_add_listener (icon_view->details->ui, ID_SORT_REVERSED, sort_reversed_state_changed_callback, view);
+	bonobo_ui_component_add_listener (icon_view->details->ui, ID_AUTOMATIC_LAYOUT,
+		automatic_layout_state_changed_callback, view);
 	icon_view->details->menus_ready = TRUE;
 
 	bonobo_ui_component_freeze (icon_view->details->ui, NULL);
@@ -1409,6 +1532,12 @@
 		nautilus_bonobo_set_hidden 
 			(icon_view->details->ui, POPUP_PATH_LAY_OUT, TRUE);
 	}
+	if (!nautilus_icon_container_get_is_desktop (get_icon_container (FM_ICON_VIEW (view)))) {
+		nautilus_bonobo_set_hidden 
+			(icon_view->details->ui, COMMAND_SNAP_TO_GRID, TRUE);
+		nautilus_bonobo_set_hidden 
+			(icon_view->details->ui, COMMAND_AUTOMATIC_LAYOUT, TRUE);
+	}
 
 	update_layout_menus (icon_view);
 
@@ -1830,6 +1959,12 @@
 		 icon_view->details->sort_reversed);
 }
 
+gboolean
+fm_icon_view_get_desktop_auto_layout (FMIconView *icon_view)
+{
+	return icon_view->details->automatic_layout;
+}
+
 void
 fm_icon_view_filter_by_screen (FMIconView *icon_view,
 			       gboolean filter)
@@ -1955,6 +2090,11 @@
 			(file, NAUTILUS_METADATA_KEY_ICON_POSITION, 
 			 NULL, position_string);
 		g_free (position_string);
+
+		/* Automatically reposition desktop icons */
+		if (fm_icon_view_using_automatic_layout (icon_view)) {
+			fm_icon_view_clean_up_by_pos (icon_view);
+		}
 	}
 
 	/* FIXME bugzilla.gnome.org 40662: 
@@ -2129,6 +2269,22 @@
 }
 
 static void
+desktop_auto_layout_changed_callback (gpointer callback_data)
+{
+	FMIconView *icon_view;
+	NautilusIconContainer *icon_container;
+
+	g_return_if_fail (FM_IS_ICON_VIEW (callback_data));
+
+	icon_view = FM_ICON_VIEW (callback_data);
+	icon_container = get_icon_container (icon_view);
+	g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (icon_container));
+
+	update_layout_menus (icon_view);
+	nautilus_icon_container_request_update_all (icon_container);
+}
+
+static void
 default_use_manual_layout_changed_callback (gpointer callback_data)
 {
 	FMIconView *icon_view;
@@ -2231,6 +2387,27 @@
 						       click_mode == NAUTILUS_CLICK_POLICY_SINGLE);
 }
 
+static gboolean
+icon_changed_cleanup (FMIconView *icon_view)
+{
+	fm_icon_view_clean_up_by_pos (icon_view);
+	return FALSE;
+}
+
+static void
+icon_changed (FMIconView *icon_view)
+{
+	if (!nautilus_icon_container_get_is_desktop (get_icon_container (icon_view))
+		|| icon_view->details->loading) {
+		return;
+	}
+
+	if (icon_view->details->automatic_layout) {
+		gtk_idle_add_priority (G_PRIORITY_LOW,
+			(GtkFunction) icon_changed_cleanup, icon_view);
+	}
+}
+
 static void
 create_icon_container (FMIconView *icon_view)
 {
@@ -2282,6 +2459,11 @@
 				 G_CALLBACK (fm_directory_view_update_menus), icon_view,
 				 G_CONNECT_SWAPPED);
 
+	g_signal_connect (icon_view, "add_file", G_CALLBACK (icon_changed), NULL);
+	g_signal_connect (icon_view, "remove_file", G_CALLBACK (icon_changed), NULL);
+	g_signal_connect (icon_view, "file_changed", G_CALLBACK (icon_changed), NULL);
+
+
 	gtk_container_add (GTK_CONTAINER (icon_view),
 			   GTK_WIDGET (icon_container));
 
@@ -2523,6 +2705,8 @@
         fm_directory_view_class->update_menus = fm_icon_view_update_menus;
 
 	klass->clean_up = fm_icon_view_real_clean_up;
+	klass->clean_up_by_pos = fm_icon_view_real_clean_up_by_pos;
+	klass->snap_to_grid = fm_icon_view_real_snap_to_grid;
 	klass->supports_auto_layout = real_supports_auto_layout;
         klass->get_directory_auto_layout = fm_icon_view_real_get_directory_auto_layout;
         klass->get_directory_sort_by = fm_icon_view_real_get_directory_sort_by;
@@ -2538,6 +2722,7 @@
 fm_icon_view_instance_init (FMIconView *icon_view)
 {
 	static gboolean setup_sound_preview = FALSE;
+	static gboolean setup_desktop_auto_layout = FALSE;
 	NautilusView *nautilus_view;
 
         g_return_if_fail (GTK_BIN (icon_view)->child == NULL);
@@ -2563,6 +2748,11 @@
 		
 		setup_sound_preview = TRUE;
 	}
+	if (!setup_desktop_auto_layout) {
+		eel_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_ICON_VIEW_DESKTOP_AUTO_LAYOUT,
+						  &icon_view->details->automatic_layout);
+		setup_desktop_auto_layout = TRUE;
+	}
 
 	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_SORT_ORDER,
 						  default_sort_order_changed_callback,
@@ -2579,6 +2769,9 @@
 	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL,
 						  default_zoom_level_changed_callback,
 						  icon_view, G_OBJECT (icon_view));
+	eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ICON_VIEW_DESKTOP_AUTO_LAYOUT,
+						  desktop_auto_layout_changed_callback,
+						  icon_view, G_OBJECT (icon_view));
 
 	g_signal_connect_object (get_icon_container (icon_view), "handle_uri_list",
 				 G_CALLBACK (icon_view_handle_uri_list), icon_view, 0);
diff -rub --exclude 'Makefile.*' nautilus-2.2.3.1-original/src/file-manager/fm-icon-view.h nautilus-2.2.3.1/src/file-manager/fm-icon-view.h
--- nautilus-2.2.3.1-original/src/file-manager/fm-icon-view.h	Tue Feb  4 11:36:21 2003
+++ nautilus-2.2.3.1/src/file-manager/fm-icon-view.h	Sun Apr 13 19:36:41 2003
@@ -77,6 +77,8 @@
 
 	/* Override "clean_up" if your subclass has its own notion of where icons should be positioned */
 	void	 (* clean_up)			 (FMIconView *icon_view);
+	void	 (* clean_up_by_pos)		 (FMIconView *icon_view);
+	void	 (* snap_to_grid)		 (FMIconView *icon_view);
 
 	/* supports_auto_layout is a function pointer that subclasses may
 	 * override to control whether or not the automatic layout options
@@ -93,4 +95,6 @@
 				    NautilusFile *b);
 void    fm_icon_view_filter_by_screen (FMIconView *icon_view, gboolean filter);
 
+gboolean fm_icon_view_get_desktop_auto_layout (FMIconView *icon_view);
+
 #endif /* FM_ICON_VIEW_H */
diff -rub --exclude 'Makefile.*' nautilus-2.2.3.1-original/src/file-manager/nautilus-icon-view-ui.xml nautilus-2.2.3.1/src/file-manager/nautilus-icon-view-ui.xml
--- nautilus-2.2.3.1-original/src/file-manager/nautilus-icon-view-ui.xml	Fri Jul  5 22:37:24 2002
+++ nautilus-2.2.3.1/src/file-manager/nautilus-icon-view-ui.xml	Tue Apr  8 15:26:55 2003
@@ -30,9 +30,18 @@
 	<cmd name="Reversed Order"
          _label="Re_versed Order"
 	 _tip="Display icons in the opposite order"/>
+	<cmd name="Automatic Layout"
+	_label="Automatic _Layout"
+	_tip="Automatically lay out icons"/>
 	<cmd name="Clean Up"
          _label="Clean _Up by Name"
 	 _tip="Reposition icons to better fit in the window and avoid overlapping"/>
+	<cmd name="Clean Up by Position"
+	_label="Clean Up by _Position"
+	_tip="Reposition icons to better fit in the window and avoid overlapping"/>
+	<cmd name="Snap to Grid"
+	_label="Snap to _Grid"
+	_tip="Reposition icons to better fit in the window and avoid overlapping"/>
 </commands>
 <menu>
 	<submenu name="Edit">
@@ -115,7 +124,12 @@
 	                                          id="Reversed Order"
 	                                          type="toggle"/>
 				</submenu>
+				<menuitem name="Automatic Layout"
+					type="toggle"
+					id="Automatic Layout"/>
 				<menuitem name="Clean Up" verb="Clean Up"/>
+				<menuitem name="Clean Up by Position" verb="Clean Up by Position"/>
+				<menuitem name="Snap to Grid" verb="Snap to Grid"/>
 			</placeholder>
 		</placeholder>
 	</popup>
