Mercurial > geeqie.yaz
changeset 134:9009856628f7
started implementation of external commands; external Delete should work
author | nadvornik |
---|---|
date | Wed, 15 Aug 2007 21:37:51 +0000 |
parents | 532c42d5ed4d |
children | 15c1925b3bfb |
files | src/editors.c src/editors.h src/gqview.h src/preferences.c src/typedefs.h src/utilops.c |
diffstat | 6 files changed, 66 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/editors.c Fri Jul 20 07:10:48 2007 +0000 +++ b/src/editors.c Wed Aug 15 21:37:51 2007 +0000 @@ -46,7 +46,7 @@ }; -static gchar *editor_slot_defaults[] = { +static gchar *editor_slot_defaults[GQVIEW_EDITOR_SLOTS * 2] = { N_("The Gimp"), "gimp-remote -n %f", N_("XV"), "xv %f", N_("Xpaint"), "xpaint %f", @@ -57,10 +57,14 @@ NULL, NULL, 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", - NULL, NULL + /* special slots */ + "External Copy command", NULL, + "External Move command", NULL, + "External Rename command", NULL, + "External Delete command", NULL, + "External New Folder command", NULL }; - static void editor_verbose_window_progress(EditorVerboseData *vd, const gchar *text); static gint editor_command_next(EditorVerboseData *vd); @@ -502,10 +506,11 @@ * * [1] Note: %v,%V may also be preceded by "%w". */ -static void editor_command_run(const gchar *template, const gchar *text, GList *list) +static gint editor_command_run(const gchar *template, const gchar *text, GList *list) { gint verbose = FALSE; gint for_each = FALSE; + gint ret = TRUE; if (!template || template[0] == '\0') return; @@ -587,36 +592,44 @@ } else { - system(result->str); + int status = system(result->str); + /* FIXME: consistent return values */ + if (!WIFEXITED(status) || WEXITSTATUS(status)) + ret = FALSE; } g_free(front); g_string_free(result, TRUE); } + return ret; } -void start_editor_from_path_list(gint n, GList *list) +gint start_editor_from_path_list(gint n, GList *list) { gchar *command; + gint ret; if (n < 0 || n >= GQVIEW_EDITOR_SLOTS || !list || !editor_command[n] || - strlen(editor_command[n]) == 0) return; + strlen(editor_command[n]) == 0) return FALSE; command = g_locale_from_utf8(editor_command[n], -1, NULL, NULL, NULL); - editor_command_run(command, editor_name[n], list); + ret = editor_command_run(command, editor_name[n], list); g_free(command); + return ret; } -void start_editor_from_file(gint n, const gchar *path) +gint start_editor_from_file(gint n, const gchar *path) { GList *list; + gint ret; - if (!path) return; + if (!path) return FALSE; list = g_list_append(NULL, (gchar *)path); - start_editor_from_path_list(n, list); + ret = start_editor_from_path_list(n, list); g_list_free(list); + return ret; } gint editor_window_flag_set(gint n)
--- a/src/editors.h Fri Jul 20 07:10:48 2007 +0000 +++ b/src/editors.h Wed Aug 15 21:37:51 2007 +0000 @@ -15,8 +15,8 @@ void editor_reset_defaults(void); -void start_editor_from_file(gint n, const gchar *path); -void start_editor_from_path_list(gint n, GList *list); +gint start_editor_from_file(gint n, const gchar *path); +gint start_editor_from_path_list(gint n, GList *list); gint editor_window_flag_set(gint n);
--- a/src/gqview.h Fri Jul 20 07:10:48 2007 +0000 +++ b/src/gqview.h Wed Aug 15 21:37:51 2007 +0000 @@ -53,7 +53,6 @@ #include <gdk-pixbuf/gdk-pixbuf.h> #include <gdk-pixbuf/gdk-pixbuf-loader.h> -#include "typedefs.h" /* *---------------------------------------------------------------------------- @@ -77,10 +76,12 @@ #define MOUSEWHEEL_SCROLL_SIZE 20 -#define GQVIEW_EDITOR_SLOTS 10 +#define GQVIEW_EDITOR_GENERIC_SLOTS 10 #define COLOR_PROFILE_INPUTS 4 +#include "typedefs.h" + /* *---------------------------------------------------------------------------- * globals
--- a/src/preferences.c Fri Jul 20 07:10:48 2007 +0000 +++ b/src/preferences.c Wed Aug 15 21:37:51 2007 +0000 @@ -199,10 +199,13 @@ for(i = 0; i < GQVIEW_EDITOR_SLOTS; i++) { - g_free(editor_name[i]); - editor_name[i] = NULL; - buf = gtk_entry_get_text(GTK_ENTRY(editor_name_entry[i])); - if (buf && strlen(buf) > 0) editor_name[i] = g_strdup(buf); + if (i < GQVIEW_EDITOR_GENERIC_SLOTS) + { + g_free(editor_name[i]); + editor_name[i] = NULL; + buf = gtk_entry_get_text(GTK_ENTRY(editor_name_entry[i])); + if (buf && strlen(buf) > 0) editor_name[i] = g_strdup(buf); + } g_free(editor_command[i]); editor_command[i] = NULL; @@ -715,7 +718,8 @@ for (i = 0; i < GQVIEW_EDITOR_SLOTS; i++) { - gtk_entry_set_text(GTK_ENTRY(editor_name_entry[i]), + if (i < GQVIEW_EDITOR_GENERIC_SLOTS) + gtk_entry_set_text(GTK_ENTRY(editor_name_entry[i]), (editor_name[i]) ? editor_name[i] : ""); gtk_entry_set_text(GTK_ENTRY(editor_command_entry[i]), (editor_command[i]) ? editor_command[i] : ""); @@ -1117,14 +1121,22 @@ { gchar *buf; - buf = g_strdup_printf("%d", i+1); - pref_table_label(table, 0, i+1, buf, 1.0); - g_free(buf); - editor_name_entry[i] = gtk_entry_new(); - gtk_entry_set_max_length(GTK_ENTRY(editor_name_entry[i]), EDITOR_NAME_MAX_LENGTH); - gtk_widget_set_size_request(editor_name_entry[i],80,-1); - if (editor_name[i]) gtk_entry_set_text(GTK_ENTRY(editor_name_entry[i]),editor_name[i]); + if (i < GQVIEW_EDITOR_GENERIC_SLOTS) + { + buf = g_strdup_printf("%d", i+1); + pref_table_label(table, 0, i+1, buf, 1.0); + g_free(buf); + editor_name_entry[i] = gtk_entry_new(); + gtk_entry_set_max_length(GTK_ENTRY(editor_name_entry[i]), EDITOR_NAME_MAX_LENGTH); + gtk_widget_set_size_request(editor_name_entry[i],80,-1); + if (editor_name[i]) gtk_entry_set_text(GTK_ENTRY(editor_name_entry[i]),editor_name[i]); + } + else + { + editor_name_entry[i] = gtk_label_new(editor_name[i]); + } + gtk_table_attach(GTK_TABLE (table),editor_name_entry[i],1,2,i+1,i+2, GTK_FILL | GTK_EXPAND, 0, 0, 0); gtk_widget_show(editor_name_entry[i]);
--- a/src/typedefs.h Fri Jul 20 07:10:48 2007 +0000 +++ b/src/typedefs.h Wed Aug 15 21:37:51 2007 +0000 @@ -13,6 +13,14 @@ #ifndef TYPEDEFS_H #define TYPEDEFS_H +typedef enum { + CMD_COPY = GQVIEW_EDITOR_GENERIC_SLOTS, + CMD_MOVE, + CMD_RENAME, + CMD_DELETE, + CMD_FOLDER, + GQVIEW_EDITOR_SLOTS +} SpecialEditor; typedef enum { SORT_NONE,
--- a/src/utilops.c Fri Jul 20 07:10:48 2007 +0000 +++ b/src/utilops.c Wed Aug 15 21:37:51 2007 +0000 @@ -1233,6 +1233,11 @@ if (!isfile(path)) return FALSE; + if (editor_command[CMD_DELETE]) + { + return start_editor_from_file(CMD_DELETE, path); + } + if (!safe_delete_enable) { return unlink_file(path);