[gimp/alxsa-soft-proofing-menu] Adding new simulation intent/bpc API



commit dbac1164e15e216bf224f32816809ac63d3bdb7f
Author: Alx Sa <cmyk student gmail com>
Date:   Tue Aug 16 11:37:54 2022 +0000

    Adding new simulation intent/bpc API

 app/display/gimpstatusbar.c | 182 ++++++++++++++++++++++++++++++--------------
 app/display/gimpstatusbar.h |   1 +
 2 files changed, 127 insertions(+), 56 deletions(-)
---
diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c
index 644c8d9b11..f24561fee4 100644
--- a/app/display/gimpstatusbar.c
+++ b/app/display/gimpstatusbar.c
@@ -117,6 +117,9 @@ static void     gimp_statusbar_soft_proof_rendering_intent_changed
 static void     gimp_statusbar_soft_proof_bpc_toggled
                                                   (GtkWidget         *button,
                                                    GimpStatusbar     *statusbar);
+static void     gimp_statusbar_soft_proof_optimize_changed
+                                                  (GtkWidget         *button,
+                                                   GimpStatusbar     *statusbar);
 static void     gimp_statusbar_soft_proof_gamut_toggled
                                                   (GtkWidget         *button,
                                                    GimpStatusbar     *statusbar);
@@ -139,10 +142,9 @@ static void     gimp_statusbar_scale_activated    (GimpScaleComboBox *combo,
 static void     gimp_statusbar_shell_image_changed(GimpStatusbar     *statusbar,
                                                    GimpImage         *image,
                                                    GimpContext       *context);
-static void     gimp_statusbar_shell_image_simulation_profile_changed
+static void     gimp_statusbar_shell_image_simulation_changed
                                                   (GimpImage        *image,
                                                    GimpStatusbar     *statusbar);
-
 static gboolean gimp_statusbar_rotate_pressed     (GtkWidget         *event_box,
                                                    GdkEvent          *event,
                                                    GimpStatusbar     *statusbar);
@@ -236,10 +238,12 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
   GtkWidget     *image;
   GtkWidget     *label;
   GtkWidget     *grid;
+  GtkWidget     *separator;
   GimpUnitStore *store;
   gchar         *text;
   GFile         *file;
   GtkListStore  *combo_store;
+  gint           row;
 
   gtk_frame_set_shadow_type (GTK_FRAME (statusbar), GTK_SHADOW_IN);
 
@@ -436,9 +440,6 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
   gtk_widget_show (image);
 
   gtk_widget_show (statusbar->soft_proof_button);
-  g_signal_connect (statusbar->soft_proof_button, "clicked",
-                    G_CALLBACK (gimp_statusbar_soft_proof_button_toggled),
-                    statusbar);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (statusbar->soft_proof_button),
                                 FALSE);
 
@@ -467,6 +468,8 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
                                  FALSE);
 
   /* soft proofing popover */
+  row = 0;
+
   statusbar->soft_proof_popover = gtk_popover_new (statusbar->soft_proof_container);
   gtk_popover_set_modal (GTK_POPOVER (statusbar->soft_proof_popover), TRUE);
 
@@ -480,14 +483,14 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
   g_free (text);
   gtk_grid_attach (GTK_GRID (grid),
                    label,
-                   0, 0, 2, 1);
+                   0, row++, 2, 1);
   gtk_widget_show (label);
 
   statusbar->proof_colors_toggle =
     gtk_check_button_new_with_mnemonic (_("_Proof Colors"));
   gtk_grid_attach (GTK_GRID (grid),
                    statusbar->proof_colors_toggle,
-                   0, 1, 1, 1);
+                   0, row++, 1, 1);
   g_signal_connect (statusbar->proof_colors_toggle, "clicked",
                     G_CALLBACK (gimp_statusbar_soft_proof_button_toggled),
                     statusbar);
@@ -503,7 +506,7 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
   g_free (text);
   gtk_grid_attach (GTK_GRID (grid),
                    statusbar->profile_label,
-                   0, 2, 2, 1);
+                   0, row++, 2, 1);
   gtk_widget_show (statusbar->profile_label);
 
   file = gimp_directory_file ("profilerc", NULL);
@@ -518,7 +521,7 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
   gimp_color_profile_combo_box_set_active_file (GIMP_COLOR_PROFILE_COMBO_BOX (statusbar->profile_combo),
                                                 NULL, NULL);
 
-  gimp_grid_attach_aligned (GTK_GRID (grid), 0, 3,
+  gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++,
                             _("_Soft-proofing Profile: "),
                             0.0, 0.5,
                             statusbar->profile_combo, 1);
@@ -537,7 +540,7 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
                             "model", combo_store,
                             "visible", TRUE,
                             NULL);
-  gimp_grid_attach_aligned (GTK_GRID (grid), 0, 4,
+  gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++,
                             _("_Rendering Intent: "),
                             0.0, 0.5,
                             statusbar->rendering_intent_combo, 1);
@@ -547,20 +550,38 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
                     statusbar);
 
   statusbar->bpc_toggle =
-    gtk_check_button_new_with_mnemonic (_("_Black Point Compensation"));
+    gtk_check_button_new_with_mnemonic (_("Use _Black Point Compensation"));
   gtk_grid_attach (GTK_GRID (grid),
                    statusbar->bpc_toggle,
-                   0, 5, 1, 1);
+                   0, row++, 1, 1);
   gtk_widget_show (statusbar->bpc_toggle);
   g_signal_connect (statusbar->bpc_toggle, "clicked",
                     G_CALLBACK (gimp_statusbar_soft_proof_bpc_toggled),
                     statusbar);
 
+  separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);
+  gtk_grid_attach (GTK_GRID (grid),separator,
+                   0, row++, 1, 1);
+  gtk_widget_show (separator);
+
+  statusbar->optimize_combo =
+    gimp_int_combo_box_new (_("Speed"),  TRUE,
+                            _("Precision / Color Fidelity"), FALSE,
+                            NULL);
+  gimp_grid_attach_aligned (GTK_GRID (grid), 0, row++,
+                            _("O_ptimize soft-proofing for: "),
+                            0.0, 0.5,
+                            statusbar->optimize_combo, 1);
+  gtk_widget_show (statusbar->optimize_combo);
+  g_signal_connect (statusbar->optimize_combo, "changed",
+                    G_CALLBACK (gimp_statusbar_soft_proof_optimize_changed),
+                    statusbar);
+
   statusbar->out_of_gamut_toggle =
     gtk_check_button_new_with_mnemonic (_("_Mark Out of Gamut Colors"));
   gtk_grid_attach (GTK_GRID (grid),
                    statusbar->out_of_gamut_toggle,
-                   0, 6, 1, 1);
+                   0, row++, 1, 1);
   gtk_widget_show (statusbar->out_of_gamut_toggle);
   g_signal_connect (statusbar->out_of_gamut_toggle, "clicked",
                     G_CALLBACK (gimp_statusbar_soft_proof_gamut_toggled),
@@ -968,43 +989,67 @@ static void
 gimp_statusbar_soft_proof_rendering_intent_changed (GtkComboBox   *combo,
                                                     GimpStatusbar *statusbar)
 {
-  GimpColorConfig          *color_config;
+  GimpImage                *image;
   GimpColorRenderingIntent  intent;
   GimpColorRenderingIntent  active;
 
-  color_config = gimp_display_shell_get_color_config (statusbar->shell);
-  intent = gimp_color_config_get_simulation_intent (color_config);
-  active =
-    (GimpColorRenderingIntent) gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
+  g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
 
-  if (active != intent)
+  image = gimp_display_get_image (statusbar->shell->display);
+  if (image)
     {
-      g_object_set (color_config,
-                    "simulation-rendering-intent", active,
-                    NULL);
-      statusbar->shell->color_config_set = TRUE;
-    }
+      intent = gimp_image_get_simulation_intent (image);
+      active =
+        (GimpColorRenderingIntent) gtk_combo_box_get_active (GTK_COMBO_BOX (combo));
 
-  gimp_statusbar_shell_color_config_notify (G_OBJECT (color_config), NULL,
-                                            statusbar);
+      if (active != intent)
+        {
+          gimp_image_set_simulation_intent (image, active);
+          gimp_image_flush (image);
+        }
+  }
 }
 
 static void
 gimp_statusbar_soft_proof_bpc_toggled (GtkWidget     *button,
                                        GimpStatusbar *statusbar)
