[gimp] libgimpwidgets, modules: improve set_color_config() functions a bit



commit 4ad2493283664ba3b5de9b9c4839d416ce94f9d4
Author: Michael Natterer <mitch gimp org>
Date:   Tue May 31 12:24:58 2016 +0200

    libgimpwidgets, modules: improve set_color_config() functions a bit
    
    Don't do anything if the config doesn't change.

 libgimpwidgets/gimpcolorarea.c   |   37 +++++++++++++++++++----------------
 libgimpwidgets/gimpcolorscale.c  |   37 +++++++++++++++++++----------------
 libgimpwidgets/gimppreviewarea.c |   37 +++++++++++++++++++----------------
 modules/color-selector-cmyk.c    |   40 +++++++++++++++++++-------------------
 modules/color-selector-water.c   |   37 +++++++++++++++++++----------------
 modules/gimpcolorwheel.c         |   37 +++++++++++++++++++----------------
 6 files changed, 120 insertions(+), 105 deletions(-)
---
diff --git a/libgimpwidgets/gimpcolorarea.c b/libgimpwidgets/gimpcolorarea.c
index a4612b9..ac70f7f 100644
--- a/libgimpwidgets/gimpcolorarea.c
+++ b/libgimpwidgets/gimpcolorarea.c
@@ -614,29 +614,32 @@ gimp_color_area_set_color_config (GimpColorArea   *area,
 
   priv = GET_PRIVATE (area);
 
-  if (priv->config)
+  if (config != priv->config)
     {
-      g_signal_handlers_disconnect_by_func (priv->config,
-                                            gimp_color_area_config_notify,
-                                            area);
-      g_object_unref (priv->config);
-
-      if (priv->transform)
+      if (priv->config)
         {
-          g_object_unref (priv->transform);
-          priv->transform = NULL;
+          g_signal_handlers_disconnect_by_func (priv->config,
+                                                gimp_color_area_config_notify,
+                                                area);
+          g_object_unref (priv->config);
+
+          if (priv->transform)
+            {
+              g_object_unref (priv->transform);
+              priv->transform = NULL;
+            }
         }
-    }
 
-  priv->config = config;
+      priv->config = config;
 
-  if (priv->config)
-    {
-      g_object_ref (priv->config);
+      if (priv->config)
+        {
+          g_object_ref (priv->config);
 
-      g_signal_connect (priv->config, "notify",
-                        G_CALLBACK (gimp_color_area_config_notify),
-                        area);
+          g_signal_connect (priv->config, "notify",
+                            G_CALLBACK (gimp_color_area_config_notify),
+                            area);
+        }
     }
 }
 
diff --git a/libgimpwidgets/gimpcolorscale.c b/libgimpwidgets/gimpcolorscale.c
index 690dbfb..22e1bef 100644
--- a/libgimpwidgets/gimpcolorscale.c
+++ b/libgimpwidgets/gimpcolorscale.c
@@ -660,29 +660,32 @@ gimp_color_scale_set_color_config (GimpColorScale  *scale,
 
   priv = GET_PRIVATE (scale);
 
-  if (priv->config)
+  if (config != priv->config)
     {
-      g_signal_handlers_disconnect_by_func (priv->config,
-                                            gimp_color_scale_config_notify,
-                                            scale);
-      g_object_unref (priv->config);
-
-      if (priv->transform)
+      if (priv->config)
         {
-          g_object_unref (priv->transform);
-          priv->transform = NULL;
+          g_signal_handlers_disconnect_by_func (priv->config,
+                                                gimp_color_scale_config_notify,
+                                                scale);
+          g_object_unref (priv->config);
+
+          if (priv->transform)
+            {
+              g_object_unref (priv->transform);
+              priv->transform = NULL;
+            }
         }
-    }
 
-  priv->config = config;
+      priv->config = config;
 
-  if (priv->config)
-    {
-      g_object_ref (priv->config);
+      if (priv->config)
+        {
+          g_object_ref (priv->config);
 
-      g_signal_connect (priv->config, "notify",
-                        G_CALLBACK (gimp_color_scale_config_notify),
-                        scale);
+          g_signal_connect (priv->config, "notify",
+                            G_CALLBACK (gimp_color_scale_config_notify),
+                            scale);
+        }
     }
 }
 
diff --git a/libgimpwidgets/gimppreviewarea.c b/libgimpwidgets/gimppreviewarea.c
index 62514a4..5cb38ef 100644
--- a/libgimpwidgets/gimppreviewarea.c
+++ b/libgimpwidgets/gimppreviewarea.c
@@ -1799,29 +1799,32 @@ gimp_preview_area_set_color_config (GimpPreviewArea *area,
 
   priv = GET_PRIVATE (area);
 
-  if (priv->config)
+  if (config != priv->config)
     {
-      g_signal_handlers_disconnect_by_func (priv->config,
-                                            gimp_preview_area_config_notify,
-                                            area);
-      g_object_unref (priv->config);
-
-      if (priv->transform)
+      if (priv->config)
         {
-          g_object_unref (priv->transform);
-          priv->transform = NULL;
+          g_signal_handlers_disconnect_by_func (priv->config,
+                                                gimp_preview_area_config_notify,
+                                                area);
+          g_object_unref (priv->config);
+
+          if (priv->transform)
+            {
+              g_object_unref (priv->transform);
+              priv->transform = NULL;
+            }
         }
-    }
 
-  priv->config = config;
+      priv->config = config;
 
-  if (priv->config)
-    {
-      g_object_ref (priv->config);
+      if (priv->config)
+        {
+          g_object_ref (priv->config);
 
-      g_signal_connect (priv->config, "notify",
-                        G_CALLBACK (gimp_preview_area_config_notify),
-                        area);
+          g_signal_connect (priv->config, "notify",
+                            G_CALLBACK (gimp_preview_area_config_notify),
+                            area);
+        }
     }
 }
 
