[gimp/soc/2022/cmyk: 20/20] core, libgimpcolor: Change simulation profile




commit 82db04d305a5dd25281dec639e8901e1b9c54519
Author: Alx Sa <cmyk student gmail com>
Date:   Sun Jun 19 13:29:52 2022 +0000

    core, libgimpcolor: Change simulation profile
    
    Updates menu options and code to support changing GimpImage’s
    internal simulation profile. Menu items are moved from View to
    Image’s Color Management section.
    New “simulation-profile-changed” signal is emitted via
    GimpColorManagedInterface so that relevant tools (such as the
    CMYK color picker, GimpColorFrame, and future dockable
    dialogue) are aware of these changes.

 app/actions/image-actions.c            | 119 +++++++++++++++++++++++++++----
 app/actions/image-commands.c           | 123 +++++++++++++++++++++++++++++++++
 app/actions/image-commands.h           |   9 +++
 app/actions/view-actions.c             |  93 +------------------------
 app/actions/view-commands.c            | 121 --------------------------------
 app/actions/view-commands.h            |   9 ---
 app/core/gimpimage.c                   |  32 ++++++++-
 app/display/gimpdisplayshell-profile.c |  35 +---------
 libgimpcolor/gimpcolor.def             |   2 +
 libgimpcolor/gimpcolormanaged.c        |  53 +++++++++++++-
 libgimpcolor/gimpcolormanaged.h        |  25 ++++---
 menus/image-menu.xml.in                |  19 ++---
 12 files changed, 353 insertions(+), 287 deletions(-)
---
diff --git a/app/actions/image-actions.c b/app/actions/image-actions.c
index cdfdef7d4b..7ef19056e9 100644
--- a/app/actions/image-actions.c
+++ b/app/actions/image-actions.c
@@ -20,6 +20,7 @@
 #include <gegl.h>
 #include <gtk/gtk.h>
 
+#include "libgimpconfig/gimpconfig.h"
 #include "libgimpwidgets/gimpwidgets.h"
 
 #include "actions-types.h"
@@ -35,6 +36,9 @@
 #include "core/gimpimage-color-profile.h"
 #include "core/gimpitemstack.h"
 
+#include "display/gimpdisplay.h"
+#include "display/gimpdisplayshell.h"
+
 #include "widgets/gimpactiongroup.h"
 #include "widgets/gimphelp-ids.h"
 
@@ -102,12 +106,21 @@ static const GimpActionEntry image_actions[] =
     image_color_profile_discard_cmd_callback,
     GIMP_HELP_IMAGE_COLOR_PROFILE_DISCARD },
 
+  { "image-softproof-profile", NULL,
+    NC_("image-action", "_Softproof Profile..."), NULL,
+    NC_("image-action", "Set the softproofing profile"),
+    image_softproof_profile_cmd_callback,
+    GIMP_HELP_VIEW_COLOR_MANAGEMENT },
+
   { "image-color-profile-save", NULL,
     NC_("image-action", "_Save Color Profile to File..."), NULL,
     NC_("image-action", "Save the image's color profile to an ICC file"),
     image_color_profile_save_cmd_callback,
     GIMP_HELP_IMAGE_COLOR_PROFILE_SAVE },
 
+  { "image-softproof-intent-menu", NULL,
+    NC_("image-action", "Soft-Proofing Re_ndering Intent") },
+
   { "image-resize", GIMP_ICON_OBJECT_RESIZE,
     NC_("image-action", "Can_vas Size..."), NULL,
     NC_("image-action", "Adjust the image dimensions"),
@@ -184,7 +197,14 @@ static const GimpToggleActionEntry image_toggle_actions[] =
         "allows to easily restore the profile."),
     image_color_profile_use_srgb_cmd_callback,
     TRUE,
-    GIMP_HELP_IMAGE_COLOR_PROFILE_USE_SRGB }
+    GIMP_HELP_IMAGE_COLOR_PROFILE_USE_SRGB },
+
+  { "image-softproof-black-point-compensation", NULL,
+    NC_("image-action", "_Black Point Compensation"), NULL,
+    NC_("image-action", "Use black point compensation for soft-proofing"),
+    image_softproof_bpc_cmd_callback,
+    TRUE,
+    GIMP_HELP_VIEW_COLOR_MANAGEMENT }
 };
 
 static const GimpRadioActionEntry image_convert_base_type_actions[] =
@@ -301,6 +321,33 @@ static const GimpEnumActionEntry image_rotate_actions[] =
     GIMP_HELP_IMAGE_ROTATE_270 }
 };
 
+static const GimpRadioActionEntry image_softproof_intent_actions[] =
+{
+  { "image-softproof-intent-perceptual", NULL,
+    NC_("image-action", "_Perceptual"), NULL,
+    NC_("image-action", "Soft-proofing rendering intent is perceptual"),
+    GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL,
+    GIMP_HELP_VIEW_COLOR_MANAGEMENT },
+
+  { "image-softproof-intent-relative-colorimetric", NULL,
+    NC_("image-action", "_Relative Colorimetric"), NULL,
+    NC_("image-action", "Soft-proofing rendering intent is relative colorimetric"),
+    GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
+    GIMP_HELP_VIEW_COLOR_MANAGEMENT },
+
+  { "image-softproof-intent-saturation", NULL,
+    NC_("image-action", "_Saturation"), NULL,
+    NC_("image-action", "Soft-proofing rendering intent is saturation"),
+    GIMP_COLOR_RENDERING_INTENT_SATURATION,
+    GIMP_HELP_VIEW_COLOR_MANAGEMENT },
+
+  { "image-softproof-intent-absolute-colorimetric", NULL,
+    NC_("image-action", "_Absolute Colorimetric"), NULL,
+    NC_("image-action", "Soft-proofing rendering intent is absolute colorimetric"),
+    GIMP_COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC,
+    GIMP_HELP_VIEW_COLOR_MANAGEMENT }
+};
+
 
 void
 image_actions_setup (GimpActionGroup *group)
