9a4158d
--- nautilus-2.12.1/src/file-manager/fm-actions.h.format	2005-07-01 06:22:19.000000000 -0400
a95948e
+++ nautilus-2.12.1/src/file-manager/fm-actions.h	2005-10-27 14:35:29.000000000 -0400
9a4158d
@@ -57,6 +57,7 @@
9a4158d
 #define FM_ACTION_MOUNT_VOLUME "Mount Volume"
9a4158d
 #define FM_ACTION_UNMOUNT_VOLUME "Unmount Volume"
9a4158d
 #define FM_ACTION_EJECT_VOLUME "Eject Volume"
9a4158d
+#define FM_ACTION_FORMAT_VOLUME "Format Volume"
9a4158d
 #define FM_ACTION_SCRIPTS "Scripts"
9a4158d
 #define FM_ACTION_NEW_DOCUMENTS "New Documents"
9a4158d
 #define FM_ACTION_NEW_EMPTY_FILE "New Empty File"
9a4158d
--- nautilus-2.12.1/src/file-manager/fm-directory-view.c.format	2005-09-27 04:31:43.000000000 -0400
a95948e
+++ nautilus-2.12.1/src/file-manager/fm-directory-view.c	2005-10-27 23:14:56.000000000 -0400
9a4158d
@@ -377,6 +377,8 @@
9a4158d
 						    gpointer   data);
9a4158d
 static void action_unmount_volume_callback         (GtkAction *action,
9a4158d
 						    gpointer   data);
9a4158d
+static void action_format_volume_callback          (GtkAction *action,
9a4158d
+						    gpointer   data);
9a4158d
 
9a4158d
 /* location popup-related actions */
9a4158d
 
a95948e
@@ -5796,6 +5798,43 @@
9a4158d
 	nautilus_file_list_free (selection);
9a4158d
 }
9a4158d
 
9a4158d
+static void 
9a4158d
+action_format_volume_callback (GtkAction *action,
9a4158d
+			       gpointer   data)
9a4158d
+{
9a4158d
+	NautilusFile *file;
9a4158d
+	GList *selection, *l;
9a4158d
+	GnomeVFSDrive *drive;
a95948e
+        char *device_path;
a95948e
+        char *cmdline;
9a4158d
+	FMDirectoryView *view;
9a4158d
+
9a4158d
+        view = FM_DIRECTORY_VIEW (data);
9a4158d
+	
9a4158d
+	selection = fm_directory_view_get_selection (view);
9a4158d
+	for (l = selection; l != NULL; l = l->next) {
9a4158d
+		file = NAUTILUS_FILE (l->data);
9a4158d
+
9a4158d
+		if (nautilus_file_has_drive (file)) {
9a4158d
+			drive = nautilus_file_get_drive (file);
a95948e
+			device_path = gnome_vfs_drive_get_device_path (drive);			
a95948e
+
9a4158d
+			if (gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_FLOPPY) {
a95948e
+
a95948e
+
a95948e
+				cmdline = g_strconcat ("gfloppy ", device_path, NULL);
a95948e
+			}
a95948e
+			else {
a95948e
+				cmdline = g_strconcat ("userformat ", device_path, NULL);
9a4158d
+			}
a95948e
+			g_spawn_command_line_async (cmdline, NULL);
a95948e
+                        g_free (cmdline);
a95948e
+			g_free (device_path);
9a4158d
+		}
9a4158d
+	}	
9a4158d
+	nautilus_file_list_free (selection);
9a4158d
+}
9a4158d
+
9a4158d
 static void
9a4158d
 action_eject_volume_callback (GtkAction *action,
9a4158d
 			      gpointer data)
a95948e
@@ -6218,6 +6257,10 @@
9a4158d
     N_("_Eject"), NULL,                /* label, accelerator */
9a4158d
     N_("Eject the selected volume"),                   /* tooltip */ 
9a4158d
     G_CALLBACK (action_eject_volume_callback) },
9a4158d
+  { "Format Volume", NULL,                  /* name, stock id */
9a4158d
+    N_("_Format"), NULL,                /* label, accelerator */
9a4158d
+    N_("Format the selected volume"),                   /* tooltip */ 
9a4158d
+    G_CALLBACK (action_format_volume_callback) },
9a4158d
   { "OpenCloseParent", NULL,                  /* name, stock id */
9a4158d
     N_("Open File and Close window"), "<alt><shift>Down",                /* label, accelerator */
9a4158d
     NULL,                   /* tooltip */ 
a95948e
@@ -6457,7 +6500,8 @@
9a4158d
 			  gboolean     *show_mount,
9a4158d
 			  gboolean     *show_unmount,
9a4158d
 			  gboolean     *show_eject,
9a4158d
-			  gboolean     *show_connect)
9a4158d
+			  gboolean     *show_connect,
9a4158d
+                          gboolean     *show_format)
9a4158d
 {
9a4158d
 	GnomeVFSVolume *volume;
9a4158d
 	GnomeVFSDrive *drive;
a95948e
@@ -6467,6 +6511,7 @@
9a4158d
 	*show_unmount = FALSE;
9a4158d
 	*show_eject = FALSE;
9a4158d
 	*show_connect = FALSE;
9a4158d
+	*show_format = FALSE;
9a4158d
 
9a4158d
 	if (nautilus_file_has_volume (file)) {
9a4158d
 		*show_unmount = TRUE;
a95948e
@@ -6476,11 +6521,18 @@
a95948e
 	} else if (nautilus_file_has_drive (file)) {
a95948e
 		drive = nautilus_file_get_drive (file);
a95948e
 		*show_eject = eject_for_type (gnome_vfs_drive_get_device_type (drive));
a95948e
+                if ((gnome_vfs_drive_get_device_type (drive) == GNOME_VFS_DEVICE_TYPE_FLOPPY &&
a95948e
+		    g_find_program_in_path ("gfloppy")) ||
a95948e
+		    g_find_program_in_path ("userformat")) {
a95948e
+			*show_format = TRUE;
a95948e
+		}
a95948e
 		if (gnome_vfs_drive_is_mounted (drive)) {
a95948e
 			*show_unmount = TRUE;
a95948e
+			*show_format = FALSE;
9a4158d
 		} else {
9a4158d
 			*show_mount = TRUE;
9a4158d
 		}
9a4158d
+
9a4158d
 	} else if (nautilus_file_is_nautilus_link (file)) {
9a4158d
 		uri = nautilus_file_get_activation_uri (file);
9a4158d
 		if (uri != NULL &&
a95948e
@@ -6507,32 +6559,38 @@
9a4158d
 	gboolean show_unmount;
9a4158d
 	gboolean show_eject;
9a4158d
 	gboolean show_connect;
9a4158d
+	gboolean show_format;
9a4158d
 	GtkAction *action;
9a4158d
 
9a4158d
 	show_mount = (selection != NULL);
9a4158d
 	show_unmount = (selection != NULL);
9a4158d
 	show_eject = (selection != NULL);
9a4158d
 	show_connect = (selection != NULL && selection_count == 1);
9a4158d
+	show_format = (selection != NULL && selection_count == 1);
9a4158d
 
9a4158d
 	for (l = selection; l != NULL && (show_mount || show_unmount
9a4158d
-					  || show_eject || show_connect);
9a4158d
+					  || show_eject || show_connect
9a4158d
+                                          || show_format);
9a4158d
 	     l = l->next) {
9a4158d
 		gboolean show_mount_one;
9a4158d
 		gboolean show_unmount_one;
9a4158d
 		gboolean show_eject_one;
9a4158d
 		gboolean show_connect_one;
9a4158d
+		gboolean show_format_one;
9a4158d
 
9a4158d
 		file = NAUTILUS_FILE (l->data);
9a4158d
 		file_should_show_foreach (file,
9a4158d
 					  &show_mount_one,
9a4158d
 					  &show_unmount_one,
9a4158d
 					  &show_eject_one,
9a4158d
-					  &show_connect_one);
9a4158d
+					  &show_connect_one,
9a4158d
+                                          &show_format_one);
9a4158d
 
9a4158d
 		show_mount &= show_mount_one;
9a4158d
 		show_unmount &= show_unmount_one;
9a4158d
 		show_eject &= show_eject_one;
9a4158d
 		show_connect &= show_connect_one;
9a4158d
+		show_format &= show_format_one;
9a4158d
 	}
9a4158d
 
9a4158d
 	/* We don't want both eject and unmount, since eject
a95948e
@@ -6556,6 +6614,10 @@
9a4158d
 	action = gtk_action_group_get_action (view->details->dir_action_group,
9a4158d
 					      FM_ACTION_EJECT_VOLUME);
9a4158d
 	gtk_action_set_visible (action, show_eject);
9a4158d
+	
9a4158d
+	action = gtk_action_group_get_action (view->details->dir_action_group,
9a4158d
+					      FM_ACTION_FORMAT_VOLUME);
9a4158d
+	gtk_action_set_visible (action, show_format);
9a4158d
 }
9a4158d
 
9a4158d
 static void
9a4158d
--- nautilus-2.12.1/src/file-manager/nautilus-directory-view-ui.xml.format	2005-10-03 03:45:27.000000000 -0400
a95948e
+++ nautilus-2.12.1/src/file-manager/nautilus-directory-view-ui.xml	2005-10-27 14:35:29.000000000 -0400
9a4158d
@@ -147,6 +147,7 @@
9a4158d
 		<menuitem name="Mount Volume" action="Mount Volume"/>
9a4158d
                 <menuitem name="Unmount Volume" action="Unmount Volume"/>
9a4158d
                 <menuitem name="Eject Volume" action="Eject Volume"/>
9a4158d
+                <menuitem name="Format Volume" action="Format Volume"/>
9a4158d
         </placeholder>
9a4158d
         <menuitem name="Connect To Server Link" action="Connect To Server Link"/>
9a4158d
 </popup>