Mercurial > geeqie
diff src/image-overlay.c @ 1439:2441a90c4bcf
compute histogram in idle time
author | nadvornik |
---|---|
date | Sun, 15 Mar 2009 11:34:09 +0000 |
parents | b4ad1d201279 |
children | 3265830658cd |
line wrap: on
line diff
--- a/src/image-overlay.c Sun Mar 15 09:06:13 2009 +0000 +++ b/src/image-overlay.c Sun Mar 15 11:34:09 2009 +0000 @@ -37,6 +37,7 @@ struct _OverlayStateData { ImageWindow *imd; ImageState changed_states; + NotifyType notify; Histogram *histogram; @@ -557,7 +558,11 @@ if (with_hist) { histmap = histmap_get(imd->image_fd); - if (!histmap) with_hist = FALSE; + if (!histmap) + { + histmap_start_idle(imd->image_fd); + with_hist = FALSE; + } } @@ -829,7 +834,8 @@ /* redraw when the image was changed, with histogram we have to redraw also when loading is finished */ if (osd->changed_states & IMAGE_STATE_IMAGE || - (osd->changed_states & IMAGE_STATE_LOADING && osd->show & OSD_SHOW_HISTOGRAM)) + (osd->changed_states & IMAGE_STATE_LOADING && osd->show & OSD_SHOW_HISTOGRAM) || + osd->notify & NOTIFY_HISTMAP) { GdkPixbuf *pixbuf; @@ -884,6 +890,7 @@ if (osd->imd->il && image_loader_get_is_done(osd->imd->il)) osd->changed_states = IMAGE_STATE_NONE; + osd->notify = 0; osd->idle_id = -1; return FALSE; } @@ -958,6 +965,18 @@ image_osd_update_schedule(osd, FALSE); } +static void image_osd_notify_cb(FileData *fd, NotifyType type, gpointer data) +{ + OverlayStateData *osd = data; + + if ((type & (NOTIFY_HISTMAP)) && osd->imd && fd == osd->imd->image_fd) + { + osd->notify |= type; + image_osd_update_schedule(osd, FALSE); + } +} + + static void image_osd_free(OverlayStateData *osd) { if (!osd) return; @@ -965,6 +984,8 @@ if (osd->idle_id != -1) g_source_remove(osd->idle_id); if (osd->timer_id != -1) g_source_remove(osd->timer_id); + file_data_unregister_notify_func(image_osd_notify_cb, osd); + if (osd->imd) { image_set_osd_data(osd->imd, NULL); @@ -1017,6 +1038,7 @@ image_set_osd_data(imd, osd); image_set_state_func(osd->imd, image_osd_state_cb, osd); + file_data_register_notify_func(image_osd_notify_cb, osd, NOTIFY_PRIORITY_LOW); } if (show & OSD_SHOW_STATUS)