Added delete calls that set up a gnome-vfs delete operation.

2000-05-30  Pavel Cisler  <pavel@eazel.com>

	* src/file-manager/dfos-xfer.h:
	* src/file-manager/dfos-xfer.c: (handle_xfer_ok),
	(fs_delete):
	Added delete calls that set up a gnome-vfs delete operation.

	* src/file-manager/dfos-xfer.c:
	(fs_xfer), (fs_move_to_trash), (fs_empty_trash):
	Changed to use new xfer options making it a little
	clearer which copy engine operation gets to run.

	* src/file-manager/dfos-xfer.c:
	(fs_xfer), (fs_move_to_trash):
	Fixed a leak of the item_names list.

	* src/file-manager/dfos-xfer.c:
	(fs_new_folder):
	Changed to use "untitled folder".

	* src/file-manager/fm-directory-view.c:
	(bonobo_menu_move_to_trash_callback),
	(fm_directory_can_move_to_trash),
	(fm_directory_view_trash_or_delete_selection), (trash_callback),
	(compute_menu_item_info), (reset_bonobo_trash_delete_menu),
	(fm_directory_view_real_merge_menus),
	(fm_directory_view_real_update_menus),
	(fm_directory_view_get_context_menu_index):
	Add logic that picks the Delete/Move To Trash menu items depending
	on whether selected items can be moved to Trash or not. Added code
	that decides if items can be moved to Trash from a given folder.

	* src/file-manager/dfos-corba.c: (convert_options):
	Disabled some dead code.
This commit is contained in:
Pavel Cisler 2000-05-31 03:49:34 +00:00 committed by Pavel Cisler
parent f17cf9f477
commit 4412765d7f
9 changed files with 307 additions and 119 deletions

View file

@ -1,3 +1,38 @@
2000-05-30 Pavel Cisler <pavel@eazel.com>
* src/file-manager/dfos-xfer.h:
* src/file-manager/dfos-xfer.c: (handle_xfer_ok),
(fs_delete):
Added delete calls that set up a gnome-vfs delete operation.
* src/file-manager/dfos-xfer.c:
(fs_xfer), (fs_move_to_trash), (fs_empty_trash):
Changed to use new xfer options making it a little
clearer which copy engine operation gets to run.
* src/file-manager/dfos-xfer.c:
(fs_xfer), (fs_move_to_trash):
Fixed a leak of the item_names list.
* src/file-manager/dfos-xfer.c:
(fs_new_folder):
Changed to use "untitled folder".
* src/file-manager/fm-directory-view.c:
(bonobo_menu_move_to_trash_callback),
(fm_directory_can_move_to_trash),
(fm_directory_view_trash_or_delete_selection), (trash_callback),
(compute_menu_item_info), (reset_bonobo_trash_delete_menu),
(fm_directory_view_real_merge_menus),
(fm_directory_view_real_update_menus),
(fm_directory_view_get_context_menu_index):
Add logic that picks the Delete/Move To Trash menu items depending
on whether selected items can be moved to Trash or not. Added code
that decides if items can be moved to Trash from a given folder.
* src/file-manager/dfos-corba.c: (convert_options):
Disabled some dead code.
2000-05-30 Eskil Heyn Olsen <eskil@eazel.com>
* components/services/install/command-line/eazel-alt-install.c:

View file

