Mercurial > geeqie.yaz
changeset 136:18c2a29e681c
more external commands
author | nadvornik |
---|---|
date | Mon, 20 Aug 2007 20:11:32 +0000 |
parents | 15c1925b3bfb |
children | be3328a58875 |
files | src/editors.c src/editors.h src/utilops.c |
diffstat | 3 files changed, 56 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/editors.c Thu Aug 16 20:57:09 2007 +0000 +++ b/src/editors.c Mon Aug 20 20:11:32 2007 +0000 @@ -58,11 +58,20 @@ N_("Rotate jpeg clockwise"), "%vif jpegtran -rotate 90 -copy all -outfile %p_tmp %p; then mv %p_tmp %p;else rm %p_tmp;fi", N_("Rotate jpeg counterclockwise"), "%vif jpegtran -rotate 270 -copy all -outfile %p_tmp %p; then mv %p_tmp %p;else rm %p_tmp;fi", /* special slots */ +#if 1 + /* for testing */ + "External Copy command", "%vset -x;cp %f", + "External Move command", "%vset -x;mv %f", + "External Rename command", "%vset -x;mv %f", + "External Delete command", "%vset -x;rm %f", + "External New Folder command", NULL +#else "External Copy command", NULL, "External Move command", NULL, "External Rename command", NULL, "External Delete command", NULL, "External New Folder command", NULL +#endif }; static void editor_verbose_window_progress(EditorVerboseData *vd, const gchar *text); @@ -629,6 +638,21 @@ return ret; } +gint start_editor_from_pair(gint n, const gchar *source, const gchar *target) +{ + GList *list; + gint ret; + + if (!source) return FALSE; + if (!target) return FALSE; + + list = g_list_append(NULL, (gchar *)source); + list = g_list_append(list, (gchar *)target); + ret = start_editor_from_path_list(n, list); + g_list_free(list); + return ret; +} + gint editor_window_flag_set(gint n) { if (n < 0 || n >= GQVIEW_EDITOR_SLOTS ||
--- a/src/editors.h Thu Aug 16 20:57:09 2007 +0000 +++ b/src/editors.h Mon Aug 20 20:11:32 2007 +0000 @@ -17,6 +17,8 @@ void editor_reset_defaults(void); gint start_editor_from_file(gint n, const gchar *path); gint start_editor_from_path_list(gint n, GList *list); +gint start_editor_from_pair(gint n, const gchar *source, const gchar *target); + gint editor_window_flag_set(gint n);
--- a/src/utilops.c Thu Aug 16 20:57:09 2007 +0000 +++ b/src/utilops.c Mon Aug 20 20:11:32 2007 +0000 @@ -333,6 +333,28 @@ *-------------------------------------------------------------------------- */ +static gint copy_file_ext(const gchar *s, const gchar *t) +{ + if (editor_command[CMD_COPY]) + return start_editor_from_pair(CMD_COPY, s, t); + return copy_file(s, t); +} + +static gint move_file_ext(const gchar *s, const gchar *t) +{ + if (editor_command[CMD_MOVE]) + return start_editor_from_pair(CMD_MOVE, s, t); + return move_file(s, t); +} + +static gint rename_file_ext(const gchar *s, const gchar *t) +{ + if (editor_command[CMD_RENAME]) + return start_editor_from_pair(CMD_RENAME, s, t); + return rename_file(s, t); +} + + /* * Multi file move */ @@ -637,7 +659,7 @@ { if (fdm->copy) { - if (copy_file(fdm->source, fdm->dest)) + if (copy_file_ext(fdm->source, fdm->dest)) { success = TRUE; file_maint_copied(fdm->source, fdm->dest); @@ -645,7 +667,7 @@ } else { - if (move_file(fdm->source, fdm->dest)) + if (move_file_ext(fdm->source, fdm->dest)) { success = TRUE; file_maint_moved(fdm->source, fdm->dest, fdm->source_list); @@ -870,7 +892,7 @@ gint success = FALSE; if (fds->copy) { - if (copy_file(fds->source, fds->dest)) + if (copy_file_ext(fds->source, fds->dest)) { success = TRUE; file_maint_copied(fds->source, fds->dest); @@ -878,7 +900,7 @@ } else { - if (move_file(fds->source, fds->dest)) + if (move_file_ext(fds->source, fds->dest)) { success = TRUE; file_maint_moved(fds->source, fds->dest, NULL); @@ -1768,7 +1790,7 @@ } else { - if (!rename_file(fd->source_path, fd->dest_path)) + if (!rename_file_ext(fd->source_path, fd->dest_path)) { gchar *text = g_strdup_printf(_("Unable to rename file:\n%s\n to:\n%s"), filename_from_path(fd->source_path), @@ -1989,7 +2011,7 @@ dest = g_strdup_printf("%s/%s%0*d%s", base, front, padding, n, end); } - if (!rename_file(path, dest)) + if (!rename_file_ext(path, dest)) { success = FALSE; } @@ -2489,7 +2511,7 @@ } else { - if (!rename_file(fds->source, fds->dest)) + if (!rename_file_ext(fds->source, fds->dest)) { gchar *text = g_strdup_printf(_("Unable to rename file:\n%s\nto:\n%s"), filename_from_path(fds->source), filename_from_path(fds->dest)); file_util_warning_dialog(_("Error renaming file"), text, GTK_STOCK_DIALOG_ERROR, NULL); @@ -2704,7 +2726,7 @@ return FALSE; } - if (!rename_file(old_path, new_path)) + if (!rename_file_ext(old_path, new_path)) { gchar *text = g_strdup_printf(_("Failed to rename %s to %s."), old_name, new_name); file_util_warning_dialog(_("Rename failed"), text, GTK_STOCK_DIALOG_ERROR, parent);