};
-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
};
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);
}
}
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)
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);
{
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)
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
{
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();
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)
} collections;
/* editors */
- gchar *editor_name[GQ_EDITOR_SLOTS];
- gchar *editor_command[GQ_EDITOR_SLOTS];
+ Editor editor[GQ_EDITOR_SLOTS];
/* file sorting */
struct {
{
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)
{
{
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);
}
}
{
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 : "");
}
}
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);
}
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);
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);
{
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;
}
{
gchar *buf;
- if (options->editor_command[CMD_DELETE])
+ if (options->editor[CMD_DELETE].command)
{
buf = g_strdup(_("Deletion by external command"));
}
typedef struct _SecureSaveInfo SecureSaveInfo;
+typedef struct _Editor Editor;
+struct _Editor {
+ gchar *name;
+ gchar *command;
+};
struct _ImageLoader
{
{
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 */
{
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 */
{
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 */
}
- if (options->editor_command[CMD_DELETE])
+ if (options->editor[CMD_DELETE].command)
{
gint flags;
work = source_list;
}
- 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)))