Commit 1eaceba2 authored by Pavel Cisler's avatar Pavel Cisler Committed by Pavel Cisler

Added a Duplicate menu item. (task 329)


2000-04-12  Pavel Cisler <pavel@eazel.com>

	* src/file-manager/fm-directory-view.c:
	(fm_directory_duplicate_selection), (bonobo_menu_duplicate_cb),
	(append_uri_one), (duplicate_cb), (fm_directory_view_real_update_menus):
	Added a Duplicate menu item. (task 329)

	* src/file-manager/dfos-xfer.c:
	(fs_xfer)
	Added support for the duplicate command. Passing in a NULL for
	target directory now starts a duplicate operation.

	* src/file-manager/dfos-xfer.c:
	(fs_xfer)
	Made the progress dialog receive the text for the setup state. Pass
	in proper text for copy and move operations.

	* src/file-manager/dfos-xfer.c:
	(handle_xfer_ok)
	Pin the values of the bytes_copied to the preflight maximum -- a copy
	may end up copying more than it estimated when items are added to
	the hierarchy after the copy started. (I was hitting this when copying
	a folder into itself, which is a separate bug).
parent b6b12659
2000-04-12 Pavel Cisler <pavel@eazel.com>
* src/file-manager/fm-directory-view.c:
(fm_directory_duplicate_selection), (bonobo_menu_duplicate_cb),
(append_uri_one), (duplicate_cb), (fm_directory_view_real_update_menus):
Added a Duplicate menu item. (task 329)
* src/file-manager/dfos-xfer.c:
(fs_xfer)
Added support for the duplicate command. Passing in a NULL for
target directory now starts a duplicate operation.
* src/file-manager/dfos-xfer.c:
(fs_xfer)
Made the progress dialog receive the text for the setup state. Pass
in proper text for copy and move operations.
* src/file-manager/dfos-xfer.c:
(handle_xfer_ok)
Pin the values of the bytes_copied to the preflight maximum -- a copy
may end up copying more than it estimated when items are added to
the hierarchy after the copy started. (I was hitting this when copying
a folder into itself, which is a separate bug).
2000-04-12 Andy Hertzfeld <andy@eazel.com>
added a framework for using custom images for icons to reflect their
......@@ -56,7 +80,7 @@
* aconfig.h: changed for i18n
* po/ru.po: added russian translation.
2000-04-11 Pavel Cisler <pavel@eazel.com>
2000-04-12 Pavel Cisler <pavel@eazel.com>
* libnautilus/nautilus-icon-dnd.c:
* libnautilus/nautilus-icon-dnd.h:
......
......@@ -34,6 +34,7 @@ typedef struct XferInfo {
GnomeVFSAsyncHandle *handle;
GtkWidget *progress_dialog;
const char *operation_name;
const char *preparation_name;
GnomeVFSXferErrorMode error_mode;
GnomeVFSXferOverwriteMode overwrite_mode;
GtkWidget *parent_view;
......@@ -106,7 +107,7 @@ handle_xfer_ok (const GnomeVFSXferProgressInfo *progress_info,
dfos_xfer_progress_dialog_set_operation_string
(DFOS_XFER_PROGRESS_DIALOG
(xfer_info->progress_dialog),
"Preparing Copy...");
xfer_info->preparation_name);
return TRUE;
case GNOME_VFS_XFER_PHASE_READYTOGO:
......@@ -136,8 +137,10 @@ handle_xfer_ok (const GnomeVFSXferProgressInfo *progress_info,
dfos_xfer_progress_dialog_update
(DFOS_XFER_PROGRESS_DIALOG
(xfer_info->progress_dialog),
progress_info->bytes_copied,
progress_info->total_bytes_copied);
MIN (progress_info->bytes_copied,
progress_info->bytes_total),
MIN (progress_info->total_bytes_copied,
progress_info->bytes_total));
}
return TRUE;
......@@ -376,9 +379,9 @@ fs_xfer (const GList *item_uris,
GnomeVFSURI *source_dir_uri;
GnomeVFSURI *target_dir_uri;
XferInfo *xfer_info;
const char *target_dir_uri_text;
g_assert (item_uris != NULL);
g_assert (target_dir != NULL);
item_names = NULL;
source_dir_uri = NULL;
......@@ -399,8 +402,15 @@ fs_xfer (const GList *item_uris,
}
source_dir = gnome_vfs_uri_to_string (source_dir_uri, GNOME_VFS_URI_HIDE_NONE);
target_dir_uri = gnome_vfs_uri_new (target_dir);
if (target_dir != NULL) {
target_dir_uri = gnome_vfs_uri_new (target_dir);
target_dir_uri_text = target_dir;
} else {
/* assume duplication */
target_dir_uri = gnome_vfs_uri_ref (source_dir_uri);
target_dir_uri_text = gnome_vfs_uri_to_string (target_dir_uri,
GNOME_VFS_URI_HIDE_NONE);
}
/* figure out the right move/copy mode */
move_options = GNOME_VFS_XFER_RECURSIVE;
......@@ -416,21 +426,27 @@ fs_xfer (const GList *item_uris,
xfer_info->parent_view = view;
xfer_info->progress_dialog = NULL;
if ((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
if ((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0) {
xfer_info->operation_name = _("Moving");
else
xfer_info->preparation_name =_("Preparing To Move...");
} else {
xfer_info->operation_name = _("Copying");
xfer_info->preparation_name =_("Preparing To Copy...");
}
xfer_info->error_mode = GNOME_VFS_XFER_ERROR_MODE_QUERY;
xfer_info->overwrite_mode = GNOME_VFS_XFER_OVERWRITE_MODE_QUERY;
gnome_vfs_async_xfer (&xfer_info->handle, source_dir, item_names,
target_dir, NULL,
target_dir_uri_text, NULL,
move_options, GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_QUERY,
&xfer_callback, xfer_info);
gnome_vfs_uri_unref (target_dir_uri);
if (!target_dir)
g_free ((char *)target_dir_uri_text);
gnome_vfs_uri_unref (target_dir_uri);
gnome_vfs_uri_unref (source_dir_uri);
g_free (source_dir);
}
......@@ -34,6 +34,7 @@ typedef struct XferInfo {
GnomeVFSAsyncHandle *handle;
GtkWidget *progress_dialog;
const char *operation_name;
const char *preparation_name;
GnomeVFSXferErrorMode error_mode;
GnomeVFSXferOverwriteMode overwrite_mode;
GtkWidget *parent_view;
......@@ -106,7 +107,7 @@ handle_xfer_ok (const GnomeVFSXferProgressInfo *progress_info,
dfos_xfer_progress_dialog_set_operation_string
(DFOS_XFER_PROGRESS_DIALOG
(xfer_info->progress_dialog),
"Preparing Copy...");
xfer_info->preparation_name);
return TRUE;
case GNOME_VFS_XFER_PHASE_READYTOGO:
......@@ -136,8 +137,10 @@ handle_xfer_ok (const GnomeVFSXferProgressInfo *progress_info,
dfos_xfer_progress_dialog_update
(DFOS_XFER_PROGRESS_DIALOG
(xfer_info->progress_dialog),
progress_info->bytes_copied,
progress_info->total_bytes_copied);
MIN (progress_info->bytes_copied,
progress_info->bytes_total),
MIN (progress_info->total_bytes_copied,
progress_info->bytes_total));
}
return TRUE;
......@@ -376,9 +379,9 @@ fs_xfer (const GList *item_uris,
GnomeVFSURI *source_dir_uri;
GnomeVFSURI *target_dir_uri;
XferInfo *xfer_info;
const char *target_dir_uri_text;
g_assert (item_uris != NULL);
g_assert (target_dir != NULL);
item_names = NULL;
source_dir_uri = NULL;
......@@ -399,8 +402,15 @@ fs_xfer (const GList *item_uris,
}
source_dir = gnome_vfs_uri_to_string (source_dir_uri, GNOME_VFS_URI_HIDE_NONE);
target_dir_uri = gnome_vfs_uri_new (target_dir);
if (target_dir != NULL) {
target_dir_uri = gnome_vfs_uri_new (target_dir);
target_dir_uri_text = target_dir;
} else {
/* assume duplication */
target_dir_uri = gnome_vfs_uri_ref (source_dir_uri);
target_dir_uri_text = gnome_vfs_uri_to_string (target_dir_uri,
GNOME_VFS_URI_HIDE_NONE);
}
/* figure out the right move/copy mode */
move_options = GNOME_VFS_XFER_RECURSIVE;
......@@ -416,21 +426,27 @@ fs_xfer (const GList *item_uris,
xfer_info->parent_view = view;
xfer_info->progress_dialog = NULL;
if ((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
if ((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0) {
xfer_info->operation_name = _("Moving");
else
xfer_info->preparation_name =_("Preparing To Move...");
} else {
xfer_info->operation_name = _("Copying");
xfer_info->preparation_name =_("Preparing To Copy...");
}
xfer_info->error_mode = GNOME_VFS_XFER_ERROR_MODE_QUERY;
xfer_info->overwrite_mode = GNOME_VFS_XFER_OVERWRITE_MODE_QUERY;
gnome_vfs_async_xfer (&xfer_info->handle, source_dir, item_names,
target_dir, NULL,
target_dir_uri_text, NULL,
move_options, GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_QUERY,
&xfer_callback, xfer_info);
gnome_vfs_uri_unref (target_dir_uri);
if (!target_dir)
g_free ((char *)target_dir_uri_text);
gnome_vfs_uri_unref (target_dir_uri);
gnome_vfs_uri_unref (source_dir_uri);
g_free (source_dir);
}
......@@ -34,6 +34,7 @@ typedef struct XferInfo {
GnomeVFSAsyncHandle *handle;
GtkWidget *progress_dialog;
const char *operation_name;
const char *preparation_name;
GnomeVFSXferErrorMode error_mode;
GnomeVFSXferOverwriteMode overwrite_mode;
GtkWidget *parent_view;
......@@ -106,7 +107,7 @@ handle_xfer_ok (const GnomeVFSXferProgressInfo *progress_info,
dfos_xfer_progress_dialog_set_operation_string
(DFOS_XFER_PROGRESS_DIALOG
(xfer_info->progress_dialog),
"Preparing Copy...");
xfer_info->preparation_name);
return TRUE;
case GNOME_VFS_XFER_PHASE_READYTOGO:
......@@ -136,8 +137,10 @@ handle_xfer_ok (const GnomeVFSXferProgressInfo *progress_info,
dfos_xfer_progress_dialog_update
(DFOS_XFER_PROGRESS_DIALOG
(xfer_info->progress_dialog),
progress_info->bytes_copied,
progress_info->total_bytes_copied);
MIN (progress_info->bytes_copied,
progress_info->bytes_total),
MIN (progress_info->total_bytes_copied,
progress_info->bytes_total));
}
return TRUE;
......@@ -376,9 +379,9 @@ fs_xfer (const GList *item_uris,
GnomeVFSURI *source_dir_uri;
GnomeVFSURI *target_dir_uri;
XferInfo *xfer_info;
const char *target_dir_uri_text;
g_assert (item_uris != NULL);
g_assert (target_dir != NULL);
item_names = NULL;
source_dir_uri = NULL;
......@@ -399,8 +402,15 @@ fs_xfer (const GList *item_uris,
}
source_dir = gnome_vfs_uri_to_string (source_dir_uri, GNOME_VFS_URI_HIDE_NONE);
target_dir_uri = gnome_vfs_uri_new (target_dir);
if (target_dir != NULL) {
target_dir_uri = gnome_vfs_uri_new (target_dir);
target_dir_uri_text = target_dir;
} else {
/* assume duplication */
target_dir_uri = gnome_vfs_uri_ref (source_dir_uri);
target_dir_uri_text = gnome_vfs_uri_to_string (target_dir_uri,
GNOME_VFS_URI_HIDE_NONE);
}
/* figure out the right move/copy mode */
move_options = GNOME_VFS_XFER_RECURSIVE;
......@@ -416,21 +426,27 @@ fs_xfer (const GList *item_uris,
xfer_info->parent_view = view;
xfer_info->progress_dialog = NULL;
if ((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0)
if ((move_options & GNOME_VFS_XFER_REMOVESOURCE) != 0) {
xfer_info->operation_name = _("Moving");
else
xfer_info->preparation_name =_("Preparing To Move...");
} else {
xfer_info->operation_name = _("Copying");
xfer_info->preparation_name =_("Preparing To Copy...");
}
xfer_info->error_mode = GNOME_VFS_XFER_ERROR_MODE_QUERY;
xfer_info->overwrite_mode = GNOME_VFS_XFER_OVERWRITE_MODE_QUERY;
gnome_vfs_async_xfer (&xfer_info->handle, source_dir, item_names,
target_dir, NULL,
target_dir_uri_text, NULL,
move_options, GNOME_VFS_XFER_ERROR_MODE_QUERY,
GNOME_VFS_XFER_OVERWRITE_MODE_QUERY,
&xfer_callback, xfer_info);
gnome_vfs_uri_unref (target_dir_uri);
if (!target_dir)
g_free ((char *)target_dir_uri_text);
gnome_vfs_uri_unref (target_dir_uri);
gnome_vfs_uri_unref (source_dir_uri);
g_free (source_dir);
}
......@@ -44,6 +44,7 @@
#include <libnautilus/nautilus-alloc.h>
#include <libnautilus/nautilus-global-preferences.h>
#include <libnautilus/nautilus-gtk-extensions.h>
#include <libnautilus/nautilus-glib-extensions.h>
#include <libnautilus/nautilus-gtk-macros.h>
#include <libnautilus/nautilus-icon-factory.h>
#include <libnautilus/nautilus-metadata.h>
......@@ -61,6 +62,7 @@
#define MENU_PATH_CLOSE "/File/Close"
#define MENU_PATH_SEPARATOR_AFTER_CLOSE "/File/SeparatorAfterClose"
#define MENU_PATH_DELETE "/File/Delete"
#define MENU_PATH_DUPLICATE "/File/Duplicate"
#define MENU_PATH_SELECT_ALL "/Edit/Select All"
#define MENU_PATH_SET_PROPERTIES "/File/Set Properties"
......@@ -117,6 +119,8 @@ static void fm_directory_view_initialize_class
static void fm_directory_view_initialize (FMDirectoryView *view);
static void fm_directory_view_delete_with_confirm (FMDirectoryView *view,
GList *files);
static void fm_directory_duplicate_selection (FMDirectoryView *view,
GList *files);
static void fm_directory_view_destroy (GtkObject *object);
static void fm_directory_view_activate_file_internal (FMDirectoryView *view,
NautilusFile *file,
......@@ -349,6 +353,27 @@ bonobo_menu_delete_cb (BonoboUIHandler *ui_handler, gpointer user_data, const ch
nautilus_file_list_free (selection);
}
static void
bonobo_menu_duplicate_cb (BonoboUIHandler *ui_handler, gpointer user_data, const char *path)
{
FMDirectoryView *view;
GList *selection;
g_assert (FM_IS_DIRECTORY_VIEW (user_data));
view = FM_DIRECTORY_VIEW (user_data);
selection = fm_directory_view_get_selection (view);
/* UI should have prevented this from being called unless at least
* one item is selected.
*/
g_assert (g_list_length(selection) > 0);
fm_directory_duplicate_selection (view, selection);
nautilus_file_list_free (selection);
}
static void
bonobo_menu_open_properties_window_cb (BonoboUIHandler *ui_handler, gpointer user_data, const char *path)
{
......@@ -1358,6 +1383,38 @@ fm_directory_view_delete_with_confirm (FMDirectoryView *view, GList *files)
}
}
static void
append_uri_one (gpointer data, gpointer user_data)
{
NautilusFile *file;
GList **result;
g_assert (NAUTILUS_IS_FILE (data));
result = (GList **)user_data;
file = (NautilusFile *)data;
*result = g_list_append (*result, nautilus_file_get_uri (file));
}
static void
fm_directory_duplicate_selection (FMDirectoryView *view, GList *files)
{
GList *uris;
g_assert (FM_IS_DIRECTORY_VIEW (view));
g_assert (g_list_length (files) > 0);
uris = NULL;
/* create a list of URIs */
g_list_foreach (files, append_uri_one, &uris);
g_assert (g_list_length (uris) == g_list_length (files));
fs_xfer (uris, NULL, NULL, GDK_ACTION_COPY, GTK_WIDGET (view));
nautilus_g_list_free_deep (uris);
}
static void
delete_cb (GtkMenuItem *item, GList *files)
{
......@@ -1366,6 +1423,14 @@ delete_cb (GtkMenuItem *item, GList *files)
files);
}
static void
duplicate_cb (GtkMenuItem *item, GList *files)
{
fm_directory_duplicate_selection
(FM_DIRECTORY_VIEW (gtk_object_get_data (GTK_OBJECT (item), "directory_view")),
files);
}
/* handle the open command */
static void
......@@ -1473,6 +1538,9 @@ compute_menu_item_info (const char *path,
} else if (strcmp (path, MENU_PATH_DELETE) == 0) {
name = g_strdup (_("_Delete..."));
*return_sensitivity = selection_length > 0;
} else if (strcmp (path, MENU_PATH_DUPLICATE) == 0) {
name = g_strdup (_("_Duplicate"));
*return_sensitivity = selection_length > 0;
} else if (strcmp (path, MENU_PATH_SET_PROPERTIES) == 0) {
name = g_strdup (_("Set _Properties..."));
*return_sensitivity = selection_length > 0;
......@@ -1534,6 +1602,8 @@ fm_directory_view_real_append_selection_context_menu_items (FMDirectoryView *vie
MENU_PATH_OPEN_IN_NEW_WINDOW, open_in_new_window_cb);
append_selection_menu_item (view, menu, files,
MENU_PATH_DELETE, delete_cb);
append_selection_menu_item (view, menu, files,
MENU_PATH_DUPLICATE, duplicate_cb);
append_selection_menu_item (view, menu, files,
MENU_PATH_SET_PROPERTIES, open_properties_window_cb);
}
......@@ -1597,6 +1667,17 @@ fm_directory_view_real_merge_menus (FMDirectoryView *view)
0,
bonobo_menu_delete_cb,
view);
bonobo_ui_handler_menu_new_item (ui_handler,
MENU_PATH_DUPLICATE,
_("Duplicate"),
_("Duplicate all selected items"),
bonobo_ui_handler_menu_get_pos (ui_handler, MENU_PATH_CLOSE) + 4,
BONOBO_UI_HANDLER_PIXMAP_NONE,
NULL,
'D',
GDK_CONTROL_MASK,
bonobo_menu_duplicate_cb,
view);
bonobo_ui_handler_menu_new_item (ui_handler,
MENU_PATH_SELECT_ALL,
_("Select All"),
......@@ -1625,19 +1706,20 @@ update_one_menu_item (BonoboUIHandler *local_ui_handler, const char* menu_path,
static void
fm_directory_view_real_update_menus (FMDirectoryView *view)
{
BonoboUIHandler *handler;
BonoboUIHandler *handler;
GList *selection;
int count;
handler = fm_directory_view_get_bonobo_ui_handler (view);
handler = fm_directory_view_get_bonobo_ui_handler (view);
selection = fm_directory_view_get_selection (view);
count = g_list_length (selection);
nautilus_file_list_free (selection);
update_one_menu_item (handler, MENU_PATH_OPEN, count);
update_one_menu_item (handler, MENU_PATH_OPEN_IN_NEW_WINDOW, count);
update_one_menu_item (handler, MENU_PATH_DELETE, count);
update_one_menu_item (handler, MENU_PATH_SET_PROPERTIES, count);
update_one_menu_item (handler, MENU_PATH_OPEN, count);
update_one_menu_item (handler, MENU_PATH_OPEN_IN_NEW_WINDOW, count);
update_one_menu_item (handler, MENU_PATH_DELETE, count);
update_one_menu_item (handler, MENU_PATH_DUPLICATE, count);
update_one_menu_item (handler, MENU_PATH_SET_PROPERTIES, count);
}
static GtkMenu *
......@@ -2108,11 +2190,7 @@ fm_directory_view_move_copy_items (NautilusIconContainer *container,
int y,
FMDirectoryView *view)
{
fs_xfer (item_uris,
relative_item_points,
target_dir,
copy_action,
GTK_WIDGET (view));
fs_xfer (item_uris, relative_item_points, target_dir, copy_action, GTK_WIDGET (view));
}
gboolean
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment