[gimp] libgimpcolor: add gimp_lcms_profile_get_summary()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] libgimpcolor: add gimp_lcms_profile_get_summary()
- Date: Fri, 14 Mar 2014 19:27:56 +0000 (UTC)
commit 6f62d6b11b70b7c23f17f12eff5ea52c3a455273
Author: Michael Natterer <mitch gimp org>
Date: Fri Mar 14 18:37:07 2014 +0100
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.
libgimpcolor/gimpcolor.def | 1 +
libgimpcolor/gimplcms.c | 111 +++++++++++++++++++++----------------------
libgimpcolor/gimplcms.h | 2 +
3 files changed, 57 insertions(+), 57 deletions(-)
---
diff --git a/libgimpcolor/gimpcolor.def b/libgimpcolor/gimpcolor.def
index f91b268..c40f29d 100644
--- a/libgimpcolor/gimpcolor.def
+++ b/libgimpcolor/gimpcolor.def
@@ -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
diff --git a/libgimpcolor/gimplcms.c b/libgimpcolor/gimplcms.c
index 24eb015..58e1361 100644
--- a/libgimpcolor/gimplcms.c
+++ b/libgimpcolor/gimplcms.c
@@ -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);
}
/**
diff --git a/libgimpcolor/gimplcms.h b/libgimpcolor/gimplcms.h
index 257f3cd..94b70f3 100644
--- a/libgimpcolor/gimplcms.h
+++ b/libgimpcolor/gimplcms.h
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]