4 * Copyright (C) 2008 The Geeqie Team
8 * This software is released under the GNU General Public License (GNU GPL).
9 * Please read the included file COPYING for more information.
10 * This software comes with no warranty of any kind, use at your own risk!
14 #include "image-overlay.h"
20 #include "histogram.h"
24 #include "pixbuf-renderer.h"
25 #include "pixbuf_util.h"
26 #include "ui_fileops.h"
29 *----------------------------------------------------------------------------
31 *----------------------------------------------------------------------------
35 typedef struct _OverlayStateData OverlayStateData;
36 struct _OverlayStateData {
38 ImageState changed_states;
49 gint icon_time[IMAGE_OSD_COUNT];
50 gint icon_id[IMAGE_OSD_COUNT];
58 typedef struct _OSDIcon OSDIcon;
60 gint reset; /* reset on new image */
61 gint x; /* x, y offset */
63 gchar *key; /* inline pixbuf */
66 static OSDIcon osd_icons[] = {
67 { TRUE, 0, 0, NULL }, /* none */
68 { TRUE, -10, -10, NULL }, /* auto rotated */
69 { TRUE, -10, -10, NULL }, /* user rotated */
70 { TRUE, -40, -10, NULL }, /* color embedded */
71 { TRUE, -70, -10, NULL }, /* first image */
72 { TRUE, -70, -10, NULL }, /* last image */
73 { FALSE, -70, -10, NULL }, /* osd enabled */
77 #define OSD_DATA "overlay-data"
79 #define IMAGE_OSD_DEFAULT_DURATION 30
81 #define HISTOGRAM_HEIGHT 140
82 #define HISTOGRAM_WIDTH 256
84 static void image_osd_timer_schedule(OverlayStateData *osd);
86 void set_image_overlay_template_string(gchar **template_string, const gchar *value)
88 g_assert(template_string);
90 g_free(*template_string);
91 *template_string = g_strdup(value);
95 void set_default_image_overlay_template_string(gchar **template_string)
97 set_image_overlay_template_string(template_string, DEFAULT_OVERLAY_INFO);
100 static OverlayStateData *image_get_osd_data(ImageWindow *imd)
102 OverlayStateData *osd;
104 if (!imd) return NULL;
108 osd = g_object_get_data(G_OBJECT(imd->pr), "IMAGE_OVERLAY_DATA");
112 static void image_set_osd_data(ImageWindow *imd, OverlayStateData *osd)
116 g_object_set_data(G_OBJECT(imd->pr), "IMAGE_OVERLAY_DATA", osd);
120 *----------------------------------------------------------------------------
122 *----------------------------------------------------------------------------
126 void image_osd_histogram_chan_toggle(ImageWindow *imd)
128 OverlayStateData *osd = image_get_osd_data(imd);
130 if (!osd || !osd->histogram) return;
132 histogram_set_channel(osd->histogram, (histogram_get_channel(osd->histogram) +1)%HCHAN_COUNT);
133 image_osd_update(imd);
136 void image_osd_histogram_log_toggle(ImageWindow *imd)
138 OverlayStateData *osd = image_get_osd_data(imd);
140 if (!osd || !osd->histogram) return;
142 histogram_set_mode(osd->histogram, !histogram_get_mode(osd->histogram));
143 image_osd_update(imd);
146 void image_osd_toggle(ImageWindow *imd)
148 OverlayStateData *osd;
152 osd = image_get_osd_data(imd);
155 image_osd_set(imd, OSD_SHOW_INFO | OSD_SHOW_STATUS);
159 if (osd->show != OSD_SHOW_NOTHING)
161 if (osd->show & OSD_SHOW_HISTOGRAM)
163 image_osd_set(imd, OSD_SHOW_NOTHING);
167 image_osd_set(imd, osd->show | OSD_SHOW_HISTOGRAM);
172 static gchar *keywords_to_string(FileData *fd)
175 GString *kwstr = NULL;
180 if (comment_read(fd, &keywords, NULL))
182 GList *work = keywords;
186 gchar *kw = work->data;
191 kwstr = g_string_new("");
193 g_string_append(kwstr, ", ");
195 g_string_append(kwstr, kw);
202 g_string_free(kwstr, FALSE);
208 static gchar *image_osd_mkinfo(const gchar *str, ImageWindow *imd, GHashTable *vars)
210 gchar delim = '%', imp = '|', sep[] = " - ";
219 if (!str || !*str) return g_strdup("");
221 new = g_string_new(str);
223 exif = exif_read_fd(imd->image_fd);
231 gchar *limpos = NULL;
233 gchar *extrapos = NULL;
236 start = strchr(new->str, delim);
239 end = strchr(start+1, delim);
243 /* Search for optionnal modifiers
244 * %name:99:extra% -> name = "name", limit=99, extra = "extra"
246 for (p = start + 1; p < end; p++)
250 if (g_ascii_isdigit(p[1]) && !limpos)
253 if (!trunc) trunc = p;
258 if (!trunc) trunc = p;
265 limit = (guint) atoi(limpos);
268 extra = g_strndup(extrapos, end - extrapos);
270 name = g_strndup(start+1, (trunc ? trunc : end)-start-1);
271 pos = start - new->str;
274 if (strcmp(name, "keywords") == 0)
276 data = keywords_to_string(imd->image_fd);
278 else if (strcmp(name, "comment") == 0)
280 comment_read(imd->image_fd, NULL, &data);
284 data = g_strdup(g_hash_table_lookup(vars, name));
285 if (data && strcmp(name, "zoom") == 0) imd->overlay_show_zoom = TRUE;
287 data = exif_get_data_as_text(exif, name);
289 if (data && *data && limit > 0 && strlen(data) > limit + 3)
291 gchar *new_data = g_strdup_printf("%-*.*s...", limit, limit, data);
298 /* Since we use pango markup to display, we need to escape here */
299 gchar *escaped = g_markup_escape_text(data, -1);
308 /* Display data between left and right parts of extra string
309 * the data is expressed by a '*' character. A '*' may be escaped
310 * by a \. You should escape all '*' characters, do not rely on the
311 * current implementation which only replaces the first unescaped '*'.
312 * If no "*" is present, the extra string is just appended to data string.
313 * Pango mark up is accepted in left and right parts.
314 * Any \n is replaced by a newline
316 * "<i>*</i>\n" -> data is displayed in italics ended with a newline
317 * "\n" -> ended with newline
318 * "ISO *" -> prefix data with "ISO " (ie. "ISO 100")
319 * "\**\*" -> prefix data with a star, and append a star (ie. "*100*")
320 * "\\*" -> prefix data with an anti slash (ie "\100")
321 * "Collection <b>*</b>\n" -> display data in bold prefixed by "Collection " and a newline is appended
323 * FIXME: using background / foreground colors lead to weird results.
327 gchar *right = extra;
329 guint len = strlen(extra);
331 /* Search for left and right parts and unescape characters */
332 for (p = extra; *p; p++, len--)
337 memmove(p+1, p+2, --len);
340 else if (p[1] != '\0')
341 memmove(p, p+1, len--); // includes \0
343 else if (p[0] == '*' && !left)
349 if (left) right[-1] = '\0';
351 new_data = g_strdup_printf("%s%s%s", left ? left : "", data, right);
358 g_string_erase(new, pos, end-start+1);
360 g_string_insert(new, pos, data);
362 if (pos-prev >= 2 && new->str[pos-1] == imp)
364 g_string_erase(new, --pos, 1);
365 if (last && data && *data)
367 g_string_insert(new, pos, sep);
372 prev = data ? pos+strlen(data)-1 : pos-1;
373 last = data ? TRUE : last;
378 exif_free_fd(imd->image_fd, exif);
379 /* search and destroy empty lines */
381 while ((start = strchr(end, '\n')))
384 while (*++(end) == '\n')
386 g_string_erase(new, start-new->str, end-start-1);
389 g_strchomp(new->str);
392 g_string_free(new, FALSE);
400 OSDT_NO_ESCAPE = 1 << 1,
404 static void osd_template_insert(GHashTable *vars, gchar *keyword, gchar *value, OsdTemplateFlags flags)
408 g_hash_table_insert(vars, keyword, g_strdup(""));
412 if (flags & OSDT_NO_DUP)
414 g_hash_table_insert(vars, keyword, value);
417 else if (flags & OSDT_NO_ESCAPE)
419 g_hash_table_insert(vars, keyword, g_strdup(value));
423 g_hash_table_insert(vars, keyword, g_markup_escape_text(value, -1));
426 if (flags & OSDT_FREE) g_free((gpointer) value);
429 static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
431 GdkPixbuf *pixbuf = NULL;
436 GdkPixbuf *imgpixbuf = NULL;
438 ImageWindow *imd = osd->imd;
439 FileData *fd = image_get_fd(imd);
441 if (!fd) return NULL;
443 name = image_get_name(imd);
451 vars = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
453 cd = image_get_collection(imd, &info);
456 t = g_list_length(cd->list);
457 n = g_list_index(cd->list, info) + 1;
460 if (file_extension_match(cd->name, GQ_COLLECTION_EXT))
461 osd_template_insert(vars, "collection", remove_extension_from_path(cd->name), OSDT_FREE);
463 osd_template_insert(vars, "collection", cd->name, OSDT_NONE);
467 osd_template_insert(vars, "collection", _("Untitled"), OSDT_NONE);
472 LayoutWindow *lw = layout_find_by_image(imd);
477 n = g_list_length(lw->slideshow->list_done);
478 t = n + g_list_length(lw->slideshow->list);
483 t = layout_list_count(lw, NULL);
484 n = layout_list_get_index(lw, image_get_fd(lw->image)) + 1;
487 else if (view_window_find_image(imd, &n, &t))
500 osd_template_insert(vars, "collection", NULL, OSDT_NONE);
503 osd_template_insert(vars, "number", g_strdup_printf("%d", n), OSDT_NO_DUP);
504 osd_template_insert(vars, "total", g_strdup_printf("%d", t), OSDT_NO_DUP);
505 osd_template_insert(vars, "name", (gchar *) name, OSDT_NONE);
506 osd_template_insert(vars, "date", (gchar *) text_from_time(imd->mtime), OSDT_NONE);
507 osd_template_insert(vars, "size", text_from_size_abrev(imd->size), OSDT_FREE);
508 osd_template_insert(vars, "zoom", image_zoom_get_as_text(imd), OSDT_FREE);
514 if (imd->delay_flip &&
515 imd->il && imd->il->pixbuf &&
516 image_get_pixbuf(imd) != imd->il->pixbuf)
518 w = gdk_pixbuf_get_width(imd->il->pixbuf);
519 h = gdk_pixbuf_get_height(imd->il->pixbuf);
520 imgpixbuf = imd->il->pixbuf;
524 image_get_image_size(imd, &w, &h);
525 imgpixbuf = (PIXBUF_RENDERER(imd->pr))->pixbuf;
529 osd_template_insert(vars, "width", g_strdup_printf("%d", w), OSDT_NO_DUP);
530 osd_template_insert(vars, "height", g_strdup_printf("%d", h), OSDT_NO_DUP);
531 osd_template_insert(vars, "res", g_strdup_printf("%d × %d", w, h), OSDT_FREE);
535 osd_template_insert(vars, "width", NULL, OSDT_NONE);
536 osd_template_insert(vars, "height", NULL, OSDT_NONE);
537 osd_template_insert(vars, "res", NULL, OSDT_NONE);
540 text = image_osd_mkinfo(options->image_overlay.common.template_string, imd, vars);
541 g_hash_table_destroy(vars);
544 /* When does this occur ?? */
545 text = g_markup_escape_text(_("Untitled"), -1);
548 with_hist = (imgpixbuf && (osd->show & OSD_SHOW_HISTOGRAM) && osd->histogram && (!imd->il || imd->il->done));
551 gint active_marks = 0;
555 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
557 active_marks += file_data_get_mark(fd, mark);
560 if (active_marks > 0)
562 GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2);
564 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
566 g_string_append_printf(buf, file_data_get_mark(fd, mark) ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + mark);
570 text2 = g_strdup_printf("%s\n%s", text, buf->str);
572 text2 = g_strdup(buf->str);
573 g_string_free(buf, TRUE);
580 gchar *escaped_histogram_label = g_markup_escape_text(histogram_label(osd->histogram), -1);
582 text2 = g_strdup_printf("%s\n%s", text, escaped_histogram_label);
584 text2 = g_strdup(escaped_histogram_label);
585 g_free(escaped_histogram_label);
591 layout = gtk_widget_create_pango_layout(imd->pr, NULL);
592 pango_layout_set_markup(layout, text, -1);
595 pango_layout_get_pixel_size(layout, &width, &height);
596 /* with empty text width is set to 0, but not height) */
599 else if (height == 0)
601 if (width > 0) width += 10;
602 if (height > 0) height += 10;
606 histogram_read(osd->histogram, imgpixbuf);
607 if (width < HISTOGRAM_WIDTH + 10) width = HISTOGRAM_WIDTH + 10;
608 height += HISTOGRAM_HEIGHT + 5;
611 if (width > 0 && height > 0)
613 /* TODO: make osd color configurable --Zas */
614 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
615 pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, 240, 240, 240, 210);
616 pixbuf_set_rect(pixbuf, 0, 0, width, height, 240, 240, 240, 80, 1, 1, 1, 1);
617 pixbuf_set_rect(pixbuf, 1, 1, width-2, height-2, 240, 240, 240, 130, 1, 1, 1, 1);
618 pixbuf_set_rect(pixbuf, 2, 2, width-4, height-4, 240, 240, 240, 180, 1, 1, 1, 1);
619 pixbuf_pixel_set(pixbuf, 0, 0, 0, 0, 0, 0);
620 pixbuf_pixel_set(pixbuf, width - 1, 0, 0, 0, 0, 0);
621 pixbuf_pixel_set(pixbuf, 0, height - 1, 0, 0, 0, 0);
622 pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0);
627 gint y = height - HISTOGRAM_HEIGHT - 5;
634 float add = w / (float)subdiv;
636 for (i = 0; i < subdiv; i++)
638 gint d = (i > 0 ? 0 : 1);
640 pixbuf_set_rect(pixbuf, x + xoffset + 0.5, y, add + d + 0.5, HISTOGRAM_HEIGHT, c, c, c, alpha, d, 1, 1, 1);
644 histogram_draw(osd->histogram, pixbuf, x, y, w, HISTOGRAM_HEIGHT);
646 pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255);
649 g_object_unref(G_OBJECT(layout));
654 static GdkPixbuf *image_osd_icon_pixbuf(ImageOSDFlag flag)
656 static GdkPixbuf **icons = NULL;
657 GdkPixbuf *icon = NULL;
659 if (!icons) icons = g_new0(GdkPixbuf *, IMAGE_OSD_COUNT);
660 if (icons[flag]) return icons[flag];
662 if (osd_icons[flag].key)
664 icon = pixbuf_inline(osd_icons[flag].key);
669 icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 24, 24);
670 pixbuf_set_rect_fill(icon, 1, 1, 22, 22, 255, 255, 255, 200);
671 pixbuf_set_rect(icon, 0, 0, 24, 24, 0, 0, 0, 128, 1, 1, 1, 1);
674 case IMAGE_OSD_ROTATE_AUTO:
675 pixbuf_set_rect(icon, 3, 8, 11, 12,
678 pixbuf_draw_triangle(icon, 14, 3, 6, 12,
679 20, 9, 14, 15, 14, 3,
682 case IMAGE_OSD_ROTATE_USER:
684 case IMAGE_OSD_COLOR:
685 pixbuf_set_rect_fill(icon, 3, 3, 18, 6, 200, 0, 0, 255);
686 pixbuf_set_rect_fill(icon, 3, 9, 18, 6, 0, 200, 0, 255);
687 pixbuf_set_rect_fill(icon, 3, 15, 18, 6, 0, 0, 200, 255);
689 case IMAGE_OSD_FIRST:
690 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 3, 0);
691 pixbuf_draw_triangle(icon, 6, 5, 12, 6,
692 12, 5, 18, 11, 6, 11,
696 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 0, 3);
697 pixbuf_draw_triangle(icon, 6, 12, 12, 6,
698 12, 18, 6, 12, 18, 12,
702 pixbuf_set_rect_fill(icon, 11, 3, 3, 12, 0, 0, 0, 255);
703 pixbuf_set_rect_fill(icon, 11, 17, 3, 3, 0, 0, 0, 255);
715 static gint image_overlay_add(ImageWindow *imd, GdkPixbuf *pixbuf, gint x, gint y,
716 OverlayRendererFlags flags)
718 return pixbuf_renderer_overlay_add((PixbufRenderer *)imd->pr, pixbuf, x, y, flags);
721 static void image_overlay_set(ImageWindow *imd, gint id, GdkPixbuf *pixbuf, gint x, gint y)
723 pixbuf_renderer_overlay_set((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
726 #if 0 /* unused for now */
727 static gint image_overlay_get(ImageWindow *imd, gint id, GdkPixbuf **pixbuf, gint *x, gint *y)
729 return pixbuf_renderer_overlay_get((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
733 static void image_overlay_remove(ImageWindow *imd, gint id)
735 pixbuf_renderer_overlay_remove((PixbufRenderer *)imd->pr, id);
738 static void image_osd_icon_show(OverlayStateData *osd, ImageOSDFlag flag)
742 if (osd->icon_id[flag]) return;
744 pixbuf = image_osd_icon_pixbuf(flag);
747 osd->icon_id[flag] = image_overlay_add(osd->imd, pixbuf,
748 osd_icons[flag].x, osd_icons[flag].y,
752 static void image_osd_icon_hide(OverlayStateData *osd, ImageOSDFlag flag)
754 if (osd->icon_id[flag])
756 image_overlay_remove(osd->imd, osd->icon_id[flag]);
757 osd->icon_id[flag] = 0;
761 static gint image_osd_update_cb(gpointer data)
763 OverlayStateData *osd = data;
765 osd->imd->overlay_show_zoom = FALSE;
767 if (osd->show & OSD_SHOW_INFO)
769 if (osd->changed_states & IMAGE_STATE_IMAGE)
773 pixbuf = image_osd_info_render(osd);
776 if (osd->ovl_info == 0)
778 osd->ovl_info = image_overlay_add(osd->imd, pixbuf,
779 osd->x, osd->y, OVL_RELATIVE);
783 image_overlay_set(osd->imd, osd->ovl_info, pixbuf, osd->x, osd->y);
785 g_object_unref(pixbuf);
787 else if (osd->ovl_info)
789 image_overlay_remove(osd->imd, osd->ovl_info);
798 image_overlay_remove(osd->imd, osd->ovl_info);
803 if (osd->show & OSD_SHOW_STATUS)
807 if (osd->changed_states & IMAGE_STATE_IMAGE)
809 for (i = 0; i < IMAGE_OSD_COUNT; i++)
811 if (osd_icons[i].reset) osd->icon_time[i] = 0;
815 if (osd->changed_states & IMAGE_STATE_COLOR_ADJ)
817 osd->icon_time[IMAGE_OSD_COLOR] = IMAGE_OSD_DEFAULT_DURATION + 1;
818 image_osd_timer_schedule(osd);
821 if (osd->changed_states & IMAGE_STATE_ROTATE_AUTO)
825 if (osd->imd->state & IMAGE_STATE_ROTATE_AUTO)
828 if (!osd->imd->cm) n += IMAGE_OSD_DEFAULT_DURATION;
831 osd->icon_time[IMAGE_OSD_ROTATE_AUTO] = n;
832 image_osd_timer_schedule(osd);
835 for (i = 0; i < IMAGE_OSD_COUNT; i++)
837 if (osd->icon_time[i] > 0)
839 image_osd_icon_show(osd, i);
843 image_osd_icon_hide(osd, i);
851 for (i = 0; i < IMAGE_OSD_COUNT; i++)
853 image_osd_icon_hide(osd, i);
857 if (osd->imd->il && osd->imd->il->done)
858 osd->changed_states = IMAGE_STATE_NONE;
863 static void image_osd_update_schedule(OverlayStateData *osd, gint force)
865 if (force) osd->changed_states |= IMAGE_STATE_IMAGE;
867 if (osd->idle_id == -1)
869 osd->idle_id = g_idle_add_full(G_PRIORITY_HIGH, image_osd_update_cb, osd, NULL);
873 void image_osd_update(ImageWindow *imd)
875 OverlayStateData *osd = image_get_osd_data(imd);
879 image_osd_update_schedule(osd, TRUE);
882 static gint image_osd_timer_cb(gpointer data)
884 OverlayStateData *osd = data;
886 gint changed = FALSE;
889 for (i = 0; i < IMAGE_OSD_COUNT; i++)
891 if (osd->icon_time[i] > 1)
894 if (osd->icon_time[i] < 2)
896 osd->icon_time[i] = 0;
906 if (changed) image_osd_update_schedule(osd, FALSE);
917 static void image_osd_timer_schedule(OverlayStateData *osd)
919 if (osd->timer_id == -1)
921 osd->timer_id = g_timeout_add(100, image_osd_timer_cb, osd);
925 static void image_osd_state_cb(ImageWindow *imd, ImageState state, gpointer data)
927 OverlayStateData *osd = data;
929 osd->changed_states |= state;
930 image_osd_update_schedule(osd, FALSE);
933 static void image_osd_free(OverlayStateData *osd)
937 if (osd->idle_id != -1) g_source_remove(osd->idle_id);
938 if (osd->timer_id != -1) g_source_remove(osd->timer_id);
944 image_set_osd_data(osd->imd, NULL);
945 g_signal_handler_disconnect(osd->imd->pr, osd->destroy_id);
947 image_set_state_func(osd->imd, NULL, NULL);
948 image_overlay_remove(osd->imd, osd->ovl_info);
950 for (i = 0; i < IMAGE_OSD_COUNT; i++)
952 image_osd_icon_hide(osd, i);
956 if (osd->histogram) histogram_free(osd->histogram);
961 static void image_osd_remove(ImageWindow *imd)
963 OverlayStateData *osd = image_get_osd_data(imd);
965 if (osd) image_osd_free(osd);
968 static void image_osd_destroy_cb(GtkWidget *widget, gpointer data)
970 OverlayStateData *osd = data;
976 static void image_osd_enable(ImageWindow *imd, OsdShowFlags show)
978 OverlayStateData *osd = image_get_osd_data(imd);
982 osd = g_new0(OverlayStateData, 1);
986 osd->show = OSD_SHOW_NOTHING;
987 osd->histogram = NULL;
988 osd->x = options->image_overlay.common.x;
989 osd->y = options->image_overlay.common.y;
991 osd->destroy_id = g_signal_connect(G_OBJECT(imd->pr), "destroy",
992 G_CALLBACK(image_osd_destroy_cb), osd);
993 image_set_osd_data(imd, osd);
995 image_set_state_func(osd->imd, image_osd_state_cb, osd);
998 if (show & OSD_SHOW_HISTOGRAM)
999 osd->histogram = histogram_new();
1000 else if (osd->histogram)
1002 histogram_free(osd->histogram);
1003 osd->histogram = NULL;
1006 if (show & OSD_SHOW_STATUS)
1007 image_osd_icon(imd, IMAGE_OSD_ICON, -1);
1009 if (show != osd->show)
1010 image_osd_update_schedule(osd, TRUE);
1015 void image_osd_set(ImageWindow *imd, OsdShowFlags show)
1019 if (show == OSD_SHOW_NOTHING)
1021 image_osd_remove(imd);
1025 image_osd_enable(imd, show);
1028 OsdShowFlags image_osd_get(ImageWindow *imd)
1030 OverlayStateData *osd = image_get_osd_data(imd);
1032 return osd ? osd->show : OSD_SHOW_NOTHING;
1038 2+ = show for duration tenths of a second
1039 -1 = use default duration
1041 void image_osd_icon(ImageWindow *imd, ImageOSDFlag flag, gint duration)
1043 OverlayStateData *osd = image_get_osd_data(imd);
1047 if (flag < IMAGE_OSD_NONE || flag >= IMAGE_OSD_COUNT) return;
1048 if (duration < 0) duration = IMAGE_OSD_DEFAULT_DURATION;
1049 if (duration > 1) duration += 1;
1051 osd->icon_time[flag] = duration;
1053 image_osd_update_schedule(osd, FALSE);
1054 image_osd_timer_schedule(osd);