diff -rupN nautilus-2.20.0-orig/libnautilus-private/nautilus-icon-container.c nautilus-2.20.0-invert/libnautilus-private/nautilus-icon-container.c
--- nautilus-2.20.0-orig/libnautilus-private/nautilus-icon-container.c	2007-09-10 12:49:01.000000000 +0200
+++ nautilus-2.20.0-invert/libnautilus-private/nautilus-icon-container.c	2007-10-24 21:20:01.000000000 +0200
@@ -6266,6 +6266,29 @@ nautilus_icon_container_get_selection (N
 	return g_list_reverse (list);
 }
 
+/**
+ * nautilus_icon_container_invert_selection:
+ * @container: An icon container.
+ * 
+ * Inverts the selection in @container.
+ * 
+ **/
+void
+nautilus_icon_container_invert_selection (NautilusIconContainer *container)
+{
+	GList *p;
+
+	g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
+
+	for (p = container->details->icons; p != NULL; p = p->next) {
+		NautilusIcon *icon;
+
+		icon = p->data;
+		icon_toggle_selected (container, icon);
+	}
+}
+
+
 /* Returns an array of GdkPoints of locations of the icons. */
 static GArray *
 nautilus_icon_container_get_icon_locations (NautilusIconContainer *container,
diff -rupN nautilus-2.20.0-orig/libnautilus-private/nautilus-icon-container.h nautilus-2.20.0-invert/libnautilus-private/nautilus-icon-container.h
--- nautilus-2.20.0-orig/libnautilus-private/nautilus-icon-container.h	2007-04-03 12:08:46.000000000 +0200
+++ nautilus-2.20.0-invert/libnautilus-private/nautilus-icon-container.h	2007-10-24 20:46:47.000000000 +0200
@@ -257,6 +257,7 @@ void              nautilus_icon_containe
 
 /* operations on the selection */
 GList     *       nautilus_icon_container_get_selection                 (NautilusIconContainer  *view);
+void			  nautilus_icon_container_invert_selection				(NautilusIconContainer  *view);
 void              nautilus_icon_container_set_selection                 (NautilusIconContainer  *view,
 									 GList                  *selection);
 GArray    *       nautilus_icon_container_get_selected_icon_locations   (NautilusIconContainer  *view);
diff -rupN nautilus-2.20.0-orig/libnautilus-private/nautilus-view.c nautilus-2.20.0-invert/libnautilus-private/nautilus-view.c
--- nautilus-2.20.0-orig/libnautilus-private/nautilus-view.c	2007-04-03 12:08:46.000000000 +0200
+++ nautilus-2.20.0-invert/libnautilus-private/nautilus-view.c	2007-10-24 20:48:47.000000000 +0200
@@ -159,6 +159,13 @@ nautilus_view_set_selection (NautilusVie
 							   list);
 }
 
+void
+nautilus_view_invert_selection (NautilusView *view)
+{
+	g_return_if_fail (NAUTILUS_IS_VIEW (view));
+	
+	(* NAUTILUS_VIEW_GET_IFACE (view)->invert_selection) (view);
+}
 
 char *
 nautilus_view_get_first_visible_file (NautilusView *view)
diff -rupN nautilus-2.20.0-orig/libnautilus-private/nautilus-view.h nautilus-2.20.0-invert/libnautilus-private/nautilus-view.h
--- nautilus-2.20.0-orig/libnautilus-private/nautilus-view.h	2007-04-03 12:08:46.000000000 +0200
+++ nautilus-2.20.0-invert/libnautilus-private/nautilus-view.h	2007-10-24 20:49:43.000000000 +0200
@@ -83,6 +83,9 @@ struct _NautilusViewIface 
 	void           (* set_selection)          (NautilusView          *view,
 						   GList                 *list);
 	
