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[] = " - ";
218 if (!str || !*str) return g_strdup("");
220 new = g_string_new(str);
229 gchar *limpos = NULL;
231 gchar *extrapos = NULL;
234 start = strchr(new->str, delim);
237 end = strchr(start+1, delim);
241 /* Search for optionnal modifiers
242 * %name:99:extra% -> name = "name", limit=99, extra = "extra"
244 for (p = start + 1; p < end; p++)
248 if (g_ascii_isdigit(p[1]) && !limpos)
251 if (!trunc) trunc = p;
256 if (!trunc) trunc = p;
263 limit = (guint) atoi(limpos);
266 extra = g_strndup(extrapos, end - extrapos);
268 name = g_strndup(start+1, (trunc ? trunc : end)-start-1);
269 pos = start - new->str;
272 if (strcmp(name, "keywords") == 0)
274 data = keywords_to_string(imd->image_fd);
276 else if (strcmp(name, "comment") == 0)
278 comment_read(imd->image_fd, NULL, &data);
283 keywords and comment can't be read between exif_read_fd and exif_free_fd calls
284 because fd->exif does not count references
285 on the other hand, it is OK to call it in the loop because it is cached
289 exif = exif_read_fd(imd->image_fd);
291 data = g_strdup(g_hash_table_lookup(vars, name));
292 if (data && strcmp(name, "zoom") == 0) imd->overlay_show_zoom = TRUE;
294 data = exif_get_data_as_text(exif, name);
295 exif_free_fd(imd->image_fd, exif);
297 if (data && *data && limit > 0 && strlen(data) > limit + 3)
299 gchar *new_data = g_strdup_printf("%-*.*s...", limit, limit, data);
306 /* Since we use pango markup to display, we need to escape here */
307 gchar *escaped = g_markup_escape_text(data, -1);
316 /* Display data between left and right parts of extra string
317 * the data is expressed by a '*' character. A '*' may be escaped
318 * by a \. You should escape all '*' characters, do not rely on the
319 * current implementation which only replaces the first unescaped '*'.
320 * If no "*" is present, the extra string is just appended to data string.
321 * Pango mark up is accepted in left and right parts.
322 * Any \n is replaced by a newline
324 * "<i>*</i>\n" -> data is displayed in italics ended with a newline
325 * "\n" -> ended with newline
326 * "ISO *" -> prefix data with "ISO " (ie. "ISO 100")
327 * "\**\*" -> prefix data with a star, and append a star (ie. "*100*")
328 * "\\*" -> prefix data with an anti slash (ie "\100")
329 * "Collection <b>*</b>\n" -> display data in bold prefixed by "Collection " and a newline is appended
331 * FIXME: using background / foreground colors lead to weird results.
335 gchar *right = extra;
337 guint len = strlen(extra);
339 /* Search for left and right parts and unescape characters */
340 for (p = extra; *p; p++, len--)
345 memmove(p+1, p+2, --len);
348 else if (p[1] != '\0')
349 memmove(p, p+1, len--); // includes \0
351 else if (p[0] == '*' && !left)
357 if (left) right[-1] = '\0';
359 new_data = g_strdup_printf("%s%s%s", left ? left : "", data, right);
366 g_string_erase(new, pos, end-start+1);
368 g_string_insert(new, pos, data);
370 if (pos-prev >= 2 && new->str[pos-1] == imp)
372 g_string_erase(new, --pos, 1);
373 if (last && data && *data)
375 g_string_insert(new, pos, sep);
380 prev = data ? pos+strlen(data)-1 : pos-1;
381 last = data ? TRUE : last;
386 /* search and destroy empty lines */
388 while ((start = strchr(end, '\n')))
391 while (*++(end) == '\n')
393 g_string_erase(new, start-new->str, end-start-1);
396 g_strchomp(new->str);
399 g_string_free(new, FALSE);
407 OSDT_NO_ESCAPE = 1 << 1,
411 static void osd_template_insert(GHashTable *vars, gchar *keyword, gchar *value, OsdTemplateFlags flags)
415 g_hash_table_insert(vars, keyword, g_strdup(""));
419 if (flags & OSDT_NO_DUP)
421 g_hash_table_insert(vars, keyword, value);
424 else if (flags & OSDT_NO_ESCAPE)
426 g_hash_table_insert(vars, keyword, g_strdup(value));
430 g_hash_table_insert(vars, keyword, g_markup_escape_text(value, -1));
433 if (flags & OSDT_FREE) g_free((gpointer) value);
436 static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
438 GdkPixbuf *pixbuf = NULL;
443 GdkPixbuf *imgpixbuf = NULL;
445 ImageWindow *imd = osd->imd;
446 FileData *fd = image_get_fd(imd);
448 if (!fd) return NULL;
450 name = image_get_name(imd);
458 vars = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
460 cd = image_get_collection(imd, &info);
463 t = g_list_length(cd->list);
464 n = g_list_index(cd->list, info) + 1;
467 if (file_extension_match(cd->name, GQ_COLLECTION_EXT))
468 osd_template_insert(vars, "collection", remove_extension_from_path(cd->name), OSDT_FREE);
470 osd_template_insert(vars, "collection", cd->name, OSDT_NONE);
474 osd_template_insert(vars, "collection", _("Untitled"), OSDT_NONE);
479 LayoutWindow *lw = layout_find_by_image(imd);
484 n = g_list_length(lw->slideshow->list_done);
485 t = n + g_list_length(lw->slideshow->list);
490 t = layout_list_count(lw, NULL);
491 n = layout_list_get_index(lw, image_get_fd(lw->image)) + 1;
494 else if (view_window_find_image(imd, &n, &t))
507 osd_template_insert(vars, "collection", NULL, OSDT_NONE);
510 osd_template_insert(vars, "number", g_strdup_printf("%d", n), OSDT_NO_DUP);
511 osd_template_insert(vars, "total", g_strdup_printf("%d", t), OSDT_NO_DUP);
512 osd_template_insert(vars, "name", (gchar *) name, OSDT_NONE);
513 osd_template_insert(vars, "date", (gchar *) text_from_time(imd->mtime), OSDT_NONE);
514 osd_template_insert(vars, "size", text_from_size_abrev(imd->size), OSDT_FREE);
515 osd_template_insert(vars, "zoom", image_zoom_get_as_text(imd), OSDT_FREE);
521 if (imd->delay_flip &&
522 imd->il && imd->il->pixbuf &&
523 image_get_pixbuf(imd) != imd->il->pixbuf)
525 w = gdk_pixbuf_get_width(imd->il->pixbuf);
526 h = gdk_pixbuf_get_height(imd->il->pixbuf);
527 imgpixbuf = imd->il->pixbuf;
531 image_get_image_size(imd, &w, &h);
532 imgpixbuf = (PIXBUF_RENDERER(imd->pr))->pixbuf;
536 osd_template_insert(vars, "width", g_strdup_printf("%d", w), OSDT_NO_DUP);
537 osd_template_insert(vars, "height", g_strdup_printf("%d", h), OSDT_NO_DUP);
538 osd_template_insert(vars, "res", g_strdup_printf("%d × %d", w, h), OSDT_FREE);
542 osd_template_insert(vars, "width", NULL, OSDT_NONE);
543 osd_template_insert(vars, "height", NULL, OSDT_NONE);
544 osd_template_insert(vars, "res", NULL, OSDT_NONE);
547 text = image_osd_mkinfo(options->image_overlay.common.template_string, imd, vars);
548 g_hash_table_destroy(vars);
551 /* When does this occur ?? */
552 text = g_markup_escape_text(_("Untitled"), -1);
555 with_hist = (imgpixbuf && (osd->show & OSD_SHOW_HISTOGRAM) && osd->histogram && (!imd->il || imd->il->done));
558 gint active_marks = 0;
562 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
564 active_marks += file_data_get_mark(fd, mark);
567 if (active_marks > 0)
569 GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2);
571 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
573 g_string_append_printf(buf, file_data_get_mark(fd, mark) ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + mark);
577 text2 = g_strdup_printf("%s\n%s", text, buf->str);
579 text2 = g_strdup(buf->str);
580 g_string_free(buf, TRUE);
587 gchar *escaped_histogram_label = g_markup_escape_text(histogram_label(osd->histogram), -1);
589 text2 = g_strdup_printf("%s\n%s", text, escaped_histogram_label);
591 text2 = g_strdup(escaped_histogram_label);
592 g_free(escaped_histogram_label);
598 layout = gtk_widget_create_pango_layout(imd->pr, NULL);
599 pango_layout_set_markup(layout, text, -1);
602 pango_layout_get_pixel_size(layout, &width, &height);
603 /* with empty text width is set to 0, but not height) */
606 else if (height == 0)
608 if (width > 0) width += 10;
609 if (height > 0) height += 10;
613 histogram_read(osd->histogram, imgpixbuf);
614 if (width < HISTOGRAM_WIDTH + 10) width = HISTOGRAM_WIDTH + 10;
615 height += HISTOGRAM_HEIGHT + 5;
618 if (width > 0 && height > 0)
620 /* TODO: make osd color configurable --Zas */
621 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
622 pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, 240, 240, 240, 210);
623 pixbuf_set_rect(pixbuf, 0, 0, width, height, 240, 240, 240, 80, 1, 1, 1, 1);
624 pixbuf_set_rect(pixbuf, 1, 1, width-2, height-2, 240, 240, 240, 130, 1, 1, 1, 1);
625 pixbuf_set_rect(pixbuf, 2, 2, width-4, height-4, 240, 240, 240, 180, 1, 1, 1, 1);
626 pixbuf_pixel_set(pixbuf, 0, 0, 0, 0, 0, 0);
627 pixbuf_pixel_set(pixbuf, width - 1, 0, 0, 0, 0, 0);
628 pixbuf_pixel_set(pixbuf, 0, height - 1, 0, 0, 0, 0);
629 pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0);
634 gint y = height - HISTOGRAM_HEIGHT - 5;
641 float add = w / (float)subdiv;
643 for (i = 0; i < subdiv; i++)
645 gint d = (i > 0 ? 0 : 1);
647 pixbuf_set_rect(pixbuf, x + xoffset + 0.5, y, add + d + 0.5, HISTOGRAM_HEIGHT, c, c, c, alpha, d, 1, 1, 1);
651 histogram_draw(osd->histogram, pixbuf, x, y, w, HISTOGRAM_HEIGHT);
653 pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255);
656 g_object_unref(G_OBJECT(layout));
661 static GdkPixbuf *image_osd_icon_pixbuf(ImageOSDFlag flag)
663 static GdkPixbuf **icons = NULL;
664 GdkPixbuf *icon = NULL;
666 if (!icons) icons = g_new0(GdkPixbuf *, IMAGE_OSD_COUNT);
667 if (icons[flag]) return icons[flag];
669 if (osd_icons[flag].key)
671 icon = pixbuf_inline(osd_icons[flag].key);
676 icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 24, 24);
677 pixbuf_set_rect_fill(icon, 1, 1, 22, 22, 255, 255, 255, 200);
678 pixbuf_set_rect(icon, 0, 0, 24, 24, 0, 0, 0, 128, 1, 1, 1, 1);
681 case IMAGE_OSD_ROTATE_AUTO:
682 pixbuf_set_rect(icon, 3, 8, 11, 12,
685 pixbuf_draw_triangle(icon, 14, 3, 6, 12,
686 20, 9, 14, 15, 14, 3,
689 case IMAGE_OSD_ROTATE_USER:
691 case IMAGE_OSD_COLOR:
692 pixbuf_set_rect_fill(icon, 3, 3, 18, 6, 200, 0, 0, 255);
693 pixbuf_set_rect_fill(icon, 3, 9, 18, 6, 0, 200, 0, 255);
694 pixbuf_set_rect_fill(icon, 3, 15, 18, 6, 0, 0, 200, 255);
696 case IMAGE_OSD_FIRST:
697 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 3, 0);
698 pixbuf_draw_triangle(icon, 6, 5, 12, 6,
699 12, 5, 18, 11, 6, 11,
703 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 0, 3);
704 pixbuf_draw_triangle(icon, 6, 12, 12, 6,
705 12, 18, 6, 12, 18, 12,
709 pixbuf_set_rect_fill(icon, 11, 3, 3, 12, 0, 0, 0, 255);
710 pixbuf_set_rect_fill(icon, 11, 17, 3, 3, 0, 0, 0, 255);
722 static gint image_overlay_add(ImageWindow *imd, GdkPixbuf *pixbuf, gint x, gint y,
723 OverlayRendererFlags flags)
725 return pixbuf_renderer_overlay_add((PixbufRenderer *)imd->pr, pixbuf, x, y, flags);
728 static void image_overlay_set(ImageWindow *imd, gint id, GdkPixbuf *pixbuf, gint x, gint y)
730 pixbuf_renderer_overlay_set((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
733 #if 0 /* unused for now */
734 static gint image_overlay_get(ImageWindow *imd, gint id, GdkPixbuf **pixbuf, gint *x, gint *y)
736 return pixbuf_renderer_overlay_get((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
740 static void image_overlay_remove(ImageWindow *imd, gint id)
742 pixbuf_renderer_overlay_remove((PixbufRenderer *)imd->pr, id);
745 static void image_osd_icon_show(OverlayStateData *osd, ImageOSDFlag flag)
749 if (osd->icon_id[flag]) return;
751 pixbuf = image_osd_icon_pixbuf(flag);
754 osd->icon_id[flag] = image_overlay_add(osd->imd, pixbuf,
755 osd_icons[flag].x, osd_icons[flag].y,
759 static void image_osd_icon_hide(OverlayStateData *osd, ImageOSDFlag flag)
761 if (osd->icon_id[flag])
763 image_overlay_remove(osd->imd, osd->icon_id[flag]);
764 osd->icon_id[flag] = 0;
768 static gint image_osd_update_cb(gpointer data)
770 OverlayStateData *osd = data;
772 osd->imd->overlay_show_zoom = FALSE;
774 if (osd->show & OSD_SHOW_INFO)
776 if (osd->changed_states & IMAGE_STATE_IMAGE)
780 pixbuf = image_osd_info_render(osd);
783 if (osd->ovl_info == 0)
785 osd->ovl_info = image_overlay_add(osd->imd, pixbuf,
786 osd->x, osd->y, OVL_RELATIVE);
790 image_overlay_set(osd->imd, osd->ovl_info, pixbuf, osd->x, osd->y);
792 g_object_unref(pixbuf);
794 else if (osd->ovl_info)
796 image_overlay_remove(osd->imd, osd->ovl_info);
805 image_overlay_remove(osd->imd, osd->ovl_info);
810 if (osd->show & OSD_SHOW_STATUS)
814 if (osd->changed_states & IMAGE_STATE_IMAGE)
816 for (i = 0; i < IMAGE_OSD_COUNT; i++)
818 if (osd_icons[i].reset) osd->icon_time[i] = 0;
822 if (osd->changed_states & IMAGE_STATE_COLOR_ADJ)
824 osd->icon_time[IMAGE_OSD_COLOR] = IMAGE_OSD_DEFAULT_DURATION + 1;
825 image_osd_timer_schedule(osd);
828 if (osd->changed_states & IMAGE_STATE_ROTATE_AUTO)
832 if (osd->imd->state & IMAGE_STATE_ROTATE_AUTO)
835 if (!osd->imd->cm) n += IMAGE_OSD_DEFAULT_DURATION;
838 osd->icon_time[IMAGE_OSD_ROTATE_AUTO] = n;
839 image_osd_timer_schedule(osd);
842 for (i = 0; i < IMAGE_OSD_COUNT; i++)
844 if (osd->icon_time[i] > 0)
846 image_osd_icon_show(osd, i);
850 image_osd_icon_hide(osd, i);
858 for (i = 0; i < IMAGE_OSD_COUNT; i++)
860 image_osd_icon_hide(osd, i);
864 if (osd->imd->il && osd->imd->il->done)
865 osd->changed_states = IMAGE_STATE_NONE;
870 static void image_osd_update_schedule(OverlayStateData *osd, gint force)
872 if (force) osd->changed_states |= IMAGE_STATE_IMAGE;
874 if (osd->idle_id == -1)
876 osd->idle_id = g_idle_add_full(G_PRIORITY_HIGH, image_osd_update_cb, osd, NULL);
880 void image_osd_update(ImageWindow *imd)
882 OverlayStateData *osd = image_get_osd_data(imd);
886 image_osd_update_schedule(osd, TRUE);
889 static gint image_osd_timer_cb(gpointer data)
891 OverlayStateData *osd = data;
893 gint changed = FALSE;
896 for (i = 0; i < IMAGE_OSD_COUNT; i++)
898 if (osd->icon_time[i] > 1)
901 if (osd->icon_time[i] < 2)
903 osd->icon_time[i] = 0;
913 if (changed) image_osd_update_schedule(osd, FALSE);
924 static void image_osd_timer_schedule(OverlayStateData *osd)
926 if (osd->timer_id == -1)
928 osd->timer_id = g_timeout_add(100, image_osd_timer_cb, osd);
932 static void image_osd_state_cb(ImageWindow *imd, ImageState state, gpointer data)
934 OverlayStateData *osd = data;
936 osd->changed_states |= state;
937 image_osd_update_schedule(osd, FALSE);
940 static void image_osd_free(OverlayStateData *osd)
944 if (osd->idle_id != -1) g_source_remove(osd->idle_id);
945 if (osd->timer_id != -1) g_source_remove(osd->timer_id);
951 image_set_osd_data(osd->imd, NULL);
952 g_signal_handler_disconnect(osd->imd->pr, osd->destroy_id);
954 image_set_state_func(osd->imd, NULL, NULL);
955 image_overlay_remove(osd->imd, osd->ovl_info);
957 for (i = 0; i < IMAGE_OSD_COUNT; i++)
959 image_osd_icon_hide(osd, i);
963 if (osd->histogram) histogram_free(osd->histogram);
968 static void image_osd_remove(ImageWindow *imd)
970 OverlayStateData *osd = image_get_osd_data(imd);
972 if (osd) image_osd_free(osd);
975 static void image_osd_destroy_cb(GtkWidget *widget, gpointer data)
977 OverlayStateData *osd = data;
983 static void image_osd_enable(ImageWindow *imd, OsdShowFlags show)
985 OverlayStateData *osd = image_get_osd_data(imd);
989 osd = g_new0(OverlayStateData, 1);
993 osd->show = OSD_SHOW_NOTHING;
994 osd->histogram = NULL;
995 osd->x = options->image_overlay.common.x;
996 osd->y = options->image_overlay.common.y;
998 osd->destroy_id = g_signal_connect(G_OBJECT(imd->pr), "destroy",
999 G_CALLBACK(image_osd_destroy_cb), osd);
1000 image_set_osd_data(imd, osd);
1002 image_set_state_func(osd->imd, image_osd_state_cb, osd);
1005 if (show & OSD_SHOW_HISTOGRAM)
1006 osd->histogram = histogram_new();
1007 else if (osd->histogram)
1009 histogram_free(osd->histogram);
1010 osd->histogram = NULL;
1013 if (show & OSD_SHOW_STATUS)
1014 image_osd_icon(imd, IMAGE_OSD_ICON, -1);
1016 if (show != osd->show)
1017 image_osd_update_schedule(osd, TRUE);
1022 void image_osd_set(ImageWindow *imd, OsdShowFlags show)
1026 if (show == OSD_SHOW_NOTHING)
1028 image_osd_remove(imd);
1032 image_osd_enable(imd, show);
1035 OsdShowFlags image_osd_get(ImageWindow *imd)
1037 OverlayStateData *osd = image_get_osd_data(imd);
1039 return osd ? osd->show : OSD_SHOW_NOTHING;
1045 2+ = show for duration tenths of a second
1046 -1 = use default duration
1048 void image_osd_icon(ImageWindow *imd, ImageOSDFlag flag, gint duration)
1050 OverlayStateData *osd = image_get_osd_data(imd);
1054 if (flag < IMAGE_OSD_NONE || flag >= IMAGE_OSD_COUNT) return;
1055 if (duration < 0) duration = IMAGE_OSD_DEFAULT_DURATION;
1056 if (duration > 1) duration += 1;
1058 osd->icon_time[flag] = duration;
1060 image_osd_update_schedule(osd, FALSE);
1061 image_osd_timer_schedule(osd);