[gimp] libgimpwidgets: add new widget GimpColorProfileView
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpwidgets: add new widget GimpColorProfileView
- Date: Sun, 16 Mar 2014 17:37:30 +0000 (UTC)
commit dc6b8ec8f690277d27a8fc5da22fc0be1141ff07
Author: Michael Natterer <mitch gimp org>
Date: Sun Mar 16 16:43:23 2014 +0100
libgimpwidgets: add new widget GimpColorProfileView
which is a totally trivial GtkTextView subclass and displays
color profile information.
libgimpwidgets/Makefile.am | 3 +
libgimpwidgets/gimpcolorprofileview.c | 173 +++++++++++++++++++++++++++++++++
libgimpwidgets/gimpcolorprofileview.h | 67 +++++++++++++
libgimpwidgets/gimpwidgets.def | 4 +
libgimpwidgets/gimpwidgetstypes.h | 1 +
5 files changed, 248 insertions(+), 0 deletions(-)
---
diff --git a/libgimpwidgets/Makefile.am b/libgimpwidgets/Makefile.am
index f76b1f5..661d2e1 100644
--- a/libgimpwidgets/Makefile.am
+++ b/libgimpwidgets/Makefile.am
@@ -91,6 +91,8 @@ libgimpwidgets_sources = \
gimpcolorprofilestore-private.h \
gimpcolorprofilestore.c \
gimpcolorprofilestore.h \
+ gimpcolorprofileview.c \
+ gimpcolorprofileview.h \
gimpcolorscale.c \
gimpcolorscale.h \
gimpcolorscales.c \
@@ -210,6 +212,7 @@ libgimpwidgetsinclude_HEADERS = \
gimpcolorprofilechooserdialog.h \
gimpcolorprofilecombobox.h \
gimpcolorprofilestore.h \
+ gimpcolorprofileview.h \
gimpcolorscale.h \
gimpcolorscales.h \
gimpcolorselect.h \
diff --git a/libgimpwidgets/gimpcolorprofileview.c b/libgimpwidgets/gimpcolorprofileview.c
new file mode 100644
index 0000000..8557d1d
--- /dev/null
+++ b/libgimpwidgets/gimpcolorprofileview.c
@@ -0,0 +1,173 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * GimpColorProfileView
+ * Copyright (C) 2014 Michael Natterer <mitch gimp org>
+ *
+ * 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 3 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 <string.h>
+
+#include <glib.h> /* lcms.h uses the "inline" keyword */
+
+#include <lcms2.h>
+
+#include <gegl.h>
+#include <gtk/gtk.h>
+
+#include "libgimpcolor/gimpcolor.h"
+
+#include "gimpwidgetstypes.h"
+
+#include "gimpcolorprofileview.h"
+
+
+struct _GimpColorProfileViewPrivate
+{
+ GimpColorProfile profile;
+};
+
+
+static void gimp_color_profile_view_constructed (GObject *object);
+
+
+G_DEFINE_TYPE (GimpColorProfileView, gimp_color_profile_view,
+ GTK_TYPE_TEXT_VIEW);
+
+#define parent_class gimp_color_profile_view_parent_class
+
+
+static void
+gimp_color_profile_view_class_init (GimpColorProfileViewClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->constructed = gimp_color_profile_view_constructed;
+
+ g_type_class_add_private (klass, sizeof (GimpColorProfileViewPrivate));
+}
+
+static void
+gimp_color_profile_view_init (GimpColorProfileView *view)
+{
+ view->private = G_TYPE_INSTANCE_GET_PRIVATE (view,
+ GIMP_TYPE_COLOR_PROFILE_VIEW,
+ GimpColorProfileViewPrivate);
+}
+
+static void
+gimp_color_profile_view_constructed (GObject *object)
+{
+ GtkTextBuffer *buffer;
+
+ G_OBJECT_CLASS (parent_class)->constructed (object);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (object));
+
+ gtk_text_buffer_create_tag (buffer, "strong",
+ "weight", PANGO_WEIGHT_BOLD,
+ "scale", PANGO_SCALE_LARGE,
+ NULL);
+ gtk_text_buffer_create_tag (buffer, "emphasis",
+ "style", PANGO_STYLE_OBLIQUE,
+ NULL);
+
+ gtk_text_view_set_editable (GTK_TEXT_VIEW (object), FALSE);
+ gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (object), GTK_WRAP_WORD);
+
+ gtk_text_view_set_pixels_above_lines (GTK_TEXT_VIEW (object), 6);
+ gtk_text_view_set_left_margin (GTK_TEXT_VIEW (object), 6);
+ gtk_text_view_set_right_margin (GTK_TEXT_VIEW (object), 6);
+}
+
+GtkWidget *
+gimp_color_profile_view_new (void)
+{
+ return g_object_new (GIMP_TYPE_COLOR_PROFILE_VIEW, NULL);
+}
+
+void
+gimp_color_profile_view_set_profile (GimpColorProfileView *view,
+ GimpColorProfile profile)
+{
+ GtkTextBuffer *buffer;
+ GtkTextIter iter;
+ gchar *desc;
+ gchar *model;
+ gchar *summary;
+
+ g_return_if_fail (GIMP_IS_COLOR_PROFILE_VIEW (view));
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ gtk_text_buffer_set_text (buffer, "", 0);
+
+ view->private->profile = profile;
+
+ if (! profile)
+ return;
+
+ gtk_text_buffer_get_start_iter (buffer, &iter);
+
+ desc = gimp_lcms_profile_get_description (profile);
+ model = gimp_lcms_profile_get_model (profile);
+ summary = gimp_lcms_profile_get_summary (profile);
+
+ if ((desc && strlen (desc)) ||
+ (model && strlen (model)))
+ {
+ gchar *title;
+
+ if (desc && strlen (desc))
+ title = desc;
+ else
+ title = model;
+
+ gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
+ title, -1,
+ "strong", NULL);
+ gtk_text_buffer_insert (buffer, &iter, "\n", 1);
+ }
+
+ if (summary)
+ gtk_text_buffer_insert (buffer, &iter, summary, -1);
+
+ g_free (desc);
+ g_free (model);
+ g_free (summary);
+}
+
+void
+gimp_color_profile_view_set_error (GimpColorProfileView *view,
+ const gchar *message)
+{
+ GtkTextBuffer *buffer;
+ GtkTextIter iter;
+
+ g_return_if_fail (GIMP_IS_COLOR_PROFILE_VIEW (view));
+ g_return_if_fail (message != NULL);
+
+ buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
+
+ gtk_text_buffer_set_text (buffer, "", 0);
+
+ gtk_text_buffer_get_start_iter (buffer, &iter);
+
+ gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
+ message, -1,
+ "emphasis", NULL);
+}
diff --git a/libgimpwidgets/gimpcolorprofileview.h b/libgimpwidgets/gimpcolorprofileview.h
new file mode 100644
index 0000000..f5b105a
--- /dev/null
+++ b/libgimpwidgets/gimpcolorprofileview.h
@@ -0,0 +1,67 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * GimpColorProfileView
+ * Copyright (C) 2014 Michael Natterer <mitch gimp org>
+ *
+ * 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 3 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 __GIMP_COLOR_PROFILE_VIEW_H__
+#define __GIMP_COLOR_PROFILE_VIEW_H__
+
+G_BEGIN_DECLS
+
+
+#define GIMP_TYPE_COLOR_PROFILE_VIEW (gimp_color_profile_view_get_type ())
+#define GIMP_COLOR_PROFILE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GIMP_TYPE_COLOR_PROFILE_VIEW, GimpColorProfileView))
+#define GIMP_COLOR_PROFILE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GIMP_TYPE_COLOR_PROFILE_VIEW, GimpColorProfileViewClass))
+#define GIMP_IS_COLOR_PROFILE_VIEW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GIMP_TYPE_COLOR_PROFILE_VIEW))
+#define GIMP_IS_COLOR_PROFILE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GIMP_TYPE_COLOR_PROFILE_VIEW))
+#define GIMP_COLOR_PROFILE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GIMP_TYPE_COLOR_PROFILE_VIEW, GimpColorProfileViewClass))
+
+
+typedef struct _GimpColorProfileViewClass GimpColorProfileViewClass;
+typedef struct _GimpColorProfileViewPrivate GimpColorProfileViewPrivate;
+
+struct _GimpColorProfileView
+{
+ GtkTextView parent_instance;
+
+ GimpColorProfileViewPrivate *private;
+};
+
+struct _GimpColorProfileViewClass
+{
+ GtkTextViewClass parent_class;
+
+ /* Padding for future expansion */
+ void (* _gimp_reserved1) (void);
+ void (* _gimp_reserved2) (void);
+ void (* _gimp_reserved3) (void);
+ void (* _gimp_reserved4) (void);
+};
+
+
+GType gimp_color_profile_view_get_type (void) G_GNUC_CONST;
+
+GtkWidget * gimp_color_profile_view_new (void);
+
+void gimp_color_profile_view_set_profile (GimpColorProfileView *view,
+ GimpColorProfile profile);
+void gimp_color_profile_view_set_error (GimpColorProfileView *view,
+ const gchar *message);
+
+
+#endif /* __GIMP_COLOR_PROFILE_VIEW_H__ */
diff --git a/libgimpwidgets/gimpwidgets.def b/libgimpwidgets/gimpwidgets.def
index 8ce0d1d..373bd27 100644
--- a/libgimpwidgets/gimpwidgets.def
+++ b/libgimpwidgets/gimpwidgets.def
@@ -83,6 +83,10 @@ EXPORTS
gimp_color_profile_store_add
gimp_color_profile_store_get_type
gimp_color_profile_store_new
+ gimp_color_profile_view_get_type
+ gimp_color_profile_view_new
+ gimp_color_profile_view_set_error
+ gimp_color_profile_view_set_profile
gimp_color_scale_entry_new
gimp_color_scale_get_type
gimp_color_scale_new
diff --git a/libgimpwidgets/gimpwidgetstypes.h b/libgimpwidgets/gimpwidgetstypes.h
index 72ece92..18c925a 100644
--- a/libgimpwidgets/gimpwidgetstypes.h
+++ b/libgimpwidgets/gimpwidgetstypes.h
@@ -44,6 +44,7 @@ typedef struct _GimpColorNotebook GimpColorNotebook;
typedef struct _GimpColorProfileChooserDialog GimpColorProfileChooserDialog;
typedef struct _GimpColorProfileComboBox GimpColorProfileComboBox;
typedef struct _GimpColorProfileStore GimpColorProfileStore;
+typedef struct _GimpColorProfileView GimpColorProfileView;
typedef struct _GimpColorScale GimpColorScale;
typedef struct _GimpColorScales GimpColorScales;
typedef struct _GimpColorSelector GimpColorSelector;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]