@@ -313,6 +360,13 @@ image_actions_setup (GimpActionGroup *group)
                                         image_toggle_actions,
                                         G_N_ELEMENTS (image_toggle_actions));
 
+  gimp_action_group_add_radio_actions (group, "image-action",
+                                       image_softproof_intent_actions,
+                                       G_N_ELEMENTS (image_softproof_intent_actions),
+                                       NULL,
+                                       GIMP_COLOR_MANAGEMENT_DISPLAY,
+                                       image_softproof_intent_cmd_callback);
+
   gimp_action_group_add_radio_actions (group, "image-convert-action",
                                        image_convert_base_type_actions,
                                        G_N_ELEMENTS (image_convert_base_type_actions),
@@ -355,17 +409,21 @@ void
 image_actions_update (GimpActionGroup *group,
                       gpointer         data)
 {
-  GimpImage *image          = action_data_get_image (data);
-  gboolean   is_indexed     = FALSE;
-  gboolean   is_u8_gamma    = FALSE;
-  gboolean   is_double      = FALSE;
-  gboolean   aux            = FALSE;
-  gboolean   lp             = FALSE;
-  gboolean   sel            = FALSE;
-  gboolean   groups         = FALSE;
-  gboolean   profile_srgb   = FALSE;
-  gboolean   profile_hidden = FALSE;
-  gboolean   profile        = FALSE;
+  GimpImage        *image          = action_data_get_image (data);
+  GimpDisplay      *display        = action_data_get_display (data);
+  GimpDisplayShell *shell          = NULL;
+  GimpColorConfig  *color_config   = NULL;
+  gboolean          is_indexed     = FALSE;
+  gboolean          is_u8_gamma    = FALSE;
+  gboolean          is_double      = FALSE;
+  gboolean          aux            = FALSE;
+  gboolean          lp             = FALSE;
+  gboolean          sel            = FALSE;
+  gboolean          groups         = FALSE;
+  gboolean          profile_srgb   = FALSE;
+  gboolean          profile_hidden = FALSE;
+  gboolean          profile        = FALSE;
+  gboolean          s_bpc          = FALSE;
 
 #define SET_LABEL(action,label) \
         gimp_action_group_set_action_label (group, action, (label))
@@ -445,6 +503,35 @@ image_actions_update (GimpActionGroup *group,
 
       profile_srgb = gimp_image_get_use_srgb_profile (image, &profile_hidden);
       profile      = (gimp_image_get_color_profile (image) != NULL);
+
+      if (display)
+        {
+          shell        = gimp_display_get_shell (display);
+          color_config = gimp_display_shell_get_color_config (shell);
+
+          switch (gimp_color_config_get_simulation_intent (color_config))
+            {
+            case GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL:
+              action = "image-softproof-intent-perceptual";
+              break;
+
+            case GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC:
+              action = "image-softproof-intent-relative-colorimetric";
+              break;
+
+            case GIMP_COLOR_RENDERING_INTENT_SATURATION:
+              action = "image-softproof-intent-saturation";
+              break;
+
+            case GIMP_COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC:
+              action = "image-softproof-intent-absolute-colorimetric";
+              break;
+            }
+
+          gimp_action_group_set_action_active (group, action, TRUE);
+
+          s_bpc  = gimp_color_config_get_simulation_bpc (color_config);
+        }
     }
   else
     {
@@ -472,6 +559,14 @@ image_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("image-convert-grayscale", image);
   SET_SENSITIVE ("image-convert-indexed",   image && !groups && is_u8_gamma);
 
+  SET_SENSITIVE ("image-softproof-profile",                      image);
+  SET_SENSITIVE ("image-softproof-intent-perceptual",            image);
+  SET_SENSITIVE ("image-softproof-intent-relative-colorimetric", image);
+  SET_SENSITIVE ("image-softproof-intent-saturation",            image);
+  SET_SENSITIVE ("image-softproof-intent-absolute-colorimetric", image);
+  SET_SENSITIVE ("image-softproof-black-point-compensation",     image);
+  SET_ACTIVE    ("image-softproof-black-point-compensation",     s_bpc);
+
   SET_SENSITIVE ("image-convert-u8",     image);
   SET_SENSITIVE ("image-convert-u16",    image && !is_indexed);
   SET_SENSITIVE ("image-convert-u32",    image && !is_indexed);
diff --git a/app/actions/image-commands.c b/app/actions/image-commands.c
index 323cc60158..019b727ce2 100644
--- a/app/actions/image-commands.c
+++ b/app/actions/image-commands.c
@@ -22,6 +22,7 @@
 
 #include "libgimpbase/gimpbase.h"
 #include "libgimpcolor/gimpcolor.h"
+#include "libgimpconfig/gimpconfig.h"
 #include "libgimpwidgets/gimpwidgets.h"
 
 #include "actions-types.h"
@@ -172,6 +173,15 @@ static void   image_merge_layers_callback      (GtkWidget              *dialog,
                                                 gboolean                discard_invisible,
                                                 gpointer                user_data);
 
+static void   image_softproof_profile_callback  (GtkWidget                *dialog,
+                                                 GimpImage                *image,
+                                                 GimpColorProfile         *new_profile,
+                                                 GFile                    *new_file,
+                                                 GimpColorRenderingIntent  intent,
+                                                 gboolean                  bpc,
+                                                 gpointer                  user_data);
+
+
 
 /*  private variables  */
 
@@ -1563,3 +1573,116 @@ image_merge_layers_callback (GtkWidget     *dialog,
 
   g_clear_pointer (&dialog, gtk_widget_destroy);
 }
+
+void
+image_softproof_profile_cmd_callback (GimpAction *action,
+                                      GVariant   *value,
+                                      gpointer    data)
+{
+  GimpImage        *image;
+  GimpDisplayShell *shell;
+  GtkWidget        *dialog;
+  return_if_no_image (image, data);
+  return_if_no_shell (shell, data);
+
+#define SOFTPROOF_PROFILE_DIALOG_KEY "gimp-softproof-profile-dialog"
+
+  dialog = dialogs_get_dialog (G_OBJECT (shell), SOFTPROOF_PROFILE_DIALOG_KEY);
+
+  if (! dialog)
+    {
+      GimpColorProfile *current_profile;
+
+      current_profile = gimp_image_get_simulation_profile (image);
+
+      dialog = color_profile_dialog_new (COLOR_PROFILE_DIALOG_SELECT_SOFTPROOF_PROFILE,
+                                         image,
+                                         action_data_get_context (data),
+                                         GTK_WIDGET (shell),
+                                         current_profile,
+                                         NULL,
+                                         0, 0,
+                                         image_softproof_profile_callback,
+                                         shell);
+
+      dialogs_attach_dialog (G_OBJECT (shell),
+                             SOFTPROOF_PROFILE_DIALOG_KEY, dialog);
+    }
+
+  gtk_window_present (GTK_WINDOW (dialog));
+}
+
+static void
+image_softproof_profile_callback (GtkWidget                *dialog,
+                                  GimpImage                *image,
+                                  GimpColorProfile         *new_profile,
+                                  GFile                    *new_file,
+                                  GimpColorRenderingIntent  intent,
+                                  gboolean                  bpc,
+                                  gpointer                  user_data)
+{
+  GimpDisplayShell *shell = user_data;
+  GimpColorConfig  *color_config;
+  gchar            *path  = NULL;
+
+  color_config = gimp_display_shell_get_color_config (shell);
+
+  if (new_file)
+    path = g_file_get_path (new_file);
+
+  g_object_set (color_config,
+                "simulation-profile", path,
+                NULL);
+  shell->color_config_set = TRUE;
+
+  /* Update image's simulation profile */
+  gimp_image_set_simulation_profile (image, new_profile);
+
+  gtk_widget_destroy (dialog);
+}
+
+void
+image_softproof_intent_cmd_callback (GimpAction *action,
+                                     GVariant   *value,
+                                     gpointer    data)
+{
+  GimpDisplayShell          *shell;
+  GimpColorConfig           *color_config;
+  GimpColorRenderingIntent   intent;
+  return_if_no_shell (shell, data);
+
+  intent = (GimpColorRenderingIntent) g_variant_get_int32 (value);
+
+  color_config = gimp_display_shell_get_color_config (shell);
+
+  if (intent != gimp_color_config_get_simulation_intent (color_config))
+    {
+      g_object_set (color_config,
+                    "simulation-rendering-intent", intent,
+                    NULL);
+      shell->color_config_set = TRUE;
+    }
+}
+
+void
+image_softproof_bpc_cmd_callback (GimpAction *action,
+                                  GVariant   *value,
+                                  gpointer    data)
+{
+  GimpDisplayShell *shell;
+  GimpColorConfig  *color_config;
+  gboolean          active;
+  return_if_no_shell (shell, data);
+
+  color_config = gimp_display_shell_get_color_config (shell);
+
+  active = g_variant_get_boolean (value);
+
+  if (active != gimp_color_config_get_simulation_bpc (color_config))
+    {
+      g_object_set (color_config,
+                    "simulation-use-black-point-compensation", active,
+                    NULL);
+      shell->color_config_set = TRUE;
+    }
+}
diff --git a/app/actions/image-commands.h b/app/actions/image-commands.h
index 964ffb2ec5..0cc6f5abc7 100644
--- a/app/actions/image-commands.h
+++ b/app/actions/image-commands.h
@@ -97,5 +97,14 @@ void   image_properties_cmd_callback               (GimpAction *action,
                                                     GVariant   *value,
                                                     gpointer    data);
 
+void   image_softproof_profile_cmd_callback          (GimpAction *action,
+                                                      GVariant   *value,
+                                                      gpointer    data);
+void   image_softproof_intent_cmd_callback           (GimpAction *action,
+                                                      GVariant   *value,
+                                                      gpointer    data);
+void   image_softproof_bpc_cmd_callback              (GimpAction *action,
+                                                      GVariant   *value,
+                                                      gpointer    data);
 
 #endif /* __IMAGE_COMMANDS_H__ */
diff --git a/app/actions/view-actions.c b/app/actions/view-actions.c
index 3943eec056..e738ca90b5 100644
--- a/app/actions/view-actions.c
+++ b/app/actions/view-actions.c
@@ -77,9 +77,6 @@ static const GimpActionEntry view_actions[] =
   { "view-display-intent-menu", NULL,
     NC_("view-action", "Display _Rendering Intent") },
 
-  { "view-softproof-intent-menu", NULL,
-    NC_("view-action", "Soft-Proofing Re_ndering Intent") },
-
   { "view-move-to-screen-menu", GIMP_ICON_WINDOW_MOVE_TO_SCREEN,
     NC_("view-action", "Move to Screen"), NULL, NULL, NULL,
     GIMP_HELP_VIEW_CHANGE_SCREEN },
@@ -165,12 +162,6 @@ static const GimpActionEntry view_actions[] =
     view_color_management_reset_cmd_callback,
     GIMP_HELP_VIEW_COLOR_MANAGEMENT },
 
-  { "view-softproof-profile", NULL,
-    NC_("view-action", "Soft-_Proofing Profile..."), NULL,
-    NC_("view-action", "Set the soft-proofing profile"),
-    view_softproof_profile_cmd_callback,
-    GIMP_HELP_VIEW_COLOR_MANAGEMENT },
-
   { "view-shrink-wrap", GIMP_ICON_ZOOM_FIT_BEST,
     NC_("view-action", "Shrink _Wrap"), "<primary>J",
     NC_("view-action", "Reduce the image window to the size of the image display"),
@@ -222,13 +213,6 @@ static const GimpToggleActionEntry view_toggle_actions[] =
     TRUE,
     GIMP_HELP_VIEW_COLOR_MANAGEMENT },
 
-  { "view-softproof-black-point-compensation", NULL,
-    NC_("view-action", "_Black Point Compensation"), NULL,
-    NC_("view-action", "Use black point compensation for soft-proofing"),
-    view_softproof_bpc_cmd_callback,
-    TRUE,
-    GIMP_HELP_VIEW_COLOR_MANAGEMENT },
-
   { "view-softproof-gamut-check", NULL,
     NC_("view-action", "_Mark Out Of Gamut Colors"), NULL,
     NC_("view-action", "When soft-proofing, mark colors which cannot "
@@ -580,33 +564,6 @@ static const GimpRadioActionEntry view_display_intent_actions[] =
     GIMP_HELP_VIEW_COLOR_MANAGEMENT }
 };
 
-static const GimpRadioActionEntry view_softproof_intent_actions[] =
-{
-  { "view-softproof-intent-perceptual", NULL,
-    NC_("view-action", "_Perceptual"), NULL,
-    NC_("view-action", "Soft-proofing rendering intent is perceptual"),
-    GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL,
-    GIMP_HELP_VIEW_COLOR_MANAGEMENT },
-
-  { "view-softproof-intent-relative-colorimetric", NULL,
-    NC_("view-action", "_Relative Colorimetric"), NULL,
-    NC_("view-action", "Soft-proofing rendering intent is relative colorimetric"),
-    GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC,
-    GIMP_HELP_VIEW_COLOR_MANAGEMENT },
-
-  { "view-softproof-intent-saturation", NULL,
-    NC_("view-action", "_Saturation"), NULL,
-    NC_("view-action", "Soft-proofing rendering intent is saturation"),
-    GIMP_COLOR_RENDERING_INTENT_SATURATION,
-    GIMP_HELP_VIEW_COLOR_MANAGEMENT },
-
-  { "view-softproof-intent-absolute-colorimetric", NULL,
-    NC_("view-action", "_Absolute Colorimetric"), NULL,
-    NC_("view-action", "Soft-proofing rendering intent is absolute colorimetric"),
-    GIMP_COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC,
-    GIMP_HELP_VIEW_COLOR_MANAGEMENT }
-};
-
 static const GimpEnumActionEntry view_padding_color_actions[] =
 {
   { "view-padding-color-theme", NULL,
@@ -775,13 +732,6 @@ view_actions_setup (GimpActionGroup *group)
                                        GIMP_COLOR_MANAGEMENT_DISPLAY,
                                        view_display_intent_cmd_callback);
 
-  gimp_action_group_add_radio_actions (group, "view-action",
-                                       view_softproof_intent_actions,
-                                       G_N_ELEMENTS (view_softproof_intent_actions),
-                                       NULL,
-                                       GIMP_COLOR_MANAGEMENT_DISPLAY,
-                                       view_softproof_intent_cmd_callback);
-
   gimp_action_group_add_enum_actions (group, "view-padding-color",
                                       view_padding_color_actions,
                                       G_N_ELEMENTS (view_padding_color_actions),
@@ -813,12 +763,6 @@ view_actions_setup (GimpActionGroup *group)
   g_signal_connect_object (group->gimp->config, "notify::check-type",
                            G_CALLBACK (view_actions_check_type_notify),
                            group, 0);
-  g_signal_connect_object (group->gimp->config, "notify::check-custom-color1",
-                           G_CALLBACK (view_actions_check_type_notify),
-                           group, 0);
-  g_signal_connect_object (group->gimp->config, "notify::check-custom-color2",
-                           G_CALLBACK (view_actions_check_type_notify),
-                           group, 0);
   view_actions_check_type_notify (GIMP_DISPLAY_CONFIG (group->gimp->config),
                                   NULL, group);
 
@@ -851,8 +795,7 @@ view_actions_update (GimpActionGroup *group,
   gboolean            cm                = FALSE;
   gboolean            sp                = FALSE;
   gboolean            d_bpc             = FALSE;
-  gboolean            s_bpc             = FALSE;
-  gboolean            gammut            = FALSE;
+  gboolean            gamut             = FALSE;
 
   if (display)
     {
@@ -913,30 +856,8 @@ view_actions_update (GimpActionGroup *group,
 
       gimp_action_group_set_action_active (group, action, TRUE);
 
-      switch (gimp_color_config_get_simulation_intent (color_config))
-        {
-        case GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL:
-          action = "view-softproof-intent-perceptual";
-          break;
-
-        case GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC:
-          action = "view-softproof-intent-relative-colorimetric";
-          break;
-
-        case GIMP_COLOR_RENDERING_INTENT_SATURATION:
-          action = "view-softproof-intent-saturation";
-          break;
-
-        case GIMP_COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC:
-          action = "view-softproof-intent-absolute-colorimetric";
-          break;
-        }
-
-      gimp_action_group_set_action_active (group, action, TRUE);
-
       d_bpc  = gimp_color_config_get_display_bpc (color_config);
-      s_bpc  = gimp_color_config_get_simulation_bpc (color_config);
-      gammut = gimp_color_config_get_simulation_gamut_check (color_config);
+      gamut  = gimp_color_config_get_simulation_gamut_check (color_config);
     }
 
 #define SET_ACTIVE(action,condition) \
@@ -1038,15 +959,7 @@ view_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("view-display-intent-absolute-colorimetric",   cm);
   SET_SENSITIVE ("view-display-black-point-compensation",       cm);
   SET_ACTIVE    ("view-display-black-point-compensation",       d_bpc);
-  SET_SENSITIVE ("view-softproof-profile",                      sp);
-  SET_SENSITIVE ("view-softproof-intent-perceptual",            sp);
-  SET_SENSITIVE ("view-softproof-intent-relative-colorimetric", sp);
-  SET_SENSITIVE ("view-softproof-intent-saturation",            sp);
-  SET_SENSITIVE ("view-softproof-intent-absolute-colorimetric", sp);
-  SET_SENSITIVE ("view-softproof-black-point-compensation",     sp);
-  SET_ACTIVE    ("view-softproof-black-point-compensation",     s_bpc);
-  SET_SENSITIVE ("view-softproof-gamut-check",                  sp);
-  SET_ACTIVE    ("view-softproof-gamut-check",                  gammut);
+  SET_ACTIVE    ("view-softproof-gamut-check",                  gamut);
   SET_SENSITIVE ("view-color-management-reset",                 image);
 
   SET_SENSITIVE ("view-show-selection",       image);
diff --git a/app/actions/view-commands.c b/app/actions/view-commands.c
index 0f6fdc0b7e..ecb0f4a129 100644
--- a/app/actions/view-commands.c
+++ b/app/actions/view-commands.c
@@ -76,13 +76,6 @@
 
 /*  local function prototypes  */
 
-static void   view_softproof_profile_callback  (GtkWidget                *dialog,
-                                                GimpImage                *image,
-                                                GimpColorProfile         *new_profile,
-                                                GFile                    *new_file,
-                                                GimpColorRenderingIntent  intent,
-                                                gboolean                  bpc,
-                                                gpointer                  user_data);
 static void   view_padding_color_dialog_update (GimpColorDialog          *dialog,
                                                 const GimpRGB            *color,
                                                 GimpColorDialogState      state,
@@ -737,94 +730,6 @@ view_display_bpc_cmd_callback (GimpAction *action,
     }
 }
 
-void
-view_softproof_profile_cmd_callback (GimpAction *action,
-                                     GVariant   *value,
-                                     gpointer    data)
-{
-  GimpImage        *image;
-  GimpDisplayShell *shell;
-  GimpColorConfig  *color_config;
-  GtkWidget        *dialog;
-  return_if_no_image (image, data);
-  return_if_no_shell (shell, data);
-
-  color_config = gimp_display_shell_get_color_config (shell);
-
-#define SOFTPROOF_PROFILE_DIALOG_KEY "gimp-softproof-profile-dialog"
-
-  dialog = dialogs_get_dialog (G_OBJECT (shell), SOFTPROOF_PROFILE_DIALOG_KEY);
-
-  if (! dialog)
-    {
-      GimpColorProfile *current_profile;
-
-      current_profile = gimp_color_config_get_simulation_color_profile (color_config,
-                                                                        NULL);
-
-      dialog = color_profile_dialog_new (COLOR_PROFILE_DIALOG_SELECT_SOFTPROOF_PROFILE,
-                                         image,
-                                         action_data_get_context (data),
-                                         GTK_WIDGET (shell),
-                                         current_profile,
-                                         NULL,
-                                         0, 0,
-                                         view_softproof_profile_callback,
-                                         shell);
-
-      dialogs_attach_dialog (G_OBJECT (shell),
-                             SOFTPROOF_PROFILE_DIALOG_KEY, dialog);
-    }
-
-  gtk_window_present (GTK_WINDOW (dialog));
-}
-
-void
-view_softproof_intent_cmd_callback (GimpAction *action,
-                                    GVariant   *value,
-                                    gpointer    data)
-{
-  GimpDisplayShell          *shell;
-  GimpColorConfig           *color_config;
-  GimpColorRenderingIntent   intent;
-  return_if_no_shell (shell, data);
-
-  intent = (GimpColorRenderingIntent) g_variant_get_int32 (value);
-
-  color_config = gimp_display_shell_get_color_config (shell);
-
-  if (intent != gimp_color_config_get_simulation_intent (color_config))
-    {
-      g_object_set (color_config,
-                    "simulation-rendering-intent", intent,
-                    NULL);
-      shell->color_config_set = TRUE;
-    }
-}
-
-void
-view_softproof_bpc_cmd_callback (GimpAction *action,
-                                 GVariant   *value,
-                                 gpointer    data)
-{
-  GimpDisplayShell *shell;
-  GimpColorConfig  *color_config;
-  gboolean          active;
-  return_if_no_shell (shell, data);
-
-  color_config = gimp_display_shell_get_color_config (shell);
-
-  active = g_variant_get_boolean (value);
-
-  if (active != gimp_color_config_get_simulation_bpc (color_config))
-    {
-      g_object_set (color_config,
-                    "simulation-use-black-point-compensation", active,
-                    NULL);
-      shell->color_config_set = TRUE;
-    }
-}
-
 void
 view_softproof_gamut_check_cmd_callback (GimpAction *action,
                                          GVariant   *value,
@@ -1247,32 +1152,6 @@ view_fullscreen_cmd_callback (GimpAction *action,
 
 /*  private functions  */
 
-static void
-view_softproof_profile_callback (GtkWidget                *dialog,
-                                 GimpImage                *image,
-                                 GimpColorProfile         *new_profile,
-                                 GFile                    *new_file,
-                                 GimpColorRenderingIntent  intent,
-                                 gboolean                  bpc,
-                                 gpointer                  user_data)
-{
-  GimpDisplayShell *shell = user_data;
-  GimpColorConfig  *color_config;
-  gchar            *path  = NULL;
-
-  color_config = gimp_display_shell_get_color_config (shell);
-
-  if (new_file)
-    path = g_file_get_path (new_file);
-
-  g_object_set (color_config,
-                "simulation-profile", path,
-                NULL);
-  shell->color_config_set = TRUE;
-
-  gtk_widget_destroy (dialog);
-}
-
 static void
 view_padding_color_dialog_update (GimpColorDialog      *dialog,
                                   const GimpRGB        *color,
diff --git a/app/actions/view-commands.h b/app/actions/view-commands.h
index b1c8d36679..51af901bb7 100644
--- a/app/actions/view-commands.h
+++ b/app/actions/view-commands.h
@@ -114,15 +114,6 @@ void   view_display_intent_cmd_callback             (GimpAction *action,
 void   view_display_bpc_cmd_callback                (GimpAction *action,
                                                      GVariant   *value,
                                                      gpointer    data);
-void   view_softproof_profile_cmd_callback          (GimpAction *action,
-                                                     GVariant   *value,
-                                                     gpointer    data);
-void   view_softproof_intent_cmd_callback           (GimpAction *action,
-                                                     GVariant   *value,
-                                                     gpointer    data);
-void   view_softproof_bpc_cmd_callback              (GimpAction *action,
-                                                     GVariant   *value,
-                                                     gpointer    data);
 void   view_softproof_gamut_check_cmd_callback      (GimpAction *action,
                                                      GVariant   *value,
                                                      gpointer    data);
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index a249e3dc4d..a161e36237 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -198,6 +198,11 @@ static GimpColorProfile *
 static void
         gimp_image_color_managed_profile_changed (GimpColorManaged  *managed);
 
+static GimpColorProfile *
+      gimp_image_color_managed_get_simulation_profile     (GimpColorManaged  *managed);
+static void
+      gimp_image_color_managed_simulation_profile_changed (GimpColorManaged  *managed);
+
 static void        gimp_image_projectable_flush  (GimpProjectable   *projectable,
                                                   gboolean           invalidate_preview);
 static GeglRectangle gimp_image_get_bounding_box (GimpProjectable   *projectable);
@@ -697,9 +702,11 @@ gimp_image_class_init (GimpImageClass *klass)
 static void
 gimp_color_managed_iface_init (GimpColorManagedInterface *iface)
 {
-  iface->get_icc_profile   = gimp_image_color_managed_get_icc_profile;
-  iface->get_color_profile = gimp_image_color_managed_get_color_profile;
-  iface->profile_changed   = gimp_image_color_managed_profile_changed;
+  iface->get_icc_profile            = gimp_image_color_managed_get_icc_profile;
+  iface->get_color_profile          = gimp_image_color_managed_get_color_profile;
+  iface->profile_changed            = gimp_image_color_managed_profile_changed;
+  iface->get_simulation_profile     = gimp_image_color_managed_get_simulation_profile;
+  iface->simulation_profile_changed = gimp_image_color_managed_simulation_profile_changed;
 }
 
 static void
@@ -1438,6 +1445,25 @@ gimp_image_color_managed_profile_changed (GimpColorManaged *managed)
   gimp_item_stack_profile_changed (layers);
 }
 
+static GimpColorProfile *
+gimp_image_color_managed_get_simulation_profile (GimpColorManaged *managed)
+{
+  GimpImage        *image = GIMP_IMAGE (managed);
+  GimpColorProfile *profile;
+
+  profile = gimp_image_get_simulation_profile (image);
+
+  return profile;
+}
+
+static void
+gimp_image_color_managed_simulation_profile_changed (GimpColorManaged *managed)
+{
+  GimpImage *image = GIMP_IMAGE (managed);
+
+  gimp_viewable_invalidate_preview (GIMP_VIEWABLE (image));
+}
+
 static void
 gimp_image_projectable_flush (GimpProjectable *projectable,
                               gboolean         invalidate_preview)
diff --git a/app/display/gimpdisplayshell-profile.c b/app/display/gimpdisplayshell-profile.c
index df6c4b144b..a7448b61d0 100644
--- a/app/display/gimpdisplayshell-profile.c
+++ b/app/display/gimpdisplayshell-profile.c
@@ -261,7 +261,7 @@ gimp_display_shell_color_config_notify (GimpColorConfig  *config,
           break;
         }
 
-      SET_ACTIVE ("view-color-management-enable",    managed);
+      SET_ACTIVE ("view-color-management-enable", managed);
       SET_ACTIVE ("view-color-management-softproof", softproof);
 
       switch (gimp_color_config_get_display_intent (config))
@@ -293,39 +293,6 @@ gimp_display_shell_color_config_notify (GimpColorConfig  *config,
       SET_SENSITIVE ("view-display-black-point-compensation", managed);
       SET_ACTIVE    ("view-display-black-point-compensation",
                      gimp_color_config_get_display_bpc (config));
-
-      SET_SENSITIVE ("view-softproof-profile", softproof);
-
-      switch (gimp_color_config_get_simulation_intent (config))
-        {
-        case GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL:
-          action = "view-softproof-intent-perceptual";
-          break;
-
-        case GIMP_COLOR_RENDERING_INTENT_RELATIVE_COLORIMETRIC:
-          action = "view-softproof-intent-relative-colorimetric";
-          break;
-
-        case GIMP_COLOR_RENDERING_INTENT_SATURATION:
-          action = "view-softproof-intent-saturation";
-          break;
-
-        case GIMP_COLOR_RENDERING_INTENT_ABSOLUTE_COLORIMETRIC:
-          action = "view-softproof-intent-absolute-colorimetric";
-          break;
-        }
-
-      SET_SENSITIVE ("view-softproof-intent-perceptual",            softproof);
-      SET_SENSITIVE ("view-softproof-intent-relative-colorimetric", softproof);
-      SET_SENSITIVE ("view-softproof-intent-saturation",            softproof);
-      SET_SENSITIVE ("view-softproof-intent-absolute-colorimetric", softproof);
-
-      SET_ACTIVE (action, TRUE);
-
-      SET_SENSITIVE ("view-softproof-black-point-compensation", softproof);
-      SET_ACTIVE    ("view-softproof-black-point-compensation",
-                     gimp_color_config_get_simulation_bpc (config));
-
       SET_SENSITIVE ("view-softproof-gamut-check", softproof);
       SET_ACTIVE    ("view-softproof-gamut-check",
                      gimp_color_config_get_simulation_gamut_check (config));
diff --git a/libgimpcolor/gimpcolor.def b/libgimpcolor/gimpcolor.def
index 47dbb99c57..01276ab7f1 100644
--- a/libgimpcolor/gimpcolor.def
+++ b/libgimpcolor/gimpcolor.def
@@ -21,8 +21,10 @@ EXPORTS
        gimp_cmyka_set_uchar
        gimp_color_managed_get_color_profile
        gimp_color_managed_get_icc_profile
+       gimp_color_managed_get_simulation_profile
        gimp_color_managed_get_type
        gimp_color_managed_profile_changed
+    gimp_color_managed_simulation_profile_changed
        gimp_color_profile_get_copyright
        gimp_color_profile_get_description
        gimp_color_profile_get_format
diff --git a/libgimpcolor/gimpcolormanaged.c b/libgimpcolor/gimpcolormanaged.c
index dca1fdbae8..586721865a 100644
--- a/libgimpcolor/gimpcolormanaged.c
+++ b/libgimpcolor/gimpcolormanaged.c
@@ -42,6 +42,7 @@
 enum
 {
   PROFILE_CHANGED,
+  SIMULATION_PROFILE_CHANGED,
   LAST_SIGNAL
 };
 
@@ -66,6 +67,15 @@ gimp_color_managed_default_init (GimpColorManagedInterface *iface)
                                    profile_changed),
                   NULL, NULL, NULL,
                   G_TYPE_NONE, 0);
+
+  gimp_color_managed_signals[SIMULATION_PROFILE_CHANGED] =
+    g_signal_new ("simulation-profile-changed",
+                  G_TYPE_FROM_INTERFACE (iface),
+                  G_SIGNAL_RUN_FIRST,
+                  G_STRUCT_OFFSET (GimpColorManagedInterface,
+                                   simulation_profile_changed),
+                  NULL, NULL, NULL,
+                  G_TYPE_NONE, 0);
 }
 
 
@@ -128,9 +138,34 @@ gimp_color_managed_get_color_profile (GimpColorManaged *managed)
 }
 
 /**
- * gimp_color_managed_profile_changed:
+ * gimp_color_managed_get_simulation_profile:
  * @managed: an object the implements the #GimpColorManaged interface
  *
+ * This function always returns a #GimpColorProfile
+ *
+ * Returns: (transfer full): The @managed's simulation #GimpColorProfile.
+ *
+ * Since: 3
+ **/
+GimpColorProfile *
+gimp_color_managed_get_simulation_profile (GimpColorManaged *managed)
+{
+  GimpColorManagedInterface *iface;
+
+  g_return_val_if_fail (GIMP_IS_COLOR_MANAGED (managed), NULL);
+
+  iface = GIMP_COLOR_MANAGED_GET_IFACE (managed);
+
+  if (iface->get_simulation_profile)
+    return iface->get_simulation_profile (managed);
+
+  return NULL;
+}
+
+/**
+ * gimp_color_managed_profile_changed:
+ * @managed: an object that implements the #GimpColorManaged interface
+ *
  * Emits the "profile-changed" signal.
  *
  * Since: 2.4
@@ -142,3 +177,19 @@ gimp_color_managed_profile_changed (GimpColorManaged *managed)
 
   g_signal_emit (managed, gimp_color_managed_signals[PROFILE_CHANGED], 0);
 }
+
+/**
+ * gimp_color_managed_simulation_profile_changed:
+ * @managed: an object that implements the #GimpColorManaged interface
+ *
+ * Emits the "simulation-profile-changed" signal.
+ *
+ * Since: 3.0
+ **/
+void
+gimp_color_managed_simulation_profile_changed (GimpColorManaged *managed)
+{
+  g_return_if_fail (GIMP_IS_COLOR_MANAGED (managed));
+
+  g_signal_emit (managed, gimp_color_managed_signals[SIMULATION_PROFILE_CHANGED], 0);
+}
diff --git a/libgimpcolor/gimpcolormanaged.h b/libgimpcolor/gimpcolormanaged.h
index b6a473b509..cf36ffad7c 100644
--- a/libgimpcolor/gimpcolormanaged.h
+++ b/libgimpcolor/gimpcolormanaged.h
@@ -43,6 +43,8 @@ G_DECLARE_INTERFACE (GimpColorManaged, gimp_color_managed, GIMP, COLOR_MANAGED,
  *                   has changed
  * @get_color_profile: Returns the #GimpColorProfile of the pixels managed
  *                     by the object
+ * @get_simulation_profile: Returns the simulation #GimpColorProfile of the
+ *                          pixels managed by the object
  **/
 struct _GimpColorManagedInterface
 {
@@ -58,22 +60,29 @@ struct _GimpColorManagedInterface
    *
    * Since: 2.4
    */
-  const guint8     * (* get_icc_profile)   (GimpColorManaged *managed,
-                                            gsize            *len);
+  const guint8     * (* get_icc_profile)            (GimpColorManaged *managed,
+                                                     gsize            *len);
 
   /*  signals  */
-  void               (* profile_changed)   (GimpColorManaged *managed);
+  void               (* profile_changed)            (GimpColorManaged *managed);
+
+  void               (* simulation_profile_changed) (GimpColorManaged *managed);
 
   /*  virtual functions  */
-  GimpColorProfile * (* get_color_profile) (GimpColorManaged *managed);
+  GimpColorProfile * (* get_color_profile)      (GimpColorManaged *managed);
+  GimpColorProfile * (* get_simulation_profile) (GimpColorManaged *managed);
 };
 
 
-const guint8     * gimp_color_managed_get_icc_profile   (GimpColorManaged *managed,
-                                                         gsize            *len);
-GimpColorProfile * gimp_color_managed_get_color_profile (GimpColorManaged *managed);
+const guint8     * gimp_color_managed_get_icc_profile            (GimpColorManaged *managed,
+                                                                  gsize            *len);
+GimpColorProfile * gimp_color_managed_get_color_profile          (GimpColorManaged *managed);
+
+GimpColorProfile * gimp_color_managed_get_simulation_profile     (GimpColorManaged *managed);
+
+void               gimp_color_managed_profile_changed            (GimpColorManaged *managed);
 
-void               gimp_color_managed_profile_changed   (GimpColorManaged *managed);
+void               gimp_color_managed_simulation_profile_changed (GimpColorManaged *managed);
 
 
 G_END_DECLS
diff --git a/menus/image-menu.xml.in b/menus/image-menu.xml.in
index f9b7b5c262..4216acf6b3 100644
--- a/menus/image-menu.xml.in
+++ b/menus/image-menu.xml.in
@@ -320,16 +320,7 @@
        </menu>
         <menuitem action="view-display-black-point-compensation" />
         <separator />
-        <menuitem action="view-softproof-profile" />
-       <menu action="view-softproof-intent-menu" name="Softproof Rendering Intent">
-          <menuitem action="view-softproof-intent-perceptual" />
-          <menuitem action="view-softproof-intent-relative-colorimetric" />
-          <menuitem action="view-softproof-intent-saturation" />
-          <menuitem action="view-softproof-intent-absolute-colorimetric" />
-       </menu>
-        <menuitem action="view-softproof-black-point-compensation" />
         <menuitem action="view-softproof-gamut-check" />
-        <separator />
         <menuitem action="view-color-management-reset" />
       </menu>
       <separator />
@@ -394,6 +385,16 @@
         <menuitem action="image-color-profile-discard" />
         <separator />
         <menuitem action="image-color-profile-save" />
+        <separator />
+        <menuitem action="image-softproof-profile" />
+        <separator />
+    <menu action="image-softproof-intent-menu" name="Softproof Rendering Intent">
+          <menuitem action="image-softproof-intent-perceptual" />
+          <menuitem action="image-softproof-intent-relative-colorimetric" />
+          <menuitem action="image-softproof-intent-saturation" />
+          <menuitem action="image-softproof-intent-absolute-colorimetric" />
+       </menu>
+        <menuitem action="image-softproof-black-point-compensation" />
      </menu>
       <separator />
       <menu action="image-transform-menu" name="Transform">


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