Fix #381: Feature-Request: Make JPEG comment available for overlays
[geeqie.git] / src / image-overlay.c
index dcba8ed..7afe1a4 100644 (file)
@@ -1,13 +1,22 @@
 /*
- * Geeqie
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2012 The Geeqie Team
+ * Copyright (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Author: John Ellis
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
 #include "main.h"
@@ -100,6 +109,14 @@ void set_default_image_overlay_template_string(gchar **template_string)
        set_image_overlay_template_string(template_string, DEFAULT_OVERLAY_INFO);
 }
 
+void set_image_overlay_font_string(gchar **font_string, const gchar *value)
+{
+       g_assert(font_string);
+
+       g_free(*font_string);
+       *font_string = g_strdup(value);
+}
+
 static OverlayStateData *image_get_osd_data(ImageWindow *imd)
 {
        OverlayStateData *osd;
@@ -319,6 +336,10 @@ static gchar *image_osd_mkinfo(const gchar *str, ImageWindow *imd, GHashTable *v
                        {
                        data = metadata_read_string(imd->image_fd, COMMENT_KEY, METADATA_PLAIN);
                        }
+               else if (strcmp(name, "imagecomment") == 0)
+                       {
+                       data = exif_get_image_comment(imd->image_fd);
+                       }
 #ifdef HAVE_LUA
                else if (strncmp(name, "lua/", 4) == 0)
                        {
@@ -493,6 +514,7 @@ static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
        const HistMap *histmap = NULL;
        ImageWindow *imd = osd->imd;
        FileData *fd = image_get_fd(imd);
+       PangoFontDescription *font_desc;
 
        if (!fd) return NULL;
 
@@ -653,7 +675,10 @@ static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
                        }
        }
 
+       font_desc = pango_font_description_from_string(options->image_overlay.font);
        layout = gtk_widget_create_pango_layout(imd->pr, NULL);
+       pango_layout_set_font_description(layout, font_desc);
+
        pango_layout_set_markup(layout, text, -1);
        g_free(text);
 
@@ -674,9 +699,9 @@ static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
 
        if (width > 0 && height > 0)
                {
-               /* TODO: make osd color configurable --Zas */
                pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
-               pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, 240, 240, 240, 210);
+               pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, options->image_overlay.background_red, options->image_overlay.background_green,
+                                                                                                                       options->image_overlay.background_blue, options->image_overlay.background_alpha);
                pixbuf_set_rect(pixbuf, 0, 0, width, height, 240, 240, 240, 80, 1, 1, 1, 1);
                pixbuf_set_rect(pixbuf, 1, 1, width-2, height-2, 240, 240, 240, 130, 1, 1, 1, 1);
                pixbuf_set_rect(pixbuf, 2, 2, width-4, height-4, 240, 240, 240, 180, 1, 1, 1, 1);
@@ -694,7 +719,8 @@ static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
                        pixbuf_set_rect_fill(pixbuf, x, y, w, HISTOGRAM_HEIGHT, 220, 220, 220, 210);
                        histogram_draw(osd->histogram, histmap, pixbuf, x, y, w, HISTOGRAM_HEIGHT);
                        }
-               pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255);
+               pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, options->image_overlay.text_red, options->image_overlay.text_green,
+                                                                                                                       options->image_overlay.text_blue, options->image_overlay.text_alpha);
        }
 
        g_object_unref(G_OBJECT(layout));