+	/* Inverts the selection in the view */	
+	void           (* invert_selection)       (NautilusView          *view);
+	
 	/* Return the uri of the first visible file */	
 	char *         (* get_first_visible_file) (NautilusView          *view);
 	/* Scroll the view so that the file specified by the uri is at the top
diff -rupN nautilus-2.20.0-orig/src/file-manager/fm-directory-view.c nautilus-2.20.0-invert/src/file-manager/fm-directory-view.c
--- nautilus-2.20.0-orig/src/file-manager/fm-directory-view.c	2007-08-27 10:03:57.000000000 +0200
+++ nautilus-2.20.0-invert/src/file-manager/fm-directory-view.c	2007-10-24 21:32:41.000000000 +0200
@@ -452,6 +452,7 @@ EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_d
 EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, set_selection)
 EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, zoom_to_level)
 EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, get_zoom_level)
+EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (fm_directory_view, invert_selection)
 
 typedef struct {
 	GnomeVFSMimeApplication *application;
@@ -1129,6 +1130,15 @@ action_select_all_callback (GtkAction *a
 }
 
 static void
+action_invert_selection_callback (GtkAction *action, 
+			    gpointer callback_data)
+{
+	g_assert (FM_IS_DIRECTORY_VIEW (callback_data));
+
+	fm_directory_view_invert_selection (callback_data);
+}
+
+static void
 pattern_select_response_cb (GtkWidget *dialog, int response, gpointer user_data)
 {
 	FMDirectoryView *view;
@@ -1885,6 +1895,7 @@ fm_directory_view_init_view_iface (Nauti
 	iface->get_selection_count = fm_directory_view_get_selection_count;
 	iface->get_selection = fm_directory_view_get_selection_uris;
 	iface->set_selection = fm_directory_view_set_selection_uris;
+	iface->invert_selection = fm_directory_view_invert_selection;
 	
 	iface->supports_zooming = (gpointer)fm_directory_view_supports_zooming;
 	iface->bump_zoom_level = (gpointer)fm_directory_view_bump_zoom_level;
@@ -3540,6 +3551,16 @@ fm_directory_view_get_selection (FMDirec
 		 get_selection, (view));
 }
 
+void
+fm_directory_view_invert_selection (FMDirectoryView *view)
+{
+	g_return_if_fail (FM_IS_DIRECTORY_VIEW (view));
+
+	return EEL_CALL_METHOD_WITH_RETURN_VALUE
+		(FM_DIRECTORY_VIEW_CLASS, view,
+		 invert_selection, (view));
+}
+
 GList *
 fm_directory_view_get_selection_for_file_transfer (FMDirectoryView *view)
 {
@@ -6971,6 +6992,10 @@ static const GtkActionEntry directory_vi
     N_("Select _Pattern"), "<control>S",                /* label, accelerator */
     N_("Select items in this window matching a given pattern"),                   /* tooltip */ 
     G_CALLBACK (action_select_pattern_callback) },
