Mercurial > geeqie
diff src/utilops.c @ 497:a33badd85f16
Allow the copy of file paths to clipboard.
This feature is disabled by default, it can be set through
Preferences > Advanced > Behavior > Show "Copy path" ...
When enabled, it adds a menu entry "Copy path" that let the
user copies current selection's paths to X clipboard.
It is very convenient to paste paths to xterm for example.
Patch by Carles Pina i Estany and me.
author | zas_ |
---|---|
date | Wed, 23 Apr 2008 22:17:21 +0000 |
parents | c7a2471e5c4e |
children | fc9c8a3e1a8b |
line wrap: on
line diff
--- a/src/utilops.c Wed Apr 23 21:08:29 2008 +0000 +++ b/src/utilops.c Wed Apr 23 22:17:21 2008 +0000 @@ -1238,6 +1238,40 @@ real_file_util_move(source_fd, source_list, dest_path, TRUE, parent); } +void file_util_copy_path_to_clipboard(FileData *fd) +{ + GtkClipboard *clipboard; + + if (!fd || !*fd->path) return; + + clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); + gtk_clipboard_set_text(clipboard, g_shell_quote(fd->path), -1); +} + +void file_util_copy_path_list_to_clipboard(GList *list) +{ + GtkClipboard *clipboard; + GList *work; + GString *new; + + clipboard = gtk_clipboard_get(GDK_SELECTION_PRIMARY); + + new = g_string_new(""); + work = list; + while (work) { + FileData *fd = work->data; + work = work->next; + + if (!fd || !*fd->path) continue; + + g_string_append(new, g_shell_quote(fd->path)); + if (work) g_string_append_c(new, ' '); + } + + gtk_clipboard_set_text(clipboard, new->str, new->len); + g_string_free(new, TRUE); +} + void file_util_move_simple(GList *list, const gchar *dest_path) { if (!list) return;