Commit 4d6640ff authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

Bug 721249 - pdb.gimp_context_set_brush_size() dont't work

Port selection/path stroking to using the PDB-controllable
paint options that live in GimpPDBContext.

Change gimp_item_stroke()'s "use_default_values" boolean which was
introduced at a time where we had no better way by a GimpPaintOptions
parameter. If a non-NULL paint_options is passed (when called from the
PDB), use it for stroking; if NULL is passed, use the actual paint
tool options from the GUI (when called from the menus or the stroke
dialog). In the PDB wrappers, get the right paint options object from
the PDB context associated with the calling plug-in.
parent 75f1f8c6
......@@ -387,7 +387,8 @@ select_stroke_last_vals_cmd_callback (GtkAction *action,
options = gimp_stroke_options_new (image->gimp, context, TRUE);
if (! gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)),
drawable, context, options, FALSE, TRUE, NULL, &error))
drawable, context, options, NULL,
TRUE, NULL, &error))
{
gimp_message_literal (image->gimp,
G_OBJECT (widget), GIMP_MESSAGE_WARNING,
......
......@@ -432,7 +432,8 @@ vectors_stroke_last_vals_cmd_callback (GtkAction *action,
else
options = gimp_stroke_options_new (image->gimp, context, TRUE);
if (! gimp_item_stroke (GIMP_ITEM (vectors), drawable, context, options, FALSE,
if (! gimp_item_stroke (GIMP_ITEM (vectors),
drawable, context, options, NULL,
TRUE, NULL, &error))
{
gimp_message_literal (image->gimp, G_OBJECT (widget),
......
......@@ -45,6 +45,8 @@
#include "gimpprogress.h"
#include "gimpstrokeoptions.h"
#include "paint/gimppaintoptions.h"
#include "gimp-intl.h"
......@@ -1495,7 +1497,7 @@ gimp_item_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpStrokeOptions *stroke_options,
gboolean use_default_values,
GimpPaintOptions *paint_options,
gboolean push_undo,
GimpProgress *progress,
GError **error)
......@@ -1509,6 +1511,8 @@ gimp_item_stroke (GimpItem *item,
g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), FALSE);
g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (stroke_options), FALSE);
g_return_val_if_fail (paint_options == NULL ||
GIMP_IS_PAINT_OPTIONS (paint_options), FALSE);
g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE);
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
......@@ -1518,7 +1522,7 @@ gimp_item_stroke (GimpItem *item,
{
GimpImage *image = gimp_item_get_image (item);
gimp_stroke_options_prepare (stroke_options, context, use_default_values);
gimp_stroke_options_prepare (stroke_options, context, paint_options);
if (push_undo)
gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_PAINT,
......
......@@ -238,7 +238,7 @@ gboolean gimp_item_stroke (GimpItem *item,
GimpDrawable *drawable,
GimpContext *context,
GimpStrokeOptions *stroke_options,
gboolean use_default_values,
GimpPaintOptions *paint_options,
gboolean push_undo,
GimpProgress *progress,
GError **error);
......
......@@ -546,12 +546,14 @@ gimp_stroke_options_take_dash_pattern (GimpStrokeOptions *options,
void
gimp_stroke_options_prepare (GimpStrokeOptions *options,
GimpContext *context,
gboolean use_default_values)
GimpPaintOptions *paint_options)
{
GimpStrokeOptionsPrivate *private;
g_return_if_fail (GIMP_IS_STROKE_OPTIONS (options));
g_return_if_fail (GIMP_IS_CONTEXT (context));
g_return_if_fail (paint_options == NULL ||
GIMP_IS_PAINT_OPTIONS (paint_options));
private = GET_PRIVATE (options);
......@@ -562,15 +564,11 @@ gimp_stroke_options_prepare (GimpStrokeOptions *options,
case GIMP_STROKE_METHOD_PAINT_CORE:
{
GimpPaintInfo *paint_info = GIMP_CONTEXT (options)->paint_info;
GimpPaintOptions *paint_options;
GimpPaintInfo *paint_info = GIMP_CONTEXT (options)->paint_info;
if (use_default_values)
if (paint_options)
{
paint_options = gimp_paint_options_new (paint_info);
gimp_paint_options_set_default_brush_size (paint_options,
gimp_context_get_brush (context));
g_return_if_fail (paint_info == paint_options->paint_info);
/* undefine the paint-relevant context properties and get them
* from the passed context
......
......@@ -74,7 +74,7 @@ void gimp_stroke_options_take_dash_pattern (GimpStrokeOptions
void gimp_stroke_options_prepare (GimpStrokeOptions *options,
GimpContext *context,
gboolean use_default_values);
GimpPaintOptions *paint_options);
void gimp_stroke_options_finish (GimpStrokeOptions *options);
......
......@@ -297,8 +297,8 @@ stroke_dialog_response (GtkWidget *widget,
saved_options,
(GDestroyNotify) g_object_unref);
if (! gimp_item_stroke (item, drawable, context, options, FALSE, TRUE,
NULL, &error))
if (! gimp_item_stroke (item, drawable, context, options, NULL,
TRUE, NULL, &error))
{
gimp_message_literal (context->gimp,
G_OBJECT (widget),
......
......@@ -25,6 +25,8 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpbase/gimpbase.h"
#include "pdb-types.h"
......@@ -45,6 +47,7 @@
#include "gimppdb.h"
#include "gimppdb-utils.h"
#include "gimppdbcontext.h"
#include "gimpprocedure.h"
#include "internal-procs.h"
......@@ -822,18 +825,25 @@ edit_stroke_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
GimpPaintOptions *paint_options;
options = gimp_stroke_options_new (gimp, context, TRUE);
g_object_set (options,
"method", GIMP_STROKE_METHOD_PAINT_CORE,
NULL);
paint_options =
gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context), NULL);
paint_options = gimp_config_duplicate (GIMP_CONFIG (paint_options));
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)),
drawable, context, options, TRUE, TRUE,
progress, error);
drawable, context, options, paint_options,
TRUE, progress, error);
g_object_unref (options);
g_object_unref (paint_options);
}
else
success = FALSE;
......@@ -867,17 +877,24 @@ edit_stroke_vectors_invoker (GimpProcedure *procedure,
gimp_item_get_image (GIMP_ITEM (drawable)),
0, error))
{
GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
GimpStrokeOptions *options;
GimpPaintOptions *paint_options;
options = gimp_stroke_options_new (gimp, context, TRUE);
g_object_set (options,
"method", GIMP_STROKE_METHOD_PAINT_CORE,
NULL);
paint_options =
gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context), NULL);
paint_options = gimp_config_duplicate (GIMP_CONFIG (paint_options));
success = gimp_item_stroke (GIMP_ITEM (vectors),
drawable, context, options, TRUE, TRUE,
progress, error);
drawable, context, options, paint_options,
TRUE, progress, error);
g_object_unref (options);
g_object_unref (paint_options);
}
else
success = FALSE;
......
......@@ -376,7 +376,9 @@ gimp_pdb_context_get_paint_options (GimpPDBContext *context,
const gchar *name)
{
g_return_val_if_fail (GIMP_IS_PDB_CONTEXT (context), NULL);
g_return_val_if_fail (name != NULL, NULL);
if (! name)
name = gimp_object_get_name (gimp_context_get_paint_info (GIMP_CONTEXT (context)));
return (GimpPaintOptions *)
gimp_container_get_child_by_name (context->paint_options_list, name);
......
......@@ -25,6 +25,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpconfig/gimpconfig.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpbase/gimpbase.h"
......@@ -43,6 +44,7 @@
#include "gimppdb.h"
#include "gimppdb-utils.h"
#include "gimppdbcontext.h"
#include "gimpprocedure.h"
#include "internal-procs.h"
......@@ -338,17 +340,24 @@ path_stroke_current_invoker (GimpProcedure *procedure,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
GimpStrokeOptions *options;
GimpPaintOptions *paint_options;
options = gimp_stroke_options_new (gimp, context, TRUE);
g_object_set (options,
"method", GIMP_STROKE_METHOD_PAINT_CORE,
NULL);
paint_options =
gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context), NULL);
paint_options = gimp_config_duplicate (GIMP_CONFIG (paint_options));
success = gimp_item_stroke (GIMP_ITEM (vectors),
drawable, context, options, TRUE, TRUE,
progress, error);
drawable, context, options, paint_options,
TRUE, progress, error);
g_object_unref (options);
g_object_unref (paint_options);
}
else
success = FALSE;
......
......@@ -903,18 +903,25 @@ HELP
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
GimpPaintOptions *paint_options;
options = gimp_stroke_options_new (gimp, context, TRUE);
g_object_set (options,
"method", GIMP_STROKE_METHOD_PAINT_CORE,
NULL);
paint_options =
gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context), NULL);
paint_options = gimp_config_duplicate (GIMP_CONFIG (paint_options));
success = gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)),
drawable, context, options, TRUE, TRUE,
progress, error);
drawable, context, options, paint_options,
TRUE, progress, error);
g_object_unref (options);
g_object_unref (paint_options);
}
else
success = FALSE;
......@@ -951,17 +958,24 @@ HELP
gimp_item_get_image (GIMP_ITEM (drawable)),
0, error))
{
GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
GimpStrokeOptions *options;
GimpPaintOptions *paint_options;
options = gimp_stroke_options_new (gimp, context, TRUE);
g_object_set (options,
"method", GIMP_STROKE_METHOD_PAINT_CORE,
NULL);
paint_options =
gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context), NULL);
paint_options = gimp_config_duplicate (GIMP_CONFIG (paint_options));
success = gimp_item_stroke (GIMP_ITEM (vectors),
drawable, context, options, TRUE, TRUE,
progress, error);
drawable, context, options, paint_options,
TRUE, progress, error);
g_object_unref (options);
g_object_unref (paint_options);
}
else
success = FALSE;
......@@ -972,12 +986,14 @@ CODE
@headers = qw(<string.h>
"libgimpconfig/gimpconfig.h"
"core/gimp.h"
"core/gimp-edit.h"
"core/gimpimage.h"
"core/gimpimage-new.h"
"core/gimpprogress.h"
"gimppdb-utils.h"
"gimppdbcontext.h"
"gimp-intl.h");
@procs = qw(edit_cut
......
......@@ -271,17 +271,24 @@ sub path_stroke_current {
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
GimpStrokeOptions *options = gimp_stroke_options_new (gimp, context, TRUE);
GimpStrokeOptions *options;
GimpPaintOptions *paint_options;
options = gimp_stroke_options_new (gimp, context, TRUE);
g_object_set (options,
"method", GIMP_STROKE_METHOD_PAINT_CORE,
NULL);
paint_options =
gimp_pdb_context_get_paint_options (GIMP_PDB_CONTEXT (context), NULL);
paint_options = gimp_config_duplicate (GIMP_CONFIG (paint_options));
success = gimp_item_stroke (GIMP_ITEM (vectors),
drawable, context, options, TRUE, TRUE,
progress, error);
drawable, context, options, paint_options,
TRUE, progress, error);
g_object_unref (options);
g_object_unref (paint_options);
}
else
success = FALSE;
......@@ -597,6 +604,7 @@ CODE
@headers = qw(<string.h>
"libgimpconfig/gimpconfig.h"
"libgimpmath/gimpmath.h"
"core/gimplist.h"
"vectors/gimpanchor.h"
......@@ -604,6 +612,7 @@ CODE
"vectors/gimpvectors.h"
"vectors/gimpvectors-compat.h"
"gimppdb-utils.h"
"gimppdbcontext.h"
"gimp-intl.h");
@procs = qw(path_list path_get_current path_set_current path_delete
......
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