Revision: 1324
http://geeqie.svn.sourceforge.net/geeqie/?rev=1324&view=rev
Author: nadvornik
Date: 2009-01-02 09:26:23 +0000 (Fri, 02 Jan 2009)
Log Message:
-----------
sidecar files grouping was made case-insensitive
added possibility to use macros %raw, %image, %meta in extensions lists
Modified Paths:
--------------
trunk/src/editors.c
trunk/src/filedata.c
trunk/src/filefilter.c
trunk/src/filefilter.h
trunk/src/options.c
trunk/src/options.h
trunk/src/preferences.c
trunk/src/rcfile.c
trunk/src/ui_fileops.c
trunk/src/ui_fileops.h
Modified: trunk/src/editors.c
===================================================================
--- trunk/src/editors.c 2008-12-27 22:53:07 UTC (rev 1323)
+++ trunk/src/editors.c 2009-01-02 09:26:23 UTC (rev 1324)
@@ -56,14 +56,14 @@
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 */
Modified: trunk/src/filedata.c
===================================================================
--- trunk/src/filedata.c 2008-12-27 22:53:07 UTC (rev 1323)
+++ trunk/src/filedata.c 2009-01-02 09:26:23 UTC (rev 1324)
@@ -395,7 +395,7 @@
work = work->next;
- if (strcmp(ext, fd->extension) == 0)
+ if (strcasecmp(ext, fd->extension) == 0)
{
new_fd = fd; /* processing the original file */
}
@@ -403,9 +403,8 @@
{
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);
@@ -730,7 +729,7 @@
gchar *ext = work->data;
work = work->next;
- if (strcmp(extension, ext) == 0) return i;
+ if (strcasecmp(extension, ext) == 0) return i;
i++;
}
return 0;
Modified: trunk/src/filefilter.c
===================================================================
--- trunk/src/filefilter.c 2008-12-27 22:53:07 UTC (rev 1323)
+++ trunk/src/filefilter.c 2009-01-02 09:26:23 UTC (rev 1324)
@@ -260,6 +260,8 @@
while (*p != '\0')
{
const gchar *b;
+ const gchar *ext;
+ gint file_class = -1;
guint l = 0;
b = p;
@@ -268,7 +270,23 @@
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++;
}
@@ -315,6 +333,8 @@
}
}
}
+
+ sidecar_ext_parse(options->sidecar.ext, FALSE); /* this must be updated
after changed file extensions */
}
gint filter_name_exists(const gchar *name)
@@ -480,30 +500,5 @@
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: */
Modified: trunk/src/filefilter.h
===================================================================
--- trunk/src/filefilter.h 2008-12-27 22:53:07 UTC (rev 1323)
+++ trunk/src/filefilter.h 2009-01-02 09:26:23 UTC (rev 1324)
@@ -42,9 +42,7 @@
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);
Modified: trunk/src/options.c
===================================================================
--- trunk/src/options.c 2008-12-27 22:53:07 UTC (rev 1323)
+++ trunk/src/options.c 2009-01-02 09:26:23 UTC (rev 1324)
@@ -203,7 +203,7 @@
}
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());
Modified: trunk/src/options.h
===================================================================
--- trunk/src/options.h 2008-12-27 22:53:07 UTC (rev 1323)
+++ trunk/src/options.h 2009-01-02 09:26:23 UTC (rev 1324)
@@ -101,6 +101,10 @@
gboolean disable;
} file_filter;
+ struct {
+ gchar *ext;
+ } sidecar;
+
/* collections */
struct {
gboolean rectangular_selection;
Modified: trunk/src/preferences.c
===================================================================
--- trunk/src/preferences.c 2008-12-27 22:53:07 UTC (rev 1323)
+++ trunk/src/preferences.c 2009-01-02 09:26:23 UTC (rev 1324)
@@ -277,7 +277,8 @@
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;
@@ -1221,7 +1222,7 @@
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);
Modified: trunk/src/rcfile.c
===================================================================
--- trunk/src/rcfile.c 2008-12-27 22:53:07 UTC (rev 1323)
+++ trunk/src/rcfile.c 2009-01-02 09:26:23 UTC (rev 1324)
@@ -463,9 +463,8 @@
WRITE_SUBTITLE("Sidecars Options");
- sidecar_ext_write(ssi);
+ WRITE_CHAR(sidecar.ext);
-
WRITE_SUBTITLE("Color Profiles");
#ifndef HAVE_LCMS
@@ -842,11 +841,7 @@
continue;
}
- if (g_ascii_strcasecmp(option, "sidecar.ext") == 0)
- {
- sidecar_ext_parse(value_all, TRUE);
- continue;
- }
+ READ_CHAR(sidecar.ext);
/* Color Profiles */
Modified: trunk/src/ui_fileops.c
===================================================================
--- trunk/src/ui_fileops.c 2008-12-27 22:53:07 UTC (rev 1323)
+++ trunk/src/ui_fileops.c 2009-01-02 09:26:23 UTC (rev 1324)
@@ -311,6 +311,51 @@
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;
Modified: trunk/src/ui_fileops.h
===================================================================
--- trunk/src/ui_fileops.h 2008-12-27 22:53:07 UTC (rev 1323)
+++ trunk/src/ui_fileops.h 2009-01-02 09:26:23 UTC (rev 1324)
@@ -44,6 +44,9 @@
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);
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn