[gimp] libgimpwidgets, app: have all previews track the monitor they are on



commit 3ed305f6f542cb2ead1ca619030bf014609a0c31
Author: Michael Natterer <mitch gimp org>
Date:   Wed Jun 1 22:38:58 2016 +0200

    libgimpwidgets, app: have all previews track the monitor they are on
    
    and update their color transforms with the new monitor's color
    profile. A widget is considered changing monitors when its toplevel
    window's center crosses, in order to let widgets within one window
    have consistent colors.

 app/widgets/gimpcontainertreeview.c |   35 +++++++
 app/widgets/gimpfgbgeditor.c        |  178 ++++++++++++++++++-----------------
 app/widgets/gimpfgbgview.c          |  151 +++++++++++++++--------------
 app/widgets/gimpview.c              |   17 +++-
 app/widgets/gimpviewrenderer.c      |   38 ++++----
 app/widgets/gimpviewrenderer.h      |    2 +-
 libgimpwidgets/gimpcolorarea.c      |   53 +++++------
 libgimpwidgets/gimpcolorscale.c     |  106 ++++++++++-----------
 libgimpwidgets/gimppreviewarea.c    |  101 ++++++++++----------
 modules/color-selector-water.c      |   94 +++++++++----------
 modules/gimpcolorwheel.c            |  104 ++++++++++-----------
 11 files changed, 456 insertions(+), 423 deletions(-)
---
diff --git a/app/widgets/gimpcontainertreeview.c b/app/widgets/gimpcontainertreeview.c
index 4aec04f..f56fa4f 100644
--- a/app/widgets/gimpcontainertreeview.c
+++ b/app/widgets/gimpcontainertreeview.c
@@ -132,6 +132,8 @@ static void          gimp_container_tree_view_expand_rows         (GtkTreeModel
                                                                    GtkTreeView              *view,
                                                                    GtkTreeIter              *parent);
 
+static void          gimp_container_tree_view_monitor_changed     (GimpContainerTreeView    *view);
+
 
 G_DEFINE_TYPE_WITH_CODE (GimpContainerTreeView, gimp_container_tree_view,
                          GIMP_TYPE_CONTAINER_BOX,
@@ -224,6 +226,10 @@ gimp_container_tree_view_init (GimpContainerTreeView *tree_view)
                                        GTK_SHADOW_IN);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (box->scrolled_win),
                                   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+  gimp_widget_track_monitor (GTK_WIDGET (tree_view),
+                             G_CALLBACK (gimp_container_tree_view_monitor_changed),
+                             NULL);
 }
 
 static void
@@ -1476,3 +1482,32 @@ gimp_container_tree_view_expand_rows (GtkTreeModel *model,
         }
     while (gtk_tree_model_iter_next (model, &iter));
 }
+
+static gboolean
+gimp_container_tree_view_monitor_changed_foreach (GtkTreeModel *model,
+                                                  GtkTreePath  *path,
+                                                  GtkTreeIter  *iter,
+                                                  gpointer      data)
+{
+  GimpViewRenderer *renderer;
+
+  gtk_tree_model_get (model, iter,
+                      GIMP_CONTAINER_TREE_STORE_COLUMN_RENDERER, &renderer,
+                      -1);
+
+  if (renderer)
+    {
+      gimp_view_renderer_free_color_transform (renderer);
+      g_object_unref (renderer);
+    }
+
+  return FALSE;
+}
+
+static void
+gimp_container_tree_view_monitor_changed (GimpContainerTreeView *view)
+{
+  gtk_tree_model_foreach (view->model,
+                          gimp_container_tree_view_monitor_changed_foreach,
+                          NULL);
+}
diff --git a/app/widgets/gimpfgbgeditor.c b/app/widgets/gimpfgbgeditor.c
index 2eec591..e5c4ef1 100644
--- a/app/widgets/gimpfgbgeditor.c
+++ b/app/widgets/gimpfgbgeditor.c
@@ -64,42 +64,41 @@ typedef enum
 } FgBgTarget;
 
 
-static void     gimp_fg_bg_editor_dispose         (GObject          *object);
-static void     gimp_fg_bg_editor_set_property    (GObject          *object,
-                                                   guint             property_id,
-                                                   const GValue     *value,
-                                                   GParamSpec       *pspec);
-static void     gimp_fg_bg_editor_get_property    (GObject          *object,
-                                                   guint             property_id,
-                                                   GValue           *value,
-                                                   GParamSpec       *pspec);
-
-static void     gimp_fg_bg_editor_style_set       (GtkWidget        *widget,
-                                                   GtkStyle         *prev_style);
-static gboolean gimp_fg_bg_editor_expose          (GtkWidget        *widget,
-                                                   GdkEventExpose   *eevent);
-static gboolean gimp_fg_bg_editor_button_press    (GtkWidget        *widget,
-                                                   GdkEventButton   *bevent);
-static gboolean gimp_fg_bg_editor_button_release  (GtkWidget        *widget,
-                                                   GdkEventButton   *bevent);
-static gboolean gimp_fg_bg_editor_drag_motion     (GtkWidget        *widget,
-                                                   GdkDragContext   *context,
-                                                   gint              x,
-                                                   gint              y,
-                                                   guint             time);
-
-static void     gimp_fg_bg_editor_drag_color      (GtkWidget        *widget,
-                                                   GimpRGB          *color,
-                                                   gpointer          data);
-static void     gimp_fg_bg_editor_drop_color      (GtkWidget        *widget,
-                                                   gint              x,
-                                                   gint              y,
-                                                   const GimpRGB    *color,
-                                                   gpointer          data);
-
-static void     gimp_fg_bg_editor_config_notify   (GimpColorConfig  *config,
-                                                   const GParamSpec *pspec,
-                                                   GimpFgBgEditor   *editor);
+static void     gimp_fg_bg_editor_dispose           (GObject          *object);
+static void     gimp_fg_bg_editor_set_property      (GObject          *object,
+                                                     guint             property_id,
+                                                     const GValue     *value,
+                                                     GParamSpec       *pspec);
+static void     gimp_fg_bg_editor_get_property      (GObject          *object,
+                                                     guint             property_id,
+                                                     GValue           *value,
+                                                     GParamSpec       *pspec);
+
+static void     gimp_fg_bg_editor_style_set         (GtkWidget        *widget,
+                                                     GtkStyle         *prev_style);
+static gboolean gimp_fg_bg_editor_expose            (GtkWidget        *widget,
+                                                     GdkEventExpose   *eevent);
+static gboolean gimp_fg_bg_editor_button_press      (GtkWidget        *widget,
+                                                     GdkEventButton   *bevent);
+static gboolean gimp_fg_bg_editor_button_release    (GtkWidget        *widget,
+                                                     GdkEventButton   *bevent);
+static gboolean gimp_fg_bg_editor_drag_motion       (GtkWidget        *widget,
+                                                     GdkDragContext   *context,
+                                                     gint              x,
+                                                     gint              y,
+                                                     guint             time);
+
+static void     gimp_fg_bg_editor_drag_color        (GtkWidget        *widget,
+                                                     GimpRGB          *color,
+                                                     gpointer          data);
+static void     gimp_fg_bg_editor_drop_color        (GtkWidget        *widget,
+                                                     gint              x,
+                                                     gint              y,
+                                                     const GimpRGB    *color,
+                                                     gpointer          data);
+
+static void     gimp_fg_bg_editor_create_transform  (GimpFgBgEditor   *editor);
+static void     gimp_fg_bg_editor_destroy_transform (GimpFgBgEditor   *editor);
 
 
 G_DEFINE_TYPE (GimpFgBgEditor, gimp_fg_bg_editor, GTK_TYPE_DRAWING_AREA)
