file chooser: Cut, Copy and Paste of files (menu, Ctrl+X/C/V) as in file managers and with them: folders with all in them, a progress row with Cancel, questions for names that are there (skip, replace or merge, rename, for all) and for errors, moves as renames where possible; the clipboard of Nautilus, Caja, Thunar, PCManFM and Dolphin, cut files dimmed
This commit is contained in:
parent
0c629f2b6e
commit
a72c02150c
10 changed files with 1760 additions and 26 deletions
|
|
@ -393,6 +393,7 @@ gtk_private_h_sources = \
|
|||
gtkfilefilterprivate.h \
|
||||
gtknativedialogprivate.h \
|
||||
gtkfilechooserutils.h \
|
||||
gtkfileoperation.h \
|
||||
gtkfilesystem.h \
|
||||
gtkfilesystemmodel.h \
|
||||
gtkfilethumbnail.h \
|
||||
|
|
@ -498,6 +499,7 @@ gtk_base_c_sources = \
|
|||
gtkfilechooserentry.c \
|
||||
gtkfilechoosersettings.c \
|
||||
gtkfilechooserutils.c \
|
||||
gtkfileoperation.c \
|
||||
gtkfilechooserwidget.c \
|
||||
gtkfilefilter.c \
|
||||
gtkfilesystem.c \
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
#include "gtkfilechooserentry.h"
|
||||
#include "gtkfilechoosersettings.h"
|
||||
#include "gtkfilechooserutils.h"
|
||||
#include "gtkfileoperation.h"
|
||||
#include "gtkfilechooser.h"
|
||||
#include "gtkfilesystem.h"
|
||||
#include "gtkfilesystemmodel.h"
|
||||
|
|
@ -3217,31 +3218,93 @@ rename_selected_file (GtkFileChooserDefault *impl)
|
|||
add_idle_to_edit_icon_view (impl, path);
|
||||
}
|
||||
|
||||
/* "Copy" (Ctrl+C) puts the selected files on the clipboard as file
|
||||
* managers do, so that they can be pasted into a folder there; programs
|
||||
* that take text get their locations, as from "Copy Location". Pasting
|
||||
* files is left to the file managers, which show the progress of it. */
|
||||
/* Cut, Copy and Paste of files, as in file managers. Cut and Copy put
|
||||
* the selected files on the clipboard in the forms file managers take:
|
||||
* x-special/gnome-copied-files ("copy" or "cut" and the URIs: Nautilus,
|
||||
* Caja, Thunar, PCManFM), text/uri-list with the cut mark of KDE
|
||||
* (Dolphin), and the locations as text for any other program. Paste
|
||||
* copies or moves what is on the clipboard into the current folder,
|
||||
* with progress, Cancel and questions (gtkfileoperation.c); after a cut
|
||||
* the clipboard is emptied, as the files are no longer where it says.
|
||||
* Cut files are shown dimmed until they are pasted or something else
|
||||
* goes on the clipboard. The clipboard is only ever asked without
|
||||
* waiting, so a program that owns it but does not answer blocks
|
||||
* nothing. */
|
||||
enum
|
||||
{
|
||||
COPIED_FILES_GNOME, /* x-special/gnome-copied-files: Nautilus, Thunar, Caja, PCManFM */
|
||||
COPIED_FILES_URIS, /* text/uri-list: Dolphin, Konqueror and most others */
|
||||
COPIED_FILES_GNOME,
|
||||
COPIED_FILES_KDE_CUT,
|
||||
COPIED_FILES_URIS,
|
||||
COPIED_FILES_TEXT
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GtkFileChooserDefault *impl; /* weak, for a cut */
|
||||
gboolean cut;
|
||||
gchar **uris;
|
||||
gchar *locations; /* one per line */
|
||||
} CopiedFiles;
|
||||
|
||||
static void
|
||||
cut_files_changed (GtkFileChooserDefault *impl)
|
||||
{
|
||||
GtkFileSystemModel *models[3];
|
||||
gint i;
|
||||
|
||||
models[0] = impl->browse_files_model;
|
||||
models[1] = impl->search_model;
|
||||
models[2] = impl->recent_model;
|
||||
for (i = 0; i < 3; i++)
|
||||
if (models[i])
|
||||
{
|
||||
_gtk_file_system_model_clear_cache (models[i], MODEL_COL_LIST_PIXBUF);
|
||||
_gtk_file_system_model_clear_cache (models[i], MODEL_COL_ICON_PIXBUF);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
copied_files_free (CopiedFiles *files)
|
||||
{
|
||||
if (files->impl)
|
||||
{
|
||||
if (files->impl->cut_files == files)
|
||||
{
|
||||
files->impl->cut_files = NULL;
|
||||
cut_files_changed (files->impl);
|
||||
}
|
||||
g_object_remove_weak_pointer (G_OBJECT (files->impl), (gpointer *) &files->impl);
|
||||
}
|
||||
g_strfreev (files->uris);
|
||||
g_free (files->locations);
|
||||
g_slice_free (CopiedFiles, files);
|
||||
}
|
||||
|
||||
/* Whether @file is cut and waits on the clipboard to be pasted */
|
||||
static gboolean
|
||||
file_is_cut (GtkFileChooserDefault *impl,
|
||||
GFile *file)
|
||||
{
|
||||
CopiedFiles *cut_files = impl->cut_files;
|
||||
gchar *uri;
|
||||
gboolean cut = FALSE;
|
||||
gint i;
|
||||
|
||||
if (cut_files == NULL || file == NULL)
|
||||
return FALSE;
|
||||
|
||||
uri = g_file_get_uri (file);
|
||||
for (i = 0; cut_files->uris[i]; i++)
|
||||
if (strcmp (cut_files->uris[i], uri) == 0)
|
||||
{
|
||||
cut = TRUE;
|
||||
break;
|
||||
}
|
||||
g_free (uri);
|
||||
|
||||
return cut;
|
||||
}
|
||||
|
||||
static void
|
||||
copied_files_get_cb (GtkClipboard *clipboard,
|
||||
GtkSelectionData *selection_data,
|
||||
|
|
@ -3255,7 +3318,7 @@ copied_files_get_cb (GtkClipboard *clipboard,
|
|||
case COPIED_FILES_GNOME:
|
||||
{
|
||||
gchar *list = g_strjoinv ("\n", files->uris);
|
||||
gchar *text = g_strconcat ("copy\n", list, NULL);
|
||||
gchar *text = g_strconcat (files->cut ? "cut\n" : "copy\n", list, NULL);
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
gtk_selection_data_get_target (selection_data),
|
||||
|
|
@ -3265,6 +3328,12 @@ copied_files_get_cb (GtkClipboard *clipboard,
|
|||
}
|
||||
break;
|
||||
|
||||
case COPIED_FILES_KDE_CUT:
|
||||
gtk_selection_data_set (selection_data,
|
||||
gtk_selection_data_get_target (selection_data),
|
||||
8, (const guchar *) (files->cut ? "1" : "0"), 1);
|
||||
break;
|
||||
|
||||
case COPIED_FILES_URIS:
|
||||
gtk_selection_data_set_uris (selection_data, files->uris);
|
||||
break;
|
||||
|
|
@ -3311,7 +3380,8 @@ copy_files_foreach_cb (GtkTreeModel *model,
|
|||
}
|
||||
|
||||
static void
|
||||
copy_files (GtkFileChooserDefault *impl)
|
||||
put_files_on_clipboard (GtkFileChooserDefault *impl,
|
||||
gboolean cut)
|
||||
{
|
||||
GPtrArray *uris = g_ptr_array_new ();
|
||||
GString *locations = g_string_new (NULL);
|
||||
|
|
@ -3334,28 +3404,255 @@ copy_files (GtkFileChooserDefault *impl)
|
|||
}
|
||||
|
||||
g_ptr_array_add (uris, NULL);
|
||||
files = g_slice_new (CopiedFiles);
|
||||
files = g_slice_new0 (CopiedFiles);
|
||||
files->cut = cut;
|
||||
files->uris = (gchar **) g_ptr_array_free (uris, FALSE);
|
||||
files->locations = g_string_free (locations, FALSE);
|
||||
|
||||
list = gtk_target_list_new (NULL, 0);
|
||||
gtk_target_list_add (list, gdk_atom_intern_static_string ("x-special/gnome-copied-files"),
|
||||
gtk_target_list_add (list, gdk_atom_intern_static_string (GTK_FILE_CLIPBOARD_GNOME),
|
||||
0, COPIED_FILES_GNOME);
|
||||
if (cut)
|
||||
gtk_target_list_add (list, gdk_atom_intern_static_string (GTK_FILE_CLIPBOARD_KDE_CUT),
|
||||
0, COPIED_FILES_KDE_CUT);
|
||||
gtk_target_list_add_uri_targets (list, COPIED_FILES_URIS);
|
||||
gtk_target_list_add_text_targets (list, COPIED_FILES_TEXT);
|
||||
targets = gtk_target_table_new_from_list (list, &n_targets);
|
||||
gtk_target_list_unref (list);
|
||||
|
||||
clipboard = gtk_widget_get_clipboard (impl->browse_files_current_view, GDK_SELECTION_CLIPBOARD);
|
||||
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (impl), GDK_SELECTION_CLIPBOARD);
|
||||
if (gtk_clipboard_set_with_data (clipboard, targets, n_targets,
|
||||
copied_files_get_cb, copied_files_clear_cb, files))
|
||||
gtk_clipboard_set_can_store (clipboard, NULL, 0);
|
||||
{
|
||||
if (cut)
|
||||
{
|
||||
/* what was cut before is no longer (its clear callback ran) */
|
||||
files->impl = impl;
|
||||
g_object_add_weak_pointer (G_OBJECT (impl), (gpointer *) &files->impl);
|
||||
impl->cut_files = files;
|
||||
cut_files_changed (impl);
|
||||
}
|
||||
else
|
||||
/* a copy stays there for others when the program ends */
|
||||
gtk_clipboard_set_can_store (clipboard, NULL, 0);
|
||||
}
|
||||
else
|
||||
copied_files_free (files);
|
||||
|
||||
gtk_target_table_free (targets, n_targets);
|
||||
}
|
||||
|
||||
static void
|
||||
copy_files (GtkFileChooserDefault *impl)
|
||||
{
|
||||
put_files_on_clipboard (impl, FALSE);
|
||||
}
|
||||
|
||||
static void
|
||||
cut_files (GtkFileChooserDefault *impl)
|
||||
{
|
||||
put_files_on_clipboard (impl, TRUE);
|
||||
}
|
||||
|
||||
/* Pasting: what is on the clipboard, asked without waiting */
|
||||
typedef struct
|
||||
{
|
||||
GtkFileChooserDefault *impl; /* weak */
|
||||
GFile *destination;
|
||||
GList *files;
|
||||
} PasteData;
|
||||
|
||||
static void
|
||||
paste_data_free (PasteData *paste)
|
||||
{
|
||||
if (paste->impl)
|
||||
g_object_remove_weak_pointer (G_OBJECT (paste->impl), (gpointer *) &paste->impl);
|
||||
g_object_unref (paste->destination);
|
||||
g_list_foreach (paste->files, (GFunc) g_object_unref, NULL);
|
||||
g_list_free (paste->files);
|
||||
g_slice_free (PasteData, paste);
|
||||
}
|
||||
|
||||
static void
|
||||
paste_done (GtkFileOperation *operation,
|
||||
gboolean cancelled,
|
||||
gboolean moved,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFileChooserDefault *impl = data;
|
||||
|
||||
impl->file_operations = g_slist_remove (impl->file_operations, operation);
|
||||
}
|
||||
|
||||
static void
|
||||
paste_cut_done (GtkFileOperation *operation,
|
||||
gboolean cancelled,
|
||||
gboolean moved,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFileChooserDefault *impl = data;
|
||||
|
||||
paste_done (operation, cancelled, moved, data);
|
||||
|
||||
/* the files are no longer where the clipboard says: it is emptied,
|
||||
* if it still holds them */
|
||||
if (moved)
|
||||
{
|
||||
GtkClipboard *clipboard = gtk_widget_get_clipboard (GTK_WIDGET (impl),
|
||||
GDK_SELECTION_CLIPBOARD);
|
||||
|
||||
if (impl->cut_files)
|
||||
gtk_clipboard_clear (clipboard);
|
||||
else
|
||||
gtk_clipboard_set_text (clipboard, "", 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
paste_start (PasteData *paste,
|
||||
gboolean cut)
|
||||
{
|
||||
GtkFileChooserDefault *impl = paste->impl;
|
||||
GtkFileOperation *operation;
|
||||
GtkWidget *toplevel;
|
||||
|
||||
if (impl == NULL || paste->files == NULL)
|
||||
return;
|
||||
|
||||
toplevel = gtk_widget_get_toplevel (GTK_WIDGET (impl));
|
||||
operation = _gtk_file_operation_start (cut ? GTK_FILE_OPERATION_MOVE : GTK_FILE_OPERATION_COPY,
|
||||
paste->files, paste->destination,
|
||||
impl->file_operations_box,
|
||||
GTK_IS_WINDOW (toplevel) ? GTK_WINDOW (toplevel) : NULL,
|
||||
cut ? paste_cut_done : paste_done, impl);
|
||||
if (operation)
|
||||
impl->file_operations = g_slist_prepend (impl->file_operations, operation);
|
||||
}
|
||||
|
||||
static void
|
||||
paste_add_uris (PasteData *paste,
|
||||
gchar **uris,
|
||||
gint first)
|
||||
{
|
||||
gint i;
|
||||
|
||||
for (i = first; uris && uris[i]; i++)
|
||||
if (*uris[i] != '\0')
|
||||
paste->files = g_list_append (paste->files, g_file_new_for_uri (uris[i]));
|
||||
}
|
||||
|
||||
static void
|
||||
paste_kde_cut_received (GtkClipboard *clipboard,
|
||||
GtkSelectionData *selection_data,
|
||||
gpointer data)
|
||||
{
|
||||
PasteData *paste = data;
|
||||
gboolean cut = FALSE;
|
||||
|
||||
if (selection_data && gtk_selection_data_get_length (selection_data) > 0)
|
||||
cut = gtk_selection_data_get_data (selection_data)[0] == '1';
|
||||
|
||||
paste_start (paste, cut);
|
||||
paste_data_free (paste);
|
||||
}
|
||||
|
||||
static void
|
||||
paste_uris_received (GtkClipboard *clipboard,
|
||||
gchar **uris,
|
||||
gpointer data)
|
||||
{
|
||||
PasteData *paste = data;
|
||||
|
||||
paste_add_uris (paste, uris, 0);
|
||||
if (paste->impl == NULL || paste->files == NULL)
|
||||
{
|
||||
paste_data_free (paste);
|
||||
return;
|
||||
}
|
||||
|
||||
/* cut in Dolphin? */
|
||||
gtk_clipboard_request_contents (clipboard,
|
||||
gdk_atom_intern_static_string (GTK_FILE_CLIPBOARD_KDE_CUT),
|
||||
paste_kde_cut_received, paste);
|
||||
}
|
||||
|
||||
static void
|
||||
paste_gnome_received (GtkClipboard *clipboard,
|
||||
GtkSelectionData *selection_data,
|
||||
gpointer data)
|
||||
{
|
||||
PasteData *paste = data;
|
||||
gint length = selection_data ? gtk_selection_data_get_length (selection_data) : -1;
|
||||
|
||||
if (paste->impl == NULL)
|
||||
{
|
||||
paste_data_free (paste);
|
||||
return;
|
||||
}
|
||||
|
||||
if (length > 0)
|
||||
{
|
||||
gchar *text = g_strndup ((const gchar *) gtk_selection_data_get_data (selection_data), length);
|
||||
gchar **lines = g_strsplit (text, "\n", -1);
|
||||
gboolean cut = lines[0] && g_str_equal (g_strstrip (lines[0]), "cut");
|
||||
gint i;
|
||||
|
||||
for (i = 1; lines[i]; i++)
|
||||
g_strstrip (lines[i]);
|
||||
paste_add_uris (paste, lines, 1);
|
||||
g_strfreev (lines);
|
||||
g_free (text);
|
||||
|
||||
paste_start (paste, cut);
|
||||
paste_data_free (paste);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_clipboard_request_uris (clipboard, paste_uris_received, paste);
|
||||
}
|
||||
|
||||
static void
|
||||
paste_files (GtkFileChooserDefault *impl)
|
||||
{
|
||||
PasteData *paste;
|
||||
|
||||
if (impl->operation_mode != OPERATION_MODE_BROWSE || impl->current_folder == NULL)
|
||||
return;
|
||||
|
||||
paste = g_slice_new0 (PasteData);
|
||||
paste->impl = impl;
|
||||
g_object_add_weak_pointer (G_OBJECT (impl), (gpointer *) &paste->impl);
|
||||
paste->destination = g_object_ref (impl->current_folder);
|
||||
|
||||
gtk_clipboard_request_contents (gtk_widget_get_clipboard (GTK_WIDGET (impl),
|
||||
GDK_SELECTION_CLIPBOARD),
|
||||
gdk_atom_intern_static_string (GTK_FILE_CLIPBOARD_GNOME),
|
||||
paste_gnome_received, paste);
|
||||
}
|
||||
|
||||
/* Paste in the menu is sensitive when the clipboard has files, which is
|
||||
* asked when the menu is built, without waiting */
|
||||
static void
|
||||
paste_targets_received (GtkClipboard *clipboard,
|
||||
GdkAtom *atoms,
|
||||
gint n_atoms,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *item = data;
|
||||
gboolean files = FALSE;
|
||||
gint i;
|
||||
|
||||
for (i = 0; atoms && i < n_atoms; i++)
|
||||
if (atoms[i] == gdk_atom_intern_static_string (GTK_FILE_CLIPBOARD_GNOME))
|
||||
files = TRUE;
|
||||
if (!files && atoms)
|
||||
files = gtk_targets_include_uri (atoms, n_atoms);
|
||||
|
||||
if (gtk_widget_get_parent (item))
|
||||
gtk_widget_set_sensitive (item, files);
|
||||
g_object_unref (item);
|
||||
}
|
||||
|
||||
/* Idle handler for creating a new folder after editing its name cell, or for
|
||||
* canceling the editing.
|
||||
*/
|
||||
|
|
@ -4868,18 +5165,30 @@ browse_files_key_press_event_cb (GtkWidget *widget,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/* Ctrl+C, on the Mac Command+C */
|
||||
if ((event->keyval == GDK_KEY_c || event->keyval == GDK_KEY_C) &&
|
||||
/* Ctrl+X, Ctrl+C and Ctrl+V, on the Mac with Command */
|
||||
#ifdef GDK_WINDOWING_QUARTZ
|
||||
(event->state & (gtk_accelerator_get_default_mod_mask () | GDK_MOD2_MASK)) == GDK_MOD2_MASK
|
||||
if ((event->state & (gtk_accelerator_get_default_mod_mask () | GDK_MOD2_MASK)) == GDK_MOD2_MASK)
|
||||
#else
|
||||
(event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_CONTROL_MASK
|
||||
if ((event->state & gtk_accelerator_get_default_mod_mask ()) == GDK_CONTROL_MASK)
|
||||
#endif
|
||||
)
|
||||
{
|
||||
copy_files (impl);
|
||||
return TRUE;
|
||||
}
|
||||
switch (event->keyval)
|
||||
{
|
||||
case GDK_KEY_c:
|
||||
case GDK_KEY_C:
|
||||
copy_files (impl);
|
||||
return TRUE;
|
||||
case GDK_KEY_x:
|
||||
case GDK_KEY_X:
|
||||
if (impl->operation_mode == OPERATION_MODE_BROWSE)
|
||||
cut_files (impl);
|
||||
return TRUE;
|
||||
case GDK_KEY_v:
|
||||
case GDK_KEY_V:
|
||||
paste_files (impl);
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if ((((event->keyval == GDK_KEY_Delete || event->keyval == GDK_KEY_KP_Delete) &&
|
||||
!(event->state & gtk_accelerator_get_default_mod_mask ()))
|
||||
|
|
@ -4938,7 +5247,9 @@ popup_menu_detach_cb (GtkWidget *attach_widget,
|
|||
|
||||
impl->browse_files_popup_menu = NULL;
|
||||
impl->browse_files_popup_menu_add_shortcut_item = NULL;
|
||||
impl->browse_files_popup_menu_cut_item = NULL;
|
||||
impl->browse_files_popup_menu_copy_item = NULL;
|
||||
impl->browse_files_popup_menu_paste_item = NULL;
|
||||
impl->browse_files_popup_menu_copy_location_item = NULL;
|
||||
impl->browse_files_popup_menu_rename_item = NULL;
|
||||
impl->browse_files_popup_menu_trash_item = NULL;
|
||||
|
|
@ -5624,6 +5935,17 @@ file_list_build_popup_menu (GtkFileChooserDefault *impl)
|
|||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
|
||||
|
||||
item = gtk_separator_menu_item_new ();
|
||||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
|
||||
|
||||
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_CUT, NULL);
|
||||
impl->browse_files_popup_menu_cut_item = item;
|
||||
g_signal_connect_swapped (item, "activate",
|
||||
G_CALLBACK (cut_files), impl);
|
||||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
|
||||
|
||||
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_COPY, NULL);
|
||||
impl->browse_files_popup_menu_copy_item = item;
|
||||
g_signal_connect_swapped (item, "activate",
|
||||
|
|
@ -5631,6 +5953,13 @@ file_list_build_popup_menu (GtkFileChooserDefault *impl)
|
|||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
|
||||
|
||||
item = gtk_image_menu_item_new_from_stock (GTK_STOCK_PASTE, NULL);
|
||||
impl->browse_files_popup_menu_paste_item = item;
|
||||
g_signal_connect_swapped (item, "activate",
|
||||
G_CALLBACK (paste_files), impl);
|
||||
gtk_widget_show (item);
|
||||
gtk_menu_shell_append (GTK_MENU_SHELL (impl->browse_files_popup_menu), item);
|
||||
|
||||
item = gtk_image_menu_item_new_with_mnemonic (_("_Copy Location"));
|
||||
impl->browse_files_popup_menu_copy_location_item = item;
|
||||
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
|
||||
|
|
@ -5786,9 +6115,20 @@ file_list_update_popup_menu (GtkFileChooserDefault *impl)
|
|||
g_signal_handlers_unblock_by_func (impl->browse_files_popup_menu_thumbnails_item,
|
||||
G_CALLBACK (show_thumbnails_toggled_cb), impl);
|
||||
|
||||
/* 'Copy' */
|
||||
/* 'Cut', 'Copy', 'Paste': cut and paste only in the folders themselves */
|
||||
gtk_widget_set_sensitive (impl->browse_files_popup_menu_copy_item,
|
||||
gtk_widget_get_sensitive (impl->browse_files_popup_menu_copy_location_item));
|
||||
gtk_widget_set_sensitive (impl->browse_files_popup_menu_cut_item,
|
||||
impl->operation_mode == OPERATION_MODE_BROWSE &&
|
||||
gtk_widget_get_sensitive (impl->browse_files_popup_menu_copy_location_item));
|
||||
gtk_widget_set_visible (impl->browse_files_popup_menu_paste_item,
|
||||
impl->operation_mode == OPERATION_MODE_BROWSE);
|
||||
gtk_widget_set_sensitive (impl->browse_files_popup_menu_paste_item, FALSE);
|
||||
if (impl->operation_mode == OPERATION_MODE_BROWSE)
|
||||
gtk_clipboard_request_targets (gtk_widget_get_clipboard (GTK_WIDGET (impl),
|
||||
GDK_SELECTION_CLIPBOARD),
|
||||
paste_targets_received,
|
||||
g_object_ref (impl->browse_files_popup_menu_paste_item));
|
||||
|
||||
/* 'Show Preview', not beside the preview of the program */
|
||||
gtk_widget_set_visible (impl->browse_files_popup_menu_preview_item,
|
||||
|
|
@ -6980,6 +7320,11 @@ file_pane_create (GtkFileChooserDefault *impl,
|
|||
gtk_box_pack_start (GTK_BOX (hbox), widget, TRUE, TRUE, 0);
|
||||
gtk_size_group_add_widget (size_group, widget);
|
||||
|
||||
/* Copying and moving files: a row for each, while it runs */
|
||||
impl->file_operations_box = gtk_vbox_new (FALSE, 6);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), impl->file_operations_box, FALSE, FALSE, 0);
|
||||
gtk_widget_show (impl->file_operations_box);
|
||||
|
||||
/* Preview */
|
||||
|
||||
impl->preview_box = gtk_vbox_new (FALSE, 12);
|
||||
|
|
@ -8977,6 +9322,12 @@ gtk_file_chooser_default_dispose (GObject *object)
|
|||
|
||||
cancel_all_operations (impl);
|
||||
|
||||
/* copies and moves stop with the file chooser; their rows go with it,
|
||||
* and they no longer call back */
|
||||
g_slist_foreach (impl->file_operations, (GFunc) _gtk_file_operation_cancel, NULL);
|
||||
g_slist_free (impl->file_operations);
|
||||
impl->file_operations = NULL;
|
||||
|
||||
/* it belongs to the toplevel, not to us, but speaks to us */
|
||||
if (impl->preferences_dialog)
|
||||
gtk_widget_destroy (impl->preferences_dialog);
|
||||
|
|
@ -10556,10 +10907,13 @@ file_icon_dim (GtkWidget *widget,
|
|||
|
||||
static GdkPixbuf *
|
||||
file_icon_dim_if_hidden (GtkFileChooserDefault *impl,
|
||||
GFile *file,
|
||||
GFileInfo *info,
|
||||
GdkPixbuf *pixbuf)
|
||||
{
|
||||
if ((g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN) &&
|
||||
/* and files that are cut, waiting to be pasted */
|
||||
if (file_is_cut (impl, file) ||
|
||||
(g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_IS_HIDDEN) &&
|
||||
g_file_info_get_is_hidden (info)) ||
|
||||
(g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_IS_BACKUP) &&
|
||||
g_file_info_get_is_backup (info)))
|
||||
|
|
@ -10659,7 +11013,7 @@ file_system_model_set (GtkFileSystemModel *model,
|
|||
icon_size = FALLBACK_LIST_VIEW_ICON_SIZE;
|
||||
}
|
||||
|
||||
g_value_take_object (value, file_icon_dim_if_hidden (impl, info,
|
||||
g_value_take_object (value, file_icon_dim_if_hidden (impl, file, info,
|
||||
_gtk_file_info_render_icon (info, GTK_WIDGET (impl), icon_size)));
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -179,11 +179,16 @@ struct _GtkFileChooserDefault
|
|||
GtkWidget *browse_shortcuts_popup_menu_rename_item;
|
||||
GtkWidget *browse_files_tree_view;
|
||||
GtkWidget *browse_files_scrolled_window;
|
||||
GtkWidget *file_operations_box; /* rows of copies and moves */
|
||||
GSList *file_operations; /* GtkFileOperation, running */
|
||||
gpointer cut_files; /* CopiedFiles on the clipboard, cut here */
|
||||
GtkWidget *browse_files_current_view;
|
||||
GtkWidget *browse_files_icon_view;
|
||||
GtkWidget *browse_files_popup_menu;
|
||||
GtkWidget *browse_files_popup_menu_add_shortcut_item;
|
||||
GtkWidget *browse_files_popup_menu_cut_item;
|
||||
GtkWidget *browse_files_popup_menu_copy_item;
|
||||
GtkWidget *browse_files_popup_menu_paste_item;
|
||||
GtkWidget *browse_files_popup_menu_copy_location_item;
|
||||
GtkWidget *browse_files_popup_menu_rename_item;
|
||||
GtkWidget *browse_files_popup_menu_trash_item;
|
||||
|
|
|
|||
1213
gtk/gtkfileoperation.c
Normal file
1213
gtk/gtkfileoperation.c
Normal file
File diff suppressed because it is too large
Load diff
70
gtk/gtkfileoperation.h
Normal file
70
gtk/gtkfileoperation.h
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/* GTK - The GIMP Toolkit
|
||||
* gtkfileoperation.h: copying and moving files for the file chooser
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
/* Not installed: for the file chooser of libgtk only */
|
||||
|
||||
#ifndef __GTK_FILE_OPERATION_H__
|
||||
#define __GTK_FILE_OPERATION_H__
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include "gtkwidget.h"
|
||||
#include "gtkwindow.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GTK_FILE_OPERATION_COPY,
|
||||
GTK_FILE_OPERATION_MOVE
|
||||
} GtkFileOperationKind;
|
||||
|
||||
typedef struct _GtkFileOperation GtkFileOperation;
|
||||
|
||||
/* Called in the main loop when the operation is over: @moved tells
|
||||
* whether all sources of a move went (none was skipped or failed) */
|
||||
typedef void (*GtkFileOperationDoneFunc) (GtkFileOperation *operation,
|
||||
gboolean cancelled,
|
||||
gboolean moved,
|
||||
gpointer user_data);
|
||||
|
||||
/* Copies or moves @sources (a list of GFile) into the folder
|
||||
* @destination in a thread of its own. Its progress and a Cancel button
|
||||
* are shown in a row that is packed into @box half a second after the
|
||||
* start, if it runs that long; questions (a file of the same name, an
|
||||
* error) are asked in dialogs transient for @parent. The operation
|
||||
* frees itself after @done. */
|
||||
GtkFileOperation *_gtk_file_operation_start (GtkFileOperationKind kind,
|
||||
GList *sources,
|
||||
GFile *destination,
|
||||
GtkWidget *box,
|
||||
GtkWindow *parent,
|
||||
GtkFileOperationDoneFunc done,
|
||||
gpointer user_data);
|
||||
|
||||
void _gtk_file_operation_cancel (GtkFileOperation *operation);
|
||||
|
||||
/* The clipboard of file managers: x-special/gnome-copied-files ("copy"
|
||||
* or "cut" and URIs, as Nautilus, Caja, Thunar and PCManFM use it) and
|
||||
* text/uri-list with application/x-kde-cutselection (Dolphin) */
|
||||
#define GTK_FILE_CLIPBOARD_GNOME "x-special/gnome-copied-files"
|
||||
#define GTK_FILE_CLIPBOARD_KDE_CUT "application/x-kde-cutselection"
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_FILE_OPERATION_H__ */
|
||||
|
|
@ -120,6 +120,7 @@ gtk_OBJECTS_file = \
|
|||
gtkfilechooserentry.obj \
|
||||
gtkfilechoosersettings.obj \
|
||||
gtkfilechooserutils.obj \
|
||||
gtkfileoperation.obj \
|
||||
gtkfilechooserwidget.obj \
|
||||
gtkfilefilter.obj \
|
||||
gtkfilesystem.obj \
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ subdir = po-properties
|
|||
top_builddir = ..
|
||||
|
||||
# These options get passed to xgettext.
|
||||
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
|
||||
XGETTEXT_OPTIONS = --from-code=UTF-8 --keyword=_ --keyword=N_
|
||||
|
||||
# This is the copyright holder that gets inserted into the header of the
|
||||
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ subdir = po
|
|||
top_builddir = ..
|
||||
|
||||
# These options get passed to xgettext.
|
||||
XGETTEXT_OPTIONS = --keyword=_ --keyword=N_
|
||||
XGETTEXT_OPTIONS = --from-code=UTF-8 --keyword=_ --keyword=N_
|
||||
|
||||
# This is the copyright holder that gets inserted into the header of the
|
||||
# $(DOMAIN).pot file. Set this to the copyright holder of the surrounding
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ gtk/gtkfilechooserembed.c
|
|||
gtk/gtkfilechooserentry.c
|
||||
gtk/gtkfilechoosersettings.c
|
||||
gtk/gtkfilechooserutils.c
|
||||
gtk/gtkfileoperation.c
|
||||
gtk/gtkfilechooserwidget.c
|
||||
gtk/gtkfilefilter.c
|
||||
gtk/gtkfilesel.c
|
||||
|
|
|
|||
88
po/de.po
88
po/de.po
|
|
@ -6130,3 +6130,91 @@ msgstr ""
|
|||
|
||||
#~ msgid "X"
|
||||
#~ msgstr "X"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
#, c-format
|
||||
msgid "%s (copy)"
|
||||
msgstr "%s (Kopie)"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
#, c-format
|
||||
msgid "%s (copy %d)"
|
||||
msgstr "%s (Kopie %d)"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
msgid "Preparing to copy…"
|
||||
msgstr "Kopieren wird vorbereitet …"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
msgid "Preparing to move…"
|
||||
msgstr "Verschieben wird vorbereitet …"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
#, c-format
|
||||
msgid "Copying “%s”: %u of %u files, %s of %s"
|
||||
msgstr "„%s“ wird kopiert: %u von %u Dateien, %s von %s"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
#, c-format
|
||||
msgid "Moving “%s”: %u of %u files, %s of %s"
|
||||
msgstr "„%s“ wird verschoben: %u von %u Dateien, %s von %s"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
#, c-format
|
||||
msgid "A folder named “%s” already exists in “%s”."
|
||||
msgstr "Ein Ordner namens „%s“ existiert bereits in „%s“."
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
#, c-format
|
||||
msgid "A file named “%s” already exists in “%s”."
|
||||
msgstr "Eine Datei namens „%s“ existiert bereits in „%s“."
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
msgid "Merging adds the contents to the folder there; files of the same name are asked for."
|
||||
msgstr "Zusammenführen fügt den Inhalt zum vorhandenen Ordner hinzu; bei Dateien gleichen Namens wird nachgefragt."
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
msgid "Replacing it overwrites its contents."
|
||||
msgstr "Ersetzen überschreibt ihren Inhalt."
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
msgid "It can be kept under another name."
|
||||
msgstr "Sie kann unter einem anderen Namen behalten werden."
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
msgid "_New name:"
|
||||
msgstr "_Neuer Name:"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
msgid "Do this for _all further conflicts"
|
||||
msgstr "Für _alle weiteren Konflikte so verfahren"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
msgid "_Skip"
|
||||
msgstr "Ü_berspringen"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
msgid "Re_name"
|
||||
msgstr "_Umbenennen"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
msgid "_Merge"
|
||||
msgstr "_Zusammenführen"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
#, c-format
|
||||
msgid "“%s” could not be copied."
|
||||
msgstr "„%s“ konnte nicht kopiert werden."
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
#, c-format
|
||||
msgid "“%s” could not be moved."
|
||||
msgstr "„%s“ konnte nicht verschoben werden."
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
msgid "Skip _all further errors"
|
||||
msgstr "_Alle weiteren Fehler überspringen"
|
||||
|
||||
#: gtk/gtkfileoperation.c
|
||||
msgid "A folder can not be copied or moved into itself."
|
||||
msgstr "Ein Ordner kann nicht in sich selbst kopiert oder verschoben werden."
|
||||
|
|
|
|||
Loading…
Reference in a new issue