mirror of https://github.com/GNOME/gimp.git
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:
parent
67391f6d9e
commit
d7037650df
app/dialogs
libgimpcolor
libgimpwidgets
modules
plug-ins/common
|
@ -792,10 +792,7 @@ prefs_profile_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);
|
||||
}
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@ EXPORTS
|
|||
gimp_lcms_create_srgb_profile
|
||||
gimp_lcms_profile_get_copyright
|
||||
gimp_lcms_profile_get_description
|
||||
gimp_lcms_profile_get_label
|
||||
gimp_lcms_profile_get_manufacturer
|
||||
gimp_lcms_profile_get_model
|
||||
gimp_lcms_profile_get_summary
|
||||
|
|
|
@ -161,6 +161,36 @@ gimp_lcms_profile_get_copyright (GimpColorProfile profile)
|
|||
return gimp_lcms_profile_get_info (profile, cmsInfoCopyright);
|
||||
}
|
||||
|
||||
gchar *
|
||||
gimp_lcms_profile_get_label (GimpColorProfile profile)
|
||||
{
|
||||
gchar *label;
|
||||
|
||||
g_return_val_if_fail (profile != NULL, NULL);
|
||||
|
||||
label = gimp_lcms_profile_get_description (profile);
|
||||
|
||||
if (label && ! strlen (label))
|
||||
{
|
||||
g_free (label);
|
||||
label = NULL;
|
||||
}
|
||||
|
||||
if (! label)
|
||||
label = gimp_lcms_profile_get_model (profile);
|
||||
|
||||
if (label && ! strlen (label))
|
||||
{
|
||||
g_free (label);
|
||||
label = NULL;
|
||||
}
|
||||
|
||||
if (! label)
|
||||
label = g_strdup (_("(unnamed profile)"));
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
gchar *
|
||||
gimp_lcms_profile_get_summary (GimpColorProfile profile)
|
||||
{
|
||||
|
|
|
@ -46,6 +46,7 @@ gchar * gimp_lcms_profile_get_manufacturer (GimpColorProfile profil
|
|||
gchar * gimp_lcms_profile_get_model (GimpColorProfile profile);
|
||||
gchar * gimp_lcms_profile_get_copyright (GimpColorProfile profile);
|
||||
|
||||
gchar * gimp_lcms_profile_get_label (GimpColorProfile profile);
|
||||
gchar * gimp_lcms_profile_get_summary (GimpColorProfile profile);
|
||||
|
||||
gboolean gimp_lcms_profile_is_equal (GimpColorProfile profile1,
|
||||
|
|
|
@ -106,8 +106,7 @@ gimp_color_profile_view_set_profile (GimpColorProfileView *view,
|
|||
{
|
||||
GtkTextBuffer *buffer;
|
||||
GtkTextIter iter;
|
||||
gchar *desc;
|
||||
gchar *model;
|
||||
gchar *label;
|
||||
gchar *summary;
|
||||
|
||||
g_return_if_fail (GIMP_IS_COLOR_PROFILE_VIEW (view));
|
||||
|
@ -123,22 +122,13 @@ gimp_color_profile_view_set_profile (GimpColorProfileView *view,
|
|||
|
||||
gtk_text_buffer_get_start_iter (buffer, &iter);
|
||||
|
||||
desc = gimp_lcms_profile_get_description (profile);
|
||||
model = gimp_lcms_profile_get_model (profile);
|
||||
label = gimp_lcms_profile_get_label (profile);
|
||||
summary = gimp_lcms_profile_get_summary (profile);
|
||||
|
||||
if ((desc && strlen (desc)) ||
|
||||
(model && strlen (model)))
|
||||
if (label && strlen (label))
|
||||
{
|
||||
gchar *title;
|
||||
|
||||
if (desc && strlen (desc))
|
||||
title = desc;
|
||||
else
|
||||
title = model;
|
||||
|
||||
gtk_text_buffer_insert_with_tags_by_name (buffer, &iter,
|
||||
title, -1,
|
||||
label, -1,
|
||||
"strong", NULL);
|
||||
gtk_text_buffer_insert (buffer, &iter, "\n", 1);
|
||||
}
|
||||
|
@ -146,8 +136,7 @@ gimp_color_profile_view_set_profile (GimpColorProfileView *view,
|
|||
if (summary)
|
||||
gtk_text_buffer_insert (buffer, &iter, summary, -1);
|
||||
|
||||
g_free (desc);
|
||||
g_free (model);
|
||||
g_free (label);
|
||||
g_free (summary);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 ==
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -578,18 +578,18 @@ lcms_icc_apply (GimpColorConfig *config,
|
|||
|
||||
if (gimp_lcms_profile_is_equal (src_profile, dest_profile))
|
||||
{
|
||||
gchar *src_desc = gimp_lcms_profile_get_description (src_profile);
|
||||
gchar *dest_desc = gimp_lcms_profile_get_description (dest_profile);
|
||||
gchar *src_label = gimp_lcms_profile_get_label (src_profile);
|
||||
gchar *dest_label = gimp_lcms_profile_get_label (dest_profile);
|
||||
|
||||
cmsCloseProfile (src_profile);
|
||||
cmsCloseProfile (dest_profile);
|
||||
|
||||
g_printerr ("lcms: skipping conversion because profiles seem to be equal:\n");
|
||||
g_printerr (" %s\n", src_desc);
|
||||
g_printerr (" %s\n", dest_desc);
|
||||
g_printerr (" %s\n", src_label);
|
||||
g_printerr (" %s\n", dest_label);
|
||||
|
||||
g_free (src_desc);
|
||||
g_free (dest_desc);
|
||||
g_free (src_label);
|
||||
g_free (dest_label);
|
||||
|
||||
return GIMP_PDB_SUCCESS;
|
||||
}
|
||||
|
@ -785,8 +785,8 @@ lcms_image_apply_profile (gint32 image,
|
|||
GimpColorRenderingIntent intent,
|
||||
gboolean bpc)
|
||||
{
|
||||
gchar *src_desc;
|
||||
gchar *dest_desc;
|
||||
gchar *src_label;
|
||||
gchar *dest_label;
|
||||
gint32 saved_selection = -1;
|
||||
|
||||
gimp_image_undo_group_start (image);
|
||||
|
@ -798,21 +798,16 @@ lcms_image_apply_profile (gint32 image,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
src_desc = gimp_lcms_profile_get_description (src_profile);
|
||||
if (! src_desc)
|
||||
src_desc = gimp_lcms_profile_get_model (src_profile);
|
||||
|
||||
dest_desc = gimp_lcms_profile_get_description (dest_profile);
|
||||
if (! dest_desc)
|
||||
dest_desc = gimp_lcms_profile_get_model (dest_profile);
|
||||
src_label = gimp_lcms_profile_get_label (src_profile);
|
||||
dest_label = gimp_lcms_profile_get_label (dest_profile);
|
||||
|
||||
gimp_progress_init_printf (_("Converting from '%s' to '%s'"),
|
||||
src_desc, dest_desc);
|
||||
src_label, dest_label);
|
||||
|
||||
g_printerr ("lcms: converting from '%s' to '%s'\n", src_desc, dest_desc);
|
||||
g_printerr ("lcms: converting from '%s' to '%s'\n", src_label, dest_label);
|
||||
|
||||
g_free (dest_desc);
|
||||
g_free (src_desc);
|
||||
g_free (dest_label);
|
||||
g_free (src_label);
|
||||
|
||||
if (! gimp_selection_is_empty (image))
|
||||
{
|
||||
|
@ -1079,7 +1074,6 @@ lcms_icc_profile_src_label_new (gint32 image,
|
|||
GtkWidget *vbox;
|
||||
GtkWidget *label;
|
||||
gchar *name;
|
||||
gchar *desc;
|
||||
gchar *text;
|
||||
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
|
||||
|
@ -1101,16 +1095,16 @@ lcms_icc_profile_src_label_new (gint32 image,
|
|||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
desc = gimp_lcms_profile_get_description (profile);
|
||||
name = gimp_lcms_profile_get_label (profile);
|
||||
label = g_object_new (GTK_TYPE_LABEL,
|
||||
"label", desc,
|
||||
"label", name,
|
||||
"wrap", TRUE,
|
||||
"justify", GTK_JUSTIFY_LEFT,
|
||||
"xalign", 0.0,
|
||||
"yalign", 0.0,
|
||||
"xpad", 24,
|
||||
NULL);
|
||||
g_free (desc);
|
||||
g_free (name);
|
||||
|
||||
gimp_label_set_attributes (GTK_LABEL (label),
|
||||
PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD,
|
||||
|
@ -1125,13 +1119,13 @@ static GtkWidget *
|
|||
lcms_icc_profile_dest_label_new (cmsHPROFILE profile)
|
||||
{
|
||||
GtkWidget *label;
|
||||
gchar *desc;
|
||||
gchar *name;
|
||||
gchar *text;
|
||||
|
||||
desc = gimp_lcms_profile_get_description (profile);
|
||||
name = gimp_lcms_profile_get_label (profile);
|
||||
text = g_strdup_printf (_("Convert the image to the RGB working space (%s)?"),
|
||||
desc);
|
||||
g_free (desc);
|
||||
name);
|
||||
g_free (name);
|
||||
|
||||
label = g_object_new (GTK_TYPE_LABEL,
|
||||
"label", text,
|
||||
|
@ -1238,10 +1232,7 @@ lcms_icc_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);
|
||||
}
|
||||
|
||||
|
@ -1319,15 +1310,12 @@ lcms_icc_combo_box_new (GimpColorConfig *config,
|
|||
if (! profile)
|
||||
profile = gimp_lcms_create_srgb_profile ();
|
||||
|
||||
name = gimp_lcms_profile_get_description (profile);
|
||||
if (! name)
|
||||
name = gimp_lcms_profile_get_model (profile);
|
||||
|
||||
cmsCloseProfile (profile);
|
||||
|
||||
name = gimp_lcms_profile_get_label (profile);
|
||||
label = g_strdup_printf (_("RGB workspace (%s)"), name);
|
||||
g_free (name);
|
||||
|
||||
cmsCloseProfile (profile);
|
||||
|
||||
gimp_color_profile_combo_box_add (GIMP_COLOR_PROFILE_COMBO_BOX (combo),
|
||||
rgb_filename, label);
|
||||
g_free (label);
|
||||
|
@ -1404,9 +1392,7 @@ lcms_dialog (GimpColorConfig *config,
|
|||
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
|
||||
gtk_widget_show (frame);
|
||||
|
||||
name = gimp_lcms_profile_get_description (src_profile);
|
||||
if (! name)
|
||||
name = gimp_lcms_profile_get_model (src_profile);
|
||||
name = gimp_lcms_profile_get_label (src_profile);
|
||||
|
||||
label = gtk_label_new (name);
|
||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
|
||||
|
|
Loading…
Reference in New Issue