Pull the search UI construction code out into a distinct function.
[geeqie.git] / src / color-man.c
index 9ca83e0..e89fd14 100644 (file)
@@ -1,16 +1,24 @@
 /*
- * Geeqie
- * (C) 2006 John Ellis
- * Copyright (C) 2008 - 2009 The Geeqie Team
+ * Copyright (C) 2006 John Ellis
+ * Copyright (C) 2008 - 2016 The Geeqie Team
  *
  * Author: John Ellis
  *
- * This software is released under the GNU General Public License (GNU GPL).
- * Please read the included file COPYING for more information.
- * This software comes with no warranty of any kind, use at your own risk!
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-
 #include "main.h"
 #include "color-man.h"
 
 #ifdef HAVE_LCMS
 /*** color support enabled ***/
 
+#ifdef HAVE_LCMS2
+#include <lcms2.h>
+#else
 #include <lcms.h>
+#endif
 
 
 typedef struct _ColorManCache ColorManCache;
@@ -52,7 +64,9 @@ static void color_man_lib_init(void)
        if (init_done) return;
        init_done = TRUE;
 
+#ifndef HAVE_LCMS2
        cmsErrorAction(LCMS_ERROR_IGNORE);
+#endif
 }
 
 static cmsHPROFILE color_man_create_adobe_comp(void)
@@ -174,7 +188,7 @@ static ColorManCache *color_man_cache_new(ColorManProfileType in_type, const gch
                                           (has_alpha) ? TYPE_RGBA_8 : TYPE_RGB_8,
                                           cc->profile_out,
                                           (has_alpha) ? TYPE_RGBA_8 : TYPE_RGB_8,
-                                          INTENT_PERCEPTUAL, 0);
+                                          options->color_profile.render_intent, 0);
 
        if (!cc->transform)
                {
@@ -412,6 +426,50 @@ ColorMan *color_man_new_embedded(ImageWindow *imd, GdkPixbuf *pixbuf,
                                  screen_type, screen_file, screen_data, screen_data_len);
 }
 
+static gchar *color_man_get_profile_name(ColorManProfileType type, cmsHPROFILE profile)
+{
+       switch (type)
+               {
+               case COLOR_PROFILE_SRGB:
+                       return g_strdup(_("sRGB"));
+               case COLOR_PROFILE_ADOBERGB:
+                       return g_strdup(_("Adobe RGB compatible"));
+                       break;
+               case COLOR_PROFILE_MEM:
+               case COLOR_PROFILE_FILE:
+                       if (profile)
+                               {
+#ifdef HAVE_LCMS2
+                               cmsUInt32Number r;
+                               char buffer[20];
+                               buffer[0] = '\0';
+                               r = cmsGetProfileInfoASCII(profile, cmsInfoDescription, "en", "US", buffer, 20);
+                               buffer[19] = '\0'; /* Just to be sure */
+                               return g_strdup(buffer);
+#else
+                               return g_strdup(cmsTakeProductName(profile));
+#endif
+                               }
+                       return g_strdup(_("Custom profile"));
+                       break;
+               case COLOR_PROFILE_NONE:
+               default:
+                       return g_strdup("");
+               }
+}
+
+gboolean color_man_get_status(ColorMan *cm, gchar **image_profile, gchar **screen_profile)
+{
+       ColorManCache *cc;
+       if (!cm) return FALSE;
+
+       cc = cm->profile;
+
+       if (image_profile) *image_profile = color_man_get_profile_name(cc->profile_in_type, cc->profile_in);
+       if (screen_profile) *screen_profile = color_man_get_profile_name(cc->profile_out_type, cc->profile_out);
+       return TRUE;
+}
+
 void color_man_free(ColorMan *cm)
 {
        if (!cm) return;
@@ -471,5 +529,10 @@ void color_man_start_bg(ColorMan *cm, ColorManDoneFunc done_func, gpointer done_
        /* no op */
 }
 
+gboolean color_man_get_status(ColorMan *cm, gchar **image_profile, gchar **screen_profile)
+{
+       return FALSE;
+}
+
 #endif /* define HAVE_LCMS */
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */