Commit e119a2eb authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

use object properties for the configurable values.

2004-07-05  Sven Neumann  <sven@gimp.org>

	* modules/cdisplay_proof.c: use object properties for the
	configurable values.
parent d476ee65
2004-07-05 Sven Neumann <sven@gimp.org>
* modules/cdisplay_proof.c: use object properties for the
configurable values.
2004-07-05 Michael Natterer <mitch@gimp.org> 2004-07-05 Michael Natterer <mitch@gimp.org>
* app/core/gimpchannel.[ch]: added signal "color-changed" and emit * app/core/gimpchannel.[ch]: added signal "color-changed" and emit
......
...@@ -36,6 +36,23 @@ ...@@ -36,6 +36,23 @@
#include "libgimp/libgimp-intl.h" #include "libgimp/libgimp-intl.h"
#define CDISPLAY_TYPE_PROOF_INTENT (cdisplay_proof_intent_type)
static GType cdisplay_proof_intent_get_type (GTypeModule *module);
static const GEnumValue cdisplay_proof_intent_enum_values[] =
{
{ INTENT_PERCEPTUAL,
N_("Perceptual"), "perceptual" },
{ INTENT_RELATIVE_COLORIMETRIC,
N_("Relative Colorimetric"), "relative-colorimetric" },
{ INTENT_SATURATION,
N_("Saturation"), "saturation" },
{ INTENT_ABSOLUTE_COLORIMETRIC,
N_("Absolute Colorimetric"), "absolute-colorimetric" },
{ 0, NULL, NULL }
};
#define CDISPLAY_TYPE_PROOF (cdisplay_proof_type) #define CDISPLAY_TYPE_PROOF (cdisplay_proof_type)
#define CDISPLAY_PROOF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CDISPLAY_TYPE_PROOF, CdisplayProof)) #define CDISPLAY_PROOF(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CDISPLAY_TYPE_PROOF, CdisplayProof))
#define CDISPLAY_PROOF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CDISPLAY_TYPE_PROOF, CdisplayProofClass)) #define CDISPLAY_PROOF_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CDISPLAY_TYPE_PROOF, CdisplayProofClass))
...@@ -52,7 +69,7 @@ struct _CdisplayProof ...@@ -52,7 +69,7 @@ struct _CdisplayProof
gint intent; gint intent;
gboolean bpc; gboolean bpc;
gchar *filename; gchar *profile;
cmsHTRANSFORM transform; cmsHTRANSFORM transform;
...@@ -67,12 +84,30 @@ struct _CdisplayProofClass ...@@ -67,12 +84,30 @@ struct _CdisplayProofClass
}; };
enum
{
PROP_0,
PROP_INTENT,
PROP_BPC,
PROP_PROFILE
};
static GType cdisplay_proof_get_type (GTypeModule *module); static GType cdisplay_proof_get_type (GTypeModule *module);
static void cdisplay_proof_class_init (CdisplayProofClass *klass); static void cdisplay_proof_class_init (CdisplayProofClass *klass);
static void cdisplay_proof_init (CdisplayProof *proof); static void cdisplay_proof_init (CdisplayProof *proof);
static void cdisplay_proof_dispose (GObject *object); static void cdisplay_proof_dispose (GObject *object);
static void cdisplay_proof_finalize (GObject *object); static void cdisplay_proof_finalize (GObject *object);
static void cdisplay_proof_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void cdisplay_proof_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static GimpColorDisplay * cdisplay_proof_clone (GimpColorDisplay *display); static GimpColorDisplay * cdisplay_proof_clone (GimpColorDisplay *display);
static void cdisplay_proof_convert (GimpColorDisplay *display, static void cdisplay_proof_convert (GimpColorDisplay *display,
...@@ -107,8 +142,9 @@ static const GimpModuleInfo cdisplay_proof_info = ...@@ -107,8 +142,9 @@ static const GimpModuleInfo cdisplay_proof_info =
"November 14, 2003" "November 14, 2003"
}; };
static GType cdisplay_proof_type = 0; static GType cdisplay_proof_type = 0;
static GimpColorDisplayClass *parent_class = NULL; static GType cdisplay_proof_intent_type = 0;
static GimpColorDisplayClass *parent_class = NULL;
G_MODULE_EXPORT const GimpModuleInfo * G_MODULE_EXPORT const GimpModuleInfo *
...@@ -121,6 +157,7 @@ G_MODULE_EXPORT gboolean ...@@ -121,6 +157,7 @@ G_MODULE_EXPORT gboolean
gimp_module_register (GTypeModule *module) gimp_module_register (GTypeModule *module)
{ {
cdisplay_proof_get_type (module); cdisplay_proof_get_type (module);
cdisplay_proof_intent_get_type (module);
return TRUE; return TRUE;
} }
...@@ -151,6 +188,18 @@ cdisplay_proof_get_type (GTypeModule *module) ...@@ -151,6 +188,18 @@ cdisplay_proof_get_type (GTypeModule *module)
return cdisplay_proof_type; return cdisplay_proof_type;
} }
static GType
cdisplay_proof_intent_get_type (GTypeModule *module)
{
if (! cdisplay_proof_intent_type)
cdisplay_proof_intent_type =
gimp_module_register_enum (module,
"CDisplayProofIntent",
cdisplay_proof_intent_enum_values);
return cdisplay_proof_intent_type;
}
static void static void
cdisplay_proof_class_init (CdisplayProofClass *klass) cdisplay_proof_class_init (CdisplayProofClass *klass)
{ {
...@@ -161,6 +210,25 @@ cdisplay_proof_class_init (CdisplayProofClass *klass) ...@@ -161,6 +210,25 @@ cdisplay_proof_class_init (CdisplayProofClass *klass)
object_class->dispose = cdisplay_proof_dispose; object_class->dispose = cdisplay_proof_dispose;
object_class->finalize = cdisplay_proof_finalize; object_class->finalize = cdisplay_proof_finalize;
object_class->get_property = cdisplay_proof_get_property;
object_class->set_property = cdisplay_proof_set_property;
g_object_class_install_property (object_class, PROP_INTENT,
g_param_spec_enum ("intent", NULL, NULL,
CDISPLAY_TYPE_PROOF_INTENT,
INTENT_PERCEPTUAL,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_BPC,
g_param_spec_boolean ("black-point-compensation", NULL, NULL,
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class, PROP_PROFILE,
g_param_spec_string ("profile", NULL, NULL,
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
display_class->name = _("Color Proof"); display_class->name = _("Color Proof");
display_class->help_id = "gimp-colordisplay-proof"; display_class->help_id = "gimp-colordisplay-proof";
...@@ -178,13 +246,9 @@ cdisplay_proof_class_init (CdisplayProofClass *klass) ...@@ -178,13 +246,9 @@ cdisplay_proof_class_init (CdisplayProofClass *klass)
static void static void
cdisplay_proof_init (CdisplayProof *proof) cdisplay_proof_init (CdisplayProof *proof)
{ {
proof->intent = INTENT_PERCEPTUAL;
proof->bpc = FALSE;
proof->transform = NULL; proof->transform = NULL;
proof->filename = NULL; proof->profile = NULL;
proof->table = NULL; proof->table = NULL;
cdisplay_proof_changed (GIMP_COLOR_DISPLAY (proof));
} }
static void static void
...@@ -203,10 +267,10 @@ cdisplay_proof_finalize (GObject *object) ...@@ -203,10 +267,10 @@ cdisplay_proof_finalize (GObject *object)
{ {
CdisplayProof *proof = CDISPLAY_PROOF (object); CdisplayProof *proof = CDISPLAY_PROOF (object);
if (proof->filename) if (proof->profile)
{ {
g_free (proof->filename); g_free (proof->profile);
proof->filename = NULL; proof->profile = NULL;
} }
if (proof->transform) if (proof->transform)
{ {
...@@ -217,6 +281,59 @@ cdisplay_proof_finalize (GObject *object) ...@@ -217,6 +281,59 @@ cdisplay_proof_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static void
cdisplay_proof_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
CdisplayProof *proof = CDISPLAY_PROOF (object);
switch (property_id)
{
case PROP_INTENT:
g_value_set_enum (value, proof->intent);
break;
case PROP_BPC:
g_value_set_boolean (value, proof->bpc);
break;
case PROP_PROFILE:
g_value_set_string (value, proof->profile);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
cdisplay_proof_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
CdisplayProof *proof = CDISPLAY_PROOF (object);
switch (property_id)
{
case PROP_INTENT:
proof->intent = g_value_get_enum (value);
break;
case PROP_BPC:
proof->bpc = g_value_get_boolean (value);
break;
case PROP_PROFILE:
g_free (proof->profile);
proof->profile = g_value_dup_string (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
gimp_color_display_changed (GIMP_COLOR_DISPLAY (proof));
}
static GimpColorDisplay * static GimpColorDisplay *
cdisplay_proof_clone (GimpColorDisplay *display) cdisplay_proof_clone (GimpColorDisplay *display)
{ {
...@@ -224,11 +341,9 @@ cdisplay_proof_clone (GimpColorDisplay *display) ...@@ -224,11 +341,9 @@ cdisplay_proof_clone (GimpColorDisplay *display)
CdisplayProof *copy; CdisplayProof *copy;
copy = CDISPLAY_PROOF (gimp_color_display_new (G_TYPE_FROM_INSTANCE (proof))); copy = CDISPLAY_PROOF (gimp_color_display_new (G_TYPE_FROM_INSTANCE (proof)));
copy->intent = proof->intent; copy->intent = proof->intent;
copy->bpc = proof->bpc; copy->bpc = proof->bpc;
copy->filename = g_strdup (proof->filename); copy->profile = g_strdup (proof->profile);
cdisplay_proof_changed (GIMP_COLOR_DISPLAY (copy));
return GIMP_COLOR_DISPLAY (copy); return GIMP_COLOR_DISPLAY (copy);
} }
...@@ -269,11 +384,11 @@ cdisplay_proof_load_state (GimpColorDisplay *display, ...@@ -269,11 +384,11 @@ cdisplay_proof_load_state (GimpColorDisplay *display,
if (tokens[0] && tokens[1] && tokens[2]) if (tokens[0] && tokens[1] && tokens[2])
{ {
g_free (proof->filename); g_object_set (proof,
"intent", atoi (tokens[0]),
proof->intent = atoi (tokens[0]); "black-point-compensation", atoi (tokens[1]),
proof->bpc = atoi (tokens[1]) ? TRUE : FALSE; "profile", tokens[2],
proof->filename = tokens[2]; NULL);
} }
g_strfreev (tokens); g_strfreev (tokens);
...@@ -290,7 +405,7 @@ cdisplay_proof_save_state (GimpColorDisplay *display) ...@@ -290,7 +405,7 @@ cdisplay_proof_save_state (GimpColorDisplay *display)
str = g_strdup_printf ("%d,%d,%s", str = g_strdup_printf ("%d,%d,%s",
proof->intent, proof->intent,
proof->bpc, proof->bpc,
proof->filename ? proof->filename : ""); proof->profile ? proof->profile : "");
state = gimp_parasite_new ("Display/Proof", GIMP_PARASITE_PERSISTENT, state = gimp_parasite_new ("Display/Proof", GIMP_PARASITE_PERSISTENT,
strlen (str) + 1, str); strlen (str) + 1, str);
...@@ -338,7 +453,7 @@ cdisplay_proof_configure (GimpColorDisplay *display) ...@@ -338,7 +453,7 @@ cdisplay_proof_configure (GimpColorDisplay *display)
proof->combo, 1, FALSE); proof->combo, 1, FALSE);
entry = gimp_file_entry_new (_("Choose an ICC Color Profile"), entry = gimp_file_entry_new (_("Choose an ICC Color Profile"),
proof->filename, FALSE, FALSE); proof->profile, FALSE, FALSE);
gimp_table_attach_aligned (GTK_TABLE (proof->table), 0, 1, gimp_table_attach_aligned (GTK_TABLE (proof->table), 0, 1,
_("_Profile:"), 0.0, 0.5, _("_Profile:"), 0.0, 0.5,
entry, 1, FALSE); entry, 1, FALSE);
...@@ -362,22 +477,22 @@ cdisplay_proof_configure (GimpColorDisplay *display) ...@@ -362,22 +477,22 @@ cdisplay_proof_configure (GimpColorDisplay *display)
} }
static void static void
cdisplay_proof_configure_reset (GimpColorDisplay * display) cdisplay_proof_configure_reset (GimpColorDisplay *display)
{ {
CdisplayProof *proof = CDISPLAY_PROOF (display); CdisplayProof *proof = CDISPLAY_PROOF (display);
proof->intent = INTENT_PERCEPTUAL; g_object_set (proof,
proof->bpc = FALSE; "intent", INTENT_PERCEPTUAL,
"black-point-compensation", FALSE,
NULL);
if (proof->table) if (proof->table)
{ {
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (proof->combo), gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (proof->combo),
INTENT_PERCEPTUAL); proof->intent);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (proof->toggle), gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (proof->toggle),
proof->bpc); proof->bpc);
} }
gimp_color_display_changed (GIMP_COLOR_DISPLAY (proof));
} }
static void static void
...@@ -393,7 +508,7 @@ cdisplay_proof_changed (GimpColorDisplay *display) ...@@ -393,7 +508,7 @@ cdisplay_proof_changed (GimpColorDisplay *display)
proof->transform = NULL; proof->transform = NULL;
} }
if (! proof->filename) if (! proof->profile)
return; return;
/* This should be read from the global parasite pool. /* This should be read from the global parasite pool.
...@@ -401,7 +516,7 @@ cdisplay_proof_changed (GimpColorDisplay *display) ...@@ -401,7 +516,7 @@ cdisplay_proof_changed (GimpColorDisplay *display)
*/ */
rgbProfile = cmsCreate_sRGBProfile (); rgbProfile = cmsCreate_sRGBProfile ();
proofProfile = cmsOpenProfileFromFile (proof->filename, "r"); proofProfile = cmsOpenProfileFromFile (proof->profile, "r");
if (proofProfile) if (proofProfile)
{ {
...@@ -425,26 +540,37 @@ static void ...@@ -425,26 +540,37 @@ static void
proof_intent_callback (GtkWidget *widget, proof_intent_callback (GtkWidget *widget,
CdisplayProof *proof) CdisplayProof *proof)
{ {
gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &proof->intent); gint value;
gimp_color_display_changed (GIMP_COLOR_DISPLAY (proof)); gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (widget), &value);
g_object_set (proof,
"intent", value,
NULL);
} }
static void static void
proof_bpc_callback (GtkWidget *widget, proof_bpc_callback (GtkWidget *widget,
CdisplayProof *proof) CdisplayProof *proof)
{ {
gimp_toggle_button_update (widget, &proof->bpc); gboolean value;
gimp_color_display_changed (GIMP_COLOR_DISPLAY (proof)); gimp_toggle_button_update (widget, &value);
g_object_set (proof,
"black-point-compensation", value,
NULL);
} }
static void static void
proof_file_callback (GtkWidget *widget, proof_file_callback (GtkWidget *widget,
CdisplayProof *proof) CdisplayProof *proof)
{ {
g_free (proof->filename); gchar *filename = gimp_file_entry_get_filename (GIMP_FILE_ENTRY (widget));
proof->filename = gimp_file_entry_get_filename (GIMP_FILE_ENTRY (widget));
gimp_color_display_changed (GIMP_COLOR_DISPLAY (proof)); g_object_set (proof,
"profile", filename,
NULL);
g_free (filename);
} }
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment