[gimp] app: add a GimpColorConfig to GimpDisplayShell



commit af976a75c35f2f998554829cab863ece71660b8b
Author: Michael Natterer <mitch gimp org>
Date:   Sat May 14 00:56:26 2016 +0200

    app: add a GimpColorConfig to GimpDisplayShell
    
    Use the shell's color config for color managing the display and
    various auxiliary widgets attached to it, like the notebook tab widget
    and navigation popup.
    
    The config is currently just a reference to the global prefs config,
    so no behavior changed.

 app/display/gimpdisplayshell-filter-dialog.c |   10 ++-----
 app/display/gimpdisplayshell-filter.c        |    7 +----
 app/display/gimpdisplayshell-filter.h        |    3 +-
 app/display/gimpdisplayshell-layer-select.c  |   33 +++++++++++++++-----------
 app/display/gimpdisplayshell-profile.c       |    7 +----
 app/display/gimpdisplayshell.c               |   21 ++++++++++++++--
 app/display/gimpdisplayshell.h               |    5 ++++
 app/display/gimpimagewindow.c                |    3 ++
 app/display/gimpnavigationeditor.c           |    2 +
 9 files changed, 53 insertions(+), 38 deletions(-)
---
diff --git a/app/display/gimpdisplayshell-filter-dialog.c b/app/display/gimpdisplayshell-filter-dialog.c
index bdaa9be..cdd9fdc 100644
--- a/app/display/gimpdisplayshell-filter-dialog.c
+++ b/app/display/gimpdisplayshell-filter-dialog.c
@@ -25,10 +25,8 @@
 
 #include "display-types.h"
 
-#include "config/gimpcoreconfig.h"
-
 #include "core/gimp.h"
-#include "core/gimpimage.h"
+#include "core/gimpviewable.h"
 
 #include "widgets/gimpcolordisplayeditor.h"
 #include "widgets/gimphelp-ids.h"
@@ -65,15 +63,13 @@ static void gimp_display_shell_filter_dialog_free     (ColorDisplayDialog *cdd);
 GtkWidget *
 gimp_display_shell_filter_dialog_new (GimpDisplayShell *shell)
 {
-  GimpDisplayConfig  *config;
   GimpImage          *image;
   ColorDisplayDialog *cdd;
   GtkWidget          *editor;
 
   g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
 
-  config = shell->display->config;
-  image  = gimp_display_get_image (shell->display);
+  image = gimp_display_get_image (shell->display);
 
   cdd = g_slice_new0 (ColorDisplayDialog);
 
@@ -123,7 +119,7 @@ gimp_display_shell_filter_dialog_new (GimpDisplayShell *shell)
     }
 
   editor = gimp_color_display_editor_new (shell->filter_stack,
-                                          GIMP_CORE_CONFIG (config)->color_management,
+                                          gimp_display_shell_get_color_config (shell),
                                           GIMP_COLOR_MANAGED (shell));
   gtk_container_set_border_width (GTK_CONTAINER (editor), 12);
   gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (cdd->dialog))),
diff --git a/app/display/gimpdisplayshell-filter.c b/app/display/gimpdisplayshell-filter.c
index b1fa583..bb69b3b 100644
--- a/app/display/gimpdisplayshell-filter.c
+++ b/app/display/gimpdisplayshell-filter.c
@@ -20,13 +20,10 @@
 #include <gegl.h>
 #include <gtk/gtk.h>
 
-#include "libgimpconfig/gimpconfig.h"
 #include "libgimpwidgets/gimpwidgets.h"
 
 #include "display-types.h"
 
-#include "config/gimpcoreconfig.h"
-
 #include "gimpdisplayshell.h"
 #include "gimpdisplayshell-expose.h"
 #include "gimpdisplayshell-filter.h"
@@ -83,11 +80,9 @@ gimp_display_shell_has_filter (GimpDisplayShell *shell)
 }
 
 GimpColorDisplayStack *
