[gnome-color-manager: 9/18] trivial: Save text data back to the profile when saving it, as we may have created a virtual profile
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager: 9/18] trivial: Save text data back to the profile when saving it, as we may have created a virtual profile
- Date: Fri, 8 Oct 2010 16:08:55 +0000 (UTC)
commit 80599ce2ace0c17445cf0f1c9f5b9021ea1722fd
Author: Richard Hughes <richard hughsie com>
Date: Fri Oct 8 12:39:48 2010 +0100
trivial: Save text data back to the profile when saving it, as we may have created a virtual profile
libcolor-glib/gcm-profile.c | 56 +++++++++++++++++++++++++++++++++++++++++-
1 files changed, 54 insertions(+), 2 deletions(-)
---
diff --git a/libcolor-glib/gcm-profile.c b/libcolor-glib/gcm-profile.c
index a0035f6..3b3634f 100644
--- a/libcolor-glib/gcm-profile.c
+++ b/libcolor-glib/gcm-profile.c
@@ -870,6 +870,20 @@ out:
return ret;
}
+/*
+ * _cmsWriteTagTextAscii:
+ */
+static cmsBool
+_cmsWriteTagTextAscii (cmsHPROFILE lcms_profile, cmsTagSignature sig, const gchar *text)
+{
+ cmsBool ret;
+ cmsMLU *mlu = cmsMLUalloc (0, 1);
+ cmsMLUsetASCII (mlu, "EN", "us", text);
+ ret = cmsWriteTag (lcms_profile, sig, mlu);
+ cmsMLUfree (mlu);
+ return ret;
+}
+
/**
* gcm_profile_save:
* @profile: A valid #GcmProfile
@@ -889,11 +903,49 @@ gcm_profile_save (GcmProfile *profile, const gchar *filename, GError **error)
GcmProfilePrivate *priv = profile->priv;
/* not loaded */
- if (priv->size == 0) {
- g_set_error_literal (error, 1, 0, "not loaded");
+ if (priv->lcms_profile == NULL) {
+ g_set_error_literal (error, 1, 0, "not loaded or generated");
goto out;
}
+ /* write text data */
+ if (priv->description != NULL) {
+ ret = _cmsWriteTagTextAscii (priv->lcms_profile,
+ cmsSigProfileDescriptionTag,
+ priv->description);
+ if (!ret) {
+ g_set_error_literal (error, 1, 0, "failed to write description");
+ goto out;
+ }
+ }
+ if (priv->copyright != NULL) {
+ ret = _cmsWriteTagTextAscii (priv->lcms_profile,
+ cmsSigCopyrightTag,
+ priv->copyright);
+ if (!ret) {
+ g_set_error_literal (error, 1, 0, "failed to write copyright");
+ goto out;
+ }
+ }
+ if (priv->model != NULL) {
+ ret = _cmsWriteTagTextAscii (priv->lcms_profile,
+ cmsSigDeviceModelDescTag,
+ priv->model);
+ if (!ret) {
+ g_set_error_literal (error, 1, 0, "failed to write model");
+ goto out;
+ }
+ }
+ if (priv->manufacturer != NULL) {
+ ret = _cmsWriteTagTextAscii (priv->lcms_profile,
+ cmsSigDeviceMfgDescTag,
+ priv->manufacturer);
+ if (!ret) {
+ g_set_error_literal (error, 1, 0, "failed to write manufacturer");
+ goto out;
+ }
+ }
+
/* save, TODO: get error */
cmsSaveProfileToFile (priv->lcms_profile, filename);
ret = TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]