[gimp] Bug 320447 - fast switching between "color managed display" and "softproof"



commit 406d1b9c6579d59b23b95bac6400b214e8b1526f
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 14 23:50:58 2016 +0200

    Bug 320447 - fast switching between "color managed display" and "softproof"
    
    Add a View -> Color Management submenu that allows to change
    the color management mode per-display.
    
    Internally, keep a GimpColorConfig object around per-display that
    is synchronized with the global config except for the properties
    that have a per-display GUI (currently the mode).
    
    Also provide an "As in Preferences" menu item to follow the global
    settings again.

 app/actions/view-actions.c              |   65 +++++++++++++
 app/actions/view-commands.c             |   42 ++++++++
 app/actions/view-commands.h             |  161 ++++++++++++++++---------------
 app/display/gimpdisplayshell-handlers.c |  125 ++++++++++++++++++------
 app/display/gimpdisplayshell-profile.c  |  100 ++++++++++++++++---
 app/display/gimpdisplayshell-profile.h  |    4 +-
 app/display/gimpdisplayshell.c          |   10 +--
 app/display/gimpdisplayshell.h          |    1 +
 app/widgets/gimphelp-ids.h              |    1 +
 9 files changed, 379 insertions(+), 130 deletions(-)
---
diff --git a/app/actions/view-actions.c b/app/actions/view-actions.c
index 75899d1..bf6cff0 100644
--- a/app/actions/view-actions.c
+++ b/app/actions/view-actions.c
@@ -22,6 +22,7 @@
 
 #include "libgimpmath/gimpmath.h"
 #include "libgimpcolor/gimpcolor.h"
+#include "libgimpconfig/gimpconfig.h"
 #include "libgimpwidgets/gimpwidgets.h"
 
 #include "actions-types.h"
@@ -70,6 +71,10 @@ static const GimpActionEntry view_actions[] =
   { "view-zoom-menu",           NULL, NC_("view-action", "_Zoom")          },
   { "view-rotate-menu",         NULL, NC_("view-action", "_Flip & Rotate") },
   { "view-padding-color-menu",  NULL, NC_("view-action", "_Padding Color") },
+
+  { "view-color-management-menu", NULL,
+    NC_("view-action", "_Color Management") },
+
   { "view-move-to-screen-menu", GIMP_STOCK_MOVE_TO_SCREEN,
     NC_("view-action", "Move to Screen"), NULL, NULL, NULL,
     GIMP_HELP_VIEW_CHANGE_SCREEN },
@@ -128,6 +133,13 @@ static const GimpActionEntry view_actions[] =
     G_CALLBACK (view_display_filters_cmd_callback),
     GIMP_HELP_DISPLAY_FILTER_DIALOG },
 
+  { "view-color-management-reset", GIMP_STOCK_RESET,
+    NC_("view-action", "As in _Preferences"), NULL,
+    NC_("view-action",
+        "Reset color management to what's configured in preferences"),
+    G_CALLBACK (view_color_management_reset_cmd_callback),
+    GIMP_HELP_VIEW_COLOR_MANAGEMENT },
+
   { "view-shrink-wrap", "zoom-fit-best",
     NC_("view-action", "Shrink _Wrap"), "<primary>J",
     NC_("view-action", "Reduce the image window to the size of the image display"),
@@ -457,6 +469,27 @@ static const GimpEnumActionEntry view_rotate_relative_actions[] =
     GIMP_HELP_VIEW_ROTATE_345 }
 };
 