@@ -152,7 +151,6 @@ gimp_fg_bg_editor_class_init (GimpFgBgEditorClass *klass)
 static void
 gimp_fg_bg_editor_init (GimpFgBgEditor *editor)
 {
-  editor->context      = NULL;
   editor->active_color = GIMP_ACTIVE_COLOR_FOREGROUND;
 
   gtk_widget_add_events (GTK_WIDGET (editor),
@@ -163,6 +161,10 @@ gimp_fg_bg_editor_init (GimpFgBgEditor *editor)
                              gimp_fg_bg_editor_drag_color, NULL);
   gimp_dnd_color_dest_add (GTK_WIDGET (editor),
                            gimp_fg_bg_editor_drop_color, NULL);
+
+  gimp_widget_track_monitor (GTK_WIDGET (editor),
+                             G_CALLBACK (gimp_fg_bg_editor_destroy_transform),
+                             NULL);
 }
 
 static void
@@ -331,20 +333,7 @@ gimp_fg_bg_editor_expose (GtkWidget      *widget,
 
 
   if (! editor->transform)
-    {
-      static GimpColorProfile *profile = NULL;
-
-      if (G_UNLIKELY (! profile))
-        profile = gimp_color_profile_new_rgb_srgb ();
-
-      editor->transform =
-        gimp_widget_get_color_transform (widget,
-                                         editor->color_config,
-                                         profile,
-                                         babl_format ("R'G'B'A double"),
-                                         babl_format ("R'G'B'A double"));
-    }
-
+    gimp_fg_bg_editor_create_transform (editor);
 
   /*  draw the background area  */
 
@@ -569,46 +558,46 @@ gimp_fg_bg_editor_set_context (GimpFgBgEditor *editor,
   g_return_if_fail (GIMP_IS_FG_BG_EDITOR (editor));
   g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));
 
-  if (context == editor->context)
-    return;
-
-  if (editor->context)
+  if (context != editor->context)
     {
-      g_signal_handlers_disconnect_by_func (editor->context,
-                                            gtk_widget_queue_draw,
-                                            editor);
-      g_object_unref (editor->context);
-
-      g_signal_handlers_disconnect_by_func (editor->color_config,
-                                            gimp_fg_bg_editor_config_notify,
-                                            editor);
-      g_object_unref (editor->color_config);
-      editor->color_config = NULL;
-    }
+      if (editor->context)
+        {
+          g_signal_handlers_disconnect_by_func (editor->context,
+                                                gtk_widget_queue_draw,
+                                                editor);
+          g_object_unref (editor->context);
+
+          g_signal_handlers_disconnect_by_func (editor->color_config,
+                                                gimp_fg_bg_editor_destroy_transform,
+                                                editor);
+          g_object_unref (editor->color_config);
+          editor->color_config = NULL;
+        }
 
-  editor->context = context;
+      editor->context = context;
 
-  if (context)
-    {
-      g_object_ref (context);
+      if (context)
+        {
+          g_object_ref (context);
 
-      g_signal_connect_swapped (context, "foreground-changed",
-                                G_CALLBACK (gtk_widget_queue_draw),
-                                editor);
-      g_signal_connect_swapped (context, "background-changed",
-                                G_CALLBACK (gtk_widget_queue_draw),
-                                editor);
+          g_signal_connect_swapped (context, "foreground-changed",
+                                    G_CALLBACK (gtk_widget_queue_draw),
+                                    editor);
+          g_signal_connect_swapped (context, "background-changed",
+                                    G_CALLBACK (gtk_widget_queue_draw),
+                                    editor);
 
-      editor->color_config = g_object_ref (context->gimp->config->color_management);
+          editor->color_config = g_object_ref (context->gimp->config->color_management);
 
-      g_signal_connect (editor->color_config, "notify",
-                        G_CALLBACK (gimp_fg_bg_editor_config_notify),
-                        editor);
-    }
+          g_signal_connect_swapped (editor->color_config, "notify",
+                                    G_CALLBACK (gimp_fg_bg_editor_destroy_transform),
+                                    editor);
+        }
 
-  gimp_fg_bg_editor_config_notify (NULL, NULL, editor);
+      gimp_fg_bg_editor_destroy_transform (editor);
 
-  g_object_notify (G_OBJECT (editor), "context");
+      g_object_notify (G_OBJECT (editor), "context");
+    }
 }
 
 void
@@ -675,9 +664,26 @@ gimp_fg_bg_editor_drop_color (GtkWidget     *widget,
 }
 
 static void
