summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2013-03-27 09:49:35 +0000
committerRichard Hughes <richard@hughsie.com>2013-05-13 09:38:29 +0100
commit3e133d378cc21803914b1bb82dbf2d1882c77768 (patch)
tree71557bdca65203f77005dc322cb6230a7d3e56cb
parentea2cef35fb8126f221f39dc9c221aa4c1564625a (diff)
downloadcolord-3e133d378cc21803914b1bb82dbf2d1882c77768.tar.gz
libcolord: Show all the translations when dumping an ICC profile
Note: You need a new version of lcms2 for this to work.
-rw-r--r--configure.ac4
-rw-r--r--lib/colord/cd-icc.c43
-rw-r--r--lib/colord/cd-self-test.c7
3 files changed, 54 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 47f8e10..1135220 100644
--- a/configure.ac
+++ b/configure.ac
@@ -157,6 +157,10 @@ AC_CHECK_LIB(lcms2, cmsGetToneCurveEstimatedTableEntries, have_lcms_table_entrie
if test x$have_lcms_table_entries != x; then
AC_DEFINE(HAVE_LCMS_GET_TABLE_ENTRIES,1,[cmsGetToneCurveEstimatedTableEntries is available])
fi
+AC_CHECK_LIB(lcms2, cmsMLUtranslationsCount, have_lcms_mlu_translations_count=yes)
+if test x$have_lcms_mlu_translations_count != x; then
+ AC_DEFINE(HAVE_LCMS_MLU_TRANSLATIONS_COUNT,1,[cmsMLUtranslationsCount is available])
+fi
PKG_CHECK_MODULES(SQLITE, sqlite3)
diff --git a/lib/colord/cd-icc.c b/lib/colord/cd-icc.c
index ad5f9bb..c06897a 100644
--- a/lib/colord/cd-icc.c
+++ b/lib/colord/cd-icc.c
@@ -340,6 +340,14 @@ cd_icc_to_string (CdIcc *icc)
cmsMLU *mlu;
gchar text_buffer[128];
guint32 text_size;
+#ifdef HAVE_LCMS_MLU_TRANSLATIONS_COUNT
+ gchar country_code[3] = "\0\0\0";
+ gchar language_code[3] = "\0\0\0";
+ gsize rc;
+ guint32 j;
+ guint32 mlu_size;
+ wchar_t wtext[128];
+#endif
g_string_append_printf (str, "Text:\n");
mlu = cmsReadTag (priv->lcms_profile, sig);
@@ -347,6 +355,40 @@ cd_icc_to_string (CdIcc *icc)
g_string_append_printf (str, " Info:\t\tMLU invalid!\n");
break;
}
+#ifdef HAVE_LCMS_MLU_TRANSLATIONS_COUNT
+ mlu_size = cmsMLUtranslationsCount (mlu);
+ if (mlu_size == 0)
+ g_string_append_printf (str, " Info:\t\tMLU empty!\n");
+ for (j = 0; j < mlu_size; j++) {
+ ret = cmsMLUtranslationsCodes (mlu,
+ j,
+ language_code,
+ country_code);
+ if (!ret)
+ continue;
+ text_size = cmsMLUgetWide (mlu,
+ language_code,
+ country_code,
+ wtext,
+ sizeof (wtext));
+ if (text_size == 0)
+ continue;
+ rc = wcstombs (text_buffer,
+ wtext,
+ sizeof (text_buffer));
+ if (rc == (gsize) -1) {
+ g_string_append_printf (str, " %s_%s:\tInvalid!\n",
+ language_code[0] != '\0' ? language_code : "en",
+ country_code[0] != '\0' ? country_code : "US");
+ continue;
+ }
+ g_string_append_printf (str, " %s_%s:\t%s [%i bytes]\n",
+ language_code[0] != '\0' ? language_code : "**",
+ country_code[0] != '\0' ? country_code : "**",
+ text_buffer,
+ text_size);
+ }
+#else
text_size = cmsMLUgetASCII (mlu,
cmsNoLanguage,
cmsNoCountry,
@@ -356,6 +398,7 @@ cd_icc_to_string (CdIcc *icc)
g_string_append_printf (str, " en_US:\t%s [%i bytes]\n",
text_buffer, text_size);
}
+#endif
break;
}
case cmsSigXYZType:
diff --git a/lib/colord/cd-self-test.c b/lib/colord/cd-self-test.c
index 0238ad9..4427a43 100644
--- a/lib/colord/cd-self-test.c
+++ b/lib/colord/cd-self-test.c
@@ -3590,6 +3590,7 @@ colord_icc_localized_func (void)
const gchar *str;
gboolean ret;
gchar *filename;
+ gchar *tmp;
GError *error = NULL;
GFile *file;
@@ -3607,6 +3608,12 @@ colord_icc_localized_func (void)
g_object_unref (file);
g_free (filename);
+ /* marshall to a string */
+ tmp = cd_icc_to_string (icc);
+ g_assert_cmpstr (tmp, !=, NULL);
+ g_debug ("CdIcc: '%s'", tmp);
+ g_free (tmp);
+
/* open a non-localized profile */
str = cd_icc_get_description (icc, NULL, &error);
g_assert_no_error (error);