[gimp] app: connect GimpHistogramView to bg-histogram "notify" signal



commit 4ad72cfc77f870d801c4a0ab49958f8fb2b057b7
Author: Ell <ell_se yahoo com>
Date:   Fri May 11 21:26:25 2018 -0400

    app: connect GimpHistogramView to bg-histogram "notify" signal
    
    In GimpHistogramView, connect the view to the bg-histogram's
    "notify" signal, and update the view in response.  Previously, we
    only updated the view in response to the main histogram's "notify"
    signal.
    
    The curves tool only uses the bg-histogram, and after the switch to
    asynchronous histogram calculation, in commit
    49382e53d55d3be65135130a2898038aad1a3719, it failed to update the
    histogram view after the calculation was complete.

 app/widgets/gimphistogramview.c |   38 ++++++++++++++++++++++++--------------
 1 files changed, 24 insertions(+), 14 deletions(-)
---
diff --git a/app/widgets/gimphistogramview.c b/app/widgets/gimphistogramview.c
index 80c27e6..2b8f6b1 100644
--- a/app/widgets/gimphistogramview.c
+++ b/app/widgets/gimphistogramview.c
@@ -643,8 +643,7 @@ gimp_histogram_view_set_histogram (GimpHistogramView *view,
                             G_CALLBACK (gimp_histogram_view_notify),
                             view);
 
-          if (view->n_bins != gimp_histogram_n_bins (histogram))
-            gimp_histogram_view_update_bins (view);
+          gimp_histogram_view_update_bins (view);
 
           if (view->channel >= gimp_histogram_n_channels (histogram))
             gimp_histogram_view_set_channel (view, GIMP_HISTOGRAM_VALUE);
@@ -677,7 +676,12 @@ gimp_histogram_view_set_background (GimpHistogramView *view,
   if (view->bg_histogram != histogram)
     {
       if (view->bg_histogram)
-        g_object_unref (view->bg_histogram);
+        {
+          g_signal_handlers_disconnect_by_func (view->bg_histogram,
+                                                gimp_histogram_view_notify,
+                                                view);
+          g_object_unref (view->bg_histogram);
+        }
 
       view->bg_histogram = histogram;
 
@@ -685,8 +689,11 @@ gimp_histogram_view_set_background (GimpHistogramView *view,
         {
           g_object_ref (histogram);
 
-          if (view->n_bins != gimp_histogram_n_bins (histogram))
-            gimp_histogram_view_update_bins (view);
+          g_signal_connect (histogram, "notify",
+                            G_CALLBACK (gimp_histogram_view_notify),
+                            view);
+
+          gimp_histogram_view_update_bins (view);
 
           if (view->channel >= gimp_histogram_n_channels (histogram))
             gimp_histogram_view_set_channel (view, GIMP_HISTOGRAM_VALUE);
@@ -799,15 +806,18 @@ gimp_histogram_view_update_bins (GimpHistogramView *view)
   else if (view->bg_histogram)
     new_bins = gimp_histogram_n_bins (view->bg_histogram);
 
-  view->start = ROUND (((gdouble) view->start *
-                        (new_bins - 1) /
-                        (view->n_bins - 1)));
-  view->end   = ROUND (((gdouble) view->end   *
-                        (new_bins - 1) /
-                        (view->n_bins - 1)));
+  if (new_bins != view->n_bins)
+    {
+      view->start = ROUND (((gdouble) view->start *
+                            (new_bins - 1) /
+                            (view->n_bins - 1)));
+      view->end   = ROUND (((gdouble) view->end   *
+                            (new_bins - 1) /
+                            (view->n_bins - 1)));
 
-  view->n_bins = new_bins;
+      view->n_bins = new_bins;
 
-  g_signal_emit (view, histogram_view_signals[RANGE_CHANGED], 0,
-                 view->start, view->end);
+      g_signal_emit (view, histogram_view_signals[RANGE_CHANGED], 0,
+                     view->start, view->end);
+    }
 }


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