[gimp] app: replace GimpHistogramEditor's "valid" by "recompute" flag.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: replace GimpHistogramEditor's "valid" by "recompute" flag.
- Date: Wed, 21 Feb 2018 18:50:11 +0000 (UTC)
commit 1a8edbed51db2ef60ee8b8118f89c781d9ad9eb3
Author: Jehan <jehan girinstud io>
Date: Wed Feb 21 17:02:07 2018 +0100
app: replace GimpHistogramEditor's "valid" by "recompute" flag.
Having to sync the "valid" flag with the presence of a histogram is
error-prone (cf. previous commit).
Instead gimp_histogram_editor_validate() return value will just depend
on the presence of the histogram. And "valid" becomes "recompute", i.e.
a flag to request for "recomputation" of the histogram.
app/widgets/gimphistogrameditor.c | 23 ++++++++---------------
app/widgets/gimphistogrameditor.h | 2 +-
2 files changed, 9 insertions(+), 16 deletions(-)
---
diff --git a/app/widgets/gimphistogrameditor.c b/app/widgets/gimphistogrameditor.c
index d771189..685f1f9 100644
--- a/app/widgets/gimphistogrameditor.c
+++ b/app/widgets/gimphistogrameditor.c
@@ -252,7 +252,6 @@ gimp_histogram_editor_set_property (GObject *object,
if (editor->histogram)
{
g_clear_object (&editor->histogram);
- editor->valid = FALSE;
gimp_histogram_view_set_histogram (view, NULL);
}
@@ -350,7 +349,6 @@ gimp_histogram_editor_set_image (GimpImageEditor *image_editor,
if (editor->histogram)
{
g_clear_object (&editor->histogram);
- editor->valid = FALSE;
gimp_histogram_view_set_histogram (view, NULL);
}
@@ -396,7 +394,6 @@ gimp_histogram_editor_layer_changed (GimpImage *image,
if (editor->histogram)
{
g_clear_object (&editor->histogram);
- editor->valid = FALSE;
gimp_histogram_view_set_histogram (view, NULL);
}
@@ -451,7 +448,7 @@ gimp_histogram_editor_layer_changed (GimpImage *image,
}
else if (editor->histogram)
{
- editor->valid = FALSE;
+ editor->recompute = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (editor->box));
}
@@ -462,7 +459,7 @@ gimp_histogram_editor_layer_changed (GimpImage *image,
static gboolean
gimp_histogram_editor_validate (GimpHistogramEditor *editor)
{
- if (! editor->valid)
+ if (editor->recompute || ! editor->histogram)
{
if (editor->drawable)
{
@@ -479,19 +476,16 @@ gimp_histogram_editor_validate (GimpHistogramEditor *editor)
editor->histogram,
TRUE);
}
- else
+ else if (editor->histogram)
{
- if (editor->histogram)
- gimp_histogram_clear_values (editor->histogram);
+ gimp_histogram_clear_values (editor->histogram);
}
gimp_histogram_editor_info_update (editor);
-
- if (editor->histogram)
- editor->valid = TRUE;
+ editor->recompute = FALSE;
}
- return editor->valid;
+ return (editor->histogram != NULL);
}
static void
@@ -552,11 +546,10 @@ gimp_histogram_editor_idle_update (GimpHistogramEditor *editor)
{
editor->idle_id = 0;
- /* Mark the histogram as invalid and queue a redraw.
+ /* Mark the histogram for recomputation and queue a redraw.
* We will then recalculate the histogram when the view is exposed.
*/
-
- editor->valid = FALSE;
+ editor->recompute = TRUE;
gtk_widget_queue_draw (GTK_WIDGET (editor->box));
return FALSE;
diff --git a/app/widgets/gimphistogrameditor.h b/app/widgets/gimphistogrameditor.h
index 33bf399..f92562e 100644
--- a/app/widgets/gimphistogrameditor.h
+++ b/app/widgets/gimphistogrameditor.h
@@ -43,7 +43,7 @@ struct _GimpHistogramEditor
GimpHistogram *bg_histogram;
guint idle_id;
- gboolean valid;
+ gboolean recompute;
GtkWidget *menu;
GtkWidget *box;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]