mount_removed_callback (GVolumeMonitor *monitor,
			GMount *mount,
			NautilusApplication *application)
{
	GList *window_list, *node, *close_list;
	NautilusWindow *window;
	NautilusWindowSlot *slot;
	NautilusWindowSlot *force_no_close_slot;
	GFile *root;

	close_list = NULL;
	force_no_close_slot = NULL;
	
	/* Check and see if any of the open windows are displaying contents from the unmounted mount */
	window_list = nautilus_application_get_window_list ();

	root = g_mount_get_root (mount);
	/* Construct a list of windows to be closed. Do not add the non-closable windows to the list. */
	for (node = window_list; node != NULL; node = node->next) {
		window = NAUTILUS_WINDOW (node->data);
  		if (window != NULL && window_can_be_closed (window)) {
			GList *l;
  			GFile *location;
  
			for (l = window->details->slots; l != NULL; l = l->next) {
				slot = l->data;
				location = slot->location;
				if (g_file_has_prefix (location, root)) {
					close_list = g_list_prepend (close_list, slot);
				} 
			}
		}
	}

	if (nautilus_application_desktop_windows == NULL &&
	    g_list_length (close_list) != 0 &&
	    g_list_length (close_list) == count_slots_of_windows (window_list)) {
		/* We are trying to close all open slots. Keep one navigation slot open. */
		force_no_close_slot = get_first_navigation_slot (close_list);
	}

	/* Handle the windows in the close list. */
	for (node = close_list; node != NULL; node = node->next) {
		slot = node->data;
		window = slot->window;

		if (NAUTILUS_IS_SPATIAL_WINDOW (window) ||
		    (nautilus_navigation_window_slot_should_close_with_mount (NAUTILUS_NAVIGATION_WINDOW_SLOT (slot), mount) &&
		     slot != force_no_close_slot)) {
			nautilus_window_slot_close (slot);
		} else {
			nautilus_window_slot_go_home (slot, FALSE);
		}
	}

	g_list_free (close_list);
}
mount_removed_callback (GVolumeMonitor *monitor,
			GMount *mount,
			NautilusApplication *application)
{
	GList *window_list, *node, *close_list;
	NautilusWindow *window;
	NautilusWindowSlot *slot;
	NautilusWindowSlot *force_no_close_slot;
	GFile *root;

	close_list = NULL;
	force_no_close_slot = NULL;
	
	 
	window_list = nautilus_application_get_window_list ();

	root = g_mount_get_root (mount);
	 
	for (node = window_list; node != NULL; node = node->next) {
		window = NAUTILUS_WINDOW (node->data);
  		if (window != NULL && window_can_be_closed (window)) {
			GList *l;
  			GFile *location;
  
			for (l = window->details->slots; l != NULL; l = l->next) {
				slot = l->data;
				location = slot->location;
				if (g_file_has_prefix (location, root)) {
					close_list = g_list_prepend (close_list, slot);
				} 
			}
		}
	}

	if (nautilus_application_desktop_windows == NULL &&
	    g_list_length (close_list) != 0 &&
	    g_list_length (close_list) == count_slots_of_windows (window_list)) {
		 
		force_no_close_slot = get_first_navigation_slot (close_list);
	}

	 
	for (node = close_list; node != NULL; node = node->next) {
		slot = node->data;
		window = slot->window;

		if (NAUTILUS_IS_SPATIAL_WINDOW (window) ||
		    (nautilus_navigation_window_slot_should_close_with_mount (NAUTILUS_NAVIGATION_WINDOW_SLOT (slot), mount) &&
		     slot != force_no_close_slot)) {
			nautilus_window_slot_close (slot);
		} else {
			nautilus_window_slot_go_home (slot, FALSE);
		}
	}

	g_list_free (close_list);
}