Revision: 1427
http://geeqie.svn.sourceforge.net/geeqie/?rev=1427&view=rev
Author: nadvornik
Date: 2009-02-27 21:30:28 +0000 (Fri, 27 Feb 2009)
Log Message:
-----------
compute histmap in idle callback and only if the histogram is expanded
Modified Paths:
--------------
trunk/src/bar_histogram.c
Modified: trunk/src/bar_histogram.c
===================================================================
--- trunk/src/bar_histogram.c 2009-02-26 21:46:27 UTC (rev 1426)
+++ trunk/src/bar_histogram.c 2009-02-27 21:30:28 UTC (rev 1427)
@@ -42,22 +42,46 @@
gint histogram_height;
GdkPixbuf *pixbuf;
FileData *fd;
+ gboolean need_update;
+ gint idle_id;
};
+static gboolean bar_pane_histogram_update_cb(gpointer data);
+
static void bar_pane_histogram_update(PaneHistogramData *phd)
{
- const HistMap *histmap;
if (phd->pixbuf) g_object_unref(phd->pixbuf);
phd->pixbuf = NULL;
if (!phd->histogram_width || !phd->histogram_height || !phd->fd) return;
+ /* histmap_get is relatively expensive, run it only when we really need
it
+ and with lower priority than pixbuf_renderer
+ FIXME: this does not work for fullscreen*/
+ if (GTK_WIDGET_DRAWABLE(phd->drawing_area))
+ {
+ if (phd->idle_id == -1) phd->idle_id =
g_idle_add_full(G_PRIORITY_DEFAULT_IDLE, bar_pane_histogram_update_cb, phd,
NULL);
+ }
+ else
+ {
+ phd->need_update = TRUE;
+ }
+}
+
+static gboolean bar_pane_histogram_update_cb(gpointer data)
+{
+ const HistMap *histmap;
+ PaneHistogramData *phd = data;
+
+ phd->idle_id = -1;
+ phd->need_update = FALSE;
+
gtk_widget_queue_draw_area(GTK_WIDGET(phd->drawing_area), 0, 0,
phd->histogram_width, phd->histogram_height);
histmap = histmap_get(phd->fd);
- if (!histmap) return;
+ if (!histmap) return FALSE;
phd->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8,
phd->histogram_width, phd->histogram_height);
gdk_pixbuf_fill(phd->pixbuf, 0xffffffff);
@@ -66,6 +90,7 @@
#if GTK_CHECK_VERSION(2,12,0)
gtk_widget_set_tooltip_text(phd->drawing_area,
histogram_label(phd->histogram));
#endif
+ return FALSE;
}
@@ -109,8 +134,15 @@
static gboolean bar_pane_histogram_expose_event_cb (GtkWidget *widget,
GdkEventExpose *event, gpointer data)
{
PaneHistogramData *phd = data;
- if (!phd || !phd->pixbuf) return TRUE;
+ if (!phd) return TRUE;
+ if (phd->need_update)
+ {
+ bar_pane_histogram_update(phd);
+ }
+
+ if (!phd->pixbuf) return TRUE;
+
gdk_draw_pixbuf(widget->window,
widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
phd->pixbuf,
@@ -143,7 +175,8 @@
static void bar_pane_histogram_destroy(GtkWidget *widget, gpointer data)
{
PaneHistogramData *phd = data;
-
+
+ g_source_remove(phd->idle_id);
file_data_unregister_notify_func(bar_pane_histogram_notify_cb, phd);
file_data_unref(phd->fd);
@@ -304,6 +337,7 @@
phd->pane.pane_write_config = bar_pane_histogram_write_config;
phd->pane.title = g_strdup(title);
phd->pane.expanded = expanded;
+ phd->idle_id = -1;
phd->histogram = histogram_new();
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn