Mercurial > geeqie
changeset 730:2d8a8e892b5e
Use a struct to handle editor's properties.
author | zas_ |
---|---|
date | Thu, 22 May 2008 08:49:52 +0000 |
parents | 9a6a7e95467a |
children | fa8f7d7396cf |
files | src/editors.c src/layout_util.c src/main.c src/menu.c src/options.h src/preferences.c src/rcfile.c src/trash.c src/typedefs.h src/utilops.c |
diffstat | 10 files changed, 71 insertions(+), 67 deletions(-) [+] |
line wrap: on
line diff
--- a/src/editors.c Wed May 21 19:37:18 2008 +0000 +++ b/src/editors.c Thu May 22 08:49:52 2008 +0000 @@ -56,31 +56,31 @@ }; -static gchar *editor_slot_defaults[GQ_EDITOR_SLOTS * 2] = { - N_("The Gimp"), "gimp-remote %{.cr2;.crw;.nef;.raw;*}f", - N_("XV"), "xv %f", - N_("Xpaint"), "xpaint %f", - N_("UFraw"), "ufraw %{.cr2;.crw;.nef;.raw}p", - N_("Add XMP sidecar"), "%vFILE=%{.cr2;.crw;.nef;.raw}p;XMP=`echo \"$FILE\"|sed -e 's|\\.[^.]*$|.xmp|'`; exiftool -tagsfromfile \"$FILE\" \"$XMP\"", - NULL, NULL, - NULL, NULL, - NULL, NULL, - N_("Rotate jpeg clockwise"), "%vif jpegtran -rotate 90 -copy all -outfile %{.jpg;.jpeg}p_tmp %{.jpg;.jpeg}p; then mv %{.jpg;.jpeg}p_tmp %{.jpg;.jpeg}p;else rm %{.jpg;.jpeg}p_tmp;fi", - N_("Rotate jpeg counterclockwise"), "%vif jpegtran -rotate 270 -copy all -outfile %{.jpg;.jpeg}p_tmp %{.jpg;.jpeg}p; then mv %{.jpg;.jpeg}p_tmp %{.jpg;.jpeg}p;else rm %{.jpg;.jpeg}p_tmp;fi", +static Editor editor_slot_defaults[GQ_EDITOR_SLOTS] = { + { N_("The Gimp"), "gimp-remote %{.cr2;.crw;.nef;.raw;*}f" }, + { N_("XV"), "xv %f" }, + { N_("Xpaint"), "xpaint %f" }, + { N_("UFraw"), "ufraw %{.cr2;.crw;.nef;.raw}p" }, + { N_("Add XMP sidecar"), "%vFILE=%{.cr2;.crw;.nef;.raw}p;XMP=`echo \"$FILE\"|sed -e 's|\\.[^.]*$|.xmp|'`; exiftool -tagsfromfile \"$FILE\" \"$XMP\"" }, + { NULL, NULL }, + { NULL, NULL }, + { NULL, NULL }, + { N_("Rotate jpeg clockwise"), "%vif jpegtran -rotate 90 -copy all -outfile %{.jpg;.jpeg}p_tmp %{.jpg;.jpeg}p; then mv %{.jpg;.jpeg}p_tmp %{.jpg;.jpeg}p;else rm %{.jpg;.jpeg}p_tmp;fi" }, + { N_("Rotate jpeg counterclockwise"), "%vif jpegtran -rotate 270 -copy all -outfile %{.jpg;.jpeg}p_tmp %{.jpg;.jpeg}p; then mv %{.jpg;.jpeg}p_tmp %{.jpg;.jpeg}p;else rm %{.jpg;.jpeg}p_tmp;fi" }, /* special slots */ #if 1 /* for testing */ - N_("External Copy command"), "%vset -x;cp %p %d", - N_("External Move command"), "%vset -x;mv %p %d", - N_("External Rename command"), "%vset -x;mv %p %d", - N_("External Delete command"), NULL, - N_("External New Folder command"), NULL + { N_("External Copy command"), "%vset -x;cp %p %d" }, + { N_("External Move command"), "%vset -x;mv %p %d" }, + { N_("External Rename command"), "%vset -x;mv %p %d" }, + { N_("External Delete command"), NULL }, + { N_("External New Folder command"), NULL }, #else - N_("External Copy command"), NULL, - N_("External Move command"), NULL, - N_("External Rename command"), NULL, - N_("External Delete command"), NULL, - N_("External New Folder command"), NULL + { N_("External Copy command"), NULL }, + { N_("External Move command"), NULL }, + { N_("External Rename command"), NULL }, + { N_("External Delete command"), NULL }, + { N_("External New Folder command"), NULL }, #endif }; @@ -101,10 +101,10 @@ for (i = 0; i < GQ_EDITOR_SLOTS; i++) { - g_free(options->editor_name[i]); - options->editor_name[i] = g_strdup(_(editor_slot_defaults[i * 2])); - g_free(options->editor_command[i]); - options->editor_command[i] = g_strdup(editor_slot_defaults[i * 2 + 1]); + g_free(options->editor[i].name); + options->editor[i].name = g_strdup(_(editor_slot_defaults[i].name)); + g_free(options->editor[i].command); + options->editor[i].command = g_strdup(editor_slot_defaults[i].command); } } @@ -797,8 +797,8 @@ static gint is_valid_editor_command(gint n) { return (n >= 0 && n < GQ_EDITOR_SLOTS - && options->editor_command[n] - && strlen(options->editor_command[n]) > 0); + && options->editor[n].command + && strlen(options->editor[n].command) > 0); } gint start_editor_from_filelist_full(gint n, GList *list, EditorCallback cb, gpointer data) @@ -809,14 +809,14 @@ if (!list) return FALSE; if (!is_valid_editor_command(n)) return FALSE; - command = g_locale_from_utf8(options->editor_command[n], -1, NULL, NULL, NULL); - error = editor_command_start(command, options->editor_name[n], list, cb, data); + command = g_locale_from_utf8(options->editor[n].command, -1, NULL, NULL, NULL); + error = editor_command_start(command, options->editor[n].name, list, cb, data); g_free(command); if (n < GQ_EDITOR_GENERIC_SLOTS && (error & EDITOR_ERROR_MASK)) { gchar *text = g_strdup_printf(_("%s\n#%d \"%s\":\n%s"), editor_get_error_str(error), n+1, - options->editor_name[n], options->editor_command[n]); + options->editor[n].name, options->editor[n].command); file_util_warning_dialog(_("Invalid editor command"), text, GTK_STOCK_DIALOG_ERROR, NULL); g_free(text); @@ -852,7 +852,7 @@ { if (!is_valid_editor_command(n)) return TRUE; - return (editor_command_parse(options->editor_command[n], NULL, NULL) & EDITOR_KEEP_FS); + return (editor_command_parse(options->editor[n].command, NULL, NULL) & EDITOR_KEEP_FS); } const gchar *editor_get_error_str(gint flags)
--- a/src/layout_util.c Wed May 21 19:37:18 2008 +0000 +++ b/src/layout_util.c Thu May 22 08:49:52 2008 +0000 @@ -879,13 +879,13 @@ action = gtk_action_group_get_action(lw->action_group, key); g_object_set_data(G_OBJECT(action), "edit_index", GINT_TO_POINTER(i)); - if (options->editor_command[i] && strlen(options->editor_command[i]) > 0) + if (options->editor[i].command && strlen(options->editor[i].command) > 0) { gchar *text; - if (options->editor_name[i] && strlen(options->editor_name[i]) > 0) + if (options->editor[i].name && strlen(options->editor[i].name) > 0) { - text = g_strdup_printf(_("_%d %s..."), i, options->editor_name[i]); + text = g_strdup_printf(_("_%d %s..."), i, options->editor[i].name); } else {
--- a/src/main.c Wed May 21 19:37:18 2008 +0000 +++ b/src/main.c Thu May 22 08:49:52 2008 +0000 @@ -553,8 +553,8 @@ for (i = 0; i < GQ_EDITOR_SLOTS; i++) { - options->editor_name[i] = NULL; - options->editor_command[i] = NULL; + options->editor[i].name = NULL; + options->editor[i].command = NULL; } editor_reset_defaults();
--- a/src/menu.c Wed May 21 19:37:18 2008 +0000 +++ b/src/menu.c Thu May 22 08:49:52 2008 +0000 @@ -69,11 +69,11 @@ for (i = 0; i < GQ_EDITOR_GENERIC_SLOTS; i++) { - if (options->editor_command[i] && strlen(options->editor_command[i]) > 0) + if (options->editor[i].command && strlen(options->editor[i].command) > 0) { gchar *text; - if (options->editor_name[i] && strlen(options->editor_name[i]) > 0) - text = g_strdup_printf(_("_%d %s..."), i, options->editor_name[i]); + if (options->editor[i].name && strlen(options->editor[i].name) > 0) + text = g_strdup_printf(_("_%d %s..."), i, options->editor[i].name); else text = g_strdup_printf(_("_%d (unknown)..."), i); if (accel_grp)
--- a/src/options.h Wed May 21 19:37:18 2008 +0000 +++ b/src/options.h Thu May 22 08:49:52 2008 +0000 @@ -108,8 +108,7 @@ } collections; /* editors */ - gchar *editor_name[GQ_EDITOR_SLOTS]; - gchar *editor_command[GQ_EDITOR_SLOTS]; + Editor editor[GQ_EDITOR_SLOTS]; /* file sorting */ struct {
--- a/src/preferences.c Wed May 21 19:37:18 2008 +0000 +++ b/src/preferences.c Thu May 22 08:49:52 2008 +0000 @@ -163,14 +163,14 @@ { if (i < GQ_EDITOR_GENERIC_SLOTS) { - g_free(options->editor_name[i]); - options->editor_name[i] = NULL; + g_free(options->editor[i].name); + options->editor[i].name = NULL; buf = gtk_entry_get_text(GTK_ENTRY(editor_name_entry[i])); - if (buf && strlen(buf) > 0) options->editor_name[i] = g_strdup(buf); + if (buf && strlen(buf) > 0) options->editor[i].name = g_strdup(buf); } - g_free(options->editor_command[i]); - options->editor_command[i] = NULL; + g_free(options->editor[i].command); + options->editor[i].command = NULL; buf = gtk_entry_get_text(GTK_ENTRY(editor_command_entry[i])); if (buf && strlen(buf) > 0) { @@ -180,10 +180,10 @@ { if (errmsg->str[0]) g_string_append(errmsg, "\n\n"); g_string_append_printf(errmsg, _("%s\n#%d \"%s\":\n%s"), editor_get_error_str(flags), - i+1, options->editor_name[i], buf); + i+1, options->editor[i].name, buf); } - options->editor_command[i] = g_strdup(buf); + options->editor[i].command = g_strdup(buf); } } @@ -759,9 +759,9 @@ { if (i < GQ_EDITOR_GENERIC_SLOTS) gtk_entry_set_text(GTK_ENTRY(editor_name_entry[i]), - (options->editor_name[i]) ? options->editor_name[i] : ""); + (options->editor[i].name) ? options->editor[i].name : ""); gtk_entry_set_text(GTK_ENTRY(editor_command_entry[i]), - (options->editor_command[i]) ? options->editor_command[i] : ""); + (options->editor[i].command) ? options->editor[i].command : ""); } } @@ -1225,12 +1225,12 @@ entry = gtk_entry_new(); gtk_entry_set_max_length(GTK_ENTRY(entry), EDITOR_NAME_MAX_LENGTH); gtk_widget_set_size_request(entry, 80, -1); - if (options->editor_name[i]) - gtk_entry_set_text(GTK_ENTRY(entry), options->editor_name[i]); + if (options->editor[i].name) + gtk_entry_set_text(GTK_ENTRY(entry), options->editor[i].name); } else { - entry = gtk_label_new(options->editor_name[i]); + entry = gtk_label_new(options->editor[i].name); gtk_misc_set_alignment(GTK_MISC(entry), 0.0, 0.5); } @@ -1243,8 +1243,8 @@ gtk_entry_set_max_length(GTK_ENTRY(entry), EDITOR_COMMAND_MAX_LENGTH); gtk_widget_set_size_request(entry, 160, -1); tab_completion_add_to_entry(entry, NULL, NULL); - if (options->editor_command[i]) - gtk_entry_set_text(GTK_ENTRY(entry), options->editor_command[i]); + if (options->editor[i].command) + gtk_entry_set_text(GTK_ENTRY(entry), options->editor[i].command); gtk_table_attach(GTK_TABLE(table), entry, 2, 3, i+1, i+2, GTK_FILL | GTK_EXPAND, 0, 0, 0); gtk_widget_show(entry);
--- a/src/rcfile.c Wed May 21 19:37:18 2008 +0000 +++ b/src/rcfile.c Thu May 22 08:49:52 2008 +0000 @@ -556,8 +556,8 @@ for (i = 0; i < GQ_EDITOR_SLOTS; i++) { if (i == GQ_EDITOR_GENERIC_SLOTS) secure_fputc(ssi, '\n'); - gchar *qname = escquote_value(options->editor_name[i]); - gchar *qcommand = escquote_value(options->editor_command[i]); + gchar *qname = escquote_value(options->editor[i].name); + gchar *qcommand = escquote_value(options->editor[i].command); secure_fprintf(ssi, "external_%d: %s %s\n", i+1, qname, qcommand); g_free(qname); g_free(qcommand); @@ -887,11 +887,11 @@ { const gchar *ptr; i--; - g_free(options->editor_name[i]); - g_free(options->editor_command[i]); + g_free(options->editor[i].name); + g_free(options->editor[i].command); - options->editor_name[i] = quoted_value(value_all, &ptr); - options->editor_command[i] = quoted_value(ptr, NULL); + options->editor[i].name = quoted_value(value_all, &ptr); + options->editor[i].command = quoted_value(ptr, NULL); } continue; }
--- a/src/trash.c Wed May 21 19:37:18 2008 +0000 +++ b/src/trash.c Thu May 22 08:49:52 2008 +0000 @@ -181,7 +181,7 @@ { gchar *buf; - if (options->editor_command[CMD_DELETE]) + if (options->editor[CMD_DELETE].command) { buf = g_strdup(_("Deletion by external command")); }
--- a/src/typedefs.h Wed May 21 19:37:18 2008 +0000 +++ b/src/typedefs.h Thu May 22 08:49:52 2008 +0000 @@ -165,6 +165,11 @@ typedef struct _SecureSaveInfo SecureSaveInfo; +typedef struct _Editor Editor; +struct _Editor { + gchar *name; + gchar *command; +}; struct _ImageLoader {
--- a/src/utilops.c Wed May 21 19:37:18 2008 +0000 +++ b/src/utilops.c Thu May 22 08:49:52 2008 +0000 @@ -363,7 +363,7 @@ { gint ok; g_assert(fd->change); - if (options->editor_command[CMD_COPY]) + if (options->editor[CMD_COPY].command) { ok = !start_editor_from_file_full(CMD_COPY, fd, copy_file_ext_cb, NULL); if (ok) return ok; /* that's all for now, let's continue in callback */ @@ -411,7 +411,7 @@ { gint ok; g_assert(fd->change); - if (options->editor_command[CMD_MOVE]) + if (options->editor[CMD_MOVE].command) { ok = !start_editor_from_file_full(CMD_MOVE, fd, move_file_ext_cb, NULL); if (ok) return ok; /* that's all for now, let's continue in callback */ @@ -458,7 +458,7 @@ { gint ok; g_assert(fd->change); - if (options->editor_command[CMD_RENAME]) + if (options->editor[CMD_RENAME].command) { ok = !start_editor_from_file_full(CMD_RENAME, fd, rename_file_ext_cb, NULL); if (ok) return ok; /* that's all for now, let's continue in callback */ @@ -1453,7 +1453,7 @@ } - if (options->editor_command[CMD_DELETE]) + if (options->editor[CMD_DELETE].command) { gint flags; work = source_list; @@ -1683,7 +1683,7 @@ } - if (options->editor_command[CMD_DELETE]) + if (options->editor[CMD_DELETE].command) { gint flags; if ((flags = start_editor_from_file_full(CMD_DELETE, fd, file_util_delete_ext_cb, NULL)))