[gthumb] added an histogram view to the sidebar
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] added an histogram view to the sidebar
- Date: Thu, 20 Jan 2011 20:20:17 +0000 (UTC)
commit b0e3cb41b4fdee356f50eabd383fb00bf0d3c6c0
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Jan 17 22:05:37 2011 +0100
added an histogram view to the sidebar
[new feature]
data/icons/hicolor/16x16/actions/Makefile.am | 43 +++---
.../hicolor/16x16/actions/histogram-linear.png | Bin 0 -> 430 bytes
.../16x16/actions/histogram-logarithmic.png | Bin 0 -> 398 bytes
data/icons/hicolor/16x16/actions/histogram.png | Bin 349 -> 362 bytes
extensions/image_viewer/Makefile.am | 2 +
extensions/image_viewer/gth-image-histogram.c | 174 ++++++++++++++++++++
extensions/image_viewer/gth-image-histogram.h | 53 ++++++
extensions/image_viewer/main.c | 2 +
8 files changed, 253 insertions(+), 21 deletions(-)
---
diff --git a/data/icons/hicolor/16x16/actions/Makefile.am b/data/icons/hicolor/16x16/actions/Makefile.am
index 9b99a65..a2e624e 100644
--- a/data/icons/hicolor/16x16/actions/Makefile.am
+++ b/data/icons/hicolor/16x16/actions/Makefile.am
@@ -4,27 +4,28 @@ context = actions
iconsdir = $(themedir)/$(size)/$(context)
-icons_DATA = \
- browser-mode.png \
- facebook.png \
- file-catalog.png \
- file-library.png \
- file-search.png \
- flickr.png \
- histogram.png \
- image-navigator.png \
- photobucket.png \
- picasaweb.png \
- tool-adjust-colors.png \
- tool-crop.png \
- tool-desaturate.png \
- tool-enhance.png \
- tool-flip.png \
- tool-invert.png \
- tool-mirror.png \
- tool-red-eye.png \
- tool-resize.png \
- tool-rotate-270.png \
+icons_DATA = \
+ browser-mode.png \
+ facebook.png \
+ file-catalog.png \
+ file-library.png \
+ file-search.png \
+ flickr.png \
+ histogram.png \
+ histogram-logarithmic.png \
+ image-navigator.png \
+ photobucket.png \
+ picasaweb.png \
+ tool-adjust-colors.png \
+ tool-crop.png \
+ tool-desaturate.png \
+ tool-enhance.png \
+ tool-flip.png \
+ tool-invert.png \
+ tool-mirror.png \
+ tool-red-eye.png \
+ tool-resize.png \
+ tool-rotate-270.png \
tool-rotate-90.png
EXTRA_DIST = $(icons_DATA)
diff --git a/data/icons/hicolor/16x16/actions/histogram-linear.png b/data/icons/hicolor/16x16/actions/histogram-linear.png
new file mode 100644
index 0000000..ff42461
Binary files /dev/null and b/data/icons/hicolor/16x16/actions/histogram-linear.png differ
diff --git a/data/icons/hicolor/16x16/actions/histogram-logarithmic.png b/data/icons/hicolor/16x16/actions/histogram-logarithmic.png
new file mode 100644
index 0000000..9788847
Binary files /dev/null and b/data/icons/hicolor/16x16/actions/histogram-logarithmic.png differ
diff --git a/data/icons/hicolor/16x16/actions/histogram.png b/data/icons/hicolor/16x16/actions/histogram.png
index a9dfdb2..43d3ff2 100644
Binary files a/data/icons/hicolor/16x16/actions/histogram.png and b/data/icons/hicolor/16x16/actions/histogram.png differ
diff --git a/extensions/image_viewer/Makefile.am b/extensions/image_viewer/Makefile.am
index 55b8b8a..f52c614 100644
--- a/extensions/image_viewer/Makefile.am
+++ b/extensions/image_viewer/Makefile.am
@@ -4,6 +4,8 @@ extensiondir = $(pkglibdir)/extensions
extension_LTLIBRARIES = libimage_viewer.la
libimage_viewer_la_SOURCES = \
+ gth-image-histogram.c \
+ gth-image-histogram.h \
gth-image-viewer-page.c \
gth-image-viewer-page.h \
gth-metadata-provider-image.c \
diff --git a/extensions/image_viewer/gth-image-histogram.c b/extensions/image_viewer/gth-image-histogram.c
new file mode 100644
index 0000000..b599682
--- /dev/null
+++ b/extensions/image_viewer/gth-image-histogram.c
@@ -0,0 +1,174 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include <gthumb.h>
+#include "gth-image-histogram.h"
+#include "gth-image-viewer-page.h"
+
+#define GTH_IMAGE_HISTOGRAM_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GTH_TYPE_IMAGE_HISTOGRAM, GthImageHistogramPrivate))
+#define MIN_HISTOGRAM_HEIGHT 200
+
+
+static gpointer parent_class = NULL;
+
+
+struct _GthImageHistogramPrivate {
+ GthHistogram *histogram;
+ GtkWidget *histogram_view;
+};
+
+
+void
+gth_image_histogram_real_set_file (GthPropertyView *base,
+ GthFileData *file_data)
+{
+ GthImageHistogram *self = GTH_IMAGE_HISTOGRAM (base);
+ GdkPixbuf *pixbuf;
+ GthBrowser *browser;
+ GtkWidget *viewer_page;
+
+ if (file_data == NULL) {
+ gth_histogram_calculate (self->priv->histogram, NULL);
+ return;
+ }
+
+ browser = (GthBrowser *) gtk_widget_get_toplevel (GTK_WIDGET (base));
+ if (! gtk_widget_is_toplevel (GTK_WIDGET (browser))) {
+ gth_histogram_calculate (self->priv->histogram, NULL);
+ return;
+ }
+
+ viewer_page = gth_browser_get_viewer_page (browser);
+ if (! GTH_IS_IMAGE_VIEWER_PAGE (viewer_page)) {
+ gth_histogram_calculate (self->priv->histogram, NULL);
+ return;
+ }
+
+ pixbuf = gth_image_viewer_page_get_pixbuf (GTH_IMAGE_VIEWER_PAGE (viewer_page));
+ gth_histogram_calculate (self->priv->histogram, pixbuf);
+}
+
+
+const char *
+gth_image_histogram_real_get_name (GthMultipageChild *self)
+{
+ return _("Histogram");
+}
+
+
+const char *
+gth_image_histogram_real_get_icon (GthMultipageChild *self)
+{
+ return "histogram";
+}
+
+
+static void
+gth_image_histogram_finalize (GObject *base)
+{
+ GthImageHistogram *self = GTH_IMAGE_HISTOGRAM (base);
+
+ g_object_unref (self->priv->histogram);
+ G_OBJECT_CLASS (parent_class)->finalize (base);
+}
+
+
+static void
+gth_image_histogram_class_init (GthImageHistogramClass *klass)
+{
+ parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (GthImageHistogramPrivate));
+
+ G_OBJECT_CLASS (klass)->finalize = gth_image_histogram_finalize;
+}
+
+
+static void
+gth_image_histogram_init (GthImageHistogram *self)
+{
+ self->priv = GTH_IMAGE_HISTOGRAM_GET_PRIVATE (self);
+ self->priv->histogram = gth_histogram_new ();
+
+ gtk_box_set_spacing (GTK_BOX (self), 6);
+ gtk_container_set_border_width (GTK_CONTAINER (self), 2);
+
+ self->priv->histogram_view = gth_histogram_view_new (self->priv->histogram);
+ gtk_widget_set_size_request (self->priv->histogram_view, -1, MIN_HISTOGRAM_HEIGHT);
+ gtk_widget_show (self->priv->histogram_view);
+ gtk_box_pack_start (GTK_BOX (self), self->priv->histogram_view, FALSE, FALSE, 0);
+}
+
+
+static void
+gth_image_histogram_gth_multipage_child_interface_init (GthMultipageChildIface *iface)
+{
+ iface->get_name = gth_image_histogram_real_get_name;
+ iface->get_icon = gth_image_histogram_real_get_icon;
+}
+
+
+static void
+gth_image_histogram_gth_property_view_interface_init (GthPropertyViewIface *iface)
+{
+ iface->set_file = gth_image_histogram_real_set_file;
+}
+
+
+GType
+gth_image_histogram_get_type (void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ static const GTypeInfo g_define_type_info = {
+ sizeof (GthImageHistogramClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gth_image_histogram_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (GthImageHistogram),
+ 0,
+ (GInstanceInitFunc) gth_image_histogram_init,
+ NULL
+ };
+ static const GInterfaceInfo gth_multipage_child_info = {
+ (GInterfaceInitFunc) gth_image_histogram_gth_multipage_child_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+ static const GInterfaceInfo gth_property_view_info = {
+ (GInterfaceInitFunc) gth_image_histogram_gth_property_view_interface_init,
+ (GInterfaceFinalizeFunc) NULL,
+ NULL
+ };
+ type = g_type_register_static (GTK_TYPE_VBOX,
+ "GthImageHistogram",
+ &g_define_type_info,
+ 0);
+ g_type_add_interface_static (type, GTH_TYPE_MULTIPAGE_CHILD, >h_multipage_child_info);
+ g_type_add_interface_static (type, GTH_TYPE_PROPERTY_VIEW, >h_property_view_info);
+ }
+
+ return type;
+}
diff --git a/extensions/image_viewer/gth-image-histogram.h b/extensions/image_viewer/gth-image-histogram.h
new file mode 100644
index 0000000..0a2d8cb
--- /dev/null
+++ b/extensions/image_viewer/gth-image-histogram.h
@@ -0,0 +1,53 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2010 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef GTH_IMAGE_HISTOGRAM_H
+#define GTH_IMAGE_HISTOGRAM_H
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GTH_TYPE_IMAGE_HISTOGRAM (gth_image_histogram_get_type ())
+#define GTH_IMAGE_HISTOGRAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_IMAGE_HISTOGRAM, GthImageHistogram))
+#define GTH_IMAGE_HISTOGRAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_IMAGE_HISTOGRAM, GthImageHistogramClass))
+#define GTH_IS_IMAGE_HISTOGRAM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_IMAGE_HISTOGRAM))
+#define GTH_IS_IMAGE_HISTOGRAM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTH_TYPE_IMAGE_HISTOGRAM))
+#define GTH_IMAGE_HISTOGRAM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTH_TYPE_IMAGE_HISTOGRAM, GthImageHistogramClass))
+
+typedef struct _GthImageHistogram GthImageHistogram;
+typedef struct _GthImageHistogramClass GthImageHistogramClass;
+typedef struct _GthImageHistogramPrivate GthImageHistogramPrivate;
+
+struct _GthImageHistogram {
+ GtkVBox parent_instance;
+ GthImageHistogramPrivate *priv;
+};
+
+struct _GthImageHistogramClass {
+ GtkVBoxClass parent_class;
+};
+
+GType gth_image_histogram_get_type (void);
+
+G_END_DECLS
+
+#endif /* GTH_IMAGE_HISTOGRAM_H */
diff --git a/extensions/image_viewer/main.c b/extensions/image_viewer/main.c
index e49c645..aff918b 100644
--- a/extensions/image_viewer/main.c
+++ b/extensions/image_viewer/main.c
@@ -23,6 +23,7 @@
#include <config.h>
#include <gtk/gtk.h>
#include <gthumb.h>
+#include "gth-image-histogram.h"
#include "gth-image-viewer-page.h"
#include "gth-metadata-provider-image.h"
#include "preferences.h"
@@ -33,6 +34,7 @@ gthumb_extension_activate (void)
{
gth_main_register_metadata_provider (GTH_TYPE_METADATA_PROVIDER_IMAGE);
gth_main_register_object (GTH_TYPE_VIEWER_PAGE, NULL, GTH_TYPE_IMAGE_VIEWER_PAGE, NULL);
+ gth_main_register_type ("file-properties", GTH_TYPE_IMAGE_HISTOGRAM);
gth_hook_add_callback ("dlg-preferences-construct", 10, G_CALLBACK (image_viewer__dlg_preferences_construct_cb), NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]