-gimp_fg_bg_editor_config_notify (GimpColorConfig  *config,
-                                 const GParamSpec *pspec,
-                                 GimpFgBgEditor   *editor)
+gimp_fg_bg_editor_create_transform (GimpFgBgEditor *editor)
+{
+  if (editor->color_config)
+    {
+      static GimpColorProfile *profile = NULL;
+
+      if (G_UNLIKELY (! profile))
+        profile = gimp_color_profile_new_rgb_srgb ();
+
+      editor->transform =
+        gimp_widget_get_color_transform (GTK_WIDGET (editor),
+                                         editor->color_config,
+                                         profile,
+                                         babl_format ("R'G'B'A double"),
+                                         babl_format ("R'G'B'A double"));
+    }
+}
+
+static void
+gimp_fg_bg_editor_destroy_transform (GimpFgBgEditor *editor)
 {
   if (editor->transform)
     {
diff --git a/app/widgets/gimpfgbgview.c b/app/widgets/gimpfgbgview.c
index 3874c57..f893100 100644
--- a/app/widgets/gimpfgbgview.c
+++ b/app/widgets/gimpfgbgview.c
@@ -47,22 +47,22 @@ enum
 };
 
 
-static void     gimp_fg_bg_view_dispose       (GObject          *object);
-static void     gimp_fg_bg_view_set_property  (GObject          *object,
-                                               guint             property_id,
-                                               const GValue     *value,
-                                               GParamSpec       *pspec);
-static void     gimp_fg_bg_view_get_property  (GObject          *object,
-                                               guint             property_id,
-                                               GValue           *value,
-                                               GParamSpec       *pspec);
-
-static gboolean gimp_fg_bg_view_expose        (GtkWidget        *widget,
-                                               GdkEventExpose   *eevent);
-
-static void     gimp_fg_bg_view_config_notify (GimpColorConfig  *config,
-                                               const GParamSpec *pspec,
-                                               GimpFgBgView     *view);
+static void     gimp_fg_bg_view_dispose           (GObject        *object);
+static void     gimp_fg_bg_view_set_property      (GObject        *object,
+                                                   guint           property_id,
+                                                   const GValue   *value,
+                                                   GParamSpec     *pspec);
+static void     gimp_fg_bg_view_get_property      (GObject        *object,
+                                                   guint           property_id,
+                                                   GValue         *value,
+                                                   GParamSpec     *pspec);
+
+static gboolean gimp_fg_bg_view_expose            (GtkWidget      *widget,
+                                                   GdkEventExpose *eevent);
+
+static void     gimp_fg_bg_view_create_transform  (GimpFgBgView   *view);
+static void     gimp_fg_bg_view_destroy_transform (GimpFgBgView   *view);
+
 
 G_DEFINE_TYPE (GimpFgBgView, gimp_fg_bg_view, GTK_TYPE_WIDGET)
 
@@ -93,7 +93,9 @@ gimp_fg_bg_view_init (GimpFgBgView *view)
 {
   gtk_widget_set_has_window (GTK_WIDGET (view), FALSE);
 
-  view->context = NULL;
+  gimp_widget_track_monitor (GTK_WIDGET (view),
+                             G_CALLBACK (gimp_fg_bg_view_destroy_transform),
+                             NULL);
 }
 
 static void
@@ -175,19 +177,7 @@ gimp_fg_bg_view_expose (GtkWidget      *widget,
   rect_h = allocation.height * 3 / 4;
 
   if (! view->transform)
-    {
-      static GimpColorProfile *profile = NULL;
-
-      if (G_UNLIKELY (! profile))
-        profile = gimp_color_profile_new_rgb_srgb ();
-
-      view->transform =
-        gimp_widget_get_color_transform (widget,
-                                         view->color_config,
-                                         profile,
-                                         babl_format ("R'G'B'A double"),
-                                         babl_format ("R'G'B'A double"));
-    }
+    gimp_fg_bg_view_create_transform (view);
 
   /*  draw the background area  */
 
@@ -251,9 +241,26 @@ gimp_fg_bg_view_expose (GtkWidget      *widget,
 }
 
 static void
-gimp_fg_bg_view_config_notify (GimpColorConfig  *config,
-                               const GParamSpec *pspec,
-                               GimpFgBgView     *view)
+gimp_fg_bg_view_create_transform (GimpFgBgView *view)
+{
+  if (view->color_config)
+    {
+      static GimpColorProfile *profile = NULL;
+
+      if (G_UNLIKELY (! profile))
+        profile = gimp_color_profile_new_rgb_srgb ();
+
+      view->transform =
+        gimp_widget_get_color_transform (GTK_WIDGET (view),
+                                         view->color_config,
+                                         profile,
+                                         babl_format ("R'G'B'A double"),
+                                         babl_format ("R'G'B'A double"));
+    }
+}
+
+static void
+gimp_fg_bg_view_destroy_transform (GimpFgBgView *view)
 {
   if (view->transform)
     {
@@ -284,45 +291,45 @@ gimp_fg_bg_view_set_context (GimpFgBgView *view,
   g_return_if_fail (GIMP_IS_FG_BG_VIEW (view));
   g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));
 
-  if (context == view->context)
-    return;
-
-  if (view->context)
-    {
-      g_signal_handlers_disconnect_by_func (view->context,
-                                            gtk_widget_queue_draw,
-                                            view);
-      g_object_unref (view->context);
-      view->context = NULL;
-
-      g_signal_handlers_disconnect_by_func (view->color_config,
-                                            gimp_fg_bg_view_config_notify,
-                                            view);
-      g_object_unref (view->color_config);
-      view->color_config = NULL;
-    }
-
-  view->context = context;
-
-  if (context)
+  if (context != view->context)
     {
-      g_object_ref (context);
-
-      g_signal_connect_swapped (context, "foreground-changed",
-                                G_CALLBACK (gtk_widget_queue_draw),
-                                view);
-      g_signal_connect_swapped (context, "background-changed",
-                                G_CALLBACK (gtk_widget_queue_draw),
-                                view);
-
-      view->color_config = g_object_ref (context->gimp->config->color_management);
-
-      g_signal_connect (view->color_config, "notify",
-                        G_CALLBACK (gimp_fg_bg_view_config_notify),
-                        view);
+      if (view->context)
+        {
+          g_signal_handlers_disconnect_by_func (view->context,
+                                                gtk_widget_queue_draw,
+                                                view);
+          g_object_unref (view->context);
+          view->context = NULL;
+
+          g_signal_handlers_disconnect_by_func (view->color_config,
+                                                gimp_fg_bg_view_destroy_transform,
+                                                view);
+          g_object_unref (view->color_config);
+          view->color_config = NULL;
+        }
+
+      view->context = context;
+
+      if (context)
+        {
+          g_object_ref (context);
+
+          g_signal_connect_swapped (context, "foreground-changed",
+                                    G_CALLBACK (gtk_widget_queue_draw),
+                                    view);
+          g_signal_connect_swapped (context, "background-changed",
+                                    G_CALLBACK (gtk_widget_queue_draw),
+                                    view);
+
+          view->color_config = g_object_ref (context->gimp->config->color_management);
+
+          g_signal_connect_swapped (view->color_config, "notify",
+                                    G_CALLBACK (gimp_fg_bg_view_destroy_transform),
+                                    view);
+        }
+
+      gimp_fg_bg_view_destroy_transform (view);
+
+      g_object_notify (G_OBJECT (view), "context");
     }
-
-  gimp_fg_bg_view_config_notify (NULL, NULL, view);
-
-  g_object_notify (G_OBJECT (view), "context");
 }
diff --git a/app/widgets/gimpview.c b/app/widgets/gimpview.c
index 7de146a..d85cb30 100644
--- a/app/widgets/gimpview.c
+++ b/app/widgets/gimpview.c
@@ -83,6 +83,8 @@ static void        gimp_view_real_set_viewable    (GimpView         *view,
 static void        gimp_view_update_callback      (GimpViewRenderer *renderer,
                                                    GimpView         *view);
 
+static void        gimp_view_monitor_changed      (GimpView         *view);
+
 static GimpViewable * gimp_view_drag_viewable     (GtkWidget        *widget,
                                                    GimpContext     **context,
                                                    gpointer          data);
@@ -173,10 +175,6 @@ gimp_view_init (GimpView *view)
                          GDK_ENTER_NOTIFY_MASK   |
                          GDK_LEAVE_NOTIFY_MASK);
 
-  view->event_window      = NULL;
-  view->viewable          = NULL;
-  view->renderer          = NULL;
-
   view->clickable         = FALSE;
   view->eat_button_events = TRUE;
   view->show_popup        = FALSE;
@@ -185,6 +183,10 @@ gimp_view_init (GimpView *view)
   view->in_button         = FALSE;
   view->has_grab          = FALSE;
   view->press_state       = 0;
+
+  gimp_widget_track_monitor (GTK_WIDGET (view),
+                             G_CALLBACK (gimp_view_monitor_changed),
+                             NULL);
 }
 
 static void
@@ -823,6 +825,13 @@ gimp_view_update_callback (GimpViewRenderer *renderer,
     }
 }
 
