Index: ChangeLog
===================================================================
--- ChangeLog	(revision 15176)
+++ ChangeLog	(working copy)
@@ -1,3 +1,20 @@
+2009-04-11  David Zeuthen  <davidz@redhat.com>
+
+	* src/nautilus-places-sidebar.c:
+	(add_place): Never show the eject button for unmounted volumes as
+	this will not work for volume monitors that sets can_eject==TRUE
+	on all volumes from drives with removable media. AIUI this
+	feature (always show eject button even for unmounted media) was an
+	optimistic attempt at providing an "open tray" mechanism, e.g. the
+	user could click the button to open the CD-ROM tray. This never
+	really worked anyway since a lot of CD-ROM drives are slot loading
+	and even for tray loading drives, there's a perfectly good button
+	on the drive itself.
+	(check_unmount_and_eject): only show eject (ie. not unmount) on
+	drives with only a single volume.
+
+	For discussion, see bug 574067 and bug 576587.
+
 2009-04-11  Alexander Larsson  <alexl@redhat.com>
 
 	* src/file-manager/fm-directory-view.c:
Index: src/nautilus-places-sidebar.c
===================================================================
--- src/nautilus-places-sidebar.c	(revision 15176)
+++ src/nautilus-places-sidebar.c	(working copy)
@@ -218,6 +218,7 @@
 	NautilusIconInfo *icon_info;
 	int icon_size;
 	gboolean show_eject, show_unmount;
+	gboolean show_eject_button;
 
 	icon_size = nautilus_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU);
 	icon_info = nautilus_icon_info_lookup (icon, icon_size);
@@ -230,7 +231,12 @@
 	if (show_unmount || show_eject) {
 		g_assert (place_type != PLACES_BOOKMARK);
 	}
- 		  
+
+	if (mount == NULL)
+		show_eject_button = FALSE;
+	else
+		show_eject_button = (show_unmount || show_eject);
+
 	gtk_list_store_append (sidebar->store, &iter);
 	gtk_list_store_set (sidebar->store, &iter,
 			    PLACES_SIDEBAR_COLUMN_ICON, pixbuf,
@@ -241,8 +247,8 @@
 			    PLACES_SIDEBAR_COLUMN_MOUNT, mount,
 			    PLACES_SIDEBAR_COLUMN_ROW_TYPE, place_type,
 			    PLACES_SIDEBAR_COLUMN_INDEX, index,
-			    PLACES_SIDEBAR_COLUMN_EJECT, (show_unmount || show_eject),
-			    PLACES_SIDEBAR_COLUMN_NO_EJECT, !(show_unmount || show_eject),
+			    PLACES_SIDEBAR_COLUMN_EJECT, show_eject_button,
+			    PLACES_SIDEBAR_COLUMN_NO_EJECT, !show_eject_button,
 			    PLACES_SIDEBAR_COLUMN_BOOKMARK, place_type != PLACES_BOOKMARK,
 			    PLACES_SIDEBAR_COLUMN_NO_BOOKMARK, place_type == PLACES_BOOKMARK,
 			    -1);
@@ -1275,10 +1281,20 @@
 			 gboolean *show_unmount,
 			 gboolean *show_eject)
 {
+	guint num_volumes_for_drive;
+
 	*show_unmount = FALSE;
 	*show_eject = FALSE;
+	num_volumes_for_drive = 0;
 
 	if (drive != NULL) {
+		GList *volumes;
+
+		volumes = g_drive_get_volumes (drive);
+		num_volumes_for_drive = g_list_length (volumes);
+		g_list_foreach (volumes, (GFunc) g_object_unref, NULL);
+		g_list_free (volumes);
+
 		*show_eject = g_drive_can_eject (drive);
 	}
 
@@ -1289,6 +1305,14 @@
 		*show_eject |= g_mount_can_eject (mount);
 		*show_unmount = g_mount_can_unmount (mount);
 	}
+
+	/* If @volume is the only GVolume for drive, then set can_unmount
+	 * to FALSE iff can_eject==TRUE
+	 *
+	 * See http://bugzilla.gnome.org/show_bug.cgi?id=576587#c12 for discussion.
+	 */
+	if (num_volumes_for_drive == 1 && *show_eject)
+		*show_unmount = FALSE;
 }
 
 static void
@@ -1312,6 +1336,7 @@
 		    !g_drive_is_media_check_automatic (drive) && 
 		    g_drive_can_poll_for_media (drive))
 			*show_rescan = TRUE;
+
 	}
 
 	if (volume != NULL) {
@@ -1373,7 +1398,6 @@
  			  &show_mount, &show_unmount, &show_eject, &show_rescan, &show_format);
 
 	/* We actually want both eject and unmount since eject will unmount all volumes. 
-	 * TODO: hide unmount if the drive only has a single mountable volume 
 	 */
 
 	show_empty_trash = (uri != NULL) &&
