static Editor editor_slot_defaults[GQ_EDITOR_SLOTS] = {
- { N_("The Gimp"), "gimp-remote %{.cr2;.crw;.nef;.raw;*}f" },
+ { N_("The Gimp"), "gimp-remote %{%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\"" },
+ { N_("UFraw"), "ufraw %{%raw}p" },
{ N_("Symlink"), "ln -s %p %d"},
{ 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 */
work = work->next;
- if (strcmp(ext, fd->extension) == 0)
+ if (strcasecmp(ext, fd->extension) == 0)
{
new_fd = fd; /* processing the original file */
}
{
struct stat nst;
g_string_truncate(fname, base_len);
- g_string_append(fname, ext);
- if (!stat_utf8(fname->str, &nst))
+ if (!stat_utf8_case_insensitive_ext(fname, ext, &nst))
continue;
new_fd = file_data_new(fname->str, &nst, FALSE);
gchar *ext = work->data;
work = work->next;
- if (strcmp(extension, ext) == 0) return i;
+ if (strcasecmp(extension, ext) == 0) return i;
i++;
}
return 0;
while (*p != '\0')
{
const gchar *b;
+ const gchar *ext;
+ gint file_class = -1;
guint l = 0;
b = p;
p++;
l++;
}
- list = g_list_append(list, g_strndup(b, l));
+
+ ext = g_strndup(b, l);
+
+ if (strcasecmp(ext, "%image") == 0) file_class = FORMAT_CLASS_IMAGE;
+ else if (strcasecmp(ext, "%raw") == 0) file_class = FORMAT_CLASS_RAWIMAGE;
+ else if (strcasecmp(ext, "%meta") == 0) file_class = FORMAT_CLASS_META;
+
+ if (file_class == -1)
+ {
+ list = g_list_append(list, ext);
+ }
+ else
+ {
+ list = g_list_concat(list, string_list_copy(file_class_extension_list[file_class]));
+ g_free(ext);
+ }
+
if (*p == ';') p++;
}
}
}
}
+
+ sidecar_ext_parse(options->sidecar.ext, FALSE); /* this must be updated after changed file extensions */
}
gint filter_name_exists(const gchar *name)
if (quoted) g_free(value);
}
-void sidecar_ext_write(SecureSaveInfo *ssi)
-{
- secure_fprintf(ssi, "sidecar.ext: \"%s\"\n", sidecar_ext_to_string());
-}
-
-gchar *sidecar_ext_to_string(void)
-{
- GList *work;
- GString *str = g_string_new("");
-
- work = sidecar_ext_list;
- while (work)
- {
- gchar *ext = work->data;
- work = work->next;
- g_string_append(str, ext);
- if (work) g_string_append(str, ";");
- }
- return g_string_free(str, FALSE);
-}
-
-void sidecar_ext_add_defaults(void)
-{
- sidecar_ext_parse(".jpg;.cr2;.nef;.crw;.pef;.dng;.arw;.xmp", FALSE);
-}
/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
void filter_parse(const gchar *text);
void sidecar_ext_parse(const gchar *text, gboolean quoted);
-void sidecar_ext_write(SecureSaveInfo *ssi);
gchar *sidecar_ext_to_string(void);
-void sidecar_ext_add_defaults(void);
GList *sidecar_ext_get_list(void);
gint ishidden(const gchar *name);
}
set_default_image_overlay_template_string(&options->image_overlay.common.template_string);
- sidecar_ext_add_defaults();
+ options->sidecar.ext = g_strdup(".jpg;%raw;.xmp");
options->layout.order = g_strdup("123");
options->properties.tabs_order = g_strdup(info_tab_default_order());
gboolean disable;
} file_filter;
+ struct {
+ gchar *ext;
+ } sidecar;
+
/* collections */
struct {
gboolean rectangular_selection;
options->file_sort.case_sensitive = c_options->file_sort.case_sensitive;
options->file_filter.disable = c_options->file_filter.disable;
- sidecar_ext_parse(gtk_entry_get_text(GTK_ENTRY(sidecar_ext_entry)), FALSE);
+ config_entry_to_option(sidecar_ext_entry, &options->sidecar.ext, NULL);
+ sidecar_ext_parse(options->sidecar.ext, FALSE);
options->slideshow.random = c_options->slideshow.random;
options->slideshow.repeat = c_options->slideshow.repeat;
group = pref_group_new(vbox, FALSE, _("Grouping sidecar extensions"), GTK_ORIENTATION_VERTICAL);
sidecar_ext_entry = gtk_entry_new();
- gtk_entry_set_text(GTK_ENTRY(sidecar_ext_entry), sidecar_ext_to_string());
+ gtk_entry_set_text(GTK_ENTRY(sidecar_ext_entry), options->sidecar.ext);
gtk_box_pack_start(GTK_BOX(group), sidecar_ext_entry, FALSE, FALSE, 0);
gtk_widget_show(sidecar_ext_entry);
WRITE_SUBTITLE("Sidecars Options");
- sidecar_ext_write(ssi);
-
+ WRITE_CHAR(sidecar.ext);
WRITE_SUBTITLE("Color Profiles");
continue;
}
- if (g_ascii_strcasecmp(option, "sidecar.ext") == 0)
- {
- sidecar_ext_parse(value_all, TRUE);
- continue;
- }
+ READ_CHAR(sidecar.ext);
/* Color Profiles */
return ret;
}
+/* extension must contain only ASCII characters */
+gint stat_utf8_case_insensitive_ext(GString *base, const gchar *ext, struct stat *st)
+{
+ gchar *sl;
+ gchar *extl;
+ gint ret = 0;
+ gint ext_len;
+ gint base_len = strlen(base->str);
+
+ g_string_append(base, ext);
+ sl = path_from_utf8(base->str);
+
+ extl = strrchr(sl, '.');
+ if (extl)
+ {
+ gint i, j;
+ extl++; /* the first char after . */
+ ext_len = strlen(extl);
+
+ for (i = 0; i < (1 << ext_len); i++)
+ {
+ for (j = 0; j < ext_len; j++)
+ {
+ if (i & (1 << j))
+ extl[j] = g_ascii_toupper(extl[j]);
+ else
+ extl[j] = g_ascii_tolower(extl[j]);
+ }
+ ret = (stat(sl, st) == 0);
+ if (ret) break;
+ }
+
+ if (ret)
+ {
+ /* append the found extension to base */
+ base = g_string_truncate(base, base_len);
+ extl--;
+ g_string_append(base, extl);
+ }
+ }
+ g_free(sl);
+
+ return ret;
+}
+
gint isname(const gchar *s)
{
struct stat st;
gint stat_utf8(const gchar *s, struct stat *st);
gint lstat_utf8(const gchar *s, struct stat *st);
+gint stat_utf8_case_insensitive_ext(GString *base, const gchar *ext, struct stat *st);
+
+
gint isname(const gchar *s);
gint isfile(const gchar *s);
gint isdir(const gchar *s);