Customizable fullscreen overlay (also Exif in fullscreen)
Timo Horstschäfer <[email protected]> Mon, 10 Sep 2007 19:02:36 +0200
| Newsgroups | gmane.comp.gnome.apps.gqview.devel |
|---|---|
| Message-ID | <[email protected]> |
--Boundary-00=_siX5G8SLT3gkulq
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline
This patch allows customization of the info overlay displayed in fullscreen=
=20
mode.
Customization is done by modifying the fulscreen_info string in gqviewrc.
Gqview then interprets variables identified by surrounding %-signs.
E. g.
%name% results in the filename of the picture.
Other variables are:
%collection%, %number%, %total%, %date%, %size% (filesize), %width%, %heigh=
t%,
%res% (image size, e. g. 800 =D7 600)
In addition all Exif data is accessible by its name in exif.c, e. g.
%fCamera% is the formatted camera name.
If two or more variables are connected with the |-sign, it prints available=
=20
variables with a seperator.
%fShutterSpeed%|%fISOSpeedRating%|%fFocalLength%
could show e. g. "1/20s - 400 - 80 mm" or "1/200 - 80 mm", if there's no IS=
O=20
information in the Exif data.
If a line is empty, it is removed. This allows to add a lines that totally=
=20
disappear if no data is present.
The patch includes a detailed default string and you'll see, the additional=
=20
lines will not show up, if the picture has no Exif data.
The patch also includes a fix to read/write strings containing linebreaks i=
n=20
the config file.
The last chunk can changes colors of the overlay, so its actually not=20
necessary.
--Boundary-00=_siX5G8SLT3gkulq
Content-Type: text/x-diff; charset="iso-8859-1"; name="custom-overlay.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="custom-overlay.patch"
Index: src/globals.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/gqview/gqview/src/globals.c,v
retrieving revision 1.6
diff -u -r1.6 globals.c
=2D-- src/globals.c 25 Nov 2006 03:00:32 -0000 1.6
+++ src/globals.c 9 Sep 2007 15:47:24 -0000
@@ -97,6 +97,7 @@
gint fullscreen_clean_flip =3D FALSE;
gint fullscreen_disable_saver =3D TRUE;
gint fullscreen_above =3D FALSE;
+gchar *fullscreen_info =3D NULL;
=20
gint dupe_custom_threshold =3D 99;
=20
Index: src/gqview.h
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/gqview/gqview/src/gqview.h,v
retrieving revision 1.8
diff -u -r1.8 gqview.h
=2D-- src/gqview.h 25 Nov 2006 03:00:32 -0000 1.8
+++ src/gqview.h 9 Sep 2007 15:47:24 -0000
@@ -161,6 +161,7 @@
extern gint fullscreen_clean_flip;
extern gint fullscreen_disable_saver;
extern gint fullscreen_above;
+extern gchar *fullscreen_info;
=20
extern gint dupe_custom_threshold;
=20
Index: src/main.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/gqview/gqview/src/main.c,v
retrieving revision 1.10
diff -u -r1.10 main.c
=2D-- src/main.c 25 Nov 2006 03:00:32 -0000 1.10
+++ src/main.c 9 Sep 2007 15:47:24 -0000
@@ -1133,6 +1133,8 @@
color_profile_input_file[i] =3D NULL;
color_profile_input_name[i] =3D NULL;
}
+
+ fullscreen_info =3D g_strdup("%collection%(%number%/%total%) <b>%name%</b=
>\n%res%|%date%|%size%\n%fAperture%|%fShutterSpeed%|%fISOSpeedRating%|%fFoc=
alLength%|%fExposureBias%\n%fCamera%|%fFlash%");
}
=20
static void exit_gqview_final(void)
Index: src/rcfile.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/gqview/gqview/src/rcfile.c,v
retrieving revision 1.7
diff -u -r1.7 rcfile.c
=2D-- src/rcfile.c 25 Nov 2006 03:00:33 -0000 1.7
+++ src/rcfile.c 9 Sep 2007 15:47:24 -0000
@@ -65,18 +65,29 @@
=20
static void write_char_option(FILE *f, gchar *label, gchar *text)
{
=2D if (text)
=2D fprintf(f,"%s: \"%s\"\n", label, text);
+ gchar *e;
+ if (text)=09
+ {
+ e =3D g_strescape(text, "");
+ fprintf(f,"%s: \"%s\"\n", label, e);
+ g_free(e);
+ }
else
fprintf(f,"%s: \n", label);
}
=20
static gchar *read_char_option(FILE *f, gchar *option, gchar *label, gchar=
*value, gchar *text)
{
+ gchar *e;
if (strcasecmp(option, label) =3D=3D 0)
{
g_free(text);
=2D text =3D quoted_value(value);
+ e =3D quoted_value(value);
+ if (e)
+ {
+ text =3D g_strcompress(e);
+ g_free(e);
+ }
}
return text;
}
@@ -289,6 +300,7 @@
write_bool_option(f, "fullscreen_clean_flip", fullscreen_clean_flip);
write_bool_option(f, "fullscreen_disable_saver", fullscreen_disable_saver=
);
write_bool_option(f, "fullscreen_above", fullscreen_above);
+ write_char_option(f, "fullscreen_info", fullscreen_info);
=20
write_int_option(f, "custom_similarity_threshold", dupe_custom_threshold);
=20
@@ -556,6 +568,8 @@
"fullscreen_disable_saver", value, fullscreen_disable_saver);
fullscreen_above =3D read_bool_option(f, option,
"fullscreen_above", value, fullscreen_above);
+ fullscreen_info =3D read_char_option(f, option,
+ "fullscreen_info", value_all, fullscreen_info);
=20
dupe_custom_threshold =3D read_int_option(f, option,
"custom_similarity_threshold", value, dupe_custom_threshold);
Index: src/image-overlay.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/gqview/gqview/src/image-overlay.c,v
retrieving revision 1.5
diff -u -r1.5 image-overlay.c
=2D-- src/image-overlay.c 2 Dec 2006 21:57:12 -0000 1.5
+++ src/image-overlay.c 9 Sep 2007 15:47:24 -0000
@@ -19,6 +19,7 @@
#include "layout.h"
#include "pixbuf-renderer.h"
#include "pixbuf_util.h"
+#include "exif.h"
=20
=20
/*
@@ -75,6 +76,77 @@
=20
static void image_osd_timer_schedule(OverlayStateData *osd);
=20
+static gchar* image_osd_mkinfo(const gchar *str, ImageWindow *imd, GHashTa=
ble *vars)
+{
+ gchar delim =3D '%', imp =3D '|', sep[] =3D " - ";
+ gchar *start, *end;
+ gint pos, prev;
+ gint last;
+ gchar *name, *data;
+ GString *new =3D g_string_new(str);
+ gchar *ret;
+ ExifData *exif;
+
+ exif =3D exif_read(imd->image_path, FALSE);
+ prev =3D 0;
+ last =3D FALSE;
+
+ while (TRUE)
+ {
+ start =3D strchr(new->str, delim);
+ if (!start)
+ break;
+ end =3D strchr(start+1, delim);
+ if (!end)
+ break;
+
+ name =3D g_strndup(start+1, end-start-1);
+ pos =3D start-new->str;
+
+ data =3D g_strdup(g_hash_table_lookup(vars, name));
+ if (!data && exif)
+ data =3D exif_get_data_as_text(exif, name);
+
+ g_string_erase(new, pos, end-start+1);
+ if (data)
+ g_string_insert(new, pos, data);
+ if (pos-prev =3D=3D 2 && new->str[pos-1] =3D=3D imp)
+ {
+ g_string_erase(new, --pos, 1);
+ if (last && data)
+ {
+ g_string_insert(new, pos, sep);
+ pos +=3D strlen(sep);
+ }
+ }
+
+ prev =3D data ? pos+strlen(data)-1 : pos-1;
+ last =3D data ? TRUE : last;
+ g_free(name);
+ g_free(data);
+ }
+=09
+ /* search and destroy empty lines */
+ end =3D new->str;
+ while (start =3D strchr(end, '\n'))
+ {
+ end =3D start;
+ while (*++(end) =3D=3D '\n')
+ ;
+ g_string_erase(new, start-new->str, end-start-1);
+ }
+ =09
+
+ g_strchomp(new->str);
+
+ ret =3D new->str;
+ g_string_free(new, FALSE);
+
+ return ret;
+}
+=09
+
+
=20
static GdkPixbuf *image_osd_info_render(ImageWindow *imd)
{
@@ -86,9 +158,13 @@
gchar *text;
gchar *size;
gint n, t;
+ gint w, h;
CollectionData *cd;
CollectInfo *info;
gchar *ct;
+ GHashTable *vars;
+
+ vars =3D g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
=20
name =3D image_get_name(imd);
if (name)
@@ -147,20 +223,10 @@
}
=20
size =3D text_from_size_abrev(imd->size);
=2D if (!name_escaped)
=2D {
=2D text =3D g_strdup_printf(_("Untitled"));
=2D }
=2D else if (imd->unknown)
=2D {
=2D text =3D g_strdup_printf("%s(%d/%d) <b>%s</b>\n%s - %s", ct,
=2D n, t, name_escaped,
=2D text_from_time(imd->mtime), size);
=2D }
=2D else
=2D {
=2D gint w, h;
=20
+
+ if (!imd->unknown)
+ {
if (imd->delay_flip &&
imd->il && imd->il->pixbuf &&
image_get_pixbuf(imd) !=3D imd->il->pixbuf)
@@ -172,15 +238,30 @@
{
pixbuf_renderer_get_image_size(PIXBUF_RENDERER(imd->pr), &w, &h);
}
+ g_hash_table_insert(vars, "width", g_strdup_printf("%d", w));
+ g_hash_table_insert(vars, "height", g_strdup_printf("%d", h));
+ g_hash_table_insert(vars, "res", g_strdup_printf("%d =C3=97 %d", w, h));
+ }
+
+ g_hash_table_insert(vars, "collection", g_strdup(ct));
+ g_hash_table_insert(vars, "number", g_strdup_printf("%d", n));
+ g_hash_table_insert(vars, "total", g_strdup_printf("%d", t));
+ g_hash_table_insert(vars, "name", g_strdup(name_escaped));
+ g_hash_table_insert(vars, "date", g_strdup(text_from_time(imd->mtime)));
+ g_hash_table_insert(vars, "size", g_strdup(size));
=20
=2D text =3D g_strdup_printf("%s(%d/%d) <b>%s</b>\n%d x %d - %s - %s", ct,
=2D n, t, name_escaped,
=2D w, h,
=2D text_from_time(imd->mtime), size);
+ if (!name_escaped)
+ {
+ text =3D g_strdup_printf(_("Untitled"));
+ }
+ else
+ {
+ text =3D image_osd_mkinfo(fullscreen_info, imd, vars);
}
g_free(size);
g_free(ct);
g_free(name_escaped);
+ g_hash_table_destroy(vars);
=20
layout =3D gtk_widget_create_pango_layout(imd->pr, NULL);
pango_layout_set_markup(layout, text, -1);
@@ -192,16 +273,16 @@
height +=3D 10;
=20
pixbuf =3D gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
=2D pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, 240, 240, 240, 21=
0);
=2D pixbuf_set_rect(pixbuf, 0, 0, width, height, 240, 240, 240, 80, 1, 1, 1=
, 1);
=2D pixbuf_set_rect(pixbuf, 1, 1, width-2, height-2, 240, 240, 240, 130, 1,=
1, 1, 1);
=2D pixbuf_set_rect(pixbuf, 2, 2, width-4, height-4, 240, 240, 240, 180, 1,=
1, 1, 1);
+ pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, 0, 0, 0, 120);
+ pixbuf_set_rect(pixbuf, 0, 0, width, height, 0, 0, 0, 30, 1, 1, 1, 1);
+ pixbuf_set_rect(pixbuf, 1, 1, width-2, height-2, 0, 0, 0, 60, 1, 1, 1, 1);
+ pixbuf_set_rect(pixbuf, 2, 2, width-4, height-4, 0, 0, 0, 90, 1, 1, 1, 1);
pixbuf_pixel_set(pixbuf, 0, 0, 0, 0, 0, 0);
pixbuf_pixel_set(pixbuf, width - 1, 0, 0, 0, 0, 0);
pixbuf_pixel_set(pixbuf, 0, height - 1, 0, 0, 0, 0);
pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0);
=20
=2D pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255);
+ pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 255, 255, 255, 255);
=20
g_object_unref(G_OBJECT(layout));
=20
--Boundary-00=_siX5G8SLT3gkulq
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
--Boundary-00=_siX5G8SLT3gkulq
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Gqview-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gqview-devel
--Boundary-00=_siX5G8SLT3gkulq--