+ /* finished */
+ g_object_unref(fd->histmap->pixbuf); /*pixbuf is no longer needed */
+ fd->histmap->pixbuf = NULL;
+ fd->histmap->idle_id = 0;
+ file_data_send_notification(fd, NOTIFY_HISTMAP);
+ return FALSE;
+ }
+ return TRUE;
+}
+
+gboolean histmap_start_idle(FileData *fd)
+{
+ if (fd->histmap || !fd->pixbuf) return FALSE;
+
+ fd->histmap = histmap_new();
+ fd->histmap->pixbuf = fd->pixbuf;
+ g_object_ref(fd->histmap->pixbuf);
+
+ fd->histmap->idle_id = g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, histmap_idle_cb, fd, NULL);
+ return TRUE;
+}
+
+
+static void histogram_vgrid(Histogram *histogram, GdkPixbuf *pixbuf, gint x, gint y, gint width, gint height)
+{
+ guint i;
+ float add;
+
+ if (histogram->vgrid == 0) return;
+
+ add = width / (float)histogram->vgrid;
+
+ for (i = 1; i < histogram->vgrid; i++)
+ {
+ gint xpos = x + (int)(i * add + 0.5);
+
+ pixbuf_draw_line(pixbuf, x, y, width, height, xpos, y, xpos, y + height,
+ histogram->grid_color.R,
+ histogram->grid_color.G,
+ histogram->grid_color.B,
+ histogram->grid_color.A);
+ }
+}
+
+static void histogram_hgrid(Histogram *histogram, GdkPixbuf *pixbuf, gint x, gint y, gint width, gint height)
+{
+ guint i;
+ float add;
+
+ if (histogram->hgrid == 0) return;
+
+ add = height / (float)histogram->hgrid;
+
+ for (i = 1; i < histogram->hgrid; i++)
+ {
+ gint ypos = y + (int)(i * add + 0.5);
+
+ pixbuf_draw_line(pixbuf, x, y, width, height, x, ypos, x + width, ypos,
+ histogram->grid_color.R,
+ histogram->grid_color.G,
+ histogram->grid_color.B,
+ histogram->grid_color.A);