filechooser: drag and drop like a file manager
Files can be dropped onto folders, the path bar and the sidebar, also from other programs. Same file system moves, otherwise it copies; Ctrl copies, Shift moves, both link. Handles XdndDirectSave (Firefox, Chromium, archive managers) and paths as text. Folders open when you hover over them and the list scrolls at the edges. Also adds Paste Into Folder.
This commit is contained in:
parent
0c96353c22
commit
b086e1f775
7 changed files with 1604 additions and 173 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -189,6 +189,7 @@ struct _GtkFileChooserDefault
|
|||
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_paste_into_item;
|
||||
GtkWidget *browse_files_popup_menu_copy_location_item;
|
||||
GtkWidget *browse_files_popup_menu_undo_item;
|
||||
GtkWidget *browse_files_popup_menu_redo_item;
|
||||
|
|
@ -261,6 +262,19 @@ struct _GtkFileChooserDefault
|
|||
ViewMode view_mode;
|
||||
|
||||
GtkWidget *location_button;
|
||||
/* dragging files over the file chooser */
|
||||
GFile *dnd_folder; /* where a drop now would go */
|
||||
gint dnd_action; /* what it would do */
|
||||
GFile *dnd_hover_folder; /* opened when a drag stays on it */
|
||||
guint dnd_hover_id;
|
||||
guint dnd_scroll_id;
|
||||
gint dnd_scroll_step;
|
||||
GtkWidget *dnd_scroll_view;
|
||||
GtkWidget *dnd_highlighted; /* a button of the path bar */
|
||||
GFile *dnd_xds_file; /* where a file saved by the source goes */
|
||||
GHashTable *dnd_filesystems; /* folder URI -> id::filesystem, per drag */
|
||||
gchar **drag_uris; /* what our own drag carries */
|
||||
|
||||
GtkWidget *history_back_button;
|
||||
GtkWidget *history_forward_button;
|
||||
|
||||
|
|
|
|||
|
|
@ -452,6 +452,22 @@ free_name_in (GFile *dir,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
GFile *
|
||||
_gtk_file_operation_free_name (GFile *folder,
|
||||
const gchar *basename)
|
||||
{
|
||||
GFile *file;
|
||||
|
||||
g_return_val_if_fail (G_IS_FILE (folder), NULL);
|
||||
|
||||
file = g_file_get_child (folder, basename);
|
||||
if (!g_file_query_exists (file, NULL))
|
||||
return file;
|
||||
g_object_unref (file);
|
||||
|
||||
return free_name_in (folder, basename, FALSE, NULL);
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
/* progress, main loop side */
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ const gchar * _gtk_file_operation_undo_label (gboolean redo,
|
|||
GFile * _gtk_file_operation_undo_removes (gboolean redo,
|
||||
GFile *folder);
|
||||
|
||||
/* @basename in @folder, or "name (2).ext" and so on when it is taken */
|
||||
GFile * _gtk_file_operation_free_name (GFile *folder,
|
||||
const gchar *basename);
|
||||
|
||||
/* What the file chooser does itself, for Undo */
|
||||
void _gtk_file_operation_add_rename (GFile *from,
|
||||
GFile *to);
|
||||
|
|
|
|||
|
|
@ -1839,5 +1839,51 @@ _gtk_path_bar_down (GtkPathBar *path_bar)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* _gtk_path_bar_get_file_at:
|
||||
* @path_bar: a #GtkPathBar
|
||||
* @x: X coordinate, relative to the path bar
|
||||
* @y: Y coordinate, relative to the path bar
|
||||
* @button: (out): the button there
|
||||
*
|
||||
* For dropping files on the folders of the path bar.
|
||||
*
|
||||
* Returns: the folder of the button at @x, @y, or %NULL
|
||||
**/
|
||||
GFile *
|
||||
_gtk_path_bar_get_file_at (GtkPathBar *path_bar,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkWidget **button)
|
||||
{
|
||||
GtkWidget *widget = GTK_WIDGET (path_bar);
|
||||
GList *l;
|
||||
|
||||
*button = NULL;
|
||||
/* the path bar has no window: the buttons are placed in the one of
|
||||
* its parent, as the coordinates of a drop are not */
|
||||
x += widget->allocation.x;
|
||||
y += widget->allocation.y;
|
||||
|
||||
for (l = path_bar->button_list; l; l = l->next)
|
||||
{
|
||||
ButtonData *button_data = l->data;
|
||||
GtkWidget *b = button_data->button;
|
||||
|
||||
if (!gtk_widget_get_visible (b) || !gtk_widget_get_child_visible (b))
|
||||
continue;
|
||||
|
||||
if (x >= b->allocation.x && x < b->allocation.x + b->allocation.width &&
|
||||
y >= b->allocation.y && y < b->allocation.y + b->allocation.height)
|
||||
{
|
||||
*button = b;
|
||||
return button_data->file;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#define __GTK_PATH_BAR_C__
|
||||
#include "gtkaliasdef.c"
|
||||
|
|
|
|||
|
|
@ -90,6 +90,10 @@ gboolean _gtk_path_bar_set_file (GtkPathBar *path_bar,
|
|||
GError **error);
|
||||
void _gtk_path_bar_up (GtkPathBar *path_bar);
|
||||
void _gtk_path_bar_down (GtkPathBar *path_bar);
|
||||
GFile *_gtk_path_bar_get_file_at (GtkPathBar *path_bar,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkWidget **button);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
|||
28
po/de.po
28
po/de.po
|
|
@ -6419,3 +6419,31 @@ msgstr "_Wiederholen"
|
|||
#: gtk/gtkfileoperation.c
|
||||
msgid "The shell could not put the file back from the Recycle Bin"
|
||||
msgstr "Die Shell konnte die Datei nicht aus dem Papierkorb zurücklegen"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "_Move Here"
|
||||
msgstr "Hierher _verschieben"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "_Copy Here"
|
||||
msgstr "Hierher _kopieren"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "_Link Here"
|
||||
msgstr "Hierher ver_knüpfen"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "_Select"
|
||||
msgstr "_Auswählen"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "Paste _Into Folder"
|
||||
msgstr "In den Ordner _einfügen"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "The file could not be saved"
|
||||
msgstr "Die Datei konnte nicht gespeichert werden"
|
||||
|
||||
#: gtk/gtkfilechooserdefault.c
|
||||
msgid "The program it came from could not write it there."
|
||||
msgstr "Das Programm, aus dem sie kommt, konnte sie dort nicht schreiben."
|
||||
|
|
|
|||
Loading…
Reference in a new issue