Commit 6f62d6b1 authored by Michael Natterer's avatar Michael Natterer 😴

libgimpcolor: add gimp_lcms_profile_get_summary()

Which returns an "executive summary" of the profile, much like lcms1's
"profile info" API. Refactor common code out of the other string
getters.
parent 60014630
......@@ -42,6 +42,7 @@ EXPORTS
gimp_lcms_profile_get_description
gimp_lcms_profile_get_manufacturer
gimp_lcms_profile_get_model
gimp_lcms_profile_get_summary
gimp_param_rgb_get_type
gimp_param_spec_rgb
gimp_param_spec_rgb_has_alpha
......
......@@ -45,104 +45,101 @@
**/
gchar *
gimp_lcms_profile_get_description (GimpColorProfile profile)
static gchar *
gimp_lcms_profile_get_info (GimpColorProfile profile,
cmsInfoType info)
{
cmsUInt32Number size;
gchar *desc = NULL;
gchar *text = NULL;
g_return_val_if_fail (profile != NULL, NULL);
size = cmsGetProfileInfoASCII (profile, cmsInfoDescription,
size = cmsGetProfileInfoASCII (profile, info,
"en", "US", NULL, 0);
if (size > 0)
{
gchar *data = g_new (gchar, size + 1);
size = cmsGetProfileInfoASCII (profile, cmsInfoDescription,
size = cmsGetProfileInfoASCII (profile, info,
"en", "US", data, size);
if (size > 0)
desc = gimp_any_to_utf8 (data, -1, NULL);
text = gimp_any_to_utf8 (data, -1, NULL);
g_free (data);
}
return desc;
return text;
}
gchar *
gimp_lcms_profile_get_manufacturer (GimpColorProfile profile)
gimp_lcms_profile_get_description (GimpColorProfile profile)
{
cmsUInt32Number size;
gchar *info = NULL;
g_return_val_if_fail (profile != NULL, NULL);
size = cmsGetProfileInfoASCII (profile, cmsInfoManufacturer,
"en", "US", NULL, 0);
if (size > 0)
{
gchar *data = g_new (gchar, size + 1);
return gimp_lcms_profile_get_info (profile, cmsInfoDescription);
}
size = cmsGetProfileInfoASCII (profile, cmsInfoManufacturer,
"en", "US", data, size);
if (size > 0)
info = gimp_any_to_utf8 (data, -1, NULL);
gchar *
gimp_lcms_profile_get_manufacturer (GimpColorProfile profile)
{
return gimp_lcms_profile_get_info (profile, cmsInfoManufacturer);
}
g_free (data);
}
gchar *
gimp_lcms_profile_get_model (GimpColorProfile profile)
{
return gimp_lcms_profile_get_info (profile, cmsInfoModel);
}
return info;
gchar *
gimp_lcms_profile_get_copyright (GimpColorProfile profile)
{
return gimp_lcms_profile_get_info (profile, cmsInfoCopyright);
}
gchar *
gimp_lcms_profile_get_model (GimpColorProfile profile)
gimp_lcms_profile_get_summary (GimpColorProfile profile)
{
cmsUInt32Number size;
gchar *name = NULL;
GString *string;
gchar *text;
g_return_val_if_fail (profile != NULL, NULL);
size = cmsGetProfileInfoASCII (profile, cmsInfoModel,
"en", "US", NULL, 0);
if (size > 0)
string = g_string_new (NULL);
text = gimp_lcms_profile_get_description (profile);
if (text)
{
gchar *data = g_new (gchar, size + 1);
g_string_append (string, text);
g_free (text);
}
size = cmsGetProfileInfoASCII (profile, cmsInfoModel,
"en", "US", data, size);
if (size > 0)
name = gimp_any_to_utf8 (data, -1, NULL);
text = gimp_lcms_profile_get_model (profile);
if (text)
{
if (string->len > 0)
g_string_append (string, "\n");
g_free (data);
g_string_append (string, text);
}
return name;
}
gchar *
gimp_lcms_profile_get_copyright (GimpColorProfile profile)
{
cmsUInt32Number size;
gchar *info = NULL;
text = gimp_lcms_profile_get_manufacturer (profile);
if (text)
{
if (string->len > 0)
g_string_append (string, "\n");
g_return_val_if_fail (profile != NULL, NULL);
g_string_append (string, text);
}
size = cmsGetProfileInfoASCII (profile, cmsInfoCopyright,
"en", "US", NULL, 0);
if (size > 0)
text = gimp_lcms_profile_get_copyright (profile);
if (text)
{
gchar *data = g_new (gchar, size + 1);
size = cmsGetProfileInfoASCII (profile, cmsInfoCopyright,
"en", "US", data, size);
if (size > 0)
info = gimp_any_to_utf8 (data, -1, NULL);
if (string->len > 0)
g_string_append (string, "\n");
g_free (data);
g_string_append (string, text);
}
return info;
return g_string_free (string, FALSE);
}
/**
......
......@@ -40,6 +40,8 @@ gchar * gimp_lcms_profile_get_manufacturer (GimpColorProfile profile)
gchar * gimp_lcms_profile_get_model (GimpColorProfile profile);
gchar * gimp_lcms_profile_get_copyright (GimpColorProfile profile);
gchar * gimp_lcms_profile_get_summary (GimpColorProfile profile);
GimpColorProfile gimp_lcms_create_srgb_profile (void);
......
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