@ -38,7 +38,8 @@ typedef enum {
XFER_MOVE,
XFER_COPY,
XFER_MOVE_TO_TRASH,
XFER_EMPTY_TRASH
XFER_EMPTY_TRASH,
XFER_DELETE
} XferKind;
@ -158,11 +159,13 @@ handle_xfer_ok (const GnomeVFSXferProgressInfo *progress_info,
(xfer_info->progress_dialog),
progress_info->source_name,
progress_info->target_name,
xfer_info->kind != XFER_MOVE_TO_TRASH &&
xfer_info->kind != XFER_EMPTY_TRASH
xfer_info->kind != XFER_MOVE_TO_TRASH
&& xfer_info->kind != XFER_EMPTY_TRASH
&& xfer_info->kind != XFER_DELETE
? _("From:") : "",
xfer_info->kind != XFER_MOVE_TO_TRASH &&
xfer_info->kind != XFER_EMPTY_TRASH
xfer_info->kind != XFER_MOVE_TO_TRASH
&& xfer_info->kind != XFER_EMPTY_TRASH
&& xfer_info->kind != XFER_DELETE
? _("To:") : NULL,
progress_info->file_index,
progress_info->file_size);
@ -566,6 +569,7 @@ fs_xfer (const GList *item_uris,
gnome_vfs_uri_unref (trash_dir_uri);
gnome_vfs_uri_unref (target_dir_uri);
gnome_vfs_uri_unref (source_dir_uri);
nautilus_g_list_free_deep (item_names);
g_free (source_dir);
}
@ -619,10 +623,10 @@ fs_new_folder (GtkWidget *parent_view, const char *parent_dir,
state->done_callback = done_callback;
state->data = data;
dest_names = g_list_append (NULL, "New Folder");
dest_names = g_list_append (NULL, "untitled folder");
gnome_vfs_async_xfer (&state->handle, NULL, NULL,
parent_dir, dest_names,
GNOME_VFS_XFER_USE_UNIQUE_NAMES,
GNOME_VFS_XFER_NEW_UNIQUE_DIRECTORY,
GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_QUERY,
&new_folder_xfer_callback, state,
@ -726,6 +730,43 @@ fs_move_to_trash (const GList *item_uris, GtkWidget *parent_view)
gnome_vfs_uri_unref (trash_dir_uri);
gnome_vfs_uri_unref (source_dir_uri);
nautilus_g_list_free_deep (item_names);
g_free (source_dir);
}
void
fs_delete (const GList *item_uris, GtkWidget *parent_view)
{
GnomeVFSURI *source_dir_uri;
char *source_dir;
GList *item_names;
XferInfo *xfer_info;
item_names = NULL;
source_dir_uri = NULL;
get_parent_make_name_list (item_uris, &source_dir_uri, &item_names);
source_dir = gnome_vfs_uri_to_string (source_dir_uri, GNOME_VFS_URI_HIDE_NONE);
xfer_info = g_new (XferInfo, 1);
xfer_info->parent_view = parent_view;
xfer_info->progress_dialog = NULL;
xfer_info->show_progress_dialog = TRUE;
xfer_info->operation_name = _("Deleting");
xfer_info->preparation_name =_("Preparing to Delete...");
xfer_info->error_mode = GNOME_VFS_XFER_ERROR_MODE_QUERY;
xfer_info->overwrite_mode = GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE;
xfer_info->kind = XFER_DELETE;
gnome_vfs_async_xfer (&xfer_info->handle, source_dir, item_names,
NULL, NULL,
GNOME_VFS_XFER_DELETE_ITEMS | GNOME_VFS_XFER_RECURSIVE,
GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
&update_xfer_callback, xfer_info,
&sync_xfer_callback, NULL);
gnome_vfs_uri_unref (source_dir_uri);
nautilus_g_list_free_deep (item_names);
g_free (source_dir);
}
@ -767,7 +808,7 @@ fs_empty_trash (GtkWidget *parent_view)
gnome_vfs_async_xfer (&xfer_info->handle, NULL, trash_dir_list,
NULL, NULL,
GNOME_VFS_XFER_REMOVESOURCE,
GNOME_VFS_XFER_EMPTY_DIRECTORIES,
GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
&update_xfer_callback, xfer_info,

View file

@ -27,28 +27,29 @@
#include <libgnomevfs/gnome-vfs.h>
#include "dfos.h"
void dfos_xfer (DFOS *dfos,
const gchar *source_directory_uri,
GList *source_file_name_list,
const gchar *target_directory_uri,
GList *target_file_name_list,
GnomeVFSXferOptions options,
GnomeVFSXferErrorMode error_mode,
GnomeVFSXferOverwriteMode overwrite_mode);
void dfos_xfer (DFOS *dfos,
const gchar *source_directory_uri,
GList *source_file_name_list,
const gchar *target_directory_uri,
GList *target_file_name_list,
GnomeVFSXferOptions options,
GnomeVFSXferErrorMode error_mode,
GnomeVFSXferOverwriteMode overwrite_mode);
void fs_xfer (const GList *item_uris,
const GdkPoint *target_item_points,
const char *target_dir,
int copy_action,
GtkWidget *parent_view);
void fs_xfer (const GList *item_uris,
const GdkPoint *target_item_points,
const char *target_dir,
int copy_action,
GtkWidget *parent_view);
void fs_move_to_trash (const GList *item_uris,
GtkWidget *parent_view);
void fs_move_to_trash (const GList *item_uris,
GtkWidget *parent_view);
void fs_empty_trash (GtkWidget *parent_view);
void fs_new_folder (GtkWidget *parent_view,
void fs_empty_trash (GtkWidget *parent_view);
void fs_new_folder (GtkWidget *parent_view,
const char *parent_dir,
void (*done_callback)(const char *new_folder_uri, gpointer data),
gpointer data);
void fs_delete (const GList *item_uris, GtkWidget *parent_view);
#endif /* DFOS_XFER_H */

View file

@ -38,7 +38,8 @@ typedef enum {
XFER_MOVE,
XFER_COPY,
XFER_MOVE_TO_TRASH,
XFER_EMPTY_TRASH
XFER_EMPTY_TRASH,
XFER_DELETE
} XferKind;
@ -158,11 +159,13 @@ handle_xfer_ok (const GnomeVFSXferProgressInfo *progress_info,
(xfer_info->progress_dialog),
progress_info->source_name,
progress_info->target_name,
xfer_info->kind != XFER_MOVE_TO_TRASH &&
xfer_info->kind != XFER_EMPTY_TRASH
xfer_info->kind != XFER_MOVE_TO_TRASH
&& xfer_info->kind != XFER_EMPTY_TRASH
&& xfer_info->kind != XFER_DELETE
? _("From:") : "",
xfer_info->kind != XFER_MOVE_TO_TRASH &&
xfer_info->kind != XFER_EMPTY_TRASH
xfer_info->kind != XFER_MOVE_TO_TRASH
&& xfer_info->kind != XFER_EMPTY_TRASH
&& xfer_info->kind != XFER_DELETE
? _("To:") : NULL,
progress_info->file_index,
progress_info->file_size);
@ -566,6 +569,7 @@ fs_xfer (const GList *item_uris,
gnome_vfs_uri_unref (trash_dir_uri);
gnome_vfs_uri_unref (target_dir_uri);
gnome_vfs_uri_unref (source_dir_uri);
nautilus_g_list_free_deep (item_names);
g_free (source_dir);
}
@ -619,10 +623,10 @@ fs_new_folder (GtkWidget *parent_view, const char *parent_dir,
state->done_callback = done_callback;
state->data = data;
dest_names = g_list_append (NULL, "New Folder");
dest_names = g_list_append (NULL, "untitled folder");
gnome_vfs_async_xfer (&state->handle, NULL, NULL,
parent_dir, dest_names,
GNOME_VFS_XFER_USE_UNIQUE_NAMES,
GNOME_VFS_XFER_NEW_UNIQUE_DIRECTORY,
GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_QUERY,
&new_folder_xfer_callback, state,
@ -726,6 +730,43 @@ fs_move_to_trash (const GList *item_uris, GtkWidget *parent_view)
gnome_vfs_uri_unref (trash_dir_uri);
gnome_vfs_uri_unref (source_dir_uri);
nautilus_g_list_free_deep (item_names);
g_free (source_dir);
}
void
fs_delete (const GList *item_uris, GtkWidget *parent_view)
{
GnomeVFSURI *source_dir_uri;
char *source_dir;
GList *item_names;
XferInfo *xfer_info;
item_names = NULL;
source_dir_uri = NULL;
get_parent_make_name_list (item_uris, &source_dir_uri, &item_names);
source_dir = gnome_vfs_uri_to_string (source_dir_uri, GNOME_VFS_URI_HIDE_NONE);
xfer_info = g_new (XferInfo, 1);
xfer_info->parent_view = parent_view;
xfer_info->progress_dialog = NULL;
xfer_info->show_progress_dialog = TRUE;
xfer_info->operation_name = _("Deleting");
xfer_info->preparation_name =_("Preparing to Delete...");
xfer_info->error_mode = GNOME_VFS_XFER_ERROR_MODE_QUERY;
xfer_info->overwrite_mode = GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE;
xfer_info->kind = XFER_DELETE;
gnome_vfs_async_xfer (&xfer_info->handle, source_dir, item_names,
NULL, NULL,
GNOME_VFS_XFER_DELETE_ITEMS | GNOME_VFS_XFER_RECURSIVE,
GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
&update_xfer_callback, xfer_info,
&sync_xfer_callback, NULL);
gnome_vfs_uri_unref (source_dir_uri);
nautilus_g_list_free_deep (item_names);
g_free (source_dir);
}
@ -767,7 +808,7 @@ fs_empty_trash (GtkWidget *parent_view)
gnome_vfs_async_xfer (&xfer_info->handle, NULL, trash_dir_list,
NULL, NULL,
GNOME_VFS_XFER_REMOVESOURCE,
GNOME_VFS_XFER_EMPTY_DIRECTORIES,
GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
&update_xfer_callback, xfer_info,

View file

@ -27,28 +27,29 @@
#include <libgnomevfs/gnome-vfs.h>
#include "dfos.h"
void dfos_xfer (DFOS *dfos,
const gchar *source_directory_uri,
GList *source_file_name_list,
const gchar *target_directory_uri,
GList *target_file_name_list,
GnomeVFSXferOptions options,
GnomeVFSXferErrorMode error_mode,
GnomeVFSXferOverwriteMode overwrite_mode);
void dfos_xfer (DFOS *dfos,
const gchar *source_directory_uri,
GList *source_file_name_list,
const gchar *target_directory_uri,
GList *target_file_name_list,
GnomeVFSXferOptions options,
GnomeVFSXferErrorMode error_mode,
GnomeVFSXferOverwriteMode overwrite_mode);
void fs_xfer (const GList *item_uris,
const GdkPoint *target_item_points,
const char *target_dir,
int copy_action,
GtkWidget *parent_view);
void fs_xfer (const GList *item_uris,
const GdkPoint *target_item_points,
const char *target_dir,
int copy_action,
GtkWidget *parent_view);
void fs_move_to_trash (const GList *item_uris,
GtkWidget *parent_view);
void fs_move_to_trash (const GList *item_uris,
GtkWidget *parent_view);
void fs_empty_trash (GtkWidget *parent_view);
void fs_new_folder (GtkWidget *parent_view,
void fs_empty_trash (GtkWidget *parent_view);
void fs_new_folder (GtkWidget *parent_view,
const char *parent_dir,
void (*done_callback)(const char *new_folder_uri, gpointer data),
gpointer data);
void fs_delete (const GList *item_uris, GtkWidget *parent_view);
#endif /* DFOS_XFER_H */

View file

@ -72,6 +72,7 @@ convert_options (GNOME_Desktop_FileOperationService_XferOptions options)
returned_options = 0;
#if 0
if (options & GNOME_Desktop_FileOperationService_XferOptionPreserve)
returned_options |= GNOME_VFS_XFER_PRESERVE;
if (options & GNOME_Desktop_FileOperationService_XferOptionFollowLinks)
@ -90,6 +91,7 @@ convert_options (GNOME_Desktop_FileOperationService_XferOptions options)
returned_options |= GNOME_VFS_XFER_UPDATEMODE;
if (options & GNOME_Desktop_FileOperationService_XferOptionRemoveSource)
returned_options |= GNOME_VFS_XFER_REMOVESOURCE;
#endif
return returned_options;
}

View file

@ -38,7 +38,8 @@ typedef enum {
XFER_MOVE,
XFER_COPY,
XFER_MOVE_TO_TRASH,
XFER_EMPTY_TRASH
XFER_EMPTY_TRASH,
XFER_DELETE
} XferKind;
@ -158,11 +159,13 @@ handle_xfer_ok (const GnomeVFSXferProgressInfo *progress_info,
(xfer_info->progress_dialog),
progress_info->source_name,
progress_info->target_name,
xfer_info->kind != XFER_MOVE_TO_TRASH &&
xfer_info->kind != XFER_EMPTY_TRASH
xfer_info->kind != XFER_MOVE_TO_TRASH
&& xfer_info->kind != XFER_EMPTY_TRASH
&& xfer_info->kind != XFER_DELETE
? _("From:") : "",
xfer_info->kind != XFER_MOVE_TO_TRASH &&
xfer_info->kind != XFER_EMPTY_TRASH
xfer_info->kind != XFER_MOVE_TO_TRASH
&& xfer_info->kind != XFER_EMPTY_TRASH
&& xfer_info->kind != XFER_DELETE
? _("To:") : NULL,
progress_info->file_index,
progress_info->file_size);
@ -566,6 +569,7 @@ fs_xfer (const GList *item_uris,
gnome_vfs_uri_unref (trash_dir_uri);
gnome_vfs_uri_unref (target_dir_uri);
gnome_vfs_uri_unref (source_dir_uri);
nautilus_g_list_free_deep (item_names);
g_free (source_dir);
}
@ -619,10 +623,10 @@ fs_new_folder (GtkWidget *parent_view, const char *parent_dir,
state->done_callback = done_callback;
state->data = data;
dest_names = g_list_append (NULL, "New Folder");
dest_names = g_list_append (NULL, "untitled folder");
gnome_vfs_async_xfer (&state->handle, NULL, NULL,
parent_dir, dest_names,
GNOME_VFS_XFER_USE_UNIQUE_NAMES,
GNOME_VFS_XFER_NEW_UNIQUE_DIRECTORY,
GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_QUERY,
&new_folder_xfer_callback, state,
@ -726,6 +730,43 @@ fs_move_to_trash (const GList *item_uris, GtkWidget *parent_view)
gnome_vfs_uri_unref (trash_dir_uri);
gnome_vfs_uri_unref (source_dir_uri);
nautilus_g_list_free_deep (item_names);
g_free (source_dir);
}
void
fs_delete (const GList *item_uris, GtkWidget *parent_view)
{
GnomeVFSURI *source_dir_uri;
char *source_dir;
GList *item_names;
XferInfo *xfer_info;
item_names = NULL;
source_dir_uri = NULL;
get_parent_make_name_list (item_uris, &source_dir_uri, &item_names);
source_dir = gnome_vfs_uri_to_string (source_dir_uri, GNOME_VFS_URI_HIDE_NONE);
xfer_info = g_new (XferInfo, 1);
xfer_info->parent_view = parent_view;
xfer_info->progress_dialog = NULL;
xfer_info->show_progress_dialog = TRUE;
xfer_info->operation_name = _("Deleting");
xfer_info->preparation_name =_("Preparing to Delete...");
xfer_info->error_mode = GNOME_VFS_XFER_ERROR_MODE_QUERY;
xfer_info->overwrite_mode = GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE;
xfer_info->kind = XFER_DELETE;
gnome_vfs_async_xfer (&xfer_info->handle, source_dir, item_names,
NULL, NULL,
GNOME_VFS_XFER_DELETE_ITEMS | GNOME_VFS_XFER_RECURSIVE,
GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
&update_xfer_callback, xfer_info,
&sync_xfer_callback, NULL);
gnome_vfs_uri_unref (source_dir_uri);
nautilus_g_list_free_deep (item_names);
g_free (source_dir);
}
@ -767,7 +808,7 @@ fs_empty_trash (GtkWidget *parent_view)
gnome_vfs_async_xfer (&xfer_info->handle, NULL, trash_dir_list,
NULL, NULL,
GNOME_VFS_XFER_REMOVESOURCE,
GNOME_VFS_XFER_EMPTY_DIRECTORIES,
GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
&update_xfer_callback, xfer_info,

View file

@ -27,28 +27,29 @@
#include <libgnomevfs/gnome-vfs.h>
#include "dfos.h"
void dfos_xfer (DFOS *dfos,
const gchar *source_directory_uri,
GList *source_file_name_list,
const gchar *target_directory_uri,
GList *target_file_name_list,
GnomeVFSXferOptions options,
GnomeVFSXferErrorMode error_mode,
GnomeVFSXferOverwriteMode overwrite_mode);
void dfos_xfer (DFOS *dfos,
const gchar *source_directory_uri,
GList *source_file_name_list,
const gchar *target_directory_uri,
GList *target_file_name_list,
GnomeVFSXferOptions options,
GnomeVFSXferErrorMode error_mode,
GnomeVFSXferOverwriteMode overwrite_mode);
void fs_xfer (const GList *item_uris,
const GdkPoint *target_item_points,
const char *target_dir,
int copy_action,
GtkWidget *parent_view);
void fs_xfer (const GList *item_uris,
const GdkPoint *target_item_points,
const char *target_dir,
int copy_action,
GtkWidget *parent_view);
void fs_move_to_trash (const GList *item_uris,
GtkWidget *parent_view);
void fs_move_to_trash (const GList *item_uris,
GtkWidget *parent_view);
void fs_empty_trash (GtkWidget *parent_view);
void fs_new_folder (GtkWidget *parent_view,
void fs_empty_trash (GtkWidget *parent_view);
void fs_new_folder (GtkWidget *parent_view,
const char *parent_dir,
void (*done_callback)(const char *new_folder_uri, gpointer data),
gpointer data);
void fs_delete (const GList *item_uris, GtkWidget *parent_view);
#endif /* DFOS_XFER_H */

View file

@ -121,7 +121,7 @@ static void fm_directory_view_delete_with_confirm
#endif
static void fm_directory_view_duplicate_selection (FMDirectoryView *view,
GList *files);
static void fm_directory_view_trash_selection (FMDirectoryView *view,
static void fm_directory_view_trash_or_delete_selection (FMDirectoryView *view,
GList *files);
static void fm_directory_view_new_folder (FMDirectoryView *view);
static void fm_directory_view_destroy (GtkObject *object);
@ -414,7 +414,7 @@ bonobo_menu_move_to_trash_callback (BonoboUIHandler *ui_handler,
view = FM_DIRECTORY_VIEW (user_data);
selection = fm_directory_view_get_selection (view);
fm_directory_view_trash_selection (view, selection);
fm_directory_view_trash_or_delete_selection (view, selection);
nautilus_file_list_free (selection);
}
@ -1446,8 +1446,36 @@ fm_directory_view_duplicate_selection (FMDirectoryView *view, GList *files)
nautilus_g_list_free_deep (uris);
}
static gboolean
fm_directory_can_move_to_trash (FMDirectoryView *view)
{
/* Return TRUE if we can get a trash directory on the same volume */
char *directory;
GnomeVFSURI *directory_uri;
GnomeVFSURI *trash_dir_uri;
gboolean result;
trash_dir_uri = NULL;
directory = fm_directory_view_get_uri (view);
directory_uri = gnome_vfs_uri_new (directory);
result = gnome_vfs_find_directory (directory_uri, GNOME_VFS_DIRECTORY_KIND_TRASH,
&trash_dir_uri, TRUE, 0777) == GNOME_VFS_OK;
if (result && (gnome_vfs_uri_equal (trash_dir_uri, directory_uri)
|| gnome_vfs_uri_is_parent (trash_dir_uri, directory_uri, TRUE))) {
/* don't allow trashing items already in the Trash */
result = FALSE;
}
gnome_vfs_uri_unref (trash_dir_uri);
gnome_vfs_uri_unref (directory_uri);
g_free (directory);
return result;
}
static void
fm_directory_view_trash_selection (FMDirectoryView *view, GList *files)
fm_directory_view_trash_or_delete_selection (FMDirectoryView *view, GList *files)
{
GList *uris;
@ -1459,8 +1487,12 @@ fm_directory_view_trash_selection (FMDirectoryView *view, GList *files)
g_list_foreach (files, append_uri_one, &uris);
g_assert (g_list_length (uris) == g_list_length (files));
fs_move_to_trash (uris, GTK_WIDGET (view));
if (fm_directory_can_move_to_trash (view))
fs_move_to_trash (uris, GTK_WIDGET (view));
else
fs_delete (uris, GTK_WIDGET (view));
nautilus_g_list_free_deep (uris);
}
@ -1475,7 +1507,7 @@ duplicate_callback (GtkMenuItem *item, GList *files)
static void
trash_callback (GtkMenuItem *item, GList *files)
{
fm_directory_view_trash_selection
fm_directory_view_trash_or_delete_selection
(FM_DIRECTORY_VIEW (gtk_object_get_data (GTK_OBJECT (item), "directory_view")),
files);
}
@ -1691,14 +1723,9 @@ compute_menu_item_info (const char *path,
*return_sensitivity = selection != NULL;
} else if (strcmp (path, FM_DIRECTORY_VIEW_MENU_PATH_NEW_FOLDER) == 0) {
name = g_strdup (_("New Folder"));
#if 0
/* FIXME bugzilla.eazel.com 634, 635:
* Delete should be used in directories that don't support moving to Trash
*/
} else if (strcmp (path, FM_DIRECTORY_VIEW_MENU_PATH_DELETE) == 0) {
name = g_strdup (_("_Delete..."));
*return_sensitivity = selection != NULL;
#endif
} else if (strcmp (path, FM_DIRECTORY_VIEW_MENU_PATH_TRASH) == 0) {
name = g_strdup (_("_Move to Trash"));
*return_sensitivity = selection != NULL;
@ -2135,6 +2162,33 @@ add_open_with_bonobo_menu_item (BonoboUIHandler *ui_handler,
g_free (path);
}
static void
reset_bonobo_trash_delete_menu (FMDirectoryView *view, BonoboUIHandler *ui_handler, GList *selection)
{
bonobo_ui_handler_menu_remove (ui_handler,
FM_DIRECTORY_VIEW_MENU_PATH_TRASH);
bonobo_ui_handler_menu_remove (ui_handler,
FM_DIRECTORY_VIEW_MENU_PATH_DELETE);
if (fm_directory_can_move_to_trash (view)) {
insert_bonobo_menu_item
(ui_handler, selection,
FM_DIRECTORY_VIEW_MENU_PATH_TRASH,
_("Move all selected items to the Trash"),
bonobo_ui_handler_menu_get_pos (ui_handler, NAUTILUS_MENU_PATH_CLOSE_ITEM) + 3,
'T', GDK_CONTROL_MASK,
bonobo_menu_move_to_trash_callback, view);
} else {
insert_bonobo_menu_item
(ui_handler, selection,
FM_DIRECTORY_VIEW_MENU_PATH_DELETE,
_("Delete all selected items"),
bonobo_ui_handler_menu_get_pos (ui_handler, NAUTILUS_MENU_PATH_CLOSE_ITEM) + 3,
0, 0,
bonobo_menu_move_to_trash_callback, view);
}
}
static void
reset_bonobo_open_with_menu (FMDirectoryView *view, BonoboUIHandler *ui_handler, GList *selection)
{
@ -2232,25 +2286,9 @@ fm_directory_view_real_merge_menus (FMDirectoryView *view)
bonobo_ui_handler_menu_get_pos (ui_handler, NAUTILUS_MENU_PATH_CLOSE_ITEM) + 2,
0, 0,
bonobo_menu_open_properties_window_callback, view);
#if 0
/* FIXME bugzilla.eazel.com 634, 635:
* Delete should be used in directories that don't support moving to Trash
*/
insert_bonobo_menu_item
(ui_handler, selection,
FM_DIRECTORY_VIEW_MENU_PATH_DELETE,
_("Delete all selected items"),
bonobo_ui_handler_menu_get_pos (ui_handler, NAUTILUS_MENU_PATH_CLOSE_ITEM) + 3,
0, 0,
bonobo_menu_delete_callback, view);
#endif
insert_bonobo_menu_item
(ui_handler, selection,
FM_DIRECTORY_VIEW_MENU_PATH_TRASH,
_("Move all selected items to the Trash"),
bonobo_ui_handler_menu_get_pos (ui_handler, NAUTILUS_MENU_PATH_CLOSE_ITEM) + 3,
'T', GDK_CONTROL_MASK,
bonobo_menu_move_to_trash_callback, view);
reset_bonobo_trash_delete_menu (view, ui_handler, selection);
insert_bonobo_menu_item
(ui_handler, selection,
FM_DIRECTORY_VIEW_MENU_PATH_DUPLICATE,
@ -2318,15 +2356,7 @@ fm_directory_view_real_update_menus (FMDirectoryView *view)
FM_DIRECTORY_VIEW_MENU_PATH_OPEN_IN_NEW_WINDOW);
reset_bonobo_open_with_menu (view, handler, selection);
#if 0
/* FIXME bugzilla.eazel.com 634, 635:
* Delete should be used in directories that don't support moving to Trash
*/
update_one_menu_item (handler, selection,
FM_DIRECTORY_VIEW_MENU_PATH_DELETE);
#endif
update_one_menu_item (handler, selection,
FM_DIRECTORY_VIEW_MENU_PATH_TRASH);
reset_bonobo_trash_delete_menu (view, handler, selection);
update_one_menu_item (handler, selection,
FM_DIRECTORY_VIEW_MENU_PATH_DUPLICATE);
update_one_menu_item (handler, selection,
@ -2826,13 +2856,8 @@ fm_directory_view_get_context_menu_index(const char *menu_name)
return 1;
} else if (g_strcasecmp(FM_DIRECTORY_VIEW_MENU_PATH_OPEN_WITH, menu_name) == 0) {
return 2;
#if 0
/* FIXME bugzilla.eazel.com 634, 635:
* Delete should be used in directories that don't support moving to Trash
*/
} else if (g_strcasecmp(FM_DIRECTORY_VIEW_MENU_PATH_DELETE, menu_name) == 0) {
return 3;
#endif
} else if (g_strcasecmp(FM_DIRECTORY_VIEW_MENU_PATH_TRASH, menu_name) == 0) {
return 3;
} else if (g_strcasecmp(FM_DIRECTORY_VIEW_MENU_PATH_DUPLICATE, menu_name) == 0) {