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[] = " - ";
213 gboolean want_separator = FALSE;
218 if (!str || !*str) return g_strdup("");
220 new = g_string_new(str);
228 gchar *limpos = NULL;
230 gchar *extrapos = NULL;
233 start = strchr(new->str, delim);
236 end = strchr(start+1, delim);
240 /* Search for optionnal modifiers
241 * %name:99:extra% -> name = "name", limit=99, extra = "extra"
243 for (p = start + 1; p < end; p++)
247 if (g_ascii_isdigit(p[1]) && !limpos)
250 if (!trunc) trunc = p;
255 if (!trunc) trunc = p;
262 limit = (guint) atoi(limpos);
265 extra = g_strndup(extrapos, end - extrapos);
267 name = g_strndup(start+1, (trunc ? trunc : end)-start-1);
268 pos = start - new->str;
271 if (strcmp(name, "keywords") == 0)
273 data = keywords_to_string(imd->image_fd);
275 else if (strcmp(name, "comment") == 0)
277 comment_read(imd->image_fd, NULL, &data);
282 keywords and comment can't be read between exif_read_fd and exif_free_fd calls
283 because fd->exif does not count references
284 on the other hand, it is OK to call it in the loop because it is cached
288 exif = exif_read_fd(imd->image_fd);
290 data = g_strdup(g_hash_table_lookup(vars, name));
291 if (data && strcmp(name, "zoom") == 0) imd->overlay_show_zoom = TRUE;
293 data = exif_get_data_as_text(exif, name);
294 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);
371 /* insert separator */
372 g_string_insert(new, pos, sep);
376 g_string_insert(new, pos, data);
380 want_separator = FALSE;
382 if (pos-prev >= 1 && new->str[pos] == imp)
384 /* pipe character is replaced by a separator, delete it
385 * and raise a flag if needed */
386 g_string_erase(new, pos--, 1);
387 want_separator = (data && *data);
396 /* search and destroy empty lines */
398 while ((start = strchr(end, '\n')))
401 while (*++(end) == '\n')
403 g_string_erase(new, start-new->str, end-start-1);
406 g_strchomp(new->str);
409 g_string_free(new, FALSE);
417 OSDT_NO_ESCAPE = 1 << 1,
421 static void osd_template_insert(GHashTable *vars, gchar *keyword, gchar *value, OsdTemplateFlags flags)
425 g_hash_table_insert(vars, keyword, g_strdup(""));
429 if (flags & OSDT_NO_DUP)
431 g_hash_table_insert(vars, keyword, value);
434 else if (flags & OSDT_NO_ESCAPE)
436 g_hash_table_insert(vars, keyword, g_strdup(value));
440 g_hash_table_insert(vars, keyword, g_markup_escape_text(value, -1));
443 if (flags & OSDT_FREE) g_free((gpointer) value);
446 static GdkPixbuf *image_osd_info_render(OverlayStateData *osd)
448 GdkPixbuf *pixbuf = NULL;
453 GdkPixbuf *imgpixbuf = NULL;
455 ImageWindow *imd = osd->imd;
456 FileData *fd = image_get_fd(imd);
458 if (!fd) return NULL;
460 name = image_get_name(imd);
468 vars = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, g_free);
470 cd = image_get_collection(imd, &info);
473 t = g_list_length(cd->list);
474 n = g_list_index(cd->list, info) + 1;
477 if (file_extension_match(cd->name, GQ_COLLECTION_EXT))
478 osd_template_insert(vars, "collection", remove_extension_from_path(cd->name), OSDT_FREE);
480 osd_template_insert(vars, "collection", cd->name, OSDT_NONE);
484 osd_template_insert(vars, "collection", _("Untitled"), OSDT_NONE);
489 LayoutWindow *lw = layout_find_by_image(imd);
494 n = g_list_length(lw->slideshow->list_done);
495 t = n + g_list_length(lw->slideshow->list);
500 t = layout_list_count(lw, NULL);
501 n = layout_list_get_index(lw, image_get_fd(lw->image)) + 1;
504 else if (view_window_find_image(imd, &n, &t))
517 osd_template_insert(vars, "collection", NULL, OSDT_NONE);
520 osd_template_insert(vars, "number", g_strdup_printf("%d", n), OSDT_NO_DUP);
521 osd_template_insert(vars, "total", g_strdup_printf("%d", t), OSDT_NO_DUP);
522 osd_template_insert(vars, "name", (gchar *) name, OSDT_NONE);
523 osd_template_insert(vars, "date", (gchar *) text_from_time(imd->mtime), OSDT_NONE);
524 osd_template_insert(vars, "size", text_from_size_abrev(imd->size), OSDT_FREE);
525 osd_template_insert(vars, "zoom", image_zoom_get_as_text(imd), OSDT_FREE);
531 if (imd->delay_flip &&
532 imd->il && imd->il->pixbuf &&
533 image_get_pixbuf(imd) != imd->il->pixbuf)
535 w = gdk_pixbuf_get_width(imd->il->pixbuf);
536 h = gdk_pixbuf_get_height(imd->il->pixbuf);
537 imgpixbuf = imd->il->pixbuf;
541 image_get_image_size(imd, &w, &h);
542 imgpixbuf = (PIXBUF_RENDERER(imd->pr))->pixbuf;
546 osd_template_insert(vars, "width", g_strdup_printf("%d", w), OSDT_NO_DUP);
547 osd_template_insert(vars, "height", g_strdup_printf("%d", h), OSDT_NO_DUP);
548 osd_template_insert(vars, "res", g_strdup_printf("%d × %d", w, h), OSDT_FREE);
552 osd_template_insert(vars, "width", NULL, OSDT_NONE);
553 osd_template_insert(vars, "height", NULL, OSDT_NONE);
554 osd_template_insert(vars, "res", NULL, OSDT_NONE);
557 text = image_osd_mkinfo(options->image_overlay.common.template_string, imd, vars);
558 g_hash_table_destroy(vars);
561 /* When does this occur ?? */
562 text = g_markup_escape_text(_("Untitled"), -1);
565 with_hist = (imgpixbuf && (osd->show & OSD_SHOW_HISTOGRAM) && osd->histogram && (!imd->il || imd->il->done));
568 gint active_marks = 0;
572 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
574 active_marks += file_data_get_mark(fd, mark);
577 if (active_marks > 0)
579 GString *buf = g_string_sized_new(FILEDATA_MARKS_SIZE * 2);
581 for (mark = 0; mark < FILEDATA_MARKS_SIZE; mark++)
583 g_string_append_printf(buf, file_data_get_mark(fd, mark) ? " <span background='#FF00FF'>%c</span>" : " %c", '1' + mark);
587 text2 = g_strdup_printf("%s\n%s", text, buf->str);
589 text2 = g_strdup(buf->str);
590 g_string_free(buf, TRUE);
597 gchar *escaped_histogram_label = g_markup_escape_text(histogram_label(osd->histogram), -1);
599 text2 = g_strdup_printf("%s\n%s", text, escaped_histogram_label);
601 text2 = g_strdup(escaped_histogram_label);
602 g_free(escaped_histogram_label);
608 layout = gtk_widget_create_pango_layout(imd->pr, NULL);
609 pango_layout_set_markup(layout, text, -1);
612 pango_layout_get_pixel_size(layout, &width, &height);
613 /* with empty text width is set to 0, but not height) */
616 else if (height == 0)
618 if (width > 0) width += 10;
619 if (height > 0) height += 10;
623 histogram_read(osd->histogram, imgpixbuf);
624 if (width < HISTOGRAM_WIDTH + 10) width = HISTOGRAM_WIDTH + 10;
625 height += HISTOGRAM_HEIGHT + 5;
628 if (width > 0 && height > 0)
630 /* TODO: make osd color configurable --Zas */
631 pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, width, height);
632 pixbuf_set_rect_fill(pixbuf, 3, 3, width-6, height-6, 240, 240, 240, 210);
633 pixbuf_set_rect(pixbuf, 0, 0, width, height, 240, 240, 240, 80, 1, 1, 1, 1);
634 pixbuf_set_rect(pixbuf, 1, 1, width-2, height-2, 240, 240, 240, 130, 1, 1, 1, 1);
635 pixbuf_set_rect(pixbuf, 2, 2, width-4, height-4, 240, 240, 240, 180, 1, 1, 1, 1);
636 pixbuf_pixel_set(pixbuf, 0, 0, 0, 0, 0, 0);
637 pixbuf_pixel_set(pixbuf, width - 1, 0, 0, 0, 0, 0);
638 pixbuf_pixel_set(pixbuf, 0, height - 1, 0, 0, 0, 0);
639 pixbuf_pixel_set(pixbuf, width - 1, height - 1, 0, 0, 0, 0);
644 gint y = height - HISTOGRAM_HEIGHT - 5;
651 float add = w / (float)subdiv;
653 for (i = 0; i < subdiv; i++)
655 gint d = (i > 0 ? 0 : 1);
657 pixbuf_set_rect(pixbuf, x + xoffset + 0.5, y, add + d + 0.5, HISTOGRAM_HEIGHT, c, c, c, alpha, d, 1, 1, 1);
661 histogram_draw(osd->histogram, pixbuf, x, y, w, HISTOGRAM_HEIGHT);
663 pixbuf_draw_layout(pixbuf, layout, imd->pr, 5, 5, 0, 0, 0, 255);
666 g_object_unref(G_OBJECT(layout));
671 static GdkPixbuf *image_osd_icon_pixbuf(ImageOSDFlag flag)
673 static GdkPixbuf **icons = NULL;
674 GdkPixbuf *icon = NULL;
676 if (!icons) icons = g_new0(GdkPixbuf *, IMAGE_OSD_COUNT);
677 if (icons[flag]) return icons[flag];
679 if (osd_icons[flag].key)
681 icon = pixbuf_inline(osd_icons[flag].key);
686 icon = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 24, 24);
687 pixbuf_set_rect_fill(icon, 1, 1, 22, 22, 255, 255, 255, 200);
688 pixbuf_set_rect(icon, 0, 0, 24, 24, 0, 0, 0, 128, 1, 1, 1, 1);
691 case IMAGE_OSD_ROTATE_AUTO:
692 pixbuf_set_rect(icon, 3, 8, 11, 12,
695 pixbuf_draw_triangle(icon, 14, 3, 6, 12,
696 20, 9, 14, 15, 14, 3,
699 case IMAGE_OSD_ROTATE_USER:
701 case IMAGE_OSD_COLOR:
702 pixbuf_set_rect_fill(icon, 3, 3, 18, 6, 200, 0, 0, 255);
703 pixbuf_set_rect_fill(icon, 3, 9, 18, 6, 0, 200, 0, 255);
704 pixbuf_set_rect_fill(icon, 3, 15, 18, 6, 0, 0, 200, 255);
706 case IMAGE_OSD_FIRST:
707 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 3, 0);
708 pixbuf_draw_triangle(icon, 6, 5, 12, 6,
709 12, 5, 18, 11, 6, 11,
713 pixbuf_set_rect(icon, 3, 3, 18, 18, 0, 0, 0, 200, 3, 3, 0, 3);
714 pixbuf_draw_triangle(icon, 6, 12, 12, 6,
715 12, 18, 6, 12, 18, 12,
719 pixbuf_set_rect_fill(icon, 11, 3, 3, 12, 0, 0, 0, 255);
720 pixbuf_set_rect_fill(icon, 11, 17, 3, 3, 0, 0, 0, 255);
732 static gint image_overlay_add(ImageWindow *imd, GdkPixbuf *pixbuf, gint x, gint y,
733 OverlayRendererFlags flags)
735 return pixbuf_renderer_overlay_add((PixbufRenderer *)imd->pr, pixbuf, x, y, flags);
738 static void image_overlay_set(ImageWindow *imd, gint id, GdkPixbuf *pixbuf, gint x, gint y)
740 pixbuf_renderer_overlay_set((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
743 #if 0 /* unused for now */
744 static gint image_overlay_get(ImageWindow *imd, gint id, GdkPixbuf **pixbuf, gint *x, gint *y)
746 return pixbuf_renderer_overlay_get((PixbufRenderer *)imd->pr, id, pixbuf, x, y);
750 static void image_overlay_remove(ImageWindow *imd, gint id)
752 pixbuf_renderer_overlay_remove((PixbufRenderer *)imd->pr, id);
755 static void image_osd_icon_show(OverlayStateData *osd, ImageOSDFlag flag)
759 if (osd->icon_id[flag]) return;
761 pixbuf = image_osd_icon_pixbuf(flag);
764 osd->icon_id[flag] = image_overlay_add(osd->imd, pixbuf,
765 osd_icons[flag].x, osd_icons[flag].y,
769 static void image_osd_icon_hide(OverlayStateData *osd, ImageOSDFlag flag)
771 if (osd->icon_id[flag])
773 image_overlay_remove(osd->imd, osd->icon_id[flag]);
774 osd->icon_id[flag] = 0;
778 static void image_osd_icons_reset_time(OverlayStateData *osd)
782 for (i = 0; i < IMAGE_OSD_COUNT; i++)
784 if (osd_icons[i].reset)
786 osd->icon_time[i] = 0;
791 static void image_osd_icons_update(OverlayStateData *osd)
795 for (i = 0; i < IMAGE_OSD_COUNT; i++)
797 if (osd->icon_time[i] > 0)
799 image_osd_icon_show(osd, i);
803 image_osd_icon_hide(osd, i);
808 static void image_osd_icons_hide(OverlayStateData *osd)
812 for (i = 0; i < IMAGE_OSD_COUNT; i++)
814 image_osd_icon_hide(osd, i);
818 static gint image_osd_update_cb(gpointer data)
820 OverlayStateData *osd = data;
822 osd->imd->overlay_show_zoom = FALSE;
824 if (osd->show & OSD_SHOW_INFO)
826 if (osd->changed_states & IMAGE_STATE_IMAGE)
830 pixbuf = image_osd_info_render(osd);
833 if (osd->ovl_info == 0)
835 osd->ovl_info = image_overlay_add(osd->imd, pixbuf,
836 osd->x, osd->y, OVL_RELATIVE);
840 image_overlay_set(osd->imd, osd->ovl_info, pixbuf, osd->x, osd->y);
842 g_object_unref(pixbuf);
844 else if (osd->ovl_info)
846 image_overlay_remove(osd->imd, osd->ovl_info);
855 image_overlay_remove(osd->imd, osd->ovl_info);
860 if (osd->show & OSD_SHOW_STATUS)
862 if (osd->changed_states & IMAGE_STATE_IMAGE)
863 image_osd_icons_reset_time(osd);
865 if (osd->changed_states & IMAGE_STATE_COLOR_ADJ)
867 osd->icon_time[IMAGE_OSD_COLOR] = IMAGE_OSD_DEFAULT_DURATION + 1;
868 image_osd_timer_schedule(osd);
871 if (osd->changed_states & IMAGE_STATE_ROTATE_AUTO)
875 if (osd->imd->state & IMAGE_STATE_ROTATE_AUTO)
878 if (!osd->imd->cm) n += IMAGE_OSD_DEFAULT_DURATION;
881 osd->icon_time[IMAGE_OSD_ROTATE_AUTO] = n;
882 image_osd_timer_schedule(osd);
885 image_osd_icons_update(osd);
889 image_osd_icons_hide(osd);
892 if (osd->imd->il && osd->imd->il->done)
893 osd->changed_states = IMAGE_STATE_NONE;
898 static void image_osd_update_schedule(OverlayStateData *osd, gint force)
900 if (force) osd->changed_states |= IMAGE_STATE_IMAGE;
902 if (osd->idle_id == -1)
904 osd->idle_id = g_idle_add_full(G_PRIORITY_HIGH, image_osd_update_cb, osd, NULL);
908 void image_osd_update(ImageWindow *imd)
910 OverlayStateData *osd = image_get_osd_data(imd);
914 image_osd_update_schedule(osd, TRUE);
917 static gint image_osd_timer_cb(gpointer data)
919 OverlayStateData *osd = data;
921 gint changed = FALSE;
924 for (i = 0; i < IMAGE_OSD_COUNT; i++)
926 if (osd->icon_time[i] > 1)
929 if (osd->icon_time[i] < 2)
931 osd->icon_time[i] = 0;
941 if (changed) image_osd_update_schedule(osd, FALSE);
952 static void image_osd_timer_schedule(OverlayStateData *osd)
954 if (osd->timer_id == -1)
956 osd->timer_id = g_timeout_add(100, image_osd_timer_cb, osd);
960 static void image_osd_state_cb(ImageWindow *imd, ImageState state, gpointer data)
962 OverlayStateData *osd = data;
964 osd->changed_states |= state;
965 image_osd_update_schedule(osd, FALSE);
968 static void image_osd_free(OverlayStateData *osd)
972 if (osd->idle_id != -1) g_source_remove(osd->idle_id);
973 if (osd->timer_id != -1) g_source_remove(osd->timer_id);
977 image_set_osd_data(osd->imd, NULL);
978 g_signal_handler_disconnect(osd->imd->pr, osd->destroy_id);
980 image_set_state_func(osd->imd, NULL, NULL);
981 image_overlay_remove(osd->imd, osd->ovl_info);
983 image_osd_icons_hide(osd);
986 if (osd->histogram) histogram_free(osd->histogram);
991 static void image_osd_remove(ImageWindow *imd)
993 OverlayStateData *osd = image_get_osd_data(imd);
995 if (osd) image_osd_free(osd);
998 static void image_osd_destroy_cb(GtkWidget *widget, gpointer data)
1000 OverlayStateData *osd = data;
1003 image_osd_free(osd);
1006 static void image_osd_enable(ImageWindow *imd, OsdShowFlags show)
1008 OverlayStateData *osd = image_get_osd_data(imd);
1012 osd = g_new0(OverlayStateData, 1);
1016 osd->show = OSD_SHOW_NOTHING;
1017 osd->histogram = NULL;
1018 osd->x = options->image_overlay.common.x;
1019 osd->y = options->image_overlay.common.y;
1021 osd->destroy_id = g_signal_connect(G_OBJECT(imd->pr), "destroy",
1022 G_CALLBACK(image_osd_destroy_cb), osd);
1023 image_set_osd_data(imd, osd);
1025 image_set_state_func(osd->imd, image_osd_state_cb, osd);
1028 if (show & OSD_SHOW_HISTOGRAM)
1029 osd->histogram = histogram_new();
1030 else if (osd->histogram)
1032 histogram_free(osd->histogram);
1033 osd->histogram = NULL;
1036 if (show & OSD_SHOW_STATUS)
1037 image_osd_icon(imd, IMAGE_OSD_ICON, -1);
1039 if (show != osd->show)
1040 image_osd_update_schedule(osd, TRUE);
1045 void image_osd_set(ImageWindow *imd, OsdShowFlags show)
1049 if (show == OSD_SHOW_NOTHING)
1051 image_osd_remove(imd);
1055 image_osd_enable(imd, show);
1058 OsdShowFlags image_osd_get(ImageWindow *imd)
1060 OverlayStateData *osd = image_get_osd_data(imd);
1062 return osd ? osd->show : OSD_SHOW_NOTHING;
1068 2+ = show for duration tenths of a second
1069 -1 = use default duration
1071 void image_osd_icon(ImageWindow *imd, ImageOSDFlag flag, gint duration)
1073 OverlayStateData *osd = image_get_osd_data(imd);
1077 if (flag < IMAGE_OSD_NONE || flag >= IMAGE_OSD_COUNT) return;
1078 if (duration < 0) duration = IMAGE_OSD_DEFAULT_DURATION;
1079 if (duration > 1) duration += 1;
1081 osd->icon_time[flag] = duration;
1083 image_osd_update_schedule(osd, FALSE);
1084 image_osd_timer_schedule(osd);