index bf690e968b5dfc4778f5f44624703173ed3f9c7e..3ba39dd30aae8e8854756450399962e97a01f48b 100644 (file)
#include <glibmm/i18n.h>
#include "../dialogs/dialog-events.h"
#include <glibmm/i18n.h>
#include "../dialogs/dialog-events.h"
-#include "../prefs-utils.h"
+#include "../preferences.h"
#include "sp-color-notebook.h"
#include "spw-utilities.h"
#include "sp-color-scales.h"
#include "sp-color-icc-selector.h"
#include "sp-color-wheel-selector.h"
#include "sp-color-notebook.h"
#include "spw-utilities.h"
#include "sp-color-scales.h"
#include "sp-color-icc-selector.h"
#include "sp-color-wheel-selector.h"
+#include "svg/svg-icc-color.h"
+#include "../inkscape.h"
+#include "../document.h"
+#include "../profile-manager.h"
struct SPColorNotebookTracker {
const gchar* name;
struct SPColorNotebookTracker {
const gchar* name;
#define XPAD 4
#define YPAD 1
#define XPAD 4
#define YPAD 1
-GtkType
-sp_color_notebook_get_type (void)
+GType sp_color_notebook_get_type(void)
{
{
- static GtkType type = 0;
- if (!type) {
- GtkTypeInfo info = {
- "SPColorNotebook",
- sizeof (SPColorNotebook),
- sizeof (SPColorNotebookClass),
- (GtkClassInitFunc) sp_color_notebook_class_init,
- (GtkObjectInitFunc) sp_color_notebook_init,
- NULL, NULL, NULL
- };
- type = gtk_type_unique (SP_TYPE_COLOR_SELECTOR, &info);
- }
- return type;
+ static GtkType type = 0;
+ if (!type) {
+ GTypeInfo info = {
+ sizeof(SPColorNotebookClass),
+ 0, // base_init
+ 0, // base_finalize
+ (GClassInitFunc)sp_color_notebook_class_init,
+ 0, // class_finalize
+ 0, // class_data
+ sizeof(SPColorNotebook),
+ 0, // n_preallocs
+ (GInstanceInitFunc)sp_color_notebook_init,
+ 0 // value_table
+ };
+ type = g_type_register_static(SP_TYPE_COLOR_SELECTOR, "SPColorNotebook", &info, static_cast<GTypeFlags>(0));
+ }
+ return type;
}
static void
}
static void
static void
sp_color_notebook_switch_page(GtkNotebook *notebook,
static void
sp_color_notebook_switch_page(GtkNotebook *notebook,
- GtkNotebookPage *page,
- guint page_num,
- SPColorNotebook *colorbook)
+ GtkNotebookPage *page,
+ guint page_num,
+ SPColorNotebook *colorbook)
{
{
- if ( colorbook )
- {
+ if ( colorbook )
+ {
ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base);
nb->switchPage( notebook, page, page_num );
ColorNotebook* nb = (ColorNotebook*)(SP_COLOR_SELECTOR(colorbook)->base);
nb->switchPage( notebook, page, page_num );
- // remember the page we seitched to
- prefs_set_int_attribute ("colorselector", "page", page_num);
-
- }
+ // remember the page we seitched to
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setInt("/colorselector/page", page_num);
+ }
}
void ColorNotebook::switchPage(GtkNotebook*,
}
void ColorNotebook::switchPage(GtkNotebook*,
XPAD, YPAD);
// restore the last active page
XPAD, YPAD);
// restore the last active page
- gtk_notebook_set_current_page (GTK_NOTEBOOK (_book), prefs_get_int_attribute ("colorselector", "page", 0));
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (_book), prefs->getInt("/colorselector/page", 0));
{
gboolean found = FALSE;
{
gboolean found = FALSE;
row++;
row++;
- /* Create RGBA entry and color preview */
GtkWidget *rgbabox = gtk_hbox_new (FALSE, 0);
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);
+ gtk_container_add (GTK_CONTAINER (_box_colormanaged), colormanaged);
+ 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, 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);
+ gtk_container_add (GTK_CONTAINER (_box_outofgamut), outofgamut);
+ 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, 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_:"));
gtk_misc_set_alignment (GTK_MISC (_rgbal), 1.0, 0.5);
gtk_box_pack_start(GTK_BOX(rgbabox), _rgbal, TRUE, TRUE, 2);
_rgbal = gtk_label_new_with_mnemonic (_("RGBA_:"));
gtk_misc_set_alignment (GTK_MISC (_rgbal), 1.0, 0.5);
gtk_box_pack_start(GTK_BOX(rgbabox), _rgbal, TRUE, TRUE, 2);
sp_set_font_size_smaller (rgbabox);
gtk_widget_show_all (rgbabox);
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);
#ifdef SPCS_PREVIEW
_p = sp_color_preview_new (0xffffffff);
const gchar *t = gtk_entry_get_text( entry );
if (t) {
const gchar *t = gtk_entry_get_text( entry );
if (t) {
- gchar *e = 0;
- guint rgba = strtoul (t, &e, 16);
- if ( e != t ) {
- ptrdiff_t len=e-t;
+ Glib::ustring text = t;
+ bool changed = false;
+ if (!text.empty() && text[0] == '#') {
+ changed = true;
+ text.erase(0,1);
+ if (text.size() == 6) {
+ // it was a standard RGB hex
+ unsigned int alph = SP_COLOR_F_TO_U(_alpha);
+ gchar* tmp = g_strdup_printf("%02x", alph);
+ text += tmp;
+ g_free(tmp);
+ }
+ }
+ gchar* str = g_strdup(text.c_str());
+ gchar* end = 0;
+ guint64 rgba = g_ascii_strtoull( str, &end, 16 );
+ if ( end != str ) {
+ ptrdiff_t len = end - str;
if ( len < 8 ) {
rgba = rgba << ( 4 * ( 8 - len ) );
}
_updatingrgba = TRUE;
if ( len < 8 ) {
rgba = rgba << ( 4 * ( 8 - len ) );
}
_updatingrgba = TRUE;
+ if ( changed ) {
+ gtk_entry_set_text( entry, str );
+ }
SPColor color( rgba );
setColorAlpha( color, SP_RGBA32_A_F(rgba), true );
_updatingrgba = FALSE;
}
SPColor color( rgba );
setColorAlpha( color, SP_RGBA32_A_F(rgba), true );
_updatingrgba = FALSE;
}
+ g_free(str);
}
}
}
}
{
g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) );
{
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){
+ Inkscape::ColorProfile* target_profile = SP_ACTIVE_DOCUMENT->profileManager->find(color.icc->colorProfile.c_str());
+ 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 )
{
gchar s[32];
if ( !_updatingrgba )
{
gchar s[32];