diff --git a/modules/color-selector-cmyk.c b/modules/color-selector-cmyk.c
index 418089e..b9e1107 100644
--- a/modules/color-selector-cmyk.c
+++ b/modules/color-selector-cmyk.c
@@ -268,28 +268,28 @@ colorsel_cmyk_set_config (GimpColorSelector *selector,
 {
   ColorselCmyk *module = COLORSEL_CMYK (selector);
 
-  if (config == module->config)
-    return;
-
-  if (module->config)
-    {
-      g_signal_handlers_disconnect_by_func (module->config,
-                                            G_CALLBACK (colorsel_cmyk_config_changed),
-                                            module);
-      g_object_unref (module->config);
-    }
-
-  module->config = config;
-
-  if (module->config)
+  if (config != module->config)
     {
-      g_object_ref (module->config);
-      g_signal_connect_swapped (module->config, "notify",
-                                G_CALLBACK (colorsel_cmyk_config_changed),
-                                module);
+      if (module->config)
+        {
+          g_signal_handlers_disconnect_by_func (module->config,
+                                                colorsel_cmyk_config_changed,
+                                                module);
+          g_object_unref (module->config);
+        }
+
+      module->config = config;
+
+      if (module->config)
+        {
+          g_object_ref (module->config);
+          g_signal_connect_swapped (module->config, "notify",
+                                    G_CALLBACK (colorsel_cmyk_config_changed),
+                                    module);
+        }
+
+      colorsel_cmyk_config_changed (module);
     }
-
-  colorsel_cmyk_config_changed (module);
 }
 
 static void
diff --git a/modules/color-selector-water.c b/modules/color-selector-water.c
index 4538239..f714374 100644
--- a/modules/color-selector-water.c
+++ b/modules/color-selector-water.c
@@ -230,29 +230,32 @@ colorsel_water_set_config (GimpColorSelector *selector,
 {
   ColorselWater *water = COLORSEL_WATER (selector);
 
-  if (water->config)
+  if (config != water->config)
     {
-      g_signal_handlers_disconnect_by_func (water->config,
-                                            colorsel_water_config_notify,
-                                            water);
-      g_object_unref (water->config);
-
-      if (water->transform)
+      if (water->config)
         {
-          g_object_unref (water->transform);
-          water->transform = NULL;
+          g_signal_handlers_disconnect_by_func (water->config,
+                                                colorsel_water_config_notify,
+                                                water);
+          g_object_unref (water->config);
+
+          if (water->transform)
+            {
+              g_object_unref (water->transform);
+              water->transform = NULL;
+            }
         }
-    }
 
-  water->config = config;
+      water->config = config;
 
-  if (water->config)
-    {
-      g_object_ref (water->config);
+      if (water->config)
+        {
+          g_object_ref (water->config);
 
-      g_signal_connect (water->config, "notify",
-                        G_CALLBACK (colorsel_water_config_notify),
-                        water);
+          g_signal_connect (water->config, "notify",
+                            G_CALLBACK (colorsel_water_config_notify),
+                            water);
+        }
     }
 }
 
diff --git a/modules/gimpcolorwheel.c b/modules/gimpcolorwheel.c
index 19fb233..4527fc2 100644
--- a/modules/gimpcolorwheel.c
+++ b/modules/gimpcolorwheel.c
@@ -1462,29 +1462,32 @@ gimp_color_wheel_set_color_config (GimpColorWheel  *wheel,
 
   priv = wheel->priv;
 
-  if (priv->config)
+  if (config != priv->config)
     {
-      g_signal_handlers_disconnect_by_func (priv->config,
-                                            gimp_color_wheel_config_notify,
-                                            wheel);
-      g_object_unref (priv->config);
-
-      if (priv->transform)
+      if (priv->config)
         {
-          g_object_unref (priv->transform);
-          priv->transform = NULL;
+          g_signal_handlers_disconnect_by_func (priv->config,
+                                                gimp_color_wheel_config_notify,
+                                                wheel);
+          g_object_unref (priv->config);
+
+          if (priv->transform)
+            {
+              g_object_unref (priv->transform);
+              priv->transform = NULL;
+            }
         }
-    }
 
-  priv->config = config;
+      priv->config = config;
 
-  if (priv->config)
-    {
-      g_object_ref (priv->config);
+      if (priv->config)
+        {
+          g_object_ref (priv->config);
 
-      g_signal_connect (priv->config, "notify",
-                        G_CALLBACK (gimp_color_wheel_config_notify),
-                        wheel);
+          g_signal_connect (priv->config, "notify",
+                            G_CALLBACK (gimp_color_wheel_config_notify),
+                            wheel);
+        }
     }
 }
 


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