+static const GimpRadioActionEntry view_color_management_mode_actions[] =
+{
+  { "view-color-management-mode-off", NULL,
+    NC_("view-action", "_No Color Management"), NULL,
+    NC_("view-action", "Don't color manage this view"),
+    GIMP_COLOR_MANAGEMENT_OFF,
+    GIMP_HELP_VIEW_COLOR_MANAGEMENT },
+
+  { "view-color-management-mode-display", NULL,
+    NC_("view-action", "_Color Managed Display"), NULL,
+    NC_("view-action", "Color manage this view"),
+    GIMP_COLOR_MANAGEMENT_DISPLAY,
+    GIMP_HELP_VIEW_COLOR_MANAGEMENT },
+
+  { "view-color-management-mode-softproof", NULL,
+    NC_("view-action", "_Print Simulation"), NULL,
+    NC_("view-action", "Use this view for softproofing"),
+    GIMP_COLOR_MANAGEMENT_SOFTPROOF,
+    GIMP_HELP_VIEW_COLOR_MANAGEMENT }
+};
+
 static const GimpEnumActionEntry view_padding_color_actions[] =
 {
   { "view-padding-color-theme", NULL,
@@ -607,6 +640,13 @@ view_actions_setup (GimpActionGroup *group)
                                       G_N_ELEMENTS (view_rotate_relative_actions),
                                       G_CALLBACK (view_rotate_relative_cmd_callback));
 
+  gimp_action_group_add_radio_actions (group, "view-action",
+                                       view_color_management_mode_actions,
+                                       G_N_ELEMENTS (view_color_management_mode_actions),
+                                       NULL,
+                                       GIMP_COLOR_MANAGEMENT_DISPLAY,
+                                       G_CALLBACK (view_color_management_mode_cmd_callback));
+
   gimp_action_group_add_enum_actions (group, "view-padding-color",
                                       view_padding_color_actions,
                                       G_N_ELEMENTS (view_padding_color_actions),
@@ -657,6 +697,7 @@ view_actions_update (GimpActionGroup *group,
   GimpImage          *image             = NULL;
   GimpDisplayShell   *shell             = NULL;
   GimpDisplayOptions *options           = NULL;
+  GimpColorConfig    *color_config      = NULL;
   gchar              *label             = NULL;
   gboolean            fullscreen        = FALSE;
   gboolean            revert_enabled    = FALSE;   /* able to revert zoom? */
@@ -666,6 +707,7 @@ view_actions_update (GimpActionGroup *group,
   if (display)
     {
       GimpImageWindow *window;
+      const gchar     *action = NULL;
 
       image  = gimp_display_get_image (display);
       shell  = gimp_display_get_shell (display);
@@ -682,6 +724,24 @@ view_actions_update (GimpActionGroup *group,
 
       flip_horizontally = shell->flip_horizontally;
       flip_vertically   = shell->flip_vertically;
+
+      color_config = gimp_display_shell_get_color_config (shell);
+
+      switch (color_config->mode)
+        {
+        case GIMP_COLOR_MANAGEMENT_OFF:
+          action = "view-color-management-mode-off";
+          break;
+
+        case GIMP_COLOR_MANAGEMENT_DISPLAY:
+          action = "view-color-management-mode-display";
+          break;
+        case GIMP_COLOR_MANAGEMENT_SOFTPROOF:
+          action = "view-color-management-mode-softproof";
+          break;
+        }
+
+      gimp_action_group_set_action_active (group, action, TRUE);
     }
 
 #define SET_ACTIVE(action,condition) \
@@ -765,6 +825,11 @@ view_actions_update (GimpActionGroup *group,
   SET_SENSITIVE ("view-navigation-window", image);
   SET_SENSITIVE ("view-display-filters",   image);
 
+  SET_SENSITIVE ("view-color-management-mode-off",       image);
+  SET_SENSITIVE ("view-color-management-mode-display",   image);
+  SET_SENSITIVE ("view-color-management-mode-softproof", image);
+  SET_SENSITIVE ("view-color-management-reset",          image);
+
   SET_SENSITIVE ("view-show-selection",      image);
   SET_ACTIVE    ("view-show-selection",      display && options->show_selection);
   SET_SENSITIVE ("view-show-layer-boundary", image);
diff --git a/app/actions/view-commands.c b/app/actions/view-commands.c
index 08e0a41..2041074 100644
--- a/app/actions/view-commands.c
+++ b/app/actions/view-commands.c
@@ -21,6 +21,7 @@
 #include <gtk/gtk.h>
 
 #include "libgimpmath/gimpmath.h"
+#include "libgimpconfig/gimpconfig.h"
 #include "libgimpwidgets/gimpwidgets.h"
 
 #include "actions-types.h"
@@ -486,6 +487,47 @@ view_display_filters_cmd_callback (GtkAction *action,
 }
 
 void
+view_color_management_reset_cmd_callback (GtkAction *action,
+                                          gpointer   data)
+{
+  GimpDisplayShell *shell;
+  GimpColorConfig  *global_config;
+  GimpColorConfig  *shell_config;
+  return_if_no_shell (shell, data);
+
+  global_config = GIMP_CORE_CONFIG (shell->display->config)->color_management;
+  shell_config  = gimp_display_shell_get_color_config (shell);
+
+  gimp_config_copy (GIMP_CONFIG (global_config),
+                    GIMP_CONFIG (shell_config),
+                    0);
+  shell->color_config_set = FALSE;
+}
+
+void
+view_color_management_mode_cmd_callback (GtkAction *action,
+                                         GtkAction *current,
+                                         gpointer   data)
+{
+  GimpDisplayShell        *shell;
+  GimpColorConfig         *color_config;
+  GimpColorManagementMode  value;
+  return_if_no_shell (shell, data);
+
+  color_config = gimp_display_shell_get_color_config (shell);
+
+  value = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+
+  if (value != color_config->mode)
+    {
+      g_object_set (color_config,
+                    "mode", value,
+                    NULL);
+      shell->color_config_set = TRUE;
+    }
+}
+
+void
 view_toggle_selection_cmd_callback (GtkAction *action,
                                     gpointer   data)
 {
diff --git a/app/actions/view-commands.h b/app/actions/view-commands.h
index 91b3a3a..3af3289 100644
--- a/app/actions/view-commands.h
+++ b/app/actions/view-commands.h
@@ -19,90 +19,97 @@
 #define __VIEW_COMMANDS_H__
 
 
-void   view_new_cmd_callback                   (GtkAction *action,
-                                                gpointer   data);
-void   view_close_cmd_callback                 (GtkAction *action,
-                                                gpointer   data);
+void   view_new_cmd_callback                    (GtkAction *action,
+                                                 gpointer   data);
+void   view_close_cmd_callback                  (GtkAction *action,
+                                                 gpointer   data);
 
-void   view_zoom_fit_in_cmd_callback           (GtkAction *action,
-                                                gpointer   data);
-void   view_zoom_fill_cmd_callback             (GtkAction *action,
-                                                gpointer   data);
-void   view_zoom_selection_cmd_callback        (GtkAction *action,
-                                                gpointer   data);
-void   view_zoom_revert_cmd_callback           (GtkAction *action,
-                                                gpointer   data);
-void   view_zoom_cmd_callback                  (GtkAction *action,
-                                                gint       value,
-                                                gpointer   data);
-void   view_zoom_explicit_cmd_callback         (GtkAction *action,
-                                                GtkAction *current,
-                                                gpointer   data);
-void   view_zoom_other_cmd_callback            (GtkAction *action,
-                                                gpointer   data);
-void   view_dot_for_dot_cmd_callback           (GtkAction *action,
-                                                gpointer   data);
+void   view_zoom_fit_in_cmd_callback            (GtkAction *action,
+                                                 gpointer   data);
+void   view_zoom_fill_cmd_callback              (GtkAction *action,
+                                                 gpointer   data);
+void   view_zoom_selection_cmd_callback         (GtkAction *action,
+                                                 gpointer   data);
+void   view_zoom_revert_cmd_callback            (GtkAction *action,
+                                                 gpointer   data);
+void   view_zoom_cmd_callback                   (GtkAction *action,
+                                                 gint       value,
+                                                 gpointer   data);
+void   view_zoom_explicit_cmd_callback          (GtkAction *action,
+                                                 GtkAction *current,
+                                                 gpointer   data);
+void   view_zoom_other_cmd_callback             (GtkAction *action,
+                                                 gpointer   data);
+void   view_dot_for_dot_cmd_callback            (GtkAction *action,
+                                                 gpointer   data);
 
-void   view_scroll_horizontal_cmd_callback     (GtkAction *action,
-                                                gint       value,
-                                                gpointer   data);
-void   view_scroll_vertical_cmd_callback       (GtkAction *action,
-                                                gint       value,
-                                                gpointer   data);
+void   view_scroll_horizontal_cmd_callback      (GtkAction *action,
+                                                 gint       value,
+                                                 gpointer   data);
+void   view_scroll_vertical_cmd_callback        (GtkAction *action,
+                                                 gint       value,
+                                                 gpointer   data);
 
-void   view_flip_horizontally_cmd_callback     (GtkAction *action,
-                                                gpointer   data);
-void   view_flip_vertically_cmd_callback       (GtkAction *action,
-                                                gpointer   data);
+void   view_flip_horizontally_cmd_callback      (GtkAction *action,
+                                                 gpointer   data);
+void   view_flip_vertically_cmd_callback        (GtkAction *action,
+                                                 gpointer   data);
 
-void   view_rotate_absolute_cmd_callback       (GtkAction *action,
-                                                gint       value,
-                                                gpointer   data);
-void   view_rotate_relative_cmd_callback       (GtkAction *action,
-                                                gint       value,
-                                                gpointer   data);
-void   view_rotate_other_cmd_callback          (GtkAction *action,
-                                                gpointer   data);
+void   view_rotate_absolute_cmd_callback        (GtkAction *action,
+                                                 gint       value,
+                                                 gpointer   data);
+void   view_rotate_relative_cmd_callback        (GtkAction *action,
+                                                 gint       value,
+                                                 gpointer   data);
+void   view_rotate_other_cmd_callback           (GtkAction *action,
+                                                 gpointer   data);
 
-void   view_navigation_window_cmd_callback     (GtkAction *action,
-                                                gpointer   data);
-void   view_display_filters_cmd_callback       (GtkAction *action,
-                                                gpointer   data);
-void   view_toggle_selection_cmd_callback      (GtkAction *action,
-                                                gpointer   data);
-void   view_toggle_layer_boundary_cmd_callback (GtkAction *action,
-                                                gpointer   data);
-void   view_toggle_menubar_cmd_callback        (GtkAction *action,
-                                                gpointer   data);
-void   view_toggle_rulers_cmd_callback         (GtkAction *action,
-                                                gpointer   data);
-void   view_toggle_scrollbars_cmd_callback     (GtkAction *action,
-                                                gpointer   data);
-void   view_toggle_statusbar_cmd_callback      (GtkAction *action,
-                                                gpointer   data);
-void   view_toggle_guides_cmd_callback         (GtkAction *action,
-                                                gpointer   data);
-void   view_toggle_grid_cmd_callback           (GtkAction *action,
-                                                gpointer   data);
-void   view_toggle_sample_points_cmd_callback  (GtkAction *action,
-                                                gpointer   data);
+void   view_navigation_window_cmd_callback      (GtkAction *action,
+                                                 gpointer   data);
+void   view_display_filters_cmd_callback        (GtkAction *action,
+                                                 gpointer   data);
 
-void   view_snap_to_guides_cmd_callback        (GtkAction *action,
-                                                gpointer   data);
-void   view_snap_to_grid_cmd_callback          (GtkAction *action,
-                                                gpointer   data);
-void   view_snap_to_canvas_cmd_callback        (GtkAction *action,
-                                                gpointer   data);
-void   view_snap_to_vectors_cmd_callback       (GtkAction *action,
-                                                gpointer   data);
-void   view_padding_color_cmd_callback         (GtkAction *action,
-                                                gint       value,
-                                                gpointer   data);
+void   view_color_management_reset_cmd_callback (GtkAction *action,
+                                                 gpointer   data);
+void   view_color_management_mode_cmd_callback  (GtkAction *action,
+                                                 GtkAction *current,
+                                                 gpointer   data);
 
-void   view_shrink_wrap_cmd_callback           (GtkAction *action,
-                                                gpointer   data);
-void   view_fullscreen_cmd_callback            (GtkAction *action,
-                                                gpointer   data);
+void   view_toggle_selection_cmd_callback       (GtkAction *action,
+                                                 gpointer   data);
+void   view_toggle_layer_boundary_cmd_callback  (GtkAction *action,
+                                                 gpointer   data);
+void   view_toggle_menubar_cmd_callback         (GtkAction *action,
+                                                 gpointer   data);
+void   view_toggle_rulers_cmd_callback          (GtkAction *action,
+                                                 gpointer   data);
+void   view_toggle_scrollbars_cmd_callback      (GtkAction *action,
+                                                 gpointer   data);
+void   view_toggle_statusbar_cmd_callback       (GtkAction *action,
+                                                 gpointer   data);
+void   view_toggle_guides_cmd_callback          (GtkAction *action,
+                                                 gpointer   data);
+void   view_toggle_grid_cmd_callback            (GtkAction *action,
+                                                 gpointer   data);
+void   view_toggle_sample_points_cmd_callback   (GtkAction *action,
+                                                 gpointer   data);
+
+void   view_snap_to_guides_cmd_callback         (GtkAction *action,
+                                                 gpointer   data);
+void   view_snap_to_grid_cmd_callback           (GtkAction *action,
+                                                 gpointer   data);
+void   view_snap_to_canvas_cmd_callback         (GtkAction *action,
+                                                 gpointer   data);
+void   view_snap_to_vectors_cmd_callback        (GtkAction *action,
+                                                 gpointer   data);
+void   view_padding_color_cmd_callback          (GtkAction *action,
+                                                 gint       value,
+                                                 gpointer   data);
+
+void   view_shrink_wrap_cmd_callback            (GtkAction *action,
+                                                 gpointer   data);
+void   view_fullscreen_cmd_callback             (GtkAction *action,
+                                                 gpointer   data);
 
 
 #endif /* __VIEW_COMMANDS_H__ */
diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c
index 2f0f3af..42ead42 100644
--- a/app/display/gimpdisplayshell-handlers.c
+++ b/app/display/gimpdisplayshell-handlers.c
@@ -22,6 +22,7 @@
 
 #include "libgimpbase/gimpbase.h"
 #include "libgimpcolor/gimpcolor.h"
+#include "libgimpconfig/gimpconfig.h"
 #include "libgimpmath/gimpmath.h"
 #include "libgimpwidgets/gimpwidgets.h"
 
@@ -167,6 +168,9 @@ static void   gimp_display_shell_ants_speed_notify_handler  (GObject          *c
 static void   gimp_display_shell_quality_notify_handler     (GObject          *config,
                                                              GParamSpec       *param_spec,
                                                              GimpDisplayShell *shell);
+static void  gimp_display_shell_color_config_notify_handler (GObject          *config,
+                                                             GParamSpec       *param_spec,
+                                                             GimpDisplayShell *shell);
 
 
 /*  public functions  */
@@ -174,18 +178,24 @@ static void   gimp_display_shell_quality_notify_handler     (GObject          *c
 void
 gimp_display_shell_connect (GimpDisplayShell *shell)
 {
-  GimpImage     *image;
-  GimpContainer *vectors;
-  GList         *list;
+  GimpImage         *image;
+  GimpContainer     *vectors;
+  GimpDisplayConfig *config;
+  GimpColorConfig   *color_config;
+  GList             *list;
 
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
   g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
 
-  image   = gimp_display_get_image (shell->display);
-  vectors = gimp_image_get_vectors (image);
+  image = gimp_display_get_image (shell->display);
 
   g_return_if_fail (GIMP_IS_IMAGE (image));
 
+  vectors = gimp_image_get_vectors (image);
+
+  config       = shell->display->config;
+  color_config = GIMP_CORE_CONFIG (config)->color_management;
+
   g_signal_connect (image, "clean",
                     G_CALLBACK (gimp_display_shell_clean_dirty_handler),
                     shell);
@@ -298,71 +308,78 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
       gimp_display_shell_vectors_add_handler (vectors, list->data, shell);
     }
 
-  g_signal_connect (shell->display->config,
+  g_signal_connect (config,
                     "notify::transparency-size",
                     G_CALLBACK (gimp_display_shell_check_notify_handler),
                     shell);
-  g_signal_connect (shell->display->config,
+  g_signal_connect (config,
                     "notify::transparency-type",
                     G_CALLBACK (gimp_display_shell_check_notify_handler),
                     shell);
 
-  g_signal_connect (shell->display->config,
+  g_signal_connect (config,
                     "notify::image-title-format",
                     G_CALLBACK (gimp_display_shell_title_notify_handler),
                     shell);
-  g_signal_connect (shell->display->config,
+  g_signal_connect (config,
                     "notify::image-status-format",
                     G_CALLBACK (gimp_display_shell_title_notify_handler),
                     shell);
-  g_signal_connect (shell->display->config,
+  g_signal_connect (config,
                     "notify::navigation-preview-size",
                     G_CALLBACK (gimp_display_shell_nav_size_notify_handler),
                     shell);
-  g_signal_connect (shell->display->config,
+  g_signal_connect (config,
                     "notify::monitor-resolution-from-windowing-system",
                     G_CALLBACK (gimp_display_shell_monitor_res_notify_handler),
                     shell);
-  g_signal_connect (shell->display->config,
+  g_signal_connect (config,
                     "notify::monitor-xresolution",
                     G_CALLBACK (gimp_display_shell_monitor_res_notify_handler),
                     shell);
-  g_signal_connect (shell->display->config,
+  g_signal_connect (config,
                     "notify::monitor-yresolution",
                     G_CALLBACK (gimp_display_shell_monitor_res_notify_handler),
                     shell);
 
-  g_signal_connect (shell->display->config->default_view,
+  g_signal_connect (config->default_view,
                     "notify::padding-mode",
                     G_CALLBACK (gimp_display_shell_padding_notify_handler),
                     shell);
-  g_signal_connect (shell->display->config->default_view,
+  g_signal_connect (config->default_view,
                     "notify::padding-color",
                     G_CALLBACK (gimp_display_shell_padding_notify_handler),
                     shell);
-  g_signal_connect (shell->display->config->default_fullscreen_view,
+  g_signal_connect (config->default_fullscreen_view,
                     "notify::padding-mode",
                     G_CALLBACK (gimp_display_shell_padding_notify_handler),
                     shell);
-  g_signal_connect (shell->display->config->default_fullscreen_view,
+  g_signal_connect (config->default_fullscreen_view,
                     "notify::padding-color",
                     G_CALLBACK (gimp_display_shell_padding_notify_handler),
                     shell);
 
-  g_signal_connect (shell->display->config,
+  g_signal_connect (config,
                     "notify::marching-ants-speed",
                     G_CALLBACK (gimp_display_shell_ants_speed_notify_handler),
                     shell);
 
-  g_signal_connect (shell->display->config,
+  g_signal_connect (config,
                     "notify::zoom-quality",
                     G_CALLBACK (gimp_display_shell_quality_notify_handler),
                     shell);
 
+  g_signal_connect (color_config, "notify",
+                    G_CALLBACK (gimp_display_shell_color_config_notify_handler),
+                    shell);
+
   gimp_display_shell_invalidate_preview_handler (image, shell);
   gimp_display_shell_quick_mask_changed_handler (image, shell);
   gimp_display_shell_profile_changed_handler    (GIMP_COLOR_MANAGED (image),
                                                  shell);
+  gimp_display_shell_color_config_notify_handler (G_OBJECT (color_config),
+                                                  NULL, /* sync all */
+                                                  shell);
 
   gimp_canvas_layer_boundary_set_layer (GIMP_CANVAS_LAYER_BOUNDARY (shell->layer_boundary),
                                         gimp_image_get_active_layer (image));
@@ -371,9 +388,11 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
 void
 gimp_display_shell_disconnect (GimpDisplayShell *shell)
 {
-  GimpImage     *image;
-  GimpContainer *vectors;
-  GList         *list;
+  GimpImage         *image;
+  GimpContainer     *vectors;
+  GimpDisplayConfig *config;
+  GimpColorConfig   *color_config;
+  GList             *list;
 
   g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
   g_return_if_fail (GIMP_IS_DISPLAY (shell->display));
@@ -384,33 +403,41 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
 
   vectors = gimp_image_get_vectors (image);
 
+  config       = shell->display->config;
+  color_config = GIMP_CORE_CONFIG (config)->color_management;
+
   gimp_display_shell_icon_update_stop (shell);
 
   gimp_canvas_layer_boundary_set_layer (GIMP_CANVAS_LAYER_BOUNDARY (shell->layer_boundary),
                                         NULL);
 
-  g_signal_handlers_disconnect_by_func (shell->display->config,
+  g_signal_handlers_disconnect_by_func (color_config,
+                                        gimp_display_shell_color_config_notify_handler,
+                                        shell);
+  shell->color_config_set = FALSE;
+
+  g_signal_handlers_disconnect_by_func (config,
                                         gimp_display_shell_quality_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (shell->display->config,
+  g_signal_handlers_disconnect_by_func (config,
                                         gimp_display_shell_ants_speed_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (shell->display->config->default_fullscreen_view,
+  g_signal_handlers_disconnect_by_func (config->default_fullscreen_view,
                                         gimp_display_shell_padding_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (shell->display->config->default_view,
+  g_signal_handlers_disconnect_by_func (config->default_view,
                                         gimp_display_shell_padding_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (shell->display->config,
+  g_signal_handlers_disconnect_by_func (config,
                                         gimp_display_shell_monitor_res_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (shell->display->config,
+  g_signal_handlers_disconnect_by_func (config,
                                         gimp_display_shell_nav_size_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (shell->display->config,
+  g_signal_handlers_disconnect_by_func (config,
                                         gimp_display_shell_title_notify_handler,
                                         shell);
-  g_signal_handlers_disconnect_by_func (shell->display->config,
+  g_signal_handlers_disconnect_by_func (config,
                                         gimp_display_shell_check_notify_handler,
                                         shell);
 
@@ -1089,3 +1116,41 @@ gimp_display_shell_quality_notify_handler (GObject          *config,
 {
   gimp_display_shell_expose_full (shell);
 }
+
+static void
+gimp_display_shell_color_config_notify_handler (GObject          *config,
+                                                GParamSpec       *param_spec,
+                                                GimpDisplayShell *shell)
+{
+  if (param_spec)
+    {
+      gboolean copy = TRUE;
+
+      if (! strcmp (param_spec->name, "mode"))
+        {
+          if (shell->color_config_set)
+            copy = FALSE;
+        }
+
+      if (copy)
+        {
+          GValue value = G_VALUE_INIT;
+
+          g_value_init (&value, param_spec->value_type);
+
+          g_object_get_property (config,
+                                 param_spec->name, &value);
+          g_object_set_property (G_OBJECT (shell->color_config),
+                                 param_spec->name, &value);
+
+          g_value_unset (&value);
+        }
+    }
+  else
+    {
+      gimp_config_copy (GIMP_CONFIG (config),
+                        GIMP_CONFIG (shell->color_config),
+                        0);
+      shell->color_config_set = FALSE;
+    }
+}
diff --git a/app/display/gimpdisplayshell-profile.c b/app/display/gimpdisplayshell-profile.c
index 745b7ad..190ecdf 100644
--- a/app/display/gimpdisplayshell-profile.c
+++ b/app/display/gimpdisplayshell-profile.c
@@ -30,6 +30,8 @@
 
 #include "display-types.h"
 
+#include "config/gimpcoreconfig.h"
+
 #include "gegl/gimp-babl.h"
 
 #include "core/gimpimage.h"
@@ -37,6 +39,7 @@
 
 #include "gimpdisplay.h"
 #include "gimpdisplayshell.h"
+#include "gimpdisplayshell-actions.h"
 #include "gimpdisplayshell-filter.h"
 #include "gimpdisplayshell-profile.h"
 #include "gimpdisplayxfer.h"
@@ -44,24 +47,41 @@
 #include "gimp-intl.h"
 
 
+/*  local function prototypes  */
+
+static void   gimp_display_shell_profile_free        (GimpDisplayShell *shell);
+
+static void   gimp_display_shell_color_config_notify (GimpColorConfig  *config,
+                                                      const GParamSpec *pspec,
+                                                      GimpDisplayShell *shell);
+
+
+/*  public functions  */
+
 void
-gimp_display_shell_profile_dispose (GimpDisplayShell *shell)
+gimp_display_shell_profile_init (GimpDisplayShell *shell)
 {
-  if (shell->profile_transform)
-    {
-      cmsDeleteTransform (shell->profile_transform);
-      shell->profile_transform   = NULL;
-      shell->profile_src_format  = NULL;
-      shell->profile_dest_format = NULL;
-    }
+  GimpColorConfig *color_config;
 
-  if (shell->profile_buffer)
+  color_config = GIMP_CORE_CONFIG (shell->display->config)->color_management;
+
+  shell->color_config = gimp_config_duplicate (GIMP_CONFIG (color_config));
+
+  g_signal_connect (shell->color_config, "notify",
+                    G_CALLBACK (gimp_display_shell_color_config_notify),
+                    shell);
+}
+
+void
+gimp_display_shell_profile_finalize (GimpDisplayShell *shell)
+{
+  if (shell->color_config)
     {
-      g_object_unref (shell->profile_buffer);
-      shell->profile_buffer = NULL;
-      shell->profile_data   = NULL;
-      shell->profile_stride = 0;
+      g_object_unref (shell->color_config);
+      shell->color_config = NULL;
     }
+
+  gimp_display_shell_profile_free (shell);
 }
 
 void
@@ -72,7 +92,7 @@ gimp_display_shell_profile_update (GimpDisplayShell *shell)
   const Babl       *src_format;
   const Babl       *dest_format;
 
-  gimp_display_shell_profile_dispose (shell);
+  gimp_display_shell_profile_free (shell);
 
   image = gimp_display_get_image (shell->display);
 
@@ -201,3 +221,55 @@ gimp_display_shell_profile_convert_buffer (GimpDisplayShell *shell,
                       iter->length);
     }
 }
+
+
+/*  private functions  */
+
+static void
+gimp_display_shell_profile_free (GimpDisplayShell *shell)
+{
+  if (shell->profile_transform)
+    {
+      cmsDeleteTransform (shell->profile_transform);
+      shell->profile_transform   = NULL;
+      shell->profile_src_format  = NULL;
+      shell->profile_dest_format = NULL;
+    }
+
+  if (shell->profile_buffer)
+    {
+      g_object_unref (shell->profile_buffer);
+      shell->profile_buffer = NULL;
+      shell->profile_data   = NULL;
+      shell->profile_stride = 0;
+    }
+}
+
+static void
+gimp_display_shell_color_config_notify (GimpColorConfig  *config,
+                                        const GParamSpec *pspec,
+                                        GimpDisplayShell *shell)
+{
+  if (! strcmp (pspec->name, "mode"))
+    {
+      const gchar *action = NULL;
+
+      switch (config->mode)
+        {
+        case GIMP_COLOR_MANAGEMENT_OFF:
+          action = "view-color-management-mode-off";
+          break;
+
+        case GIMP_COLOR_MANAGEMENT_DISPLAY:
+          action = "view-color-management-mode-display";
+          break;
+        case GIMP_COLOR_MANAGEMENT_SOFTPROOF:
+          action = "view-color-management-mode-softproof";
+          break;
+        }
+
+      gimp_display_shell_set_action_active (shell, action, TRUE);
+    }
+
+  gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (shell));
+}
diff --git a/app/display/gimpdisplayshell-profile.h b/app/display/gimpdisplayshell-profile.h
index a961f6c..8730b92 100644
--- a/app/display/gimpdisplayshell-profile.h
+++ b/app/display/gimpdisplayshell-profile.h
@@ -19,7 +19,9 @@
 #define __GIMP_DISPLAY_SHELL_PROFILE_H__
 
 
-void     gimp_display_shell_profile_dispose           (GimpDisplayShell *shell);
+void     gimp_display_shell_profile_init              (GimpDisplayShell *shell);
+void     gimp_display_shell_profile_finalize          (GimpDisplayShell *shell);
+
 void     gimp_display_shell_profile_update            (GimpDisplayShell *shell);
 
 gboolean gimp_display_shell_profile_can_convert_to_u8 (GimpDisplayShell *shell);
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 4a777e2..0c79ea0 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -405,7 +405,7 @@ gimp_display_shell_constructed (GObject *object)
   config = shell->display->config;
   image  = gimp_display_get_image (shell->display);
 
-  shell->color_config = g_object_ref (GIMP_CORE_CONFIG (config)->color_management);
+  gimp_display_shell_profile_init (shell);
 
   if (image)
     {
@@ -817,13 +817,7 @@ gimp_display_shell_dispose (GObject *object)
       shell->checkerboard = NULL;
     }
 
-  if (shell->color_config)
-    {
-      g_object_unref (shell->color_config);
-      shell->color_config = NULL;
-    }
-
-  gimp_display_shell_profile_dispose (shell);
+  gimp_display_shell_profile_finalize (shell);
 
   if (shell->filter_buffer)
     {
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index 8310baf..30fa249 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -151,6 +151,7 @@ struct _GimpDisplayShell
   GtkWidget         *grid_dialog;      /*  grid configuration dialog          */
 
   GimpColorConfig   *color_config;     /*  color management settings          */
+  gboolean           color_config_set; /*  settings changed from defaults     */
 
   GimpColorTransform profile_transform;
   const Babl        *profile_src_format;
diff --git a/app/widgets/gimphelp-ids.h b/app/widgets/gimphelp-ids.h
index e82a003..ebcc1a1 100644
--- a/app/widgets/gimphelp-ids.h
+++ b/app/widgets/gimphelp-ids.h
@@ -98,6 +98,7 @@
 #define GIMP_HELP_VIEW_ROTATE_270                 "gimp-view-rotate-270"
 #define GIMP_HELP_VIEW_ROTATE_345                 "gimp-view-rotate-345"
 #define GIMP_HELP_VIEW_ROTATE_OTHER               "gimp-view-rotate-other"
+#define GIMP_HELP_VIEW_COLOR_MANAGEMENT           "gimp-view-color-management"
 #define GIMP_HELP_VIEW_SHOW_SELECTION             "gimp-view-show-selection"
 #define GIMP_HELP_VIEW_SHOW_LAYER_BOUNDARY        "gimp-view-show-layer-boundary"
 #define GIMP_HELP_VIEW_SHOW_GUIDES                "gimp-view-show-guides"


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