Code

Fix compile when lcms is disabled (someone please check that this fix is correct).
[inkscape.git] / src / widgets / sp-color-notebook.cpp
index 5eb44c2cb3d8b4ab1805d38f42db37d9b250a91c..3ba39dd30aae8e8854756450399962e97a01f48b 100644 (file)
@@ -329,6 +329,8 @@ void ColorNotebook::init()
        row++;
 
        GtkWidget *rgbabox = gtk_hbox_new (FALSE, 0);
+
+#if ENABLE_LCMS
        /* Create color management icons */
         _box_colormanaged = gtk_event_box_new ();
         GtkWidget *colormanaged = gtk_image_new_from_icon_name ("color-management-icon", GTK_ICON_SIZE_SMALL_TOOLBAR);
@@ -336,7 +338,7 @@ void ColorNotebook::init()
         GtkTooltips *tooltips_colormanaged = gtk_tooltips_new ();
         gtk_tooltips_set_tip (tooltips_colormanaged, _box_colormanaged, _("Color Managed"), "");
         gtk_widget_set_sensitive (_box_colormanaged, false);
-       gtk_box_pack_start(GTK_BOX(rgbabox), _box_colormanaged, TRUE, FALSE, 2);
+       gtk_box_pack_start(GTK_BOX(rgbabox), _box_colormanaged, FALSE, FALSE, 2);
 
         _box_outofgamut = gtk_event_box_new ();
         GtkWidget *outofgamut = gtk_image_new_from_icon_name ("out-of-gamut-icon", GTK_ICON_SIZE_SMALL_TOOLBAR);
@@ -344,7 +346,17 @@ void ColorNotebook::init()
         GtkTooltips *tooltips_outofgamut = gtk_tooltips_new ();
         gtk_tooltips_set_tip (tooltips_outofgamut, _box_outofgamut, _("Out of gamut!"), "");
         gtk_widget_set_sensitive (_box_outofgamut, false);
-       gtk_box_pack_start(GTK_BOX(rgbabox), _box_outofgamut, TRUE, FALSE, 2);        
+       gtk_box_pack_start(GTK_BOX(rgbabox), _box_outofgamut, FALSE, FALSE, 2);
+
+        _box_toomuchink = gtk_event_box_new ();
+        GtkWidget *toomuchink = gtk_image_new_from_icon_name ("too-much-ink-icon", GTK_ICON_SIZE_SMALL_TOOLBAR);
+        gtk_container_add (GTK_CONTAINER (_box_toomuchink), toomuchink);
+        GtkTooltips *tooltips_toomuchink = gtk_tooltips_new ();
+        gtk_tooltips_set_tip (tooltips_toomuchink, _box_toomuchink, _("Too much ink!"), "");
+        gtk_widget_set_sensitive (_box_toomuchink, false);
+       gtk_box_pack_start(GTK_BOX(rgbabox), _box_toomuchink, FALSE, FALSE, 2);
+
+#endif //ENABLE_LCMS
 
        /* Create RGBA entry and color preview */
        _rgbal = gtk_label_new_with_mnemonic (_("RGBA_:"));
@@ -361,7 +373,13 @@ void ColorNotebook::init()
 
        sp_set_font_size_smaller (rgbabox);
        gtk_widget_show_all (rgbabox);
-       gtk_table_attach (GTK_TABLE (table), rgbabox, 1, 2, row, row + 1, GTK_FILL, GTK_SHRINK, XPAD, YPAD);
+
+#if ENABLE_LCMS
+        //the "too much ink" icon is initially hidden
+        gtk_widget_hide(GTK_WIDGET(_box_toomuchink));
+#endif //ENABLE_LCMS
+
+        gtk_table_attach (GTK_TABLE (table), rgbabox, 0, 2, row, row + 1, GTK_FILL, GTK_SHRINK, XPAD, YPAD);
 
 #ifdef SPCS_PREVIEW
        _p = sp_color_preview_new (0xffffffff);
@@ -504,38 +522,40 @@ void ColorNotebook::_rgbaEntryChanged(GtkEntry* entry)
 void ColorNotebook::_updateRgbaEntry( const SPColor& color, gfloat alpha )
 {
     g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) );
-    
+
+#if ENABLE_LCMS    
     /* update color management icon*/
     gtk_widget_set_sensitive (_box_colormanaged, color.icc != NULL);
 
     /* update out-of-gamut icon */
     gtk_widget_set_sensitive (_box_outofgamut, false);
     if (color.icc){
-        BYTE outofgamut;
-        cmsSetAlarmCodes(255, 255, 255);
-        static cmsHPROFILE hNULL = cmsCreateNULLProfile();
-        static cmsHPROFILE hsRGB = cmsCreate_sRGBProfile();
-
-        cmsHTRANSFORM trans;
         Inkscape::ColorProfile* target_profile = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str());
-        if ( target_profile ) {
-            trans = cmsCreateProofingTransform(hsRGB, TYPE_RGB_DBL, hNULL, TYPE_GRAY_8, target_profile->profHandle,
-             INTENT_RELATIVE_COLORIMETRIC, INTENT_RELATIVE_COLORIMETRIC, (cmsFLAGS_GAMUTCHECK|cmsFLAGS_SOFTPROOFING));
-
-            if ( trans ) {
-                guint32 val = color.toRGBA32(0);
-                guchar check_color[4] = {
-                    SP_RGBA32_R_U(val),
-                    SP_RGBA32_G_U(val),
-                    SP_RGBA32_B_U(val),
-                    255};
-
-                cmsDoTransform(trans, &check_color, &outofgamut, 1);
-                gtk_widget_set_sensitive (_box_outofgamut, outofgamut == 255);
+        if ( target_profile )
+            gtk_widget_set_sensitive (_box_outofgamut, target_profile->GamutCheck(color));
+    }
+
+    /* update too-much-ink icon */
+    gtk_widget_set_sensitive (_box_toomuchink, false);
+    if (color.icc){
+        Inkscape::ColorProfile* prof = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str());
+        if (prof->getColorSpace() == icSigCmykData || prof->getColorSpace() == icSigCmyData){
+            gtk_widget_show(GTK_WIDGET(_box_toomuchink));
+            double ink_sum = 0;
+            for (unsigned int i=0; i<color.icc->colors.size(); i++){
+                ink_sum += color.icc->colors[i];
             }
+
+            /* Some literature states that when the sum of paint values exceed 320%, it is considered to be a satured color,
+                which means the paper can get too wet due to an excessive ammount of ink. This may lead to several issues
+                such as misalignment and poor quality of printing in general.*/
+            if ( ink_sum > 3.2 )
+                gtk_widget_set_sensitive (_box_toomuchink, true);
+        } else {
+            gtk_widget_hide(GTK_WIDGET(_box_toomuchink));
         }
     }
-
+#endif //ENABLE_LCMS
 
     if ( !_updatingrgba )
     {