libgimpcolor: add gimp_lcms_profile_get_label()

which returns a string meant to label the profile in the GUI, it's
either the profile's description, its model, or "(unnamed profile)" as
a fallback. Use the function instead of duplicating that logic
inconsistently and imcompletely all over the place.
This commit is contained in:
Michael Natterer
2014-03-30 03:12:42 +02:00
parent 67391f6d9e
commit d7037650df
9 changed files with 75 additions and 86 deletions

View File

@ -379,7 +379,7 @@ colorsel_cmyk_config_changed (ColorselCmyk *module)
cmsUInt32Number flags = 0;
cmsHPROFILE rgb_profile;
cmsHPROFILE cmyk_profile;
gchar *name;
gchar *label;
gchar *summary;
gchar *text;
@ -407,18 +407,15 @@ colorsel_cmyk_config_changed (ColorselCmyk *module)
if (! cmyk_profile)
goto out;
name = gimp_lcms_profile_get_description (cmyk_profile);
if (! name)
name = gimp_lcms_profile_get_model (cmyk_profile);
label = gimp_lcms_profile_get_label (cmyk_profile);
summary = gimp_lcms_profile_get_summary (cmyk_profile);
text = g_strdup_printf (_("Profile: %s"), name);
text = g_strdup_printf (_("Profile: %s"), label);
gtk_label_set_text (GTK_LABEL (module->name_label), text);
gimp_help_set_help_data (module->name_label, summary, NULL);
g_free (text);
g_free (name);
g_free (label);
g_free (summary);
if (config->display_intent ==

View File

@ -167,27 +167,18 @@ cdisplay_lcms_finalize (GObject *object)
static void
cdisplay_lcms_profile_get_info (cmsHPROFILE profile,
gchar **name,
gchar **info)
gchar **label,
gchar **summary)
{
if (profile)
{
*name = gimp_lcms_profile_get_description (profile);
if (! *name)
*name = gimp_lcms_profile_get_model (profile);
if (! *name)
{
/* a color profile without a name */
*name = g_strdup (_("(unnamed profile)"));
}
*info = gimp_lcms_profile_get_summary (profile);
*label = gimp_lcms_profile_get_label (profile);
*summary = gimp_lcms_profile_get_summary (profile);
}
else
{
*name = g_strdup (_("None"));
*info = NULL;
*label = g_strdup (_("None"));
*summary = NULL;
}
}

View File

@ -271,10 +271,7 @@ cdisplay_proof_combo_box_set_active (GimpColorProfileComboBox *combo,
if (profile)
{
label = gimp_lcms_profile_get_description (profile);
if (! label)
label = gimp_lcms_profile_get_model (profile);
label = gimp_lcms_profile_get_label (profile);
cmsCloseProfile (profile);
}