Commit dd171bbf authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

Bug 760175 - paintbrush size not applied in python scripts in version 2.9

Remove the code that links size, spacing etc. to brush defaults from
the GimpPaintOptions class impl and add it to gimppaintoptions-gui.c
as a callback instead.

It's not a core thing and that magic with side effects should only be
applied to the GimpPaintOptions behind the tool options GUI.
parent 84030aaf
......@@ -149,10 +149,6 @@ static gboolean gimp_paint_options_copy (GimpConfig *src,
GimpConfig *dest,
GParamFlags flags);
static void gimp_paint_options_brush_changed (GimpContext *context,
GimpBrush *brush);
G_DEFINE_TYPE_WITH_CODE (GimpPaintOptions, gimp_paint_options,
GIMP_TYPE_TOOL_OPTIONS,
......@@ -167,16 +163,13 @@ static GimpConfigInterface *parent_config_iface = NULL;
static void
gimp_paint_options_class_init (GimpPaintOptionsClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpContextClass *context_class = GIMP_CONTEXT_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = gimp_paint_options_dispose;
object_class->finalize = gimp_paint_options_finalize;
object_class->set_property = gimp_paint_options_set_property;
object_class->get_property = gimp_paint_options_get_property;
context_class->brush_changed = gimp_paint_options_brush_changed;
g_object_class_install_property (object_class, PROP_PAINT_INFO,
g_param_spec_object ("paint-info",
NULL, NULL,
......@@ -743,24 +736,7 @@ gimp_paint_options_get_property (GObject *object,
static GimpConfig *
gimp_paint_options_duplicate (GimpConfig *config)
{
GimpPaintOptions *options = GIMP_PAINT_OPTIONS (config);
GimpPaintOptions *new_options;
new_options = GIMP_PAINT_OPTIONS (parent_config_iface->duplicate (config));
/* after duplicating, copy those properties again which might have
* changed by setting the brush on the copy, see
* gimp_paint_options_brush_changed().
*/
g_object_set (new_options,
"brush-size", options->brush_size,
"brush-aspect-ratio", options->brush_aspect_ratio,
"brush-angle", options->brush_angle,
"brush-spacing", options->brush_spacing,
"brush-hardness", options->brush_hardness,
NULL);
return GIMP_CONFIG (new_options);
return parent_config_iface->duplicate (config);
}
static gboolean
......@@ -768,55 +744,7 @@ gimp_paint_options_copy (GimpConfig *src,
GimpConfig *dest,
GParamFlags flags)
{
if (parent_config_iface->copy (src, dest, flags))
{
GimpPaintOptions *options = GIMP_PAINT_OPTIONS (src);
/* after copying, copy those properties again which might have
* changed by setting the brush on dest, see
* gimp_paint_options_brush_changed().
*/
g_object_set (dest,
"brush-size", options->brush_size,
"brush-aspect-ratio", options->brush_aspect_ratio,
"brush-angle", options->brush_angle,
"brush-spacing", options->brush_spacing,
"brush-hardness", options->brush_hardness,
NULL);
return TRUE;
}
return FALSE;
}
static void
gimp_paint_options_brush_changed (GimpContext *context,
GimpBrush *brush)
{
GimpPaintOptions *options = GIMP_PAINT_OPTIONS (context);
if (GIMP_IS_BRUSH (brush))
{
if (options->brush_link_size)
gimp_paint_options_set_default_brush_size (options, brush);
if (options->brush_link_aspect_ratio)
g_object_set (options,
"brush-aspect-ratio", 0.0,
NULL);
if (options->brush_link_angle)
g_object_set (options,
"brush-angle", 0.0,
NULL);
if (options->brush_link_spacing)
gimp_paint_options_set_default_brush_spacing (options, brush);
if (options->brush_link_hardness)
gimp_paint_options_set_default_brush_hardness (options, brush);
}
return parent_config_iface->copy (src, dest, flags);
}
GimpPaintOptions *
......
......@@ -51,6 +51,10 @@
#include "gimp-intl.h"
static void gimp_paint_options_gui_brush_changed
(GimpContext *context,
GimpBrush *brush);
static void gimp_paint_options_gui_reset_size (GtkWidget *button,
GimpPaintOptions *paint_options);
static void gimp_paint_options_gui_reset_aspect_ratio
......@@ -224,6 +228,10 @@ gimp_paint_options_gui (GimpToolOptions *tool_options)
frame = jitter_options_gui (options, tool_type);
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
gtk_widget_show (frame);
g_signal_connect (options, "brush-changed",
G_CALLBACK (gimp_paint_options_gui_brush_changed),
NULL);
}
/* the "smooth stroke" options */
......@@ -419,6 +427,35 @@ smoothing_options_gui (GimpPaintOptions *paint_options,
return frame;
}
static void
gimp_paint_options_gui_brush_changed (GimpContext *context,
GimpBrush *brush)
{
GimpPaintOptions *options = GIMP_PAINT_OPTIONS (context);
if (brush)
{
if (options->brush_link_size)
gimp_paint_options_set_default_brush_size (options, brush);
if (options->brush_link_aspect_ratio)
g_object_set (options,
"brush-aspect-ratio", 0.0,
NULL);
if (options->brush_link_angle)
g_object_set (options,
"brush-angle", 0.0,
NULL);
if (options->brush_link_spacing)
gimp_paint_options_set_default_brush_spacing (options, brush);
if (options->brush_link_hardness)
gimp_paint_options_set_default_brush_hardness (options, brush);
}
}
static void
gimp_paint_options_gui_reset_size (GtkWidget *button,
GimpPaintOptions *paint_options)
......
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