Revision: 1394
          http://geeqie.svn.sourceforge.net/geeqie/?rev=1394&view=rev
Author:   nadvornik
Date:     2009-02-15 19:25:55 +0000 (Sun, 15 Feb 2009)

Log Message:
-----------
added histogram pane

Modified Paths:
--------------
    trunk/src/Makefile.am
    trunk/src/bar.c
    trunk/src/histogram.c
    trunk/src/histogram.h
    trunk/src/image-overlay.c
    trunk/src/image.c

Added Paths:
-----------
    trunk/src/bar_histogram.c
    trunk/src/bar_histogram.h

Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am       2009-02-15 17:27:48 UTC (rev 1393)
+++ trunk/src/Makefile.am       2009-02-15 19:25:55 UTC (rev 1394)
@@ -82,6 +82,8 @@
        bar.h           \
        bar_comment.c   \
        bar_comment.h   \
+       bar_histogram.c \
+       bar_histogram.h \
        bar_keywords.c  \
        bar_keywords.h  \
        bar_exif.c      \

Modified: trunk/src/bar.c
===================================================================
--- trunk/src/bar.c     2009-02-15 17:27:48 UTC (rev 1393)
+++ trunk/src/bar.c     2009-02-15 19:25:55 UTC (rev 1394)
@@ -26,6 +26,7 @@
 #include "bar_comment.h"
 #include "bar_keywords.h"
 #include "bar_exif.h"
+#include "bar_histogram.h"
 
 #define BAR_SIZE_INCREMENT 48
 #define BAR_ARROW_SIZE 7
@@ -334,6 +335,8 @@
        gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrolled), 
GTK_SHADOW_NONE);
        gtk_widget_show(bd->vbox);
        
+       widget = bar_pane_histogram_new(_("Histogram"), 80);
+       bar_add(bd->widget, widget);
 
        widget = bar_pane_comment_new(_("Title"), "Xmp.dc.title", 40);
        bar_add(bd->widget, widget);

Added: trunk/src/bar_histogram.c
===================================================================
--- trunk/src/bar_histogram.c                           (rev 0)
+++ trunk/src/bar_histogram.c   2009-02-15 19:25:55 UTC (rev 1394)
@@ -0,0 +1,172 @@
+/*
+ * Geeqie
+ * (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2009 The Geeqie Team
+ *
+ * Author: Vladimir Nadvornik
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+
+#include "main.h"
+#include "bar_comment.h"
+
+#include "bar.h"
+#include "metadata.h"
+#include "filedata.h"
+#include "ui_menu.h"
+#include "ui_misc.h"
+#include "histogram.h"
+
+/*
+ *-------------------------------------------------------------------
+ * keyword / comment utils
+ *-------------------------------------------------------------------
+ */
+
+
+
+typedef struct _PaneHistogramData PaneHistogramData;
+struct _PaneHistogramData
+{
+       PaneData pane;
+       GtkWidget *widget;
+       GtkWidget *drawing_area;
+       Histogram *histogram;
+       gint histogram_width;
+       gint histogram_height;
+       GdkPixbuf *pixbuf;
+       FileData *fd;
+};
+
+
+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;
+
+       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;
+       
+       phd->pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, FALSE, 8, 
phd->histogram_width, phd->histogram_height);
+       gdk_pixbuf_fill(phd->pixbuf, 0xffffffff);
+       histogram_draw(phd->histogram, histmap, phd->pixbuf, 0, 0, 
phd->histogram_width, phd->histogram_height);
+}
+
+
+static void bar_pane_histogram_set_fd(GtkWidget *pane, FileData *fd)
+{
+       PaneHistogramData *phd;
+
+       phd = g_object_get_data(G_OBJECT(pane), "pane_data");
+       if (!phd) return;
+
+       file_data_unref(phd->fd);
+       phd->fd = file_data_ref(fd);
+
+       bar_pane_histogram_update(phd);
+}
+
+static void bar_pane_histogram_notify_cb(FileData *fd, NotifyType type, 
gpointer data)
+{
+       PaneHistogramData *phd = data;
+       if (fd == phd->fd) bar_pane_histogram_update(phd);
+}
+
+static gboolean bar_pane_histogram_expose_event_cb (GtkWidget *widget, 
GdkEventExpose *event, gpointer data)
+{
+       PaneHistogramData *phd = data;
+       if (!phd || !phd->pixbuf) return TRUE;
+       
+       gdk_draw_pixbuf(widget->window,
+                       widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
+                       phd->pixbuf,
+                       0, 0,
+                       0, 0,
+                       -1, -1,
+                       GDK_RGB_DITHER_NORMAL, 0, 0);
+       return TRUE;
+}
+
+static void bar_pane_histogram_size_cb(GtkWidget *widget, GtkAllocation 
*allocation, gpointer data)
+{
+       PaneHistogramData *phd = data;
+
+       phd->histogram_width = allocation->width;
+       phd->histogram_height = allocation->height;
+       bar_pane_histogram_update(phd);
+}
+
+static void bar_pane_histogram_close(GtkWidget *pane)
+{
+       PaneHistogramData *phd;
+
+       phd = g_object_get_data(G_OBJECT(pane), "pane_data");
+       if (!phd) return;
+
+       gtk_widget_destroy(phd->widget);
+}
+
+static void bar_pane_histogram_destroy(GtkWidget *widget, gpointer data)
+{
+       PaneHistogramData *phd = data;
+
+       file_data_unregister_notify_func(bar_pane_histogram_notify_cb, phd);
+
+       file_data_unref(phd->fd);
+       g_free(phd->pane.title);
+       histogram_free(phd->histogram);
+       if (phd->pixbuf) g_object_unref(phd->pixbuf);
+
+       g_free(phd);
+}
+
+
+GtkWidget *bar_pane_histogram_new(const gchar *title, gint height)
+{
+       PaneHistogramData *phd;
+
+       phd = g_new0(PaneHistogramData, 1);
+       
+       phd->pane.pane_set_fd = bar_pane_histogram_set_fd;
+       phd->pane.title = g_strdup(title);
+       
+       phd->histogram = histogram_new();
+       
+       phd->widget = gtk_vbox_new(FALSE, PREF_PAD_GAP);
+
+       g_object_set_data(G_OBJECT(phd->widget), "pane_data", phd);
+       g_signal_connect(G_OBJECT(phd->widget), "destroy",
+                        G_CALLBACK(bar_pane_histogram_destroy), phd);
+       
+
+       gtk_widget_set_size_request(GTK_WIDGET(phd->widget), -1, height);
+
+       phd->drawing_area = gtk_drawing_area_new();
+       g_signal_connect_after(G_OBJECT(phd->drawing_area), "size_allocate",
+                               G_CALLBACK(bar_pane_histogram_size_cb), phd);
+
+       g_signal_connect(G_OBJECT(phd->drawing_area), "expose_event",  
+                        G_CALLBACK(bar_pane_histogram_expose_event_cb), phd);
+                        
+       gtk_box_pack_start(GTK_BOX(phd->widget), phd->drawing_area, TRUE, TRUE, 
0);
+       gtk_widget_show(phd->drawing_area);
+
+
+       gtk_widget_show(phd->widget);
+
+       file_data_register_notify_func(bar_pane_histogram_notify_cb, phd, 
NOTIFY_PRIORITY_LOW);
+
+       return phd->widget;
+}
+
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */

Added: trunk/src/bar_histogram.h
===================================================================
--- trunk/src/bar_histogram.h                           (rev 0)
+++ trunk/src/bar_histogram.h   2009-02-15 19:25:55 UTC (rev 1394)
@@ -0,0 +1,20 @@
+/*
+ * Geeqie
+ * (C) 2004 John Ellis
+ * Copyright (C) 2008 - 2009 The Geeqie Team
+ *
+ * Author: Vladimir Nadvornik
+ *
+ * This software is released under the GNU General Public License (GNU GPL).
+ * Please read the included file COPYING for more information.
+ * This software comes with no warranty of any kind, use at your own risk!
+ */
+
+
+#ifndef BAR_HISTOGRAM_H
+#define BAR_HISTOGRAM_H
+
+GtkWidget *bar_pane_histogram_new(const gchar *title, gint height);
+
+#endif
+/* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */

Modified: trunk/src/histogram.c
===================================================================
--- trunk/src/histogram.c       2009-02-15 17:27:48 UTC (rev 1393)
+++ trunk/src/histogram.c       2009-02-15 19:25:55 UTC (rev 1394)
@@ -154,7 +154,7 @@
        return histmap;
 }
 
-HistMap *histmap_get(FileData *fd)
+const HistMap *histmap_get(FileData *fd)
 {
        if (fd->histmap) return fd->histmap;
        
@@ -166,7 +166,7 @@
        return NULL;
 }
 
-gint histogram_draw(Histogram *histogram, HistMap *histmap, GdkPixbuf *pixbuf, 
gint x, gint y, gint width, gint height)
+gint histogram_draw(Histogram *histogram, const HistMap *histmap, GdkPixbuf 
*pixbuf, gint x, gint y, gint width, gint height)
 {
        /* FIXME: use the coordinates correctly */
        gint i;

Modified: trunk/src/histogram.h
===================================================================
--- trunk/src/histogram.h       2009-02-15 17:27:48 UTC (rev 1393)
+++ trunk/src/histogram.h       2009-02-15 19:25:55 UTC (rev 1394)
@@ -30,8 +30,8 @@
 gint histogram_set_mode(Histogram *histogram, gint mode);
 gint histogram_get_mode(Histogram *histogram);
 const gchar *histogram_label(Histogram *histogram);
-HistMap *histmap_get(FileData *fd);
-gint histogram_draw(Histogram *histogram, HistMap *histmap, GdkPixbuf *pixbuf, 
gint x, gint y, gint width, gint height);
+const HistMap *histmap_get(FileData *fd);
+gint histogram_draw(Histogram *histogram, const HistMap *histmap, GdkPixbuf 
*pixbuf, gint x, gint y, gint width, gint height);
 
 void histogram_notify_cb(FileData *fd, NotifyType type, gpointer data);
 

Modified: trunk/src/image-overlay.c
===================================================================
--- trunk/src/image-overlay.c   2009-02-15 17:27:48 UTC (rev 1393)
+++ trunk/src/image-overlay.c   2009-02-15 19:25:55 UTC (rev 1394)
@@ -442,7 +442,7 @@
        gchar *text;
        GdkPixbuf *imgpixbuf = NULL;
        gboolean with_hist;
-       HistMap *histmap;
+       const HistMap *histmap;
        ImageWindow *imd = osd->imd;
        FileData *fd = image_get_fd(imd);
 

Modified: trunk/src/image.c
===================================================================
--- trunk/src/image.c   2009-02-15 17:27:48 UTC (rev 1393)
+++ trunk/src/image.c   2009-02-15 19:25:55 UTC (rev 1394)
@@ -484,6 +484,7 @@
        g_assert(fd->pixbuf);
 
        file_cache_put(image_get_cache(), fd, 
(gulong)gdk_pixbuf_get_rowstride(fd->pixbuf) * 
(gulong)gdk_pixbuf_get_height(fd->pixbuf));
+       file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); /* to update 
histogram */
 }
 
 static gint image_cache_get(ImageWindow *imd)


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

Reply via email to