[gnome-color-manager] trivial: create gcm_profile_has_colorspace_description() so we can reuse this logic for future code
- From: Richard Hughes <rhughes src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-color-manager] trivial: create gcm_profile_has_colorspace_description() so we can reuse this logic for future code
- Date: Tue, 27 Apr 2010 21:14:09 +0000 (UTC)
commit 2876e32f127144b44a53c8e72946b007ad7e44e1
Author: Richard Hughes <richard hughsie com>
Date: Tue Apr 27 15:33:42 2010 +0100
trivial: create gcm_profile_has_colorspace_description() so we can reuse this logic for future code
src/gcm-prefs.c | 11 +++--------
src/gcm-profile.c | 22 ++++++++++++++++++++++
src/gcm-profile.h | 1 +
3 files changed, 26 insertions(+), 8 deletions(-)
---
diff --git a/src/gcm-prefs.c b/src/gcm-prefs.c
index 33bb7a5..bbdeb55 100644
--- a/src/gcm-prefs.c
+++ b/src/gcm-prefs.c
@@ -2231,19 +2231,14 @@ gcm_prefs_setup_space_combobox (GtkWidget *widget, GcmColorspace colorspace, con
GcmProfile *profile;
guint i;
const gchar *filename;
- const gchar *description;
GcmColorspace colorspace_tmp;
gboolean has_profile = FALSE;
gboolean has_vcgt;
+ gboolean has_colorspace_description;
gchar *text = NULL;
- const gchar *search = "RGB";
GPtrArray *profile_array = NULL;
GtkTreeIter iter;
- /* search is a way to reduce to number of profiles */
- if (colorspace == GCM_COLORSPACE_CMYK)
- search = "CMYK";
-
/* get new list */
profile_array = gcm_profile_store_get_array (profile_store);
@@ -2252,13 +2247,13 @@ gcm_prefs_setup_space_combobox (GtkWidget *widget, GcmColorspace colorspace, con
profile = g_ptr_array_index (profile_array, i);
/* only for correct kind */
- description = gcm_profile_get_description (profile);
has_vcgt = gcm_profile_get_has_vcgt (profile);
+ has_colorspace_description = gcm_profile_has_colorspace_description (profile);
colorspace_tmp = gcm_profile_get_colorspace (profile);
if (!has_vcgt &&
colorspace == colorspace_tmp &&
(colorspace == GCM_COLORSPACE_CMYK ||
- g_strstr_len (description, -1, search) != NULL)) {
+ has_colorspace_description)) {
gcm_prefs_combobox_add_profile (widget, profile, GCM_PREFS_ENTRY_TYPE_PROFILE, &iter);
/* set active option */
diff --git a/src/gcm-profile.c b/src/gcm-profile.c
index efd070c..97efbf4 100644
--- a/src/gcm-profile.c
+++ b/src/gcm-profile.c
@@ -143,6 +143,28 @@ gcm_profile_get_filename (GcmProfile *profile)
}
/**
+ * gcm_profile_has_colorspace_description:
+ *
+ * Return value: if the description mentions the profile colorspace explicity,
+ * e.g. "Adobe RGB" for %GCM_COLORSPACE_RGB.
+ **/
+gboolean
+gcm_profile_has_colorspace_description (GcmProfile *profile)
+{
+ GcmProfilePrivate *priv = profile->priv;
+ g_return_val_if_fail (GCM_IS_PROFILE (profile), FALSE);
+
+ /* for each profile type */
+ if (priv->colorspace == GCM_COLORSPACE_RGB)
+ return (g_strstr_len (priv->description, -1, "RGB") != NULL);
+ if (priv->colorspace == GCM_COLORSPACE_CMYK)
+ return (g_strstr_len (priv->description, -1, "CMYK") != NULL);
+
+ /* nothing */
+ return FALSE;
+}
+
+/**
* gcm_profile_set_filename:
**/
void
diff --git a/src/gcm-profile.h b/src/gcm-profile.h
index d081aa3..89a412b 100644
--- a/src/gcm-profile.h
+++ b/src/gcm-profile.h
@@ -117,6 +117,7 @@ void gcm_profile_set_colorspace (GcmProfile *profile,
gboolean gcm_profile_get_has_vcgt (GcmProfile *profile);
void gcm_profile_set_has_vcgt (GcmProfile *profile,
gboolean has_vcgt);
+gboolean gcm_profile_has_colorspace_description (GcmProfile *profile);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]