+static void
+gimp_view_monitor_changed (GimpView *view)
+{
+  if (view->renderer)
+    gimp_view_renderer_free_color_transform (view->renderer);
+}
+
 static GimpViewable *
 gimp_view_drag_viewable (GtkWidget    *widget,
                          GimpContext **context,
diff --git a/app/widgets/gimpviewrenderer.c b/app/widgets/gimpviewrenderer.c
index c871c02..6043441 100644
--- a/app/widgets/gimpviewrenderer.c
+++ b/app/widgets/gimpviewrenderer.c
@@ -113,8 +113,6 @@ static cairo_pattern_t *
                  gimp_view_renderer_create_background (GimpViewRenderer   *renderer,
                                                        GtkWidget          *widget);
 
-static void      gimp_view_renderer_transform_free    (GimpViewRenderer   *renderer);
-
 
 G_DEFINE_TYPE (GimpViewRenderer, gimp_view_renderer, G_TYPE_OBJECT)
 
@@ -362,7 +360,7 @@ gimp_view_renderer_set_viewable (GimpViewRenderer *renderer,
       renderer->priv->pixbuf = NULL;
     }
 
-  gimp_view_renderer_transform_free (renderer);
+  gimp_view_renderer_free_color_transform (renderer);
 
   if (renderer->viewable)
     {
@@ -887,8 +885,7 @@ static void
 gimp_view_renderer_profile_changed (GimpViewRenderer *renderer,
                                     GimpViewable     *viewable)
 {
-  gimp_view_renderer_transform_free (renderer);
-  gimp_view_renderer_invalidate (renderer);
+  gimp_view_renderer_free_color_transform (renderer);
 }
 
 static void
@@ -896,8 +893,7 @@ gimp_view_renderer_config_notify (GObject          *config,
                                   const GParamSpec *pspec,
                                   GimpViewRenderer *renderer)
 {
-  gimp_view_renderer_transform_free (renderer);
-  gimp_view_renderer_invalidate (renderer);
+  gimp_view_renderer_free_color_transform (renderer);
 }
 
 
@@ -983,9 +979,8 @@ gimp_view_renderer_render_pixbuf (GimpViewRenderer *renderer,
 
   format = gimp_pixbuf_get_format (pixbuf);
 
-  transform =
-    gimp_view_renderer_get_color_transform (renderer, widget,
-                                            format, format);
+  transform = gimp_view_renderer_get_color_transform (renderer, widget,
+                                                      format, format);
 
   if (transform)
     {
@@ -1133,6 +1128,19 @@ gimp_view_renderer_get_color_transform (GimpViewRenderer *renderer,
   return renderer->priv->profile_transform;
 }
 
+void
+gimp_view_renderer_free_color_transform (GimpViewRenderer *renderer)
+{
+  g_return_if_fail (GIMP_IS_VIEW_RENDERER (renderer));
+
+  if (renderer->priv->profile_transform)
+    {
+      g_object_unref (renderer->priv->profile_transform);
+      renderer->priv->profile_transform = NULL;
+    }
+
+  gimp_view_renderer_invalidate (renderer);
+}
 
 /*  private functions  */
 
@@ -1413,13 +1421,3 @@ gimp_view_renderer_create_background (GimpViewRenderer *renderer,
 
   return pattern;
 }
-
-static void
-gimp_view_renderer_transform_free (GimpViewRenderer *renderer)
-{
-  if (renderer->priv->profile_transform)
-    {
-      g_object_unref (renderer->priv->profile_transform);
-      renderer->priv->profile_transform = NULL;
-    }
-}
diff --git a/app/widgets/gimpviewrenderer.h b/app/widgets/gimpviewrenderer.h
index c5237eb..c532862 100644
--- a/app/widgets/gimpviewrenderer.h
+++ b/app/widgets/gimpviewrenderer.h
@@ -161,7 +161,7 @@ GimpColorTransform *
                                                   GtkWidget        *widget,
                                                   const Babl       *src_format,
                                                   const Babl       *dest_format);
-
+void   gimp_view_renderer_free_color_transform   (GimpViewRenderer *renderer);
 
 
 #endif /* __GIMP_VIEW_RENDERER_H__ */
diff --git a/libgimpwidgets/gimpcolorarea.c b/libgimpwidgets/gimpcolorarea.c
index ac70f7f..ee88f94 100644
--- a/libgimpwidgets/gimpcolorarea.c
+++ b/libgimpwidgets/gimpcolorarea.c
@@ -123,11 +123,8 @@ static void  gimp_color_area_drag_data_get      (GtkWidget        *widget,
                                                  guint             info,
                                                  guint             time);
 
-static void  gimp_color_area_config_notify      (GimpColorConfig  *config,
-                                                 const GParamSpec *pspec,
-                                                 GimpColorArea    *area);
-
 static void  gimp_color_area_create_transform   (GimpColorArea    *area);
+static void  gimp_color_area_destroy_transform  (GimpColorArea    *area);
 
 
 G_DEFINE_TYPE (GimpColorArea, gimp_color_area, GTK_TYPE_DRAWING_AREA)
@@ -242,6 +239,10 @@ gimp_color_area_init (GimpColorArea *area)
                      GTK_DEST_DEFAULT_DROP,
                      &target, 1,
                      GDK_ACTION_COPY);
+
+  gimp_widget_track_monitor (GTK_WIDGET (area),
+                             G_CALLBACK (gimp_color_area_destroy_transform),
+                             NULL);
 }
 
 static void
@@ -619,15 +620,11 @@ gimp_color_area_set_color_config (GimpColorArea   *area,
       if (priv->config)
         {
           g_signal_handlers_disconnect_by_func (priv->config,
-                                                gimp_color_area_config_notify,
+                                                gimp_color_area_destroy_transform,
                                                 area);
           g_object_unref (priv->config);
 
-          if (priv->transform)
-            {
-              g_object_unref (priv->transform);
-              priv->transform = NULL;
-            }
+          gimp_color_area_destroy_transform (area);
         }
 
       priv->config = config;
@@ -636,9 +633,9 @@ gimp_color_area_set_color_config (GimpColorArea   *area,
         {
           g_object_ref (priv->config);
 
-          g_signal_connect (priv->config, "notify",
-                            G_CALLBACK (gimp_color_area_config_notify),
-                            area);
+          g_signal_connect_swapped (priv->config, "notify",
+                                    G_CALLBACK (gimp_color_area_destroy_transform),
+                                    area);
         }
     }
 }
@@ -916,22 +913,6 @@ gimp_color_area_drag_data_get (GtkWidget        *widget,
 }
 
 static void
-gimp_color_area_config_notify (GimpColorConfig  *config,
-                               const GParamSpec *pspec,
-                               GimpColorArea    *area)
-{
-  GimpColorAreaPrivate *priv = GET_PRIVATE (area);
-
-  if (priv->transform)
-    {
-      g_object_unref (priv->transform);
-      priv->transform = NULL;
-    }
-
-  gtk_widget_queue_draw (GTK_WIDGET (area));
-}
-
-static void
 gimp_color_area_create_transform (GimpColorArea *area)
 {
   GimpColorAreaPrivate *priv = GET_PRIVATE (area);
@@ -952,3 +933,17 @@ gimp_color_area_create_transform (GimpColorArea *area)
                                                          format);
     }
 }