-gimp_display_shell_filter_new (GimpDisplayShell *shell,
-                               GimpColorConfig  *config)
+gimp_display_shell_filter_new (GimpDisplayShell *shell)
 {
   g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
-  g_return_val_if_fail (GIMP_IS_COLOR_CONFIG (config), NULL);
 
 #if 0
   /*  disabled because we use gimpdisplayshell-profile now, keep
diff --git a/app/display/gimpdisplayshell-filter.h b/app/display/gimpdisplayshell-filter.h
index af22c3d..aa49027 100644
--- a/app/display/gimpdisplayshell-filter.h
+++ b/app/display/gimpdisplayshell-filter.h
@@ -25,8 +25,7 @@ void       gimp_display_shell_filter_set (GimpDisplayShell      *shell,
 gboolean   gimp_display_shell_has_filter (GimpDisplayShell      *shell);
 
 GimpColorDisplayStack *
-           gimp_display_shell_filter_new (GimpDisplayShell      *shell,
-                                          GimpColorConfig       *config);
+           gimp_display_shell_filter_new (GimpDisplayShell      *shell);
 
 
 #endif /* __GIMP_DISPLAY_SHELL_FILTER_H__ */
diff --git a/app/display/gimpdisplayshell-layer-select.c b/app/display/gimpdisplayshell-layer-select.c
index 55a69fc..0b52dcb 100644
--- a/app/display/gimpdisplayshell-layer-select.c
+++ b/app/display/gimpdisplayshell-layer-select.c
@@ -33,6 +33,7 @@
 #include "core/gimplayer.h"
 
 #include "widgets/gimpview.h"
+#include "widgets/gimpviewrenderer.h"
 
 #include "gimpdisplay.h"
 #include "gimpdisplayshell.h"
@@ -54,16 +55,17 @@ typedef struct
 
 /*  local function prototypes  */
 
-static LayerSelect * layer_select_new       (GimpImage   *image,
-                                             GimpLayer   *layer,
-                                             gint         view_size);
-static void          layer_select_destroy   (LayerSelect *layer_select,
-                                             guint32      time);
-static void          layer_select_advance   (LayerSelect *layer_select,
-                                             gint         move);
-static gboolean      layer_select_events    (GtkWidget   *widget,
-                                             GdkEvent    *event,
-                                             LayerSelect *layer_select);
+static LayerSelect * layer_select_new       (GimpDisplayShell *shell,
+                                             GimpImage        *image,
+                                             GimpLayer        *layer,
+                                             gint              view_size);
+static void          layer_select_destroy   (LayerSelect      *layer_select,
+                                             guint32           time);
+static void          layer_select_advance   (LayerSelect      *layer_select,
+                                             gint              move);
+static gboolean      layer_select_events    (GtkWidget        *widget,
+                                             GdkEvent         *event,
+                                             LayerSelect      *layer_select);
 
 
 /*  public functions  */
@@ -86,7 +88,7 @@ gimp_display_shell_layer_select_init (GimpDisplayShell *shell,
   if (! layer)
     return;
 
-  layer_select = layer_select_new (image, layer,
+  layer_select = layer_select_new (shell, image, layer,
                                    image->gimp->config->layer_preview_size);
   layer_select_advance (layer_select, move);
 
@@ -102,9 +104,10 @@ gimp_display_shell_layer_select_init (GimpDisplayShell *shell,
 /*  private functions  */
 
 static LayerSelect *
-layer_select_new (GimpImage *image,
-                  GimpLayer *layer,
-                  gint       view_size)
+layer_select_new (GimpDisplayShell *shell,
+                  GimpImage        *image,
+                  GimpLayer        *layer,
+                  gint              view_size)
 {
   LayerSelect *layer_select;
   GtkWidget   *frame1;
@@ -155,6 +158,8 @@ layer_select_new (GimpImage *image,
                             GIMP_TYPE_VIEW,
                             GIMP_TYPE_LAYER,
                             view_size, 1, FALSE);
+  gimp_view_renderer_set_color_config (GIMP_VIEW (layer_select->view)->renderer,
+                                       gimp_display_shell_get_color_config (shell));
   gimp_view_set_viewable (GIMP_VIEW (layer_select->view),
                           GIMP_VIEWABLE (layer));
   gtk_container_add (GTK_CONTAINER (alignment), layer_select->view);
diff --git a/app/display/gimpdisplayshell-profile.c b/app/display/gimpdisplayshell-profile.c
index 3bb5557..745b7ad 100644
--- a/app/display/gimpdisplayshell-profile.c
+++ b/app/display/gimpdisplayshell-profile.c
@@ -30,8 +30,6 @@
 
 #include "display-types.h"
 
-#include "config/gimpcoreconfig.h"
-
 #include "gegl/gimp-babl.h"
 
 #include "core/gimpimage.h"
@@ -70,7 +68,6 @@ void
 gimp_display_shell_profile_update (GimpDisplayShell *shell)
 {
   GimpImage        *image;
-  GimpColorConfig  *config;
   GimpColorProfile *src_profile;
   const Babl       *src_format;
   const Babl       *dest_format;
@@ -84,8 +81,6 @@ gimp_display_shell_profile_update (GimpDisplayShell *shell)
   if (! image)
     return;
 
-  config = GIMP_CORE_CONFIG (shell->display->config)->color_management;
-
   src_profile = gimp_color_managed_get_color_profile (GIMP_COLOR_MANAGED (shell));
 
   if (! src_profile)
@@ -112,7 +107,7 @@ gimp_display_shell_profile_update (GimpDisplayShell *shell)
 
   shell->profile_transform =
     gimp_widget_get_color_transform (gtk_widget_get_toplevel (GTK_WIDGET (shell)),
-                                     config,
+                                     gimp_display_shell_get_color_config (shell),
                                      src_profile,
                                      &src_format,
                                      &dest_format);
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 5aa2478..4a777e2 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -405,6 +405,8 @@ 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);
+
   if (image)
     {
       image_width  = gimp_image_get_width  (image);
@@ -745,10 +747,9 @@ gimp_display_shell_constructed (GObject *object)
 
   gtk_widget_show (GTK_WIDGET (shell->canvas));
 
-  /*  add display filter for color management  */
+  /*  add display filters  */
 
-  filter = gimp_display_shell_filter_new (shell,
-                                          GIMP_CORE_CONFIG (config)->color_management);
+  filter = gimp_display_shell_filter_new (shell);
 
   if (filter)
     {
@@ -816,6 +817,12 @@ 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);
 
   if (shell->filter_buffer)
@@ -1377,6 +1384,14 @@ gimp_display_shell_get_statusbar (GimpDisplayShell *shell)
   return GIMP_STATUSBAR (shell->statusbar);
 }
 
+GimpColorConfig *
+gimp_display_shell_get_color_config (GimpDisplayShell *shell)
+{
+  g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
+
+  return shell->color_config;
+}
+
 void
 gimp_display_shell_present (GimpDisplayShell *shell)
 {
diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h
index 33692bc..8310baf 100644
--- a/app/display/gimpdisplayshell.h
+++ b/app/display/gimpdisplayshell.h
@@ -150,6 +150,8 @@ struct _GimpDisplayShell
   GtkWidget         *nav_popup;        /*  navigation popup                   */
   GtkWidget         *grid_dialog;      /*  grid configuration dialog          */
 
+  GimpColorConfig   *color_config;     /*  color management settings          */
+
   GimpColorTransform profile_transform;
   const Babl        *profile_src_format;
   const Babl        *profile_dest_format;
@@ -253,6 +255,9 @@ void              gimp_display_shell_move_overlay  (GimpDisplayShell   *shell,
 GimpImageWindow * gimp_display_shell_get_window    (GimpDisplayShell   *shell);
 GimpStatusbar   * gimp_display_shell_get_statusbar (GimpDisplayShell   *shell);
 
+GimpColorConfig * gimp_display_shell_get_color_config
+                                                   (GimpDisplayShell   *shell);
+
 void              gimp_display_shell_present       (GimpDisplayShell   *shell);
 
 void              gimp_display_shell_reconnect     (GimpDisplayShell   *shell);
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 9914b24..47baf91 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -54,6 +54,7 @@
 #include "widgets/gimptoolbox.h"
 #include "widgets/gimpuimanager.h"
 #include "widgets/gimpview.h"
+#include "widgets/gimpviewrenderer.h"
 #include "widgets/gimpwidgets-utils.h"
 
 #include "gimpdisplay.h"
@@ -2297,6 +2298,8 @@ gimp_image_window_create_tab_label (GimpImageWindow  *window,
                                  GIMP_TYPE_VIEW, GIMP_TYPE_IMAGE,
                                  GIMP_VIEW_SIZE_LARGE, 0, FALSE);
   gtk_widget_set_size_request (view, GIMP_VIEW_SIZE_LARGE, -1);
+  gimp_view_renderer_set_color_config (GIMP_VIEW (view)->renderer,
+                                       gimp_display_shell_get_color_config (shell));
   gtk_box_pack_start (GTK_BOX (hbox), view, FALSE, FALSE, 0);
   gtk_widget_show (view);
 
diff --git a/app/display/gimpnavigationeditor.c b/app/display/gimpnavigationeditor.c
index 33a2e61..02390d2 100644
--- a/app/display/gimpnavigationeditor.c
+++ b/app/display/gimpnavigationeditor.c
@@ -365,6 +365,8 @@ gimp_navigation_editor_new_private (GimpMenuFactory  *menu_factory,
                                    view->renderer->border_width);
       gimp_view_renderer_set_context (view->renderer,
                                       gimp_get_user_context (gimp));
+      gimp_view_renderer_set_color_config (view->renderer,
+                                           gimp_display_shell_get_color_config (shell));
 
       gimp_navigation_editor_set_shell (editor, shell);
 


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