From 12f643329a27c77ce8d169b24e1fec4e161a7ba7 Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Sat, 7 Jun 2025 01:36:06 +0000 Subject: [PATCH] modules: Display Total Ink Coverage on CMYK selector Total Ink Coverage shows the total percentage of ink that would be needed to print a particular color. It is the simple addition of all CMYK channels. This patch adds a Total Ink Coverage label to the CMYK color selector, as a reference when selecting a color for print. --- modules/color-selector-cmyk.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/color-selector-cmyk.c b/modules/color-selector-cmyk.c index 700bc767a9..b13a832aca 100644 --- a/modules/color-selector-cmyk.c +++ b/modules/color-selector-cmyk.c @@ -51,6 +51,7 @@ struct _ColorselCmyk GtkWidget *scales[4]; GtkWidget *name_label; + GtkWidget *tic_label; gboolean in_destruction; }; @@ -182,6 +183,15 @@ colorsel_cmyk_init (ColorselCmyk *module) gtk_widget_show (module->scales[i]); } + module->tic_label = gtk_label_new (NULL); + gtk_label_set_xalign (GTK_LABEL (module->tic_label), 0.0); + gtk_label_set_ellipsize (GTK_LABEL (module->tic_label), PANGO_ELLIPSIZE_END); + gimp_label_set_attributes (GTK_LABEL (module->tic_label), + PANGO_ATTR_WEIGHT, PANGO_WEIGHT_BOLD, + -1); + gtk_grid_attach (GTK_GRID (grid), module->tic_label, 1, 4, 3, 1); + gtk_widget_set_visible (module->tic_label, TRUE); + module->name_label = gtk_label_new (NULL); gtk_label_set_xalign (GTK_LABEL (module->name_label), 0.0); gtk_label_set_ellipsize (GTK_LABEL (module->name_label), PANGO_ELLIPSIZE_END); @@ -213,6 +223,8 @@ colorsel_cmyk_set_color (GimpColorSelector *selector, GimpColorRenderingIntent intent = GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC; const Babl *space = NULL; ColorselCmyk *module = COLORSEL_CMYK (selector); + gfloat tic_val = 0; + gchar *tic_str; gfloat cmyk[4]; /* Try Image Soft-proofing profile first, then default CMYK profile */ @@ -245,8 +257,14 @@ colorsel_cmyk_set_color (GimpColorSelector *selector, g_signal_handlers_unblock_by_func (module->scales[i], colorsel_cmyk_scale_update, module); + tic_val += cmyk[i]; } + tic_str = g_strdup_printf ("%s: %d%%", _("Total Ink Coverage"), + (gint) tic_val); + gtk_label_set_text (GTK_LABEL (module->tic_label), tic_str); + g_free (tic_str); + if (cmyk_profile && ! module->simulation_profile) g_object_unref (cmyk_profile); }