+  { "Invert Selection", NULL,                  /* name, stock id */
+    N_("_Invert Selection"), "<control><shift>I",                /* label, accelerator */
+    N_("Select all and only the items that are not currently selected"),                   /* tooltip */ 
+    G_CALLBACK (action_invert_selection_callback) },    
   { "Duplicate", NULL,                  /* name, stock id */
     N_("D_uplicate"), NULL,                /* label, accelerator */
     N_("Duplicate each selected item"),                   /* tooltip */ 
diff -rupN nautilus-2.20.0-orig/src/file-manager/fm-directory-view.h nautilus-2.20.0-invert/src/file-manager/fm-directory-view.h
--- nautilus-2.20.0-orig/src/file-manager/fm-directory-view.h	2007-04-03 12:08:04.000000000 +0200
+++ nautilus-2.20.0-invert/src/file-manager/fm-directory-view.h	2007-10-24 21:23:55.000000000 +0200
@@ -158,6 +158,11 @@ struct FMDirectoryViewClass {
 
         void     (* set_selection)	 	(FMDirectoryView *view, 
         					 GList *selection);
+        					 
+        /* invert_selection is a function pointer that subclasses must
+         * override to invert selection. */
+
+        void     (* invert_selection)	 	(FMDirectoryView *view);        					 
 
 	/* Return an array of locations of selected icons in their view. */
 	GArray * (* get_selected_icon_locations) (FMDirectoryView *view);
@@ -328,6 +333,7 @@ gboolean            fm_directory_view_ca
 void                fm_directory_view_display_selection_info           (FMDirectoryView  *view);
 GList *             fm_directory_view_get_selection                    (FMDirectoryView  *view);
 GList *             fm_directory_view_get_selection_for_file_transfer  (FMDirectoryView  *view);
+void                fm_directory_view_invert_selection                 (FMDirectoryView  *view);
 void                fm_directory_view_stop                             (FMDirectoryView  *view);
 guint               fm_directory_view_get_item_count                   (FMDirectoryView  *view);
 gboolean            fm_directory_view_can_zoom_in                      (FMDirectoryView  *view);
diff -rupN nautilus-2.20.0-orig/src/file-manager/fm-icon-view.c nautilus-2.20.0-invert/src/file-manager/fm-icon-view.c
--- nautilus-2.20.0-orig/src/file-manager/fm-icon-view.c	2007-04-03 12:08:04.000000000 +0200
+++ nautilus-2.20.0-invert/src/file-manager/fm-icon-view.c	2007-10-24 20:56:23.000000000 +0200
@@ -1689,6 +1689,15 @@ fm_icon_view_set_selection (FMDirectoryV
 		(get_icon_container (FM_ICON_VIEW (view)), selection);
 }
 
+static void
+fm_icon_view_invert_selection (FMDirectoryView *view)
+{
+	g_return_if_fail (FM_IS_ICON_VIEW (view));
+
+	nautilus_icon_container_invert_selection
+		(get_icon_container (FM_ICON_VIEW (view)));
+}
+
 static gboolean
 fm_icon_view_using_manual_layout (FMDirectoryView *view)
 {
@@ -2643,6 +2652,7 @@ fm_icon_view_class_init (FMIconViewClass
 	fm_directory_view_class->reveal_selection = fm_icon_view_reveal_selection;
 	fm_directory_view_class->select_all = fm_icon_view_select_all;
 	fm_directory_view_class->set_selection = fm_icon_view_set_selection;
+	fm_directory_view_class->invert_selection = fm_icon_view_invert_selection;
 	fm_directory_view_class->compare_files = compare_files;
 	fm_directory_view_class->zoom_to_level = fm_icon_view_zoom_to_level;
 	fm_directory_view_class->get_zoom_level = fm_icon_view_get_zoom_level;
diff -rupN nautilus-2.20.0-orig/src/file-manager/fm-list-view.c nautilus-2.20.0-invert/src/file-manager/fm-list-view.c
--- nautilus-2.20.0-orig/src/file-manager/fm-list-view.c	2007-08-21 11:37:48.000000000 +0200
+++ nautilus-2.20.0-invert/src/file-manager/fm-list-view.c	2007-10-24 21:25:43.000000000 +0200
@@ -1865,6 +1865,43 @@ fm_list_view_set_selection (FMDirectoryV
 }
 
 static void
+fm_list_view_invert_selection (FMDirectoryView *view)
+{
+	FMListView *list_view;
+	GtkTreeSelection *tree_selection;
+	GList *node;
+	GList *iters, *l;
+	NautilusFile *file;
+	GList *selection = NULL;
+	
+	list_view = FM_LIST_VIEW (view);
+	tree_selection = gtk_tree_view_get_selection (list_view->details->tree_view);
+
+	g_signal_handlers_block_by_func (tree_selection, list_selection_changed_callback, view);
+	
+	gtk_tree_selection_selected_foreach (tree_selection,
+					 fm_list_view_get_selection_foreach_func, &selection);
+
+	gtk_tree_selection_select_all (tree_selection);
+	
+	for (node = selection; node != NULL; node = node->next) {
+		file = node->data;
+		iters = fm_list_model_get_all_iters_for_file (list_view->details->model, file);
+
+		for (l = iters; l != NULL; l = l->next) {
+			gtk_tree_selection_unselect_iter (tree_selection,
+							(GtkTreeIter *)l->data);
+		}
+		eel_g_list_free_deep (iters);
+	}
+
+	g_list_free (selection);
+
+	g_signal_handlers_unblock_by_func (tree_selection, list_selection_changed_callback, view);
+	fm_directory_view_notify_selection_changed (view);
+}
+
+static void
 fm_list_view_select_all (FMDirectoryView *view)
 {
 	gtk_tree_selection_select_all (gtk_tree_view_get_selection (FM_LIST_VIEW (view)->details->tree_view));
@@ -2621,6 +2658,7 @@ fm_list_view_class_init (FMListViewClass
 	fm_directory_view_class->reveal_selection = fm_list_view_reveal_selection;
 	fm_directory_view_class->select_all = fm_list_view_select_all;
 	fm_directory_view_class->set_selection = fm_list_view_set_selection;
+	fm_directory_view_class->invert_selection = fm_list_view_invert_selection;
 	fm_directory_view_class->compare_files = fm_list_view_compare_files;
 	fm_directory_view_class->sort_directories_first_changed = fm_list_view_sort_directories_first_changed;
 	fm_directory_view_class->start_renaming_file = fm_list_view_start_renaming_file;
diff -rupN nautilus-2.20.0-orig/src/file-manager/nautilus-directory-view-ui.xml nautilus-2.20.0-invert/src/file-manager/nautilus-directory-view-ui.xml
--- nautilus-2.20.0-orig/src/file-manager/nautilus-directory-view-ui.xml	2007-04-03 12:08:04.000000000 +0200
+++ nautilus-2.20.0-invert/src/file-manager/nautilus-directory-view-ui.xml	2007-10-24 21:30:04.000000000 +0200
@@ -57,6 +57,7 @@
 		<placeholder name="Select Items">
 		<menuitem name="Select All" action="Select All"/>
 		<menuitem name="Select Pattern" action="Select Pattern"/>
+		<menuitem name="Invert Selection" action="Invert Selection"/>
 		</placeholder>
 		<placeholder name="File Items Placeholder">
 			<menuitem name="Duplicate" action="Duplicate"/>
