2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2006-10-25 07:31:04 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* GimpImageProfileView
|
|
|
|
* Copyright (C) 2006 Sven Neumann <sven@gimp.org>
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2006-10-25 07:31:04 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2006-10-25 07:31:04 +00:00
|
|
|
* (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
|
2009-01-17 22:28:01 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-10-25 07:31:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2014-03-16 18:33:52 +01:00
|
|
|
#include <glib.h> /* lcms.h uses the "inline" keyword */
|
|
|
|
|
|
|
|
#include <lcms2.h>
|
|
|
|
|
2008-10-09 20:24:04 +00:00
|
|
|
#include <gegl.h>
|
2006-10-25 07:31:04 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
2014-03-16 18:33:52 +01:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
2006-10-25 07:31:04 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
|
|
|
#include "core/gimpimage.h"
|
2014-03-16 23:49:02 +01:00
|
|
|
#include "core/gimpimage-profile.h"
|
2006-10-25 07:31:04 +00:00
|
|
|
|
|
|
|
#include "gimpimageprofileview.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2007-06-26 15:07:58 +00:00
|
|
|
static void gimp_image_profile_view_update (GimpImageParasiteView *view);
|
2006-10-25 07:31:04 +00:00
|
|
|
|
|
|
|
|
2006-11-03 13:52:17 +00:00
|
|
|
G_DEFINE_TYPE (GimpImageProfileView,
|
|
|
|
gimp_image_profile_view, GIMP_TYPE_IMAGE_PARASITE_VIEW)
|
2006-10-25 07:31:04 +00:00
|
|
|
|
|
|
|
#define parent_class gimp_image_profile_view_parent_class
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_profile_view_class_init (GimpImageProfileViewClass *klass)
|
|
|
|
{
|
2006-11-03 13:52:17 +00:00
|
|
|
GimpImageParasiteViewClass *view_class;
|
|
|
|
|
|
|
|
view_class = GIMP_IMAGE_PARASITE_VIEW_CLASS (klass);
|
|
|
|
|
2014-03-16 18:33:52 +01:00
|
|
|
view_class->update = gimp_image_profile_view_update;
|
2006-10-25 07:31:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_image_profile_view_init (GimpImageProfileView *view)
|
|
|
|
{
|
2007-06-26 15:07:58 +00:00
|
|
|
GtkWidget *scrolled_window;
|
2014-03-16 18:33:52 +01:00
|
|
|
GtkWidget *profile_view;
|
2007-06-26 15:07:58 +00:00
|
|
|
|
|
|
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (scrolled_window), 2);
|
2010-10-30 15:42:25 +02:00
|
|
|
gtk_box_pack_start (GTK_BOX (view), scrolled_window, TRUE, TRUE, 0);
|
2007-06-26 15:07:58 +00:00
|
|
|
gtk_widget_show (scrolled_window);
|
|
|
|
|
2014-03-16 18:33:52 +01:00
|
|
|
profile_view = gimp_color_profile_view_new ();
|
|
|
|
gtk_container_add (GTK_CONTAINER (scrolled_window), profile_view);
|
|
|
|
gtk_widget_show (profile_view);
|
2007-06-26 15:07:58 +00:00
|
|
|
|
2014-03-16 18:33:52 +01:00
|
|
|
view->profile_view = GIMP_COLOR_PROFILE_VIEW (profile_view);
|
2006-10-26 14:11:14 +00:00
|
|
|
}
|
|
|
|
|
2006-10-25 07:31:04 +00:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_image_profile_view_new (GimpImage *image)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
|
|
|
|
|
|
|
return g_object_new (GIMP_TYPE_IMAGE_PROFILE_VIEW,
|
2006-11-03 13:52:17 +00:00
|
|
|
"image", image,
|
2014-03-16 23:49:02 +01:00
|
|
|
"parasite", GIMP_ICC_PROFILE_PARASITE_NAME,
|
2006-10-25 07:31:04 +00:00
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
2014-03-16 18:33:52 +01:00
|
|
|
static void
|
|
|
|
gimp_image_profile_view_update (GimpImageParasiteView *view)
|
2006-10-26 14:11:14 +00:00
|
|
|
{
|
2014-03-16 18:33:52 +01:00
|
|
|
GimpImageProfileView *profile_view = GIMP_IMAGE_PROFILE_VIEW (view);
|
|
|
|
GimpImage *image;
|
2014-03-17 02:28:36 +01:00
|
|
|
GimpColorProfile *profile;
|
|
|
|
GError *error = NULL;
|
2007-06-26 20:16:43 +00:00
|
|
|
|
2014-03-17 02:28:36 +01:00
|
|
|
image = gimp_image_parasite_view_get_image (view);
|
2007-06-26 15:07:58 +00:00
|
|
|
|
2014-03-17 02:28:36 +01:00
|
|
|
profile = gimp_image_get_profile (image, NULL, &error);
|
2006-10-26 14:11:14 +00:00
|
|
|
|
2014-03-17 02:28:36 +01:00
|
|
|
if (! profile && error)
|
2014-03-16 18:33:52 +01:00
|
|
|
{
|
2014-03-17 02:28:36 +01:00
|
|
|
g_message ("%s", error->message);
|
|
|
|
g_clear_error (&error);
|
2014-03-16 18:33:52 +01:00
|
|
|
}
|
2006-10-25 07:31:04 +00:00
|
|
|
|
2014-03-16 18:33:52 +01:00
|
|
|
if (! profile)
|
2014-03-23 23:34:47 +01:00
|
|
|
profile = gimp_lcms_create_srgb_profile (NULL);
|
2006-11-03 13:52:17 +00:00
|
|
|
|
2014-03-16 18:33:52 +01:00
|
|
|
gimp_color_profile_view_set_profile (profile_view->profile_view, profile);
|
2006-10-25 07:31:04 +00:00
|
|
|
|
2014-03-16 18:33:52 +01:00
|
|
|
cmsCloseProfile (profile);
|
2006-10-25 07:31:04 +00:00
|
|
|
}
|