mirror of https://github.com/GNOME/gimp.git
added GimpColorConfig and GimpColorManaged as construct-only properties.
2007-08-06 Sven Neumann <sven@gimp.org> * libgimpwidgets/gimpcolordisplay.[ch]: added GimpColorConfig and GimpColorManaged as construct-only properties. Deprecated gimp_color_display_new(). * libgimpwidgets/gimpwidgets.def: updated for new symbols. * app/widgets/gimpcolordisplayeditor.c: use g_object_new() instead of gimp_color_display_new(). * modules/cdisplay_lcms.c: use the image's embedded color profile for the display filter. Assume sRGB if no monitor profile is configured. * app/display/gimpdisplayshell.c: * app/display/gimpdisplayshell-filter.[ch]: pass the display as color-managed object to the display filter. svn path=/trunk/; revision=23127
This commit is contained in:
parent
2195c84297
commit
a737408eeb
19
ChangeLog
19
ChangeLog
|
@ -1,3 +1,22 @@
|
|||
2007-08-06 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpwidgets/gimpcolordisplay.[ch]: added GimpColorConfig and
|
||||
GimpColorManaged as construct-only properties.
|
||||
Deprecated gimp_color_display_new().
|
||||
|
||||
* libgimpwidgets/gimpwidgets.def: updated for new symbols.
|
||||
|
||||
* app/widgets/gimpcolordisplayeditor.c: use g_object_new() instead
|
||||
of gimp_color_display_new().
|
||||
|
||||
* modules/cdisplay_lcms.c: use the image's embedded color profile
|
||||
for the display filter. Assume sRGB if no monitor profile is
|
||||
configured.
|
||||
|
||||
* app/display/gimpdisplayshell.c:
|
||||
* app/display/gimpdisplayshell-filter.[ch]: pass the display as
|
||||
color-managed object to the display filter.
|
||||
|
||||
2007-08-06 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimpimage.c: added missing static qualifier.
|
||||
|
|
|
@ -73,8 +73,10 @@ gimp_display_shell_filter_set (GimpDisplayShell *shell,
|
|||
}
|
||||
|
||||
GimpColorDisplayStack *
|
||||
gimp_display_shell_filter_new (GimpColorConfig *config)
|
||||
gimp_display_shell_filter_new (GimpDisplayShell *shell,
|
||||
GimpColorConfig *config)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
|
||||
g_return_val_if_fail (GIMP_IS_COLOR_CONFIG (config), NULL);
|
||||
|
||||
if (config->display_module)
|
||||
|
@ -87,7 +89,8 @@ gimp_display_shell_filter_new (GimpColorConfig *config)
|
|||
GimpColorDisplayStack *stack;
|
||||
|
||||
display = g_object_new (type,
|
||||
"config", config,
|
||||
"color-config", config,
|
||||
"color-managed", shell,
|
||||
NULL);
|
||||
|
||||
stack = gimp_color_display_stack_new ();
|
||||
|
|
|
@ -23,7 +23,8 @@
|
|||
void gimp_display_shell_filter_set (GimpDisplayShell *shell,
|
||||
GimpColorDisplayStack *stack);
|
||||
|
||||
GimpColorDisplayStack * gimp_display_shell_filter_new (GimpColorConfig *config);
|
||||
GimpColorDisplayStack * gimp_display_shell_filter_new (GimpDisplayShell *shell,
|
||||
GimpColorConfig *config);
|
||||
|
||||
|
||||
#endif /* __GIMP_DISPLAY_SHELL_FILTER_H__ */
|
||||
|
|
|
@ -1102,7 +1102,8 @@ gimp_display_shell_new (GimpDisplay *display,
|
|||
|
||||
color_config = display->image->gimp->config->color_management;
|
||||
gimp_display_shell_filter_set (shell,
|
||||
gimp_display_shell_filter_new (color_config));
|
||||
gimp_display_shell_filter_new (shell,
|
||||
color_config));
|
||||
|
||||
gimp_display_shell_connect (shell);
|
||||
|
||||
|
|
|
@ -418,7 +418,7 @@ gimp_color_display_editor_new (GimpColorDisplayStack *stack)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_color_display_editor_add_clicked (GtkWidget *widget,
|
||||
gimp_color_display_editor_add_clicked (GtkWidget *widget,
|
||||
GimpColorDisplayEditor *editor)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
|
@ -431,7 +431,7 @@ gimp_color_display_editor_add_clicked (GtkWidget *widget,
|
|||
|
||||
gtk_tree_model_get (model, &iter, SRC_COLUMN_TYPE, &type, -1);
|
||||
|
||||
display = gimp_color_display_new (type);
|
||||
display = g_object_new (type, NULL);
|
||||
|
||||
if (display)
|
||||
{
|
||||
|
|
|
@ -32,14 +32,18 @@
|
|||
|
||||
#include "gimpwidgetstypes.h"
|
||||
|
||||
#include "gimpcolordisplay.h"
|
||||
#include "gimpstock.h"
|
||||
|
||||
#undef GIMP_DISABLE_DEPRECATED
|
||||
#include "gimpcolordisplay.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_ENABLED
|
||||
PROP_ENABLED,
|
||||
PROP_COLOR_CONFIG,
|
||||
PROP_COLOR_MANAGED
|
||||
};
|
||||
|
||||
enum
|
||||
|
@ -48,15 +52,31 @@ enum
|
|||
LAST_SIGNAL
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
GimpColorConfig *config;
|
||||
GimpColorManaged *managed;
|
||||
} GimpColorDisplayPrivate;
|
||||
|
||||
static void gimp_color_display_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_color_display_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
#define GIMP_COLOR_DISPLAY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GIMP_TYPE_COLOR_DISPLAY, GimpColorDisplayPrivate))
|
||||
|
||||
static GObject * gimp_color_display_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static void gimp_color_display_finalize (GObject *object);
|
||||
static void gimp_color_display_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_color_display_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
static void gimp_color_display_set_color_config (GimpColorDisplay *display,
|
||||
GimpColorConfig *config);
|
||||
static void gimp_color_display_set_color_managed (GimpColorDisplay *display,
|
||||
GimpColorManaged *managed);
|
||||
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GimpColorDisplay, gimp_color_display, G_TYPE_OBJECT,
|
||||
|
@ -72,15 +92,30 @@ gimp_color_display_class_init (GimpColorDisplayClass *klass)
|
|||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
object_class->constructor = gimp_color_display_constructor;
|
||||
object_class->finalize = gimp_color_display_finalize;
|
||||
object_class->set_property = gimp_color_display_set_property;
|
||||
object_class->get_property = gimp_color_display_get_property;
|
||||
|
||||
g_type_class_add_private (object_class, sizeof (GimpColorDisplayPrivate));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_ENABLED,
|
||||
g_param_spec_boolean ("enabled", NULL, NULL,
|
||||
TRUE,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_COLOR_CONFIG,
|
||||
g_param_spec_object ("color-config",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_COLOR_CONFIG,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
g_object_class_install_property (object_class, PROP_COLOR_MANAGED,
|
||||
g_param_spec_object ("color-managed",
|
||||
NULL, NULL,
|
||||
GIMP_TYPE_COLOR_MANAGED,
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT_ONLY));
|
||||
display_signals[CHANGED] =
|
||||
g_signal_new ("changed",
|
||||
G_TYPE_FROM_CLASS (klass),
|
||||
|
@ -106,6 +141,48 @@ gimp_color_display_class_init (GimpColorDisplayClass *klass)
|
|||
static void
|
||||
gimp_color_display_init (GimpColorDisplay *display)
|
||||
{
|
||||
display->enabled = FALSE;
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_color_display_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
/* emit an initial "changed" signal after all construct properties are set */
|
||||
gimp_color_display_changed (GIMP_COLOR_DISPLAY (object));
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_display_finalize (GObject *object)
|
||||
{
|
||||
GimpColorDisplayPrivate *private = GIMP_COLOR_DISPLAY_GET_PRIVATE (object);
|
||||
|
||||
if (private->config)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (private->config,
|
||||
gimp_color_display_changed,
|
||||
object);
|
||||
g_object_unref (private->config);
|
||||
private->config = NULL;
|
||||
}
|
||||
|
||||
if (private->managed)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (private->managed,
|
||||
gimp_color_display_changed,
|
||||
object);
|
||||
g_object_unref (private->managed);
|
||||
private->managed = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -121,6 +198,17 @@ gimp_color_display_set_property (GObject *object,
|
|||
case PROP_ENABLED:
|
||||
display->enabled = g_value_get_boolean (value);
|
||||
break;
|
||||
|
||||
case PROP_COLOR_CONFIG:
|
||||
gimp_color_display_set_color_config (display,
|
||||
g_value_get_object (value));
|
||||
break;
|
||||
|
||||
case PROP_COLOR_MANAGED:
|
||||
gimp_color_display_set_color_managed (display,
|
||||
g_value_get_object (value));
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
|
@ -140,23 +228,74 @@ gimp_color_display_get_property (GObject *object,
|
|||
case PROP_ENABLED:
|
||||
g_value_set_boolean (value, display->enabled);
|
||||
break;
|
||||
|
||||
case PROP_COLOR_CONFIG:
|
||||
g_value_set_object (value,
|
||||
GIMP_COLOR_DISPLAY_GET_PRIVATE (display)->config);
|
||||
break;
|
||||
|
||||
case PROP_COLOR_MANAGED:
|
||||
g_value_set_object (value,
|
||||
GIMP_COLOR_DISPLAY_GET_PRIVATE (display)->managed);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_display_set_color_config (GimpColorDisplay *display,
|
||||
GimpColorConfig *config)
|
||||
{
|
||||
GimpColorDisplayPrivate *private = GIMP_COLOR_DISPLAY_GET_PRIVATE (display);
|
||||
|
||||
g_return_if_fail (private->config == NULL);
|
||||
|
||||
if (config)
|
||||
{
|
||||
private->config = g_object_ref (config);
|
||||
|
||||
g_signal_connect_swapped (private->config, "notify",
|
||||
G_CALLBACK (gimp_color_display_changed),
|
||||
display);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_color_display_set_color_managed (GimpColorDisplay *display,
|
||||
GimpColorManaged *managed)
|
||||
{
|
||||
GimpColorDisplayPrivate *private = GIMP_COLOR_DISPLAY_GET_PRIVATE (display);
|
||||
|
||||
g_return_if_fail (private->managed == NULL);
|
||||
|
||||
if (managed)
|
||||
{
|
||||
private->managed = g_object_ref (managed);
|
||||
|
||||
g_signal_connect_swapped (private->managed, "profile-changed",
|
||||
G_CALLBACK (gimp_color_display_changed),
|
||||
display);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_display_new:
|
||||
* @display_type: the GType of the GimpColorDisplay to instantiate.
|
||||
*
|
||||
* This function is deprecated. Please use g_object_new() directly.
|
||||
*
|
||||
* Return value: a new %GimpColorDisplay object.
|
||||
**/
|
||||
GimpColorDisplay *
|
||||
gimp_color_display_new (GType display_type)
|
||||
{
|
||||
GimpColorDisplay *display;
|
||||
|
||||
g_return_val_if_fail (g_type_is_a (display_type, GIMP_TYPE_COLOR_DISPLAY),
|
||||
NULL);
|
||||
|
||||
display = g_object_new (display_type, NULL);
|
||||
|
||||
return display;
|
||||
return g_object_new (display_type, NULL);
|
||||
}
|
||||
|
||||
GimpColorDisplay *
|
||||
|
@ -168,12 +307,21 @@ gimp_color_display_clone (GimpColorDisplay *display)
|
|||
*/
|
||||
if (GIMP_COLOR_DISPLAY_GET_CLASS (display)->clone)
|
||||
{
|
||||
GimpColorDisplay *clone = NULL;
|
||||
GimpColorDisplay *clone;
|
||||
|
||||
clone = GIMP_COLOR_DISPLAY_GET_CLASS (display)->clone (display);
|
||||
|
||||
if (clone)
|
||||
clone->enabled = display->enabled;
|
||||
{
|
||||
GimpColorDisplayPrivate *private;
|
||||
|
||||
private = GIMP_COLOR_DISPLAY_GET_PRIVATE (display);
|
||||
|
||||
g_object_set (clone,
|
||||
"enabled", display->enabled,
|
||||
"color-managed", private->managed,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return clone;
|
||||
}
|
||||
|
@ -302,3 +450,34 @@ gimp_color_display_get_enabled (GimpColorDisplay *display)
|
|||
return display->enabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_display_get_config:
|
||||
* @display:
|
||||
*
|
||||
* Return value: a pointer to the #GimpColorConfig object or %NULL.
|
||||
*
|
||||
* Since: GIMP 2.4
|
||||
**/
|
||||
GimpColorConfig *
|
||||
gimp_color_display_get_config (GimpColorDisplay *display)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY (display), NULL);
|
||||
|
||||
return GIMP_COLOR_DISPLAY_GET_PRIVATE (display)->config;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_color_display_get_managed:
|
||||
* @display:
|
||||
*
|
||||
* Return value: a pointer to the #GimpColorManaged object or %NULL.
|
||||
*
|
||||
* Since: GIMP 2.4
|
||||
**/
|
||||
GimpColorManaged *
|
||||
gimp_color_display_get_managed (GimpColorDisplay *display)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_COLOR_DISPLAY (display), NULL);
|
||||
|
||||
return GIMP_COLOR_DISPLAY_GET_PRIVATE (display)->managed;
|
||||
}
|
||||
|
|
|
@ -89,7 +89,11 @@ struct _GimpColorDisplayClass
|
|||
|
||||
|
||||
GType gimp_color_display_get_type (void) G_GNUC_CONST;
|
||||
|
||||
#ifndef GIMP_DISABLE_DEPRECATED
|
||||
GimpColorDisplay * gimp_color_display_new (GType display_type);
|
||||
#endif
|
||||
|
||||
GimpColorDisplay * gimp_color_display_clone (GimpColorDisplay *display);
|
||||
|
||||
void gimp_color_display_convert (GimpColorDisplay *display,
|
||||
|
@ -110,6 +114,9 @@ void gimp_color_display_set_enabled (GimpColorDisplay *display,
|
|||
gboolean enabled);
|
||||
gboolean gimp_color_display_get_enabled (GimpColorDisplay *display);
|
||||
|
||||
GimpColorConfig * gimp_color_display_get_config (GimpColorDisplay *display);
|
||||
GimpColorManaged * gimp_color_display_get_managed (GimpColorDisplay *display);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
|
|
@ -39,7 +39,9 @@ EXPORTS
|
|||
gimp_color_display_configure
|
||||
gimp_color_display_configure_reset
|
||||
gimp_color_display_convert
|
||||
gimp_color_display_get_config
|
||||
gimp_color_display_get_enabled
|
||||
gimp_color_display_get_managed
|
||||
gimp_color_display_get_type
|
||||
gimp_color_display_load_state
|
||||
gimp_color_display_new
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpmodule/gimpmodule.h"
|
||||
|
@ -50,7 +51,6 @@ struct _CdisplayLcms
|
|||
{
|
||||
GimpColorDisplay parent_instance;
|
||||
|
||||
GimpColorConfig *config;
|
||||
cmsHTRANSFORM transform;
|
||||
};
|
||||
|
||||
|
@ -60,25 +60,10 @@ struct _CdisplayLcmsClass
|
|||
};
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_CONFIG
|
||||
};
|
||||
|
||||
|
||||
static GType cdisplay_lcms_get_type (GTypeModule *module);
|
||||
static void cdisplay_lcms_class_init (CdisplayLcmsClass *klass);
|
||||
static void cdisplay_lcms_init (CdisplayLcms *lcms);
|
||||
static void cdisplay_lcms_dispose (GObject *object);
|
||||
static void cdisplay_lcms_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void cdisplay_lcms_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void cdisplay_lcms_finalize (GObject *object);
|
||||
|
||||
static GtkWidget * cdisplay_lcms_configure (GimpColorDisplay *display);
|
||||
static void cdisplay_lcms_convert (GimpColorDisplay *display,
|
||||
|
@ -88,8 +73,6 @@ static void cdisplay_lcms_convert (GimpColorDisplay *display,
|
|||
gint bpp,
|
||||
gint bpl);
|
||||
static void cdisplay_lcms_changed (GimpColorDisplay *display);
|
||||
static void cdisplay_lcms_set_config (CdisplayLcms *lcms,
|
||||
GimpColorConfig *config);
|
||||
|
||||
static cmsHPROFILE cdisplay_lcms_get_rgb_profile (CdisplayLcms *lcms);
|
||||
static cmsHPROFILE cdisplay_lcms_get_display_profile (CdisplayLcms *lcms);
|
||||
|
@ -115,9 +98,9 @@ static const GimpModuleInfo cdisplay_lcms_info =
|
|||
GIMP_MODULE_ABI_VERSION,
|
||||
N_("Color management display filter using ICC color profiles"),
|
||||
"Sven Neumann",
|
||||
"v0.1",
|
||||
"(c) 2005, released under the GPL",
|
||||
"2005"
|
||||
"v0.2",
|
||||
"(c) 2005 - 2007, released under the GPL",
|
||||
"2005 - 2007"
|
||||
};
|
||||
|
||||
static GType cdisplay_lcms_type = 0;
|
||||
|
@ -172,14 +155,7 @@ cdisplay_lcms_class_init (CdisplayLcmsClass *klass)
|
|||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->dispose = cdisplay_lcms_dispose;
|
||||
object_class->get_property = cdisplay_lcms_get_property;
|
||||
object_class->set_property = cdisplay_lcms_set_property;
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_OBJECT (object_class, PROP_CONFIG,
|
||||
"config", NULL,
|
||||
GIMP_TYPE_COLOR_CONFIG,
|
||||
0);
|
||||
object_class->finalize = cdisplay_lcms_finalize;
|
||||
|
||||
display_class->name = _("Color Management");
|
||||
display_class->help_id = "gimp-colordisplay-lcms";
|
||||
|
@ -195,56 +171,21 @@ cdisplay_lcms_class_init (CdisplayLcmsClass *klass)
|
|||
static void
|
||||
cdisplay_lcms_init (CdisplayLcms *lcms)
|
||||
{
|
||||
lcms->config = NULL;
|
||||
lcms->transform = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
cdisplay_lcms_dispose (GObject *object)
|
||||
cdisplay_lcms_finalize (GObject *object)
|
||||
{
|
||||
CdisplayLcms *lcms = CDISPLAY_LCMS (object);
|
||||
|
||||
cdisplay_lcms_set_config (lcms, NULL);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
cdisplay_lcms_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CdisplayLcms *lcms = CDISPLAY_LCMS (object);
|
||||
|
||||
switch (property_id)
|
||||
if (lcms->transform)
|
||||
{
|
||||
case PROP_CONFIG:
|
||||
g_value_set_object (value, lcms->config);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
cmsDeleteTransform (lcms->transform);
|
||||
lcms->transform = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
cdisplay_lcms_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
CdisplayLcms *lcms = CDISPLAY_LCMS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_CONFIG:
|
||||
cdisplay_lcms_set_config (lcms, g_value_get_object (value));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -273,7 +214,7 @@ static GtkWidget *
|
|||
cdisplay_lcms_configure (GimpColorDisplay *display)
|
||||
{
|
||||
CdisplayLcms *lcms = CDISPLAY_LCMS (display);
|
||||
GObject *config = G_OBJECT (lcms->config);
|
||||
GObject *config = G_OBJECT (gimp_color_display_get_config (display));
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *hint;
|
||||
GtkWidget *table;
|
||||
|
@ -306,7 +247,7 @@ cdisplay_lcms_configure (GimpColorDisplay *display)
|
|||
label = gtk_label_new (NULL);
|
||||
g_object_set_data (G_OBJECT (lcms), "rgb-profile", label);
|
||||
cdisplay_lcms_attach_labelled (GTK_TABLE (table), row++,
|
||||
_("RGB working space profile:"),
|
||||
_("Image profile:"),
|
||||
label, TRUE);
|
||||
cdisplay_lcms_update_profile_label (lcms, "rgb-profile");
|
||||
|
||||
|
@ -356,7 +297,7 @@ static void
|
|||
cdisplay_lcms_changed (GimpColorDisplay *display)
|
||||
{
|
||||
CdisplayLcms *lcms = CDISPLAY_LCMS (display);
|
||||
GimpColorConfig *config = lcms->config;
|
||||
GimpColorConfig *config = gimp_color_display_get_config (display);
|
||||
|
||||
cmsHPROFILE src_profile = NULL;
|
||||
cmsHPROFILE dest_profile = NULL;
|
||||
|
@ -378,7 +319,6 @@ cdisplay_lcms_changed (GimpColorDisplay *display)
|
|||
|
||||
case GIMP_COLOR_MANAGEMENT_SOFTPROOF:
|
||||
proof_profile = cdisplay_lcms_get_printer_profile (lcms);
|
||||
|
||||
/* fallthru */
|
||||
|
||||
case GIMP_COLOR_MANAGEMENT_DISPLAY:
|
||||
|
@ -389,18 +329,28 @@ cdisplay_lcms_changed (GimpColorDisplay *display)
|
|||
|
||||
if (proof_profile)
|
||||
{
|
||||
lcms->transform = cmsCreateProofingTransform (src_profile, TYPE_RGB_8,
|
||||
(dest_profile ?
|
||||
dest_profile :
|
||||
src_profile), TYPE_RGB_8,
|
||||
if (! src_profile)
|
||||
src_profile = cmsCreate_sRGBProfile ();
|
||||
|
||||
if (! dest_profile)
|
||||
dest_profile = cmsCreate_sRGBProfile ();
|
||||
|
||||
lcms->transform = cmsCreateProofingTransform (src_profile, TYPE_RGB_8,
|
||||
dest_profile, TYPE_RGB_8,
|
||||
proof_profile,
|
||||
config->simulation_intent,
|
||||
config->display_intent,
|
||||
cmsFLAGS_SOFTPROOFING);
|
||||
cmsCloseProfile (proof_profile);
|
||||
}
|
||||
else if (dest_profile)
|
||||
else if (src_profile || dest_profile)
|
||||
{
|
||||
if (! src_profile)
|
||||
src_profile = cmsCreate_sRGBProfile ();
|
||||
|
||||
if (! dest_profile)
|
||||
dest_profile = cmsCreate_sRGBProfile ();
|
||||
|
||||
lcms->transform = cmsCreateTransform (src_profile, TYPE_RGB_8,
|
||||
dest_profile, TYPE_RGB_8,
|
||||
config->display_intent,
|
||||
|
@ -410,65 +360,75 @@ cdisplay_lcms_changed (GimpColorDisplay *display)
|
|||
if (dest_profile)
|
||||
cmsCloseProfile (dest_profile);
|
||||
|
||||
cmsCloseProfile (src_profile);
|
||||
if (src_profile)
|
||||
cmsCloseProfile (src_profile);
|
||||
}
|
||||
|
||||
static void
|
||||
cdisplay_lcms_set_config (CdisplayLcms *lcms,
|
||||
GimpColorConfig *config)
|
||||
static gboolean
|
||||
cdisplay_lcms_profile_is_rgb (cmsHPROFILE profile)
|
||||
{
|
||||
if (config == lcms->config)
|
||||
return;
|
||||
|
||||
if (lcms->config)
|
||||
{
|
||||
g_signal_handlers_disconnect_by_func (lcms->config,
|
||||
G_CALLBACK (gimp_color_display_changed),
|
||||
lcms);
|
||||
g_object_unref (lcms->config);
|
||||
}
|
||||
|
||||
lcms->config = config;
|
||||
|
||||
if (lcms->config)
|
||||
{
|
||||
g_object_ref (lcms->config);
|
||||
g_signal_connect_swapped (lcms->config, "notify",
|
||||
G_CALLBACK (gimp_color_display_changed),
|
||||
lcms);
|
||||
}
|
||||
|
||||
gimp_color_display_changed (GIMP_COLOR_DISPLAY (lcms));
|
||||
return (cmsGetColorSpace (profile) == icSigRgbData);
|
||||
}
|
||||
|
||||
static cmsHPROFILE
|
||||
cdisplay_lcms_get_rgb_profile (CdisplayLcms *lcms)
|
||||
{
|
||||
GimpColorConfig *config = lcms->config;
|
||||
cmsHPROFILE profile = NULL;
|
||||
GimpColorConfig *config;
|
||||
GimpColorManaged *managed;
|
||||
cmsHPROFILE profile = NULL;
|
||||
|
||||
/* this should be taken from the image */
|
||||
managed = gimp_color_display_get_managed (GIMP_COLOR_DISPLAY (lcms));
|
||||
|
||||
if (config->rgb_profile)
|
||||
profile = cmsOpenProfileFromFile (config->rgb_profile, "r");
|
||||
if (managed)
|
||||
{
|
||||
gsize len;
|
||||
const guint8 *data = gimp_color_managed_get_icc_profile (managed, &len);
|
||||
|
||||
return profile ? profile : cmsCreate_sRGBProfile ();
|
||||
if (data)
|
||||
profile = cmsOpenProfileFromMem ((gpointer) data, len);
|
||||
|
||||
if (! cdisplay_lcms_profile_is_rgb (profile))
|
||||
{
|
||||
cmsCloseProfile (profile);
|
||||
profile = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (! profile)
|
||||
{
|
||||
config = gimp_color_display_get_config (GIMP_COLOR_DISPLAY (lcms));
|
||||
|
||||
if (config->rgb_profile)
|
||||
profile = cmsOpenProfileFromFile (config->rgb_profile, "r");
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
static cmsHPROFILE
|
||||
cdisplay_lcms_get_display_profile (CdisplayLcms *lcms)
|
||||
{
|
||||
GimpColorConfig *config = lcms->config;
|
||||
GimpColorConfig *config;
|
||||
cmsHPROFILE profile = NULL;
|
||||
|
||||
config = gimp_color_display_get_config (GIMP_COLOR_DISPLAY (lcms));
|
||||
|
||||
#if defined (GDK_WINDOWING_X11)
|
||||
if (config->display_profile_from_gdk)
|
||||
{
|
||||
/* FIXME: need to access the display's screen here */
|
||||
GdkScreen *screen = gdk_screen_get_default ();
|
||||
GdkAtom type = GDK_NONE;
|
||||
gint format = 0;
|
||||
gint nitems = 0;
|
||||
guchar *data = NULL;
|
||||
GimpColorManaged *managed;
|
||||
GdkScreen *screen;
|
||||
GdkAtom type = GDK_NONE;
|
||||
gint format = 0;
|
||||
gint nitems = 0;
|
||||
guchar *data = NULL;
|
||||
|
||||
managed = gimp_color_display_get_managed (GIMP_COLOR_DISPLAY (lcms));
|
||||
|
||||
if (GTK_IS_WIDGET (managed))
|
||||
screen = gtk_widget_get_screen (GTK_WIDGET (managed));
|
||||
else
|
||||
screen = gdk_screen_get_default ();
|
||||
|
||||
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
|
||||
|
||||
|
@ -478,25 +438,26 @@ cdisplay_lcms_get_display_profile (CdisplayLcms *lcms)
|
|||
0, 64 * 1024 * 1024, FALSE,
|
||||
&type, &format, &nitems, &data) && nitems > 0)
|
||||
{
|
||||
cmsHPROFILE profile = cmsOpenProfileFromMem (data, nitems);
|
||||
profile = cmsOpenProfileFromMem (data, nitems);
|
||||
|
||||
/* FIXME: check memory mamagement of cmsOpenProfileFromMem */
|
||||
g_free (data);
|
||||
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (config->display_profile)
|
||||
return cmsOpenProfileFromFile (config->display_profile, "r");
|
||||
profile = cmsOpenProfileFromFile (config->display_profile, "r");
|
||||
|
||||
return NULL;
|
||||
return profile;
|
||||
}
|
||||
|
||||
static cmsHPROFILE
|
||||
cdisplay_lcms_get_printer_profile (CdisplayLcms *lcms)
|
||||
{
|
||||
GimpColorConfig *config = lcms->config;
|
||||
GimpColorConfig *config;
|
||||
|
||||
config = gimp_color_display_get_config (GIMP_COLOR_DISPLAY (lcms));
|
||||
|
||||
if (config->printer_profile)
|
||||
return cmsOpenProfileFromFile (config->printer_profile, "r");
|
||||
|
|
Loading…
Reference in New Issue