summaryrefslogtreecommitdiff
path: root/src/file-manager/fm-directory-view.c
diff options
context:
space:
mode:
authorAlexander Larsson <alexl@redhat.com>2003-11-05 16:20:01 +0000
committerAlexander Larsson <alexl@src.gnome.org>2003-11-05 16:20:01 +0000
commit3613a86b2039395b3ee229c901a00e35b85865b6 (patch)
treecdbbfdc443182435f71d4c230400c9bfb084d7e2 /src/file-manager/fm-directory-view.c
parentfb27d9086b6448e10a535c6cc4a52ee919096dc5 (diff)
downloadnautilus-3613a86b2039395b3ee229c901a00e35b85865b6.tar.gz
Require new gnome-vfs
2003-11-05 Alexander Larsson <alexl@redhat.com> * configure.in: Require new gnome-vfs * components/tree/nautilus-tree-view.c: * libnautilus-private/nautilus-desktop-link-monitor.c: * libnautilus-private/nautilus-desktop-link.[ch]: * libnautilus-private/nautilus-monitor.c: * libnautilus-private/nautilus-trash-directory.c: * libnautilus-private/nautilus-trash-monitor.[ch]: * src/nautilus-application.c: Use gnome-vfs-volume-manager instead of nautilus-volume-manager.c * libnautilus-private/nautilus-desktop-icon-file.c: Set the volume on the nautilusfile * libnautilus-private/nautilus-directory-async.c: Load volume info from link * libnautilus-private/nautilus-file-attributes.h: * libnautilus-private/nautilus-mime-actions.c: Add new VOLUMES attribute * libnautilus-private/nautilus-file-private.h: Add has_volume and has_drive to NautilusFile * libnautilus-private/nautilus-file.[ch]: Add has_volume and has_drive to NautilusFile Volumes/drives are sorted separately * libnautilus-private/nautilus-link-desktop-file.[ch]: * libnautilus-private/nautilus-link.[ch]: Read drive and volume id from links * src/file-manager/fm-desktop-icon-view.c: * src/file-manager/nautilus-desktop-icon-view-ui.xml: Remove volume ops. Remove disks menu * src/file-manager/fm-directory-view.c: * src/file-manager/nautilus-directory-view-ui.xml: Implement volume ops using gnome-vfs * src/file-manager/fm-properties-window.c: Handle drives/volumes * src/nautilus-window.c: Make a nicer title for some specific locations * libnautilus-private/nautilus-volume-monitor.[ch]: * libnautilus-private/Makefile.am remove this old crap
Diffstat (limited to 'src/file-manager/fm-directory-view.c')
-rw-r--r--src/file-manager/fm-directory-view.c201
1 files changed, 201 insertions, 0 deletions
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 30f95220f..2f0ce241e 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -132,6 +132,11 @@
#define FM_DIRECTORY_VIEW_COMMAND_COPY_FILES "/commands/Copy Files"
#define FM_DIRECTORY_VIEW_COMMAND_PASTE_FILES "/commands/Paste Files"
#define FM_DIRECTORY_VIEW_COMMAND_PASTE_FILES_INTO "/commands/Paste Files Into"
+#define FM_DIRECTORY_VIEW_COMMAND_MOUNT_VOLUME_CONDITIONAL "/commands/Mount Volume Conditional"
+#define FM_DIRECTORY_VIEW_COMMAND_UNMOUNT_VOLUME_CONDITIONAL "/commands/Unmount Volume Conditional"
+#define FM_DIRECTORY_VIEW_COMMAND_PROTECT_VOLUME_CONDITIONAL "/commands/Protect Conditional"
+#define FM_DIRECTORY_VIEW_COMMAND_FORMAT_VOLUME_CONDITIONAL "/commands/Format Conditional"
+#define FM_DIRECTORY_VIEW_COMMAND_MEDIA_PROPERTIES_VOLUME_CONDITIONAL "/commands/Media Properties Conditional"
#define FM_DIRECTORY_VIEW_MENU_PATH_OPEN_WITH "/menu/File/Open Placeholder/Open With"
#define FM_DIRECTORY_VIEW_MENU_PATH_SCRIPTS "/menu/File/Open Placeholder/Scripts"
@@ -4657,6 +4662,128 @@ rename_file_callback (BonoboUIComponent *component, gpointer callback_data, cons
}
static void
+drive_mounted_callback (gboolean succeeded,
+ char *error,
+ char *detailed_error,
+ gpointer data)
+{
+ if (!succeeded) {
+ eel_show_error_dialog_with_details (error, _("Mount Error"), detailed_error, NULL);
+ }
+}
+
+
+static void
+mount_volume_callback (BonoboUIComponent *component,
+ gpointer data,
+ const char *verb)
+{
+ NautilusFile *file;
+ GList *selection;
+ GnomeVFSDrive *drive;
+ FMDirectoryView *view;
+
+ view = FM_DIRECTORY_VIEW (data);
+
+ selection = fm_directory_view_get_selection (view);
+
+ if (!eel_g_list_exactly_one_item (selection)) {
+ nautilus_file_list_free (selection);
+ return;
+ }
+
+ file = NAUTILUS_FILE (selection->data);
+
+ if (nautilus_file_has_drive (file)) {
+ drive = nautilus_file_get_drive (file);
+ if (drive != NULL) {
+ gnome_vfs_drive_mount (drive, drive_mounted_callback, NULL);
+ }
+ }
+
+ nautilus_file_list_free (selection);
+}
+
+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_or_drive_unmounted_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, _("Unmount Error"), detailed_error, NULL);
+ } else {
+ eel_show_error_dialog_with_details (error, _("Eject Error"), detailed_error, NULL);
+ }
+ }
+}
+
+
+static void
+unmount_volume_callback (BonoboUIComponent *component,
+ gpointer data,
+ const char *verb)
+{
+ NautilusFile *file;
+ GList *selection;
+ GnomeVFSDrive *drive;
+ GnomeVFSVolume *volume;
+ FMDirectoryView *view;
+
+ view = FM_DIRECTORY_VIEW (data);
+
+ selection = fm_directory_view_get_selection (view);
+
+ if (!eel_g_list_exactly_one_item (selection)) {
+ nautilus_file_list_free (selection);
+ return;
+ }
+
+ file = NAUTILUS_FILE (selection->data);
+
+ if (nautilus_file_has_volume (file)) {
+ volume = nautilus_file_get_volume (file);
+ if (volume != NULL) {
+ if (eject_for_type (gnome_vfs_volume_get_device_type (volume))) {
+ gnome_vfs_volume_eject (volume, volume_or_drive_unmounted_callback, GINT_TO_POINTER (TRUE));
+ } else {
+ gnome_vfs_volume_unmount (volume, volume_or_drive_unmounted_callback, GINT_TO_POINTER (FALSE));
+ }
+ }
+ } else if (nautilus_file_has_drive (file)) {
+ drive = nautilus_file_get_drive (file);
+ if (drive != NULL) {
+ if (eject_for_type (gnome_vfs_drive_get_device_type (drive))) {
+ gnome_vfs_drive_eject (drive, volume_or_drive_unmounted_callback, GINT_TO_POINTER (TRUE));
+ } else {
+ gnome_vfs_drive_unmount (drive, volume_or_drive_unmounted_callback, GINT_TO_POINTER (FALSE));
+ }
+ }
+ }
+
+ nautilus_file_list_free (selection);
+}
+
+
+static void
real_merge_menus (FMDirectoryView *view)
{
BonoboUIVerb verbs [] = {
@@ -4683,6 +4810,8 @@ real_merge_menus (FMDirectoryView *view)
BONOBO_UI_VERB ("Select Pattern", bonobo_menu_select_pattern_callback),
BONOBO_UI_VERB ("Properties", open_properties_window_callback),
BONOBO_UI_VERB ("Trash", trash_callback),
+ BONOBO_UI_VERB ("Mount Volume Conditional", mount_volume_callback),
+ BONOBO_UI_VERB ("Unmount Volume Conditional", unmount_volume_callback),
BONOBO_UI_VERB_END
};
@@ -4773,6 +4902,74 @@ file_list_all_can_use_components (GList *file_list)
}
return TRUE;
}
+
+static void
+real_update_menus_volumes (FMDirectoryView *view,
+ GList *selection,
+ gint selection_count)
+{
+ NautilusFile *file;
+ gboolean show_mount;
+ gboolean show_unmount;
+ gboolean show_properties;
+ gboolean show_format;
+ gboolean show_protect;
+ gboolean unmount_is_eject;
+ GnomeVFSVolume *volume;
+ GnomeVFSDrive *drive;
+
+ show_mount = FALSE;
+ show_unmount = FALSE;
+ unmount_is_eject = FALSE;
+ show_properties = FALSE;
+ show_format = FALSE;
+ show_protect = FALSE;
+
+ if (selection_count == 1) {
+ file = NAUTILUS_FILE (selection->data);
+
+ if (nautilus_file_has_volume (file)) {
+ show_unmount = TRUE;
+
+ volume = nautilus_file_get_volume (file);
+ unmount_is_eject = eject_for_type (gnome_vfs_volume_get_device_type (volume));
+ } else if (nautilus_file_has_drive (file)) {
+ drive = nautilus_file_get_drive (file);
+ volume = gnome_vfs_drive_get_mounted_volume (drive);
+ if (volume == NULL) {
+ show_mount = TRUE;
+ } else {
+ show_unmount = TRUE;
+ unmount_is_eject = eject_for_type (gnome_vfs_drive_get_device_type (drive));
+ }
+
+ gnome_vfs_volume_unref (volume);
+ }
+ }
+
+ nautilus_bonobo_set_hidden (view->details->ui,
+ FM_DIRECTORY_VIEW_COMMAND_MOUNT_VOLUME_CONDITIONAL,
+ !show_mount);
+ nautilus_bonobo_set_hidden (view->details->ui,
+ FM_DIRECTORY_VIEW_COMMAND_UNMOUNT_VOLUME_CONDITIONAL,
+ !show_unmount);
+ if (show_unmount) {
+ nautilus_bonobo_set_label (view->details->ui,
+ FM_DIRECTORY_VIEW_COMMAND_UNMOUNT_VOLUME_CONDITIONAL,
+ unmount_is_eject? _("E_ject"):_("_Unmount Volume"));
+ }
+
+ nautilus_bonobo_set_hidden (view->details->ui,
+ FM_DIRECTORY_VIEW_COMMAND_PROTECT_VOLUME_CONDITIONAL,
+ !show_protect);
+ nautilus_bonobo_set_hidden (view->details->ui,
+ FM_DIRECTORY_VIEW_COMMAND_FORMAT_VOLUME_CONDITIONAL,
+ !show_format);
+ nautilus_bonobo_set_hidden (view->details->ui,
+ FM_DIRECTORY_VIEW_COMMAND_MEDIA_PROPERTIES_VOLUME_CONDITIONAL,
+ !show_properties);
+}
+
static void
real_update_menus (FMDirectoryView *view)
{
@@ -5003,6 +5200,10 @@ real_update_menus (FMDirectoryView *view)
FM_DIRECTORY_VIEW_COMMAND_EDIT_LAUNCHER,
selection_count == 1);
+
+
+ real_update_menus_volumes (view, selection, selection_count);
+
bonobo_ui_component_thaw (view->details->ui, NULL);
nautilus_file_list_free (selection);