[gimp] Bug 721249 - pdb.gimp_context_set_brush_size() dont't work
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Bug 721249 - pdb.gimp_context_set_brush_size() dont't work
- Date: Thu, 6 Feb 2014 22:27:58 +0000 (UTC)
commit 4d6640ff79ff13ae6d031da477a21c85119b2f15
Author: Michael Natterer <mitch gimp org>
Date: Thu Feb 6 23:20:39 2014 +0100
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.
app/actions/select-commands.c | 3 ++-
app/actions/vectors-commands.c | 3 ++-
app/core/gimpitem.c | 8 ++++++--
app/core/gimpitem.h | 2 +-
app/core/gimpstrokeoptions.c | 14 ++++++--------
app/core/gimpstrokeoptions.h | 2 +-
app/dialogs/stroke-dialog.c | 4 ++--
app/pdb/edit-cmds.c | 29 +++++++++++++++++++++++------
app/pdb/gimppdbcontext.c | 4 +++-
app/pdb/paths-cmds.c | 15 ++++++++++++---
tools/pdbgen/pdb/edit.pdb | 28 ++++++++++++++++++++++------
tools/pdbgen/pdb/paths.pdb | 15 ++++++++++++---
12 files changed, 92 insertions(+), 35 deletions(-)
---
diff --git a/app/actions/select-commands.c b/app/actions/select-commands.c
index 3f0e52b..f11dd27 100644
--- a/app/actions/select-commands.c
+++ b/app/actions/select-commands.c
@@ -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,
diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c
index d531546..0880d4e 100644
--- a/app/actions/vectors-commands.c
+++ b/app/actions/vectors-commands.c
@@ -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),
diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c
index 7d50143..fb77010 100644
--- a/app/core/gimpitem.c
+++ b/app/core/gimpitem.c
@@ -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,
diff --git a/app/core/gimpitem.h b/app/core/gimpitem.h
index f35e4dd..7291365 100644
--- a/app/core/gimpitem.h
+++ b/app/core/gimpitem.h
@@ -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);
diff --git a/app/core/gimpstrokeoptions.c b/app/core/gimpstrokeoptions.c
index 2aa5501..2d2577f 100644
--- a/app/core/gimpstrokeoptions.c
+++ b/app/core/gimpstrokeoptions.c
@@ -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
diff --git a/app/core/gimpstrokeoptions.h b/app/core/gimpstrokeoptions.h
index f7737a5..5f125a5 100644
--- a/app/core/gimpstrokeoptions.h
+++ b/app/core/gimpstrokeoptions.h
@@ -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);
diff --git a/app/dialogs/stroke-dialog.c b/app/dialogs/stroke-dialog.c
index 31a159e..a7c10df 100644
--- a/app/dialogs/stroke-dialog.c
+++ b/app/dialogs/stroke-dialog.c
@@ -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),
diff --git a/app/pdb/edit-cmds.c b/app/pdb/edit-cmds.c
index 5f85633..03ac9c3 100644
--- a/app/pdb/edit-cmds.c
+++ b/app/pdb/edit-cmds.c
@@ -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;
diff --git a/app/pdb/gimppdbcontext.c b/app/pdb/gimppdbcontext.c
index c2c9b0e..30ec917 100644
--- a/app/pdb/gimppdbcontext.c
+++ b/app/pdb/gimppdbcontext.c
@@ -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);
diff --git a/app/pdb/paths-cmds.c b/app/pdb/paths-cmds.c
index 34a3cc3..4352452 100644
--- a/app/pdb/paths-cmds.c
+++ b/app/pdb/paths-cmds.c
@@ -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;
diff --git a/tools/pdbgen/pdb/edit.pdb b/tools/pdbgen/pdb/edit.pdb
index 9f6a0f1..8abc97b 100644
--- a/tools/pdbgen/pdb/edit.pdb
+++ b/tools/pdbgen/pdb/edit.pdb
@@ -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
diff --git a/tools/pdbgen/pdb/paths.pdb b/tools/pdbgen/pdb/paths.pdb
index 1967bed..dafbf86 100644
--- a/tools/pdbgen/pdb/paths.pdb
+++ b/tools/pdbgen/pdb/paths.pdb
@@ -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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]