Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.6280
diff -u -p -r1.6280 ChangeLog
--- ChangeLog	1 Oct 2004 15:57:40 -0000	1.6280
+++ ChangeLog	2 Oct 2004 03:46:28 -0000
@@ -1,3 +1,10 @@
+2004-10-01  Dennis Cranston <dennis_cranston@yahoo.com>
+
+	* libnautilus-private/nautilus-desktop-link-monitor.c
+	(nautilus_desktop_link_monitor_delete_link):
+	Add query dialog to eject or unmount volumes dropped onto
+	trash (#15555).
+	
 2004-10-01  Martin Wehner  <martin.wehner@epost.de>
 
 	* src/file-manager/fm-directory-view.c:
Index: libnautilus-private/nautilus-desktop-link-monitor.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-desktop-link-monitor.c,v
retrieving revision 1.10
diff -u -p -r1.10 nautilus-desktop-link-monitor.c
--- libnautilus-private/nautilus-desktop-link-monitor.c	14 May 2004 09:34:07 -0000	1.10
+++ libnautilus-private/nautilus-desktop-link-monitor.c	2 Oct 2004 03:46:28 -0000
@@ -30,9 +30,11 @@
 #include "nautilus-desktop-directory.h"
 #include "nautilus-global-preferences.h"
 
+#include <eel/eel-alert-dialog.h>
 #include <eel/eel-debug.h>
 #include <eel/eel-gtk-macros.h>
 #include <eel/eel-glib-extensions.h>
+#include <eel/eel-gtk-extensions.h>
 #include <eel/eel-vfs-extensions.h>
 #include <eel/eel-stock-dialogs.h>
 #include <gtk/gtkmessagedialog.h>
@@ -86,6 +88,141 @@ nautilus_desktop_link_monitor_get (void)
 	return link_monitor;
 }
 
+static gboolean
+eject_for_type (GnomeVFSDeviceType type)
+{
+	switch (type) {
+	case GNOME_VFS_DEVICE_TYPE_CDROM:
+	case GNOME_VFS_DEVICE_TYPE_ZIP:
+	case GNOME_VFS_DEVICE_TYPE_JAZ:
+		return TRUE;
+	default:
+		return FALSE;
+	}
+}
+
+static void
+volume_ejected_callback (gboolean succeeded,
+                         char *error,
+                         char *detailed_error,
+                         gpointer data)
+{
+	gboolean eject;
+
+	eject = GPOINTER_TO_INT (data);
+	if (!succeeded) {
+		if (eject) {
+			eel_show_error_dialog_with_details (error, NULL, 
+			                                    _("Eject Error"), 
+			                                    detailed_error, NULL);
+		} else {
+			eel_show_error_dialog_with_details (error, NULL, 
+			                                    _("Unmount Error"), 
+			                                    detailed_error, NULL);
+		}
+	}
+}
+
+static void
+volume_eject_if_yes (GtkDialog *dialog, 
+                     int response, 
+                     gpointer data)
+{
+	GnomeVFSVolume *volume;
+	NautilusDesktopLink *file;
+
+	if (response == GTK_RESPONSE_OK) {
+		
+		file = (NautilusDesktopLink *) data;
+		
+		if (file != NULL) {
+			volume = nautilus_desktop_link_get_volume (file);
+			if (volume != NULL) {
+				if (eject_for_type (gnome_vfs_volume_get_device_type (volume))) {
+					gnome_vfs_volume_eject (volume, 
+					                        volume_ejected_callback, 
+					                        GINT_TO_POINTER (TRUE));
+				} else {
+					gnome_vfs_volume_unmount (volume, 
+					                          volume_ejected_callback, 
+					                          GINT_TO_POINTER (FALSE));
+				}
+			}	
+		}
+	}
+	gtk_object_destroy (GTK_OBJECT (dialog));
+}
+
+static void
+volume_eject_query (GtkWindow *window,
+                    NautilusDesktopLink *link)
+{
+	GnomeVFSVolume *volume;
+	GtkWidget *button;
+	GtkWidget *dialog;
+	char *action_label;
+	char *dialog_str1;
+	char *dialog_str2;
+
+	volume = nautilus_desktop_link_get_volume (link);
+
+	if (volume != NULL) {
+
+		if (eject_for_type (gnome_vfs_volume_get_device_type (volume))) {
+
+			action_label = g_strdup (_("E_ject"));
+		
+			dialog_str1 = g_strdup_printf (
+			                 _("Are you sure you want to eject the volume \"%s\"?"),
+			                 nautilus_desktop_link_get_display_name (link));
+				 
+			dialog_str2 = g_strdup (_("If you eject the volume, its contents will "
+				                  "be unavailable for viewing or editing."));
+		} else {
+
+			action_label = g_strdup (_("_Unmount"));
+		
+			dialog_str1 = g_strdup_printf (
+				         _("Are you sure you want to unmount the volume \"%s\"?"),
+			                 nautilus_desktop_link_get_display_name (link));
+				 
+			dialog_str2 = g_strdup (_("If you unmount the volume, its contents will "
+						  "be unavailable for viewing or editing."));
+		}
+								 
+		dialog = eel_alert_dialog_new (window, 
+			                       0,
+		                               GTK_MESSAGE_QUESTION,
+		                               GTK_BUTTONS_NONE,
+		                               dialog_str1,
+		                               dialog_str2,
+		                               NULL);
+					       
+		gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, 
+		                       GTK_RESPONSE_CANCEL);
+
+		button = eel_gtk_button_new_with_stock_icon (action_label,
+		                                             GTK_STOCK_OK);
+		gtk_widget_show (button);
+		GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
+				
+		gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, 
+		                              GTK_RESPONSE_OK);
+
+		gtk_dialog_set_default_response (GTK_DIALOG(dialog), 
+		                                 GTK_RESPONSE_CANCEL);
+		
+		g_signal_connect (dialog, "response",
+		                  G_CALLBACK (volume_eject_if_yes), link);
+		
+		gtk_widget_show (GTK_WIDGET (dialog));
+
+		g_free (action_label);			
+		g_free (dialog_str1);
+		g_free (dialog_str2);
+	}
+}
+
 void
 nautilus_desktop_link_monitor_delete_link (NautilusDesktopLinkMonitor *monitor,
 					   NautilusDesktopLink *link,
@@ -98,16 +235,9 @@ nautilus_desktop_link_monitor_delete_lin
 		/* just ignore. We don't allow you to delete these */
 		break;
 	default:
-		eel_run_simple_dialog
-			(parent_view, 
-			 FALSE,
-			 GTK_MESSAGE_ERROR,
-			 _("You cannot delete a volume icon."),
-			 _("If you want to eject the volume, please use Eject in the "
-			   "right-click menu of the volume."),
-			 _("Can't Delete Volume"),
-			 GTK_STOCK_OK, NULL);
-		break;
+		volume_eject_query (GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (parent_view))),
+		                    link);
+		break;	
 	}
 }
 