+{
+  GimpImage *image;
+  gboolean   bpc_enabled;
+  gboolean   active;
+
+  g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
+
+  image = gimp_display_get_image (statusbar->shell->display);
+  if (image)
+    {
+      bpc_enabled = gimp_image_get_simulation_bpc (image);
+      active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+
+      if (active != bpc_enabled)
+        {
+          gimp_image_set_simulation_bpc (image, active);
+          gimp_image_flush (image);
+        }
+    }
+}
+
+static void
+gimp_statusbar_soft_proof_optimize_changed (GtkWidget     *combo,
+                                            GimpStatusbar *statusbar)
 {
   GimpColorConfig *color_config;
-  gboolean         bpc_enabled;
-  gboolean         active;
+  gint             optimize;
+  gint             active;
 
   color_config = gimp_display_shell_get_color_config (statusbar->shell);
-  bpc_enabled = gimp_color_config_get_simulation_bpc (color_config);
-  active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
+  optimize = gimp_color_config_get_simulation_optimize (color_config);
+  gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo), &active);
 
-  if (active != bpc_enabled)
+  if (active != optimize)
     {
       g_object_set (color_config,
-                    "simulation-use-black-point-compensation", active,
+                    "simulation-optimize", active,
                     NULL);
       statusbar->shell->color_config_set = TRUE;
     }
@@ -1041,10 +1086,25 @@ static gboolean gimp_statusbar_soft_proof_popover_shown (GtkWidget      *button,
                                                          GdkEventButton *bevent,
                                                          GimpStatusbar  *statusbar)
 {
-  if (bevent->type == GDK_BUTTON_PRESS && bevent->button == 3)
-    gtk_widget_show (statusbar->soft_proof_popover);
+  if (bevent->type == GDK_BUTTON_PRESS)
+    {
+      if (bevent->button == 3)
+        gtk_widget_show (statusbar->soft_proof_popover);
 
-  return FALSE;
+      if (bevent->button == 1 &&
+          gtk_widget_get_sensitive (statusbar->soft_proof_button))
+        {
+          gboolean active =
+            gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (statusbar->soft_proof_button));
+          gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (statusbar->soft_proof_button),
+                                        ! active);
+
+          gimp_statusbar_soft_proof_button_toggled (statusbar->soft_proof_button,
+                                                    statusbar);
+        }
+    }
+
+  return TRUE;
 }
 
 static void
@@ -1885,11 +1945,9 @@ gimp_statusbar_shell_color_config_notify (GObject          *config,
                                           GimpStatusbar    *statusbar)
 {
   gboolean                 active       = FALSE;
+  gint                     optimize     = 0;
   GimpColorConfig         *color_config = GIMP_COLOR_CONFIG (config);
   GimpColorManagementMode  mode         = gimp_color_config_get_mode (color_config);
-  GimpColorRenderingIntent intent;
-
-  intent = gimp_color_config_get_simulation_intent (color_config);
 
   if (mode == GIMP_COLOR_MANAGEMENT_SOFTPROOF)
     {
@@ -1910,12 +1968,9 @@ gimp_statusbar_shell_color_config_notify (GObject          *config,
                              GTK_RELIEF_NONE);
     }
 
-  gtk_combo_box_set_active (GTK_COMBO_BOX (statusbar->rendering_intent_combo),
-                            intent);
-
-  active = gimp_color_config_get_simulation_bpc (color_config);
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (statusbar->bpc_toggle),
-                                active);
+  optimize = gimp_color_config_get_simulation_optimize (color_config);
+  gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (statusbar->optimize_combo),
+                                 optimize);
 
   active = gimp_color_config_get_simulation_gamut_check (color_config);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (statusbar->out_of_gamut_toggle),
@@ -1933,7 +1988,7 @@ gimp_statusbar_shell_set_image (GimpStatusbar *statusbar,
       if (statusbar->image)
         {
           g_signal_handlers_disconnect_by_func (statusbar->image,
-                                                gimp_statusbar_shell_image_simulation_profile_changed,
+                                                gimp_statusbar_shell_image_simulation_changed,
                                                 statusbar);
           g_object_unref (statusbar->image);
         }
@@ -1946,11 +2001,17 @@ gimp_statusbar_shell_set_image (GimpStatusbar *statusbar,
       g_object_ref (statusbar->image);
 
       g_signal_connect (statusbar->image, "simulation-profile-changed",
-                        G_CALLBACK (gimp_statusbar_shell_image_simulation_profile_changed),
+                        G_CALLBACK (gimp_statusbar_shell_image_simulation_changed),
+                        statusbar);
+      g_signal_connect (statusbar->image, "simulation-intent-changed",
+                        G_CALLBACK (gimp_statusbar_shell_image_simulation_changed),
+                        statusbar);
+      g_signal_connect (statusbar->image, "simulation-bpc-changed",
+                        G_CALLBACK (gimp_statusbar_shell_image_simulation_changed),
                         statusbar);
 
-      gimp_statusbar_shell_image_simulation_profile_changed (statusbar->image,
-                                                             statusbar);
+      gimp_statusbar_shell_image_simulation_changed (statusbar->image,
+                                                     statusbar);
     }
 }
 
@@ -1999,17 +2060,22 @@ gimp_statusbar_shell_image_changed (GimpStatusbar *statusbar,
 }
 
 static void
-gimp_statusbar_shell_image_simulation_profile_changed (GimpImage     *image,
-                                                       GimpStatusbar *statusbar)
+gimp_statusbar_shell_image_simulation_changed (GimpImage     *image,
+                                               GimpStatusbar *statusbar)
 {
-  GimpColorProfile *simulation_profile = NULL;
-  GFile            *file;
-  GtkListStore     *profile_store;
-  gchar            *text;
-  const gchar      *profile_label;
+  GimpColorProfile        *simulation_profile = NULL;
+  gchar                   *text;
+  const gchar             *profile_label;
+  GimpColorRenderingIntent intent             =
+    GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC;
+  gboolean                 bpc                = FALSE;
 
   if (image)
-    simulation_profile = gimp_image_get_simulation_profile (image);
+    {
+      simulation_profile = gimp_image_get_simulation_profile (image);
+      intent             = gimp_image_get_simulation_intent (image);
+      bpc                = gimp_image_get_simulation_bpc (image);
+    }
 
   if (simulation_profile && GIMP_IS_COLOR_PROFILE (simulation_profile))
     {
@@ -2034,6 +2100,10 @@ gimp_statusbar_shell_image_simulation_profile_changed (GimpImage     *image,
 
   gimp_color_profile_combo_box_set_active_profile (GIMP_COLOR_PROFILE_COMBO_BOX (statusbar->profile_combo),
                                                    simulation_profile);
+  gtk_combo_box_set_active (GTK_COMBO_BOX (statusbar->rendering_intent_combo),
+                            intent);
+  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (statusbar->bpc_toggle),
+                                bpc);
 }
 
 static gboolean
diff --git a/app/display/gimpstatusbar.h b/app/display/gimpstatusbar.h
index a91263a310..398cb1c453 100644
--- a/app/display/gimpstatusbar.h
+++ b/app/display/gimpstatusbar.h
@@ -90,6 +90,7 @@ struct _GimpStatusbar
   GtkWidget           *profile_combo;
   GtkWidget           *rendering_intent_combo;
   GtkWidget           *bpc_toggle;
+  GtkWidget           *optimize_combo;
   GtkWidget           *out_of_gamut_toggle;
 
   GSList              *size_widgets;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]