+
+static void
+gimp_color_area_destroy_transform (GimpColorArea *area)
+{
+  GimpColorAreaPrivate *priv = GET_PRIVATE (area);
+
+  if (priv->transform)
+    {
+      g_object_unref (priv->transform);
+      priv->transform = NULL;
+    }
+
+  gtk_widget_queue_draw (GTK_WIDGET (area));
+}
diff --git a/libgimpwidgets/gimpcolorscale.c b/libgimpwidgets/gimpcolorscale.c
index 22e1bef..9810ce6 100644
--- a/libgimpwidgets/gimpcolorscale.c
+++ b/libgimpwidgets/gimpcolorscale.c
@@ -68,36 +68,34 @@ struct _GimpColorScalePrivate
                                      GimpColorScalePrivate)
 
 
-static void     gimp_color_scale_dispose          (GObject          *object);
-static void     gimp_color_scale_finalize         (GObject          *object);
-static void     gimp_color_scale_get_property     (GObject          *object,
-                                                   guint             property_id,
-                                                   GValue           *value,
-                                                   GParamSpec       *pspec);
-static void     gimp_color_scale_set_property     (GObject          *object,
-                                                   guint             property_id,
-                                                   const GValue     *value,
-                                                   GParamSpec       *pspec);
-
-static void     gimp_color_scale_size_allocate    (GtkWidget        *widget,
-                                                   GtkAllocation    *allocation);
-static void     gimp_color_scale_state_changed    (GtkWidget        *widget,
-                                                   GtkStateType      previous_state);
-static gboolean gimp_color_scale_button_press     (GtkWidget        *widget,
-                                                   GdkEventButton   *event);
-static gboolean gimp_color_scale_button_release   (GtkWidget        *widget,
-                                                   GdkEventButton   *event);
-static gboolean gimp_color_scale_expose           (GtkWidget        *widget,
-                                                   GdkEventExpose   *event);
-
-static void     gimp_color_scale_render           (GimpColorScale   *scale);
-static void     gimp_color_scale_render_alpha     (GimpColorScale   *scale);
-static void     gimp_color_scale_render_stipple   (GimpColorScale   *scale);
-
-static void     gimp_color_scale_config_notify    (GimpColorConfig  *config,
-                                                   const GParamSpec *pspec,
-                                                   GimpColorScale   *scale);
-static void     gimp_color_scale_create_transform (GimpColorScale   *scale);
+static void     gimp_color_scale_dispose           (GObject          *object);
+static void     gimp_color_scale_finalize          (GObject          *object);
+static void     gimp_color_scale_get_property      (GObject          *object,
+                                                    guint             property_id,
+                                                    GValue           *value,
+                                                    GParamSpec       *pspec);
+static void     gimp_color_scale_set_property      (GObject          *object,
+                                                    guint             property_id,
+                                                    const GValue     *value,
+                                                    GParamSpec       *pspec);
+
+static void     gimp_color_scale_size_allocate     (GtkWidget        *widget,
+                                                    GtkAllocation    *allocation);
+static void     gimp_color_scale_state_changed     (GtkWidget        *widget,
+                                                    GtkStateType      previous_state);
+static gboolean gimp_color_scale_button_press      (GtkWidget        *widget,
+                                                    GdkEventButton   *event);
+static gboolean gimp_color_scale_button_release    (GtkWidget        *widget,
+                                                    GdkEventButton   *event);
+static gboolean gimp_color_scale_expose            (GtkWidget        *widget,
+                                                    GdkEventExpose   *event);
+
+static void     gimp_color_scale_render            (GimpColorScale   *scale);
+static void     gimp_color_scale_render_alpha      (GimpColorScale   *scale);
+static void     gimp_color_scale_render_stipple    (GimpColorScale   *scale);
+
+static void     gimp_color_scale_create_transform  (GimpColorScale   *scale);
+static void     gimp_color_scale_destroy_transform (GimpColorScale   *scale);
 
 
 G_DEFINE_TYPE (GimpColorScale, gimp_color_scale, GTK_TYPE_SCALE)
@@ -167,6 +165,10 @@ gimp_color_scale_init (GimpColorScale *scale)
 
   gimp_rgba_set (&scale->rgb, 0.0, 0.0, 0.0, 1.0);
   gimp_rgb_to_hsv (&scale->rgb, &scale->hsv);
+
+  gimp_widget_track_monitor (GTK_WIDGET (scale),
+                             G_CALLBACK (gimp_color_scale_destroy_transform),
+                             NULL);
 }
 
 static void
