[gimp] app: simplify display update when the color management config changes



commit 9775b2083bee295016d613fac2ed257188055d35
Author: Michael Natterer <mitch gimp org>
Date:   Wed Sep 2 20:55:48 2015 +0200

    app: simplify display update when the color management config changes
    
    gimp_image_constructed(): connect to "notify" on GimpColorConfig
    and call gimp_color_managed_profile_changed() on the image.
    
    Remove the "notify" handler on GimpColorConfig from
    gimpdisplayshell-handlers.c because it already connects to the
    image's "profile-changed" signal.
    
    Additionally, implement GimpColorManaged::profile_changed() in
    GimpImage and invalidate the image and all layer previews. One step
    closer to color managing image and layer previews.

 app/core/gimpimage.c                    |   17 +++++++++++++++++
 app/display/gimpdisplayshell-handlers.c |   21 ---------------------
 2 files changed, 17 insertions(+), 21 deletions(-)
---
diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c
index 833a5d4..b7f99ec 100644
--- a/app/core/gimpimage.c
+++ b/app/core/gimpimage.c
@@ -182,6 +182,8 @@ static const guint8 *
                                                   gsize             *len);
 static GimpColorProfile *
       gimp_image_color_managed_get_color_profile (GimpColorManaged  *managed);
+static void
+        gimp_image_color_managed_profile_changed (GimpColorManaged  *managed);
 
 static void        gimp_image_projectable_flush  (GimpProjectable   *projectable,
                                                   gboolean           invalidate_preview);
@@ -635,6 +637,7 @@ 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;
 }
 
 static void
@@ -825,6 +828,10 @@ gimp_image_constructed (GObject *object)
                            G_CALLBACK (gimp_viewable_size_changed),
                            image, G_CONNECT_SWAPPED);
 
+  g_signal_connect_object (config->color_management, "notify",
+                           G_CALLBACK (gimp_color_managed_profile_changed),
+                           image, G_CONNECT_SWAPPED);
+
   gimp_container_add (image->gimp->images, GIMP_OBJECT (image));
 }
 
@@ -1396,6 +1403,16 @@ gimp_image_color_managed_get_color_profile (GimpColorManaged *managed)
 }
 
 static void
+gimp_image_color_managed_profile_changed (GimpColorManaged *managed)
+{
+  GimpImage     *image  = GIMP_IMAGE (managed);
+  GimpItemStack *layers = GIMP_ITEM_STACK (gimp_image_get_layers (image));
+
+  gimp_viewable_invalidate_preview (GIMP_VIEWABLE (image));
+  gimp_item_stack_invalidate_previews (layers);
+}
+
+static void
 gimp_image_projectable_flush (GimpProjectable *projectable,
                               gboolean         invalidate_preview)
 {
diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c
index 9849d65..37c218e 100644
--- a/app/display/gimpdisplayshell-handlers.c
+++ b/app/display/gimpdisplayshell-handlers.c
@@ -165,9 +165,6 @@ 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  */
@@ -360,11 +357,6 @@ gimp_display_shell_connect (GimpDisplayShell *shell)
                     G_CALLBACK (gimp_display_shell_quality_notify_handler),
                     shell);
 
-  g_signal_connect (GIMP_CORE_CONFIG (shell->display->config)->color_management,
-                    "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),
@@ -395,10 +387,6 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell)
   gimp_canvas_layer_boundary_set_layer (GIMP_CANVAS_LAYER_BOUNDARY (shell->layer_boundary),
                                         NULL);
 
-  g_signal_handlers_disconnect_by_func (GIMP_CORE_CONFIG (shell->display->config)->color_management,
-                                        gimp_display_shell_color_config_notify_handler,
-                                        shell);
-
   g_signal_handlers_disconnect_by_func (shell->display->config,
                                         gimp_display_shell_quality_notify_handler,
                                         shell);
@@ -1073,12 +1061,3 @@ 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)
-{
-  gimp_display_shell_profile_update (shell);
-  gimp_display_shell_expose_full (shell);
-}


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