[gnome-color-manager] Add gcm_profile_get_data() and gcm_profile_set_data() which can be used with the DICT tag when avail



commit 632c5dc0e3f85807ec259a0d44901e248787f502
Author: Richard Hughes <richard hughsie com>
Date:   Sun Oct 31 10:02:19 2010 +0000

    Add gcm_profile_get_data() and gcm_profile_set_data() which can be used with the DICT tag when available

 libcolor-glib/gcm-profile.c |   39 +++++++++++++++++++++++++++++++++++++++
 libcolor-glib/gcm-profile.h |    5 +++++
 2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/libcolor-glib/gcm-profile.c b/libcolor-glib/gcm-profile.c
index 396ea54..74adaa8 100644
--- a/libcolor-glib/gcm-profile.c
+++ b/libcolor-glib/gcm-profile.c
@@ -62,6 +62,7 @@ struct _GcmProfilePrivate
 	gchar			*datetime;
 	gchar			*checksum;
 	guint			 temperature;
+	GHashTable		*dict;
 	GcmColorXYZ		*white;
 	GcmColorXYZ		*black;
 	GcmColorXYZ		*red;
@@ -1201,6 +1202,42 @@ out:
 }
 
 /**
+ * gcm_profile_get_data:
+ * @profile: A valid #GcmProfile
+ * @key: the dictionary key
+ *
+ * Gets an item of data from the profile dictionary.
+ *
+ * Return value: The dictinary data, or %NULL if the key does not exist.
+ *
+ * Since: 2.91.2
+ **/
+const gchar *
+gcm_profile_get_data (GcmProfile *profile, const gchar *key)
+{
+	g_warning ("lcms2 support for dict missing: Cannot get %s", key);
+	return (const gchar *) g_hash_table_lookup (profile->priv->dict, key);
+}
+
+/**
+ * gcm_profile_get_data:
+ * @profile: A valid #GcmProfile
+ * @key: the dictionary key
+ * @data: the dictionary data
+ *
+ * Sets an item of data from the profile dictionary, overwriting it if
+ * it already exists.
+ *
+ * Since: 2.91.2
+ **/
+void
+gcm_profile_set_data (GcmProfile *profile, const gchar *key, const gchar *data)
+{
+	g_warning ("lcms2 support for dict missing: Cannot set %s to %s", key, data);
+	g_hash_table_insert (profile->priv->dict, g_strdup (key), g_strdup (data));
+}
+
+/**
  * gcm_profile_create_from_chroma:
  * @profile: A valid #GcmProfile
  * @red: primary color data
@@ -1885,6 +1922,7 @@ gcm_profile_init (GcmProfile *profile)
 	profile->priv = GCM_PROFILE_GET_PRIVATE (profile);
 	profile->priv->can_delete = FALSE;
 	profile->priv->monitor = NULL;
+	profile->priv->dict = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
 	profile->priv->kind = GCM_PROFILE_KIND_UNKNOWN;
 	profile->priv->colorspace = GCM_COLORSPACE_UNKNOWN;
 	profile->priv->white = gcm_color_new_XYZ ();
@@ -1918,6 +1956,7 @@ gcm_profile_finalize (GObject *object)
 	gcm_color_free_XYZ (priv->red);
 	gcm_color_free_XYZ (priv->green);
 	gcm_color_free_XYZ (priv->blue);
+	g_hash_table_destroy (profile->priv->dict);
 	if (priv->file != NULL)
 		g_object_unref (priv->file);
 	if (priv->monitor != NULL)
diff --git a/libcolor-glib/gcm-profile.h b/libcolor-glib/gcm-profile.h
index b60d912..c752931 100644
--- a/libcolor-glib/gcm-profile.h
+++ b/libcolor-glib/gcm-profile.h
@@ -139,6 +139,11 @@ const GcmColorXYZ *gcm_profile_get_red			(GcmProfile	*profile);
 const GcmColorXYZ *gcm_profile_get_green		(GcmProfile	*profile);
 const GcmColorXYZ *gcm_profile_get_blue			(GcmProfile	*profile);
 const GcmColorXYZ *gcm_profile_get_white		(GcmProfile	*profile);
+const gchar	*gcm_profile_get_data			(GcmProfile	*profile,
+							 const gchar	*key);
+void		 gcm_profile_set_data			(GcmProfile	*profile,
+							 const gchar	*key,
+							 const gchar	*data);
 
 G_END_DECLS
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]