@@ -665,15 +667,11 @@ gimp_color_scale_set_color_config (GimpColorScale  *scale,
       if (priv->config)
         {
           g_signal_handlers_disconnect_by_func (priv->config,
-                                                gimp_color_scale_config_notify,
+                                                gimp_color_scale_destroy_transform,
                                                 scale);
           g_object_unref (priv->config);
 
-          if (priv->transform)
-            {
-              g_object_unref (priv->transform);
-              priv->transform = NULL;
-            }
+          gimp_color_scale_destroy_transform (scale);
         }
 
       priv->config = config;
@@ -682,9 +680,9 @@ gimp_color_scale_set_color_config (GimpColorScale  *scale,
         {
           g_object_ref (priv->config);
 
-          g_signal_connect (priv->config, "notify",
-                            G_CALLBACK (gimp_color_scale_config_notify),
-                            scale);
+          g_signal_connect_swapped (priv->config, "notify",
+                                    G_CALLBACK (gimp_color_scale_destroy_transform),
+                                    scale);
         }
     }
 }
@@ -982,22 +980,6 @@ gimp_color_scale_render_stipple (GimpColorScale *scale)
 }
 
 static void
-gimp_color_scale_config_notify (GimpColorConfig  *config,
-                                const GParamSpec *pspec,
-                                GimpColorScale   *scale)
-{
-  GimpColorScalePrivate *priv = GET_PRIVATE (scale);
-
-  if (priv->transform)
-    {
-      g_object_unref (priv->transform);
-      priv->transform = NULL;
-    }
-
-  gtk_widget_queue_draw (GTK_WIDGET (scale));
-}
-
-static void
 gimp_color_scale_create_transform (GimpColorScale *scale)
 {
   GimpColorScalePrivate *priv = GET_PRIVATE (scale);
@@ -1018,3 +1000,17 @@ gimp_color_scale_create_transform (GimpColorScale *scale)
                                                          format);
     }
 }
+
+static void
+gimp_color_scale_destroy_transform (GimpColorScale *scale)
+{
+  GimpColorScalePrivate *priv = GET_PRIVATE (scale);
+
+  if (priv->transform)
+    {
+      g_object_unref (priv->transform);
+      priv->transform = NULL;
+    }
+
+  gtk_widget_queue_draw (GTK_WIDGET (scale));
+}
diff --git a/libgimpwidgets/gimppreviewarea.c b/libgimpwidgets/gimppreviewarea.c
index 5cb38ef..02b6fd3 100644
--- a/libgimpwidgets/gimppreviewarea.c
+++ b/libgimpwidgets/gimppreviewarea.c
@@ -75,34 +75,31 @@ struct _GimpPreviewAreaPrivate
                                      GimpPreviewAreaPrivate)
 
 
-static void      gimp_preview_area_dispose          (GObject          *object);
-static void      gimp_preview_area_finalize         (GObject          *object);
-static void      gimp_preview_area_set_property     (GObject          *object,
-                                                     guint             property_id,
-                                                     const GValue     *value,
-                                                     GParamSpec       *pspec);
-static void      gimp_preview_area_get_property     (GObject          *object,
-                                                     guint             property_id,
-                                                     GValue           *value,
-                                                     GParamSpec       *pspec);
-
-static void      gimp_preview_area_size_allocate    (GtkWidget        *widget,
-                                                     GtkAllocation    *allocation);
-static gboolean  gimp_preview_area_expose           (GtkWidget        *widget,
-                                                     GdkEventExpose   *event);
-
-static void      gimp_preview_area_queue_draw       (GimpPreviewArea  *area,
-                                                     gint              x,
-                                                     gint              y,
-                                                     gint              width,
-                                                     gint              height);
-static gint      gimp_preview_area_image_type_bytes (GimpImageType     type);
-
-static void      gimp_preview_area_config_notify    (GimpColorConfig  *config,
-                                                     const GParamSpec *pspec,
-                                                     GimpPreviewArea  *area);
-
-static void      gimp_preview_area_create_transform (GimpPreviewArea  *area);
+static void      gimp_preview_area_dispose           (GObject          *object);
+static void      gimp_preview_area_finalize          (GObject          *object);
+static void      gimp_preview_area_set_property      (GObject          *object,
+                                                      guint             property_id,
+                                                      const GValue     *value,
+                                                      GParamSpec       *pspec);
+static void      gimp_preview_area_get_property      (GObject          *object,
+                                                      guint             property_id,
+                                                      GValue           *value,
+                                                      GParamSpec       *pspec);
+
+static void      gimp_preview_area_size_allocate     (GtkWidget        *widget,
+                                                      GtkAllocation    *allocation);
+static gboolean  gimp_preview_area_expose            (GtkWidget        *widget,
+                                                      GdkEventExpose   *event);
+
+static void      gimp_preview_area_queue_draw        (GimpPreviewArea  *area,
+                                                      gint              x,
+                                                      gint              y,
+                                                      gint              width,
+                                                      gint              height);
+static gint      gimp_preview_area_image_type_bytes  (GimpImageType     type);
+
+static void      gimp_preview_area_create_transform  (GimpPreviewArea  *area);
+static void      gimp_preview_area_destroy_transform (GimpPreviewArea  *area);
 
 
 G_DEFINE_TYPE (GimpPreviewArea, gimp_preview_area, GTK_TYPE_DRAWING_AREA)
@@ -155,6 +152,10 @@ gimp_preview_area_init (GimpPreviewArea *area)
   area->rowstride  = 0;
   area->max_width  = -1;
   area->max_height = -1;
+
+  gimp_widget_track_monitor (GTK_WIDGET (area),
+                             G_CALLBACK (gimp_preview_area_destroy_transform),
+                             NULL);
 }
 
 static void
@@ -387,22 +388,6 @@ gimp_preview_area_image_type_bytes (GimpImageType type)
 }
 
 static void
-gimp_preview_area_config_notify (GimpColorConfig  *config,
-                                 const GParamSpec *pspec,
-                                 GimpPreviewArea  *area)
-{
-  GimpPreviewAreaPrivate *priv = GET_PRIVATE (area);
-
-  if (priv->transform)
-    {
-      g_object_unref (priv->transform);
-      priv->transform = NULL;
-    }
-
-  gtk_widget_queue_draw (GTK_WIDGET (area));
-}
-
-static void
 gimp_preview_area_create_transform (GimpPreviewArea *area)
 {
   GimpPreviewAreaPrivate *priv = GET_PRIVATE (area);
@@ -424,6 +409,20 @@ gimp_preview_area_create_transform (GimpPreviewArea *area)
     }
 }
 
