Commit b9ba9058 authored by Massimo Valentini's avatar Massimo Valentini

Bug 678085 - Cage tool freezes GIMP

Use a proper "progress" signal instead of a property "notify" one
to update the on-canvas progress widget.

This way the graph is not invalidated while processing it
parent 589dd3d4
......@@ -74,13 +74,11 @@ gimp_gegl_color_new (const GimpRGB *rgb)
static void
gimp_gegl_progress_notify (GObject *object,
const GParamSpec *pspec,
gdouble value,
GimpProgress *progress)
{
const gchar *text;
gdouble value;
g_object_get (object, "progress", &value, NULL);
text = g_object_get_data (object, "gimp-progress-text");
......@@ -115,7 +113,7 @@ gimp_gegl_progress_connect (GeglNode *node,
g_return_if_fail (operation != NULL);
g_signal_connect (operation, "notify::progress",
g_signal_connect (operation, "progress",
G_CALLBACK (gimp_gegl_progress_notify),
progress);
......
......@@ -28,6 +28,7 @@
#include "operations-types.h"
#include "core/gimpmarshal.h"
#include "gimpoperationcagetransform.h"
#include "gimpcageconfig.h"
......@@ -38,7 +39,12 @@ enum
PROP_0,
PROP_CONFIG,
PROP_FILL,
PROP_PROGRESS
};
enum
{
PROGRESS,
LAST_SIGNAL
};
......@@ -88,6 +94,8 @@ G_DEFINE_TYPE (GimpOperationCageTransform, gimp_operation_cage_transform,
#define parent_class gimp_operation_cage_transform_parent_class
static guint cage_transform_signals[LAST_SIGNAL] = { 0 };
static void
gimp_operation_cage_transform_class_init (GimpOperationCageTransformClass *klass)
......@@ -96,6 +104,15 @@ gimp_operation_cage_transform_class_init (GimpOperationCageTransformClass *klass
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationComposerClass *filter_class = GEGL_OPERATION_COMPOSER_CLASS (klass);
cage_transform_signals[PROGRESS] =
g_signal_new ("progress",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
gimp_marshal_VOID__DOUBLE,
G_TYPE_NONE, 0);
object_class->get_property = gimp_operation_cage_transform_get_property;
object_class->set_property = gimp_operation_cage_transform_set_property;
object_class->finalize = gimp_operation_cage_transform_finalize;
......@@ -129,13 +146,6 @@ gimp_operation_cage_transform_class_init (GimpOperationCageTransformClass *klass
_("Fill the original position of the cage with a plain color"),
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_PROGRESS,
g_param_spec_double ("progress",
"Progress",
"Progress indicator, and a bad hack",
0.0, 1.0, 0.0,
G_PARAM_READABLE));
}
static void
......@@ -174,9 +184,6 @@ gimp_operation_cage_transform_get_property (GObject *object,
case PROP_FILL:
g_value_set_boolean (value, self->fill_plain_color);
break;
case PROP_PROGRESS:
g_value_set_double (value, self->progress);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
......@@ -222,6 +229,13 @@ gimp_operation_cage_transform_prepare (GeglOperation *operation)
babl_format_n (babl_type ("float"), 2));
}
static void
gimp_operation_cage_transform_notify_progress (gpointer instance,
gdouble progress)
{
g_signal_emit (instance, cage_transform_signals[PROGRESS], 0, progress);
}
static gboolean
gimp_operation_cage_transform_process (GeglOperation *operation,
GeglBuffer *in_buf,
......@@ -299,8 +313,7 @@ gimp_operation_cage_transform_process (GeglOperation *operation,
}
}
oct->progress = 0.0;
g_object_notify (G_OBJECT (oct), "progress");
gimp_operation_cage_transform_notify_progress (oct, 0.0);
/* pre-allocate memory outside of the loop */
coords = g_slice_alloc (2 * sizeof (gfloat));
......@@ -365,8 +378,7 @@ gimp_operation_cage_transform_process (GeglOperation *operation,
/* 0.0 and 1.0 indicate progress start/end, so avoid them */
if (fraction > 0.0 && fraction < 1.0)
{
oct->progress = fraction;
g_object_notify (G_OBJECT (oct), "progress");
gimp_operation_cage_transform_notify_progress (oct, fraction);
}
}
}
......@@ -374,8 +386,7 @@ gimp_operation_cage_transform_process (GeglOperation *operation,
g_free (coef);
g_slice_free1 (2 * sizeof (gfloat), coords);
oct->progress = 1.0;
g_object_notify (G_OBJECT (oct), "progress");
gimp_operation_cage_transform_notify_progress (oct, 1.0);
return TRUE;
}
......
......@@ -44,8 +44,6 @@ struct _GimpOperationCageTransform
gboolean fill_plain_color;
const Babl *format_coords;
gdouble progress; /* bad hack */
};
struct _GimpOperationCageTransformClass
......
......@@ -29,6 +29,7 @@
#include "operations-types.h"
#include "core/gimpmarshal.h"
#include "gimpoperationshapeburst.h"
......@@ -36,7 +37,12 @@ enum
{
PROP_0,
PROP_NORMALIZE,
PROP_PROGRESS
};
enum
{
PROGRESS,
LAST_SIGNAL
};
......@@ -69,6 +75,8 @@ G_DEFINE_TYPE (GimpOperationShapeburst, gimp_operation_shapeburst,
#define parent_class gimp_operation_shapeburst_parent_class
static guint shapeburst_signals[LAST_SIGNAL] = { 0 };
static void
gimp_operation_shapeburst_class_init (GimpOperationShapeburstClass *klass)
......@@ -77,6 +85,15 @@ gimp_operation_shapeburst_class_init (GimpOperationShapeburstClass *klass)
GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
GeglOperationFilterClass *filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
shapeburst_signals[PROGRESS] =
g_signal_new ("progress",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
0,
NULL, NULL,
gimp_marshal_VOID__DOUBLE,
G_TYPE_NONE, 0);
object_class->set_property = gimp_operation_shapeburst_set_property;
object_class->get_property = gimp_operation_shapeburst_get_property;
......@@ -98,13 +115,6 @@ gimp_operation_shapeburst_class_init (GimpOperationShapeburstClass *klass)
"Normalize",
FALSE,
G_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_PROGRESS,
g_param_spec_double ("progress",
"Progress",
"Progress indicator, and a bad hack",
0.0, 1.0, 0.0,
G_PARAM_READWRITE));
}
static void
......@@ -126,10 +136,6 @@ gimp_operation_shapeburst_get_property (GObject *object,
g_value_set_boolean (value, self->normalize);
break;
case PROP_PROGRESS:
g_value_set_double (value, self->progress);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -150,16 +156,19 @@ gimp_operation_shapeburst_set_property (GObject *object,
self->normalize = g_value_get_boolean (value);
break;
case PROP_PROGRESS:
self->progress = g_value_get_double (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_operation_shapeburst_notify_progress (gpointer instance,
gdouble progress)
{
g_signal_emit (instance, shapeburst_signals[PROGRESS], 0, progress);
}
static void
gimp_operation_shapeburst_prepare (GeglOperation *operation)
{
......@@ -310,9 +319,7 @@ gimp_operation_shapeburst_process (GeglOperation *operation,
0, output_format, distbuf_cur,
GEGL_AUTO_ROWSTRIDE);
g_object_set (operation,
"progress", (gdouble) y / roi->height,
NULL);
gimp_operation_shapeburst_notify_progress (operation, (gdouble) y / roi->height);
}
g_free (distbuf);
......@@ -334,5 +341,7 @@ gimp_operation_shapeburst_process (GeglOperation *operation,
}
}
gimp_operation_shapeburst_notify_progress (operation, 1.0);
return TRUE;
}
......@@ -41,7 +41,6 @@ struct _GimpOperationShapeburst
GeglOperationFilter parent_instance;
gboolean normalize;
gdouble progress;
};
struct _GimpOperationShapeburstClass
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment