Commit 180f9eb0 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

no point in crashing if gimp_enum_get_desc() returns NULL.

2005-01-22  Sven Neumann  <sven@gimp.org>

	* libgimpbase/gimputils.c (gimp_enum_value_get_desc): no point in
	crashing if gimp_enum_get_desc() returns NULL.

	* modules/cdisplay_colorblind.c
	* modules/cdisplay_proof.c: register enum descriptions, use
	GimpEnumComboBox.
parent 5c6dae19
2005-01-22 Sven Neumann <sven@gimp.org>
* libgimpbase/gimputils.c (gimp_enum_value_get_desc): no point in
crashing if gimp_enum_get_desc() returns NULL.
* modules/cdisplay_colorblind.c
* modules/cdisplay_proof.c: register enum descriptions, use
GimpEnumComboBox.
2005-01-21 Sven Neumann <sven@gimp.org>
* libgimpwidgets/gimppreviewarea.c: improved docs.
......
......@@ -454,7 +454,7 @@ gimp_enum_value_get_desc (GEnumClass *enum_class,
enum_desc = gimp_enum_get_desc (enum_class, enum_value->value);
if (enum_desc->value_desc)
if (enum_desc && enum_desc->value_desc)
return dgettext (gimp_type_get_translation_domain (type),
enum_desc->value_desc);
......
......@@ -51,17 +51,27 @@ typedef enum
#define CDISPLAY_TYPE_COLORBLIND_DEFICIENCY (cdisplay_colorblind_deficiency_type)
static GType cdisplay_colorblind_deficiency_get_type (GTypeModule *module);
static const GEnumValue cdisplay_colorblind_deficiency_enum_values[] =
static const GEnumValue enum_values[] =
{
{ COLORBLIND_DEFICIENCY_PROTANOPIA,
N_("Protanopia (insensitivity to red)"), "protanopia" },
"COLORBLIND_DEFICIENCY_PROTANOPIA", "protanopia" },
{ COLORBLIND_DEFICIENCY_DEUTERANOPIA,
N_("Deuteranopia (insensitivity to green)"), "deuteranopia" },
"COLORBLIND_DEFICIENCY_DEUTERANOPIA", "deuteranopia" },
{ COLORBLIND_DEFICIENCY_TRITANOPIA,
N_("Tritanopia (insensitivity to blue)"), "tritanopia" },
"COLORBLIND_DEFICIENCY_TRITANOPIA", "tritanopia" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc enum_descs[] =
{
{ COLORBLIND_DEFICIENCY_PROTANOPIA,
N_("Protanopia (insensitivity to red"), NULL },
{ COLORBLIND_DEFICIENCY_DEUTERANOPIA,
N_("Deuteranopia (insensitivity to green)"), NULL },
{ COLORBLIND_DEFICIENCY_TRITANOPIA,
N_("Tritanopia (insensitivity to blue)"), NULL },
{ 0, NULL, NULL }
};
#define DEFAULT_DEFICIENCY COLORBLIND_DEFICIENCY_DEUTERANOPIA
#define COLOR_CACHE_SIZE 1021
......@@ -211,10 +221,14 @@ static GType
cdisplay_colorblind_deficiency_get_type (GTypeModule *module)
{
if (! cdisplay_colorblind_deficiency_type)
cdisplay_colorblind_deficiency_type =
gimp_module_register_enum (module,
"CDisplayColorblindDeficiency",
cdisplay_colorblind_deficiency_enum_values);
{
cdisplay_colorblind_deficiency_type =
gimp_module_register_enum (module,
"CDisplayColorblindDeficiency", enum_values);
gimp_enum_set_value_descriptions (cdisplay_colorblind_deficiency_type,
enum_descs);
}
return cdisplay_colorblind_deficiency_type;
}
......@@ -542,14 +556,7 @@ cdisplay_colorblind_configure (GimpColorDisplay *display)
gtk_widget_show (label);
colorblind->combo =
gimp_int_combo_box_new (_("Protanopia (insensitivity to red)"),
COLORBLIND_DEFICIENCY_PROTANOPIA,
_("Deuteranopia (insensitivity to green)"),
COLORBLIND_DEFICIENCY_DEUTERANOPIA,
_("Tritanopia (insensitivity to blue)"),
COLORBLIND_DEFICIENCY_TRITANOPIA,
NULL);
gimp_enum_combo_box_new (CDISPLAY_TYPE_COLORBLIND_DEFICIENCY);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (colorblind->combo),
colorblind->deficiency);
......
......@@ -39,16 +39,25 @@
#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[] =
static const GEnumValue enum_values[] =
{
{ INTENT_PERCEPTUAL,
N_("Perceptual"), "perceptual" },
"INTENT_PERCEPTUAL", "perceptual " },
{ INTENT_RELATIVE_COLORIMETRIC,
N_("Relative Colorimetric"), "relative-colorimetric" },
"INTENT_RELATIVE_COLORIMETRIC", "relative-colorimetric" },
{ INTENT_SATURATION,
N_("Saturation"), "saturation" },
"INTENT_SATURATION", "saturation" },
{ INTENT_ABSOLUTE_COLORIMETRIC,
N_("Absolute Colorimetric"), "absolute-colorimetric" },
"INTENT_ABSOLUTE_COLORIMETRIC" "absolute-colorimetric" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc enum_descs[] =
{
{ INTENT_PERCEPTUAL, N_("Perceptual"), NULL },
{ INTENT_RELATIVE_COLORIMETRIC, N_("Relative Colorimetric"), NULL },
{ INTENT_SATURATION, N_("Saturation"), NULL },
{ INTENT_ABSOLUTE_COLORIMETRIC, N_("Absolute Colorimetric"), NULL },
{ 0, NULL, NULL }
};
......@@ -192,10 +201,14 @@ 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);
{
cdisplay_proof_intent_type =
gimp_module_register_enum (module,
"CDisplayProofIntent", enum_values);
gimp_enum_set_value_descriptions (cdisplay_proof_intent_type,
enum_descs);
}
return cdisplay_proof_intent_type;
}
......@@ -437,15 +450,7 @@ cdisplay_proof_configure (GimpColorDisplay *display)
G_CALLBACK (gtk_widget_destroyed),
&proof->table);
proof->combo = gimp_int_combo_box_new (_("Perceptual"),
INTENT_PERCEPTUAL,
_("Relative Colorimetric"),
INTENT_RELATIVE_COLORIMETRIC,
_("Saturation"),
INTENT_SATURATION,
_("Absolute Colorimetric"),
INTENT_ABSOLUTE_COLORIMETRIC,
NULL);
proof->combo = gimp_enum_combo_box_new (CDISPLAY_TYPE_PROOF_INTENT);
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (proof->combo),
proof->intent);
......
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