+static void
+gimp_preview_area_destroy_transform (GimpPreviewArea *area)
+{
+  GimpPreviewAreaPrivate *priv = GET_PRIVATE (area);
+
+  if (priv->transform)
+    {
+      g_object_unref (priv->transform);
+      priv->transform = NULL;
+    }
+
+  gtk_widget_queue_draw (GTK_WIDGET (area));
+}
+
 
 /**
  * gimp_preview_area_new:
@@ -1804,15 +1803,11 @@ gimp_preview_area_set_color_config (GimpPreviewArea *area,
       if (priv->config)
         {
           g_signal_handlers_disconnect_by_func (priv->config,
-                                                gimp_preview_area_config_notify,
+                                                gimp_preview_area_destroy_transform,
                                                 area);
           g_object_unref (priv->config);
 
-          if (priv->transform)
-            {
-              g_object_unref (priv->transform);
-              priv->transform = NULL;
-            }
+          gimp_preview_area_destroy_transform (area);
         }
 
       priv->config = config;
@@ -1821,9 +1816,9 @@ gimp_preview_area_set_color_config (GimpPreviewArea *area,
         {
           g_object_ref (priv->config);
 
-          g_signal_connect (priv->config, "notify",
-                            G_CALLBACK (gimp_preview_area_config_notify),
-                            area);
+          g_signal_connect_swapped (priv->config, "notify",
+                                    G_CALLBACK (gimp_preview_area_destroy_transform),
+                                    area);
         }
     }
 }
diff --git a/modules/color-selector-water.c b/modules/color-selector-water.c
index 25ffde6..ab67e14 100644
--- a/modules/color-selector-water.c
+++ b/modules/color-selector-water.c
@@ -64,32 +64,30 @@ struct _ColorselWaterClass
 };
 
 
-static GType      colorsel_water_get_type         (void);
-
-static void       colorsel_water_dispose          (GObject           *object);
-
-static void       colorsel_water_set_config       (GimpColorSelector *selector,
-                                                   GimpColorConfig   *config);
-
-static void       colorsel_water_config_notify    (GimpColorConfig   *config,
-                                                   const GParamSpec  *pspec,
-                                                   ColorselWater     *water);
-static void       colorsel_water_create_transform (ColorselWater     *water);
-
-static gboolean   select_area_expose              (GtkWidget         *widget,
-                                                   GdkEventExpose    *event,
-                                                   ColorselWater     *water);
-static gboolean   button_press_event              (GtkWidget         *widget,
-                                                   GdkEventButton    *event,
-                                                   ColorselWater     *water);
-static gboolean   motion_notify_event             (GtkWidget         *widget,
-                                                   GdkEventMotion    *event,
-                                                   ColorselWater     *water);
-static gboolean   proximity_out_event             (GtkWidget         *widget,
-                                                   GdkEventProximity *event,
-                                                   ColorselWater     *water);
-static void       pressure_adjust_update          (GtkAdjustment     *adj,
-                                                   ColorselWater     *water);
+static GType      colorsel_water_get_type          (void);
+
+static void       colorsel_water_dispose           (GObject           *object);
+
+static void       colorsel_water_set_config        (GimpColorSelector *selector,
+                                                    GimpColorConfig   *config);
+
+static void       colorsel_water_create_transform  (ColorselWater     *water);
+static void       colorsel_water_destroy_transform (ColorselWater     *water);
+
+static gboolean   select_area_expose               (GtkWidget         *widget,
+                                                    GdkEventExpose    *event,
+                                                    ColorselWater     *water);
+static gboolean   button_press_event               (GtkWidget         *widget,
+                                                    GdkEventButton    *event,
+                                                    ColorselWater     *water);
+static gboolean   motion_notify_event              (GtkWidget         *widget,
+                                                    GdkEventMotion    *event,
+                                                    ColorselWater     *water);
+static gboolean   proximity_out_event              (GtkWidget         *widget,
+                                                    GdkEventProximity *event,
+                                                    ColorselWater     *water);
+static void       pressure_adjust_update           (GtkAdjustment     *adj,
+                                                    ColorselWater     *water);
 
 
 static const GimpModuleInfo colorsel_water_info =
@@ -203,6 +201,10 @@ colorsel_water_init (ColorselWater *water)
   gtk_box_pack_start (GTK_BOX (hbox), scale, FALSE, FALSE, 0);
 
   gtk_widget_show_all (hbox);
+
+  gimp_widget_track_monitor (GTK_WIDGET (water),
+                             G_CALLBACK (colorsel_water_destroy_transform),
+                             NULL);
 }
 
 static gdouble
@@ -235,15 +237,11 @@ colorsel_water_set_config (GimpColorSelector *selector,
       if (water->config)
         {
           g_signal_handlers_disconnect_by_func (water->config,
-                                                colorsel_water_config_notify,
+                                                colorsel_water_destroy_transform,
                                                 water);
           g_object_unref (water->config);
 
-          if (water->transform)
-            {
-              g_object_unref (water->transform);
-              water->transform = NULL;
-            }
+          colorsel_water_destroy_transform (water);
         }
 
       water->config = config;
@@ -252,28 +250,14 @@ colorsel_water_set_config (GimpColorSelector *selector,
         {
           g_object_ref (water->config);
 
-          g_signal_connect (water->config, "notify",
-                            G_CALLBACK (colorsel_water_config_notify),
-                            water);
+          g_signal_connect_swapped (water->config, "notify",
+                                    G_CALLBACK (colorsel_water_destroy_transform),
+                                    water);
         }
     }
 }
 
 static void
-colorsel_water_config_notify (GimpColorConfig   *config,
-                              const GParamSpec  *pspec,
-                              ColorselWater     *water)
-{
-  if (water->transform)
-    {
-      g_object_unref (water->transform);
-      water->transform = NULL;
-    }
-
-  gtk_widget_queue_draw (GTK_WIDGET (water->area));
-}
-
-static void
 colorsel_water_create_transform (ColorselWater *water)
 {
   if (water->config)
@@ -293,6 +277,18 @@ colorsel_water_create_transform (ColorselWater *water)
     }
 }
 
+static void
+colorsel_water_destroy_transform (ColorselWater *water)
+{
+  if (water->transform)
+    {
+      g_object_unref (water->transform);
+      water->transform = NULL;
+    }
+
+  gtk_widget_queue_draw (GTK_WIDGET (water->area));
+}
+
 static gboolean
 select_area_expose (GtkWidget      *widget,
                     GdkEventExpose *event,
diff --git a/modules/gimpcolorwheel.c b/modules/gimpcolorwheel.c
index 4527fc2..eff3928 100644
--- a/modules/gimpcolorwheel.c
+++ b/modules/gimpcolorwheel.c
@@ -95,35 +95,33 @@ enum
   LAST_SIGNAL
 };
 
-static void     gimp_color_wheel_dispose          (GObject            *object);
-
-static void     gimp_color_wheel_map              (GtkWidget          *widget);
-static void     gimp_color_wheel_unmap            (GtkWidget          *widget);
-static void     gimp_color_wheel_realize          (GtkWidget          *widget);
-static void     gimp_color_wheel_unrealize        (GtkWidget          *widget);
-static void     gimp_color_wheel_size_request     (GtkWidget          *widget,
-                                                   GtkRequisition     *requisition);
-static void     gimp_color_wheel_size_allocate    (GtkWidget          *widget,
-                                                   GtkAllocation      *allocation);
-static gboolean gimp_color_wheel_button_press     (GtkWidget          *widget,
-                                                   GdkEventButton     *event);
-static gboolean gimp_color_wheel_button_release   (GtkWidget          *widget,
-                                                   GdkEventButton     *event);
-static gboolean gimp_color_wheel_motion           (GtkWidget          *widget,
-                                                   GdkEventMotion     *event);
-static gboolean gimp_color_wheel_expose           (GtkWidget          *widget,
-                                                   GdkEventExpose     *event);
-static gboolean gimp_color_wheel_grab_broken      (GtkWidget          *widget,
-                                                   GdkEventGrabBroken *event);
-static gboolean gimp_color_wheel_focus            (GtkWidget          *widget,
-                                                   GtkDirectionType    direction);
-static void     gimp_color_wheel_move             (GimpColorWheel     *wheel,
-                                                   GtkDirectionType    dir);
-
-static void     gimp_color_wheel_config_notify    (GimpColorConfig    *config,
-                                                   const GParamSpec   *pspec,
-                                                   GimpColorWheel     *wheel);
-static void     gimp_color_wheel_create_transform (GimpColorWheel     *wheel);
+static void     gimp_color_wheel_dispose           (GObject            *object);
+
+static void     gimp_color_wheel_map               (GtkWidget          *widget);
+static void     gimp_color_wheel_unmap             (GtkWidget          *widget);
+static void     gimp_color_wheel_realize           (GtkWidget          *widget);
+static void     gimp_color_wheel_unrealize         (GtkWidget          *widget);
+static void     gimp_color_wheel_size_request      (GtkWidget          *widget,
+                                                    GtkRequisition     *requisition);
+static void     gimp_color_wheel_size_allocate     (GtkWidget          *widget,
+                                                    GtkAllocation      *allocation);
+static gboolean gimp_color_wheel_button_press      (GtkWidget          *widget,
+                                                    GdkEventButton     *event);
+static gboolean gimp_color_wheel_button_release    (GtkWidget          *widget,
+                                                    GdkEventButton     *event);
+static gboolean gimp_color_wheel_motion            (GtkWidget          *widget,
+                                                    GdkEventMotion     *event);
+static gboolean gimp_color_wheel_expose            (GtkWidget          *widget,
+                                                    GdkEventExpose     *event);
+static gboolean gimp_color_wheel_grab_broken       (GtkWidget          *widget,
+                                                    GdkEventGrabBroken *event);
+static gboolean gimp_color_wheel_focus             (GtkWidget          *widget,
+                                                    GtkDirectionType    direction);
+static void     gimp_color_wheel_move              (GimpColorWheel     *wheel,
+                                                    GtkDirectionType    dir);
+
+static void     gimp_color_wheel_create_transform  (GimpColorWheel     *wheel);
+static void     gimp_color_wheel_destroy_transform (GimpColorWheel     *wheel);
 
 
 static guint wheel_signals[LAST_SIGNAL];
@@ -238,6 +236,10 @@ gimp_color_wheel_init (GimpColorWheel *wheel)
   priv->ring_fraction = DEFAULT_FRACTION;
   priv->size          = DEFAULT_SIZE;
   priv->ring_width    = DEFAULT_RING_WIDTH;
+
+  gimp_widget_track_monitor (GTK_WIDGET (wheel),
+                             G_CALLBACK (gimp_color_wheel_destroy_transform),
+                             NULL);
 }
 
 static void
@@ -1467,15 +1469,11 @@ gimp_color_wheel_set_color_config (GimpColorWheel  *wheel,
       if (priv->config)
         {
           g_signal_handlers_disconnect_by_func (priv->config,
-                                                gimp_color_wheel_config_notify,
+                                                gimp_color_wheel_destroy_transform,
                                                 wheel);
           g_object_unref (priv->config);
 
-          if (priv->transform)
-            {
-              g_object_unref (priv->transform);
-              priv->transform = NULL;
-            }
+          gimp_color_wheel_destroy_transform (wheel);
         }
 
       priv->config = config;
@@ -1484,9 +1482,9 @@ gimp_color_wheel_set_color_config (GimpColorWheel  *wheel,
         {
           g_object_ref (priv->config);
 
-          g_signal_connect (priv->config, "notify",
-                            G_CALLBACK (gimp_color_wheel_config_notify),
-                            wheel);
+          g_signal_connect_swapped (priv->config, "notify",
+                                    G_CALLBACK (gimp_color_wheel_destroy_transform),
+                                    wheel);
         }
     }
 }
@@ -1595,22 +1593,6 @@ gimp_color_wheel_move (GimpColorWheel   *wheel,
 }
 
 static void
-gimp_color_wheel_config_notify (GimpColorConfig  *config,
-                                const GParamSpec *pspec,
-                                GimpColorWheel   *wheel)
-{
-  GimpColorWheelPrivate *priv = wheel->priv;
-
-  if (priv->transform)
-    {
-      g_object_unref (priv->transform);
-      priv->transform = NULL;
-    }
-
-  gtk_widget_queue_draw (GTK_WIDGET (wheel));
-}
-
-static void
 gimp_color_wheel_create_transform (GimpColorWheel *wheel)
 {
   GimpColorWheelPrivate *priv = wheel->priv;
@@ -1631,3 +1613,17 @@ gimp_color_wheel_create_transform (GimpColorWheel *wheel)
                                                          format);
     }
 }
+
+static void
+gimp_color_wheel_destroy_transform (GimpColorWheel *wheel)
+{
+  GimpColorWheelPrivate *priv = wheel->priv;
+
+  if (priv->transform)
+    {
+      g_object_unref (priv->transform);
+      priv->transform = NULL;
+    }
+
+  gtk_widget_queue_draw (GTK_WIDGET (wheel));
+}


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