mirror of https://github.com/GNOME/gimp.git
tools/pdbgen/pdb/context.pdb added gimp-context-get/set-paint-method which
2006-01-02 Michael Natterer <mitch@gimp.org> * tools/pdbgen/pdb/context.pdb * libgimp/gimp.def: added gimp-context-get/set-paint-method which get/set the context's paint-info by name. Use these functions to stroke with any paint method (still only with its default paint options). * app/pdb/context_cmds.c * app/pdb/internal_procs.c * libgimp/gimpcontext_pdb.[ch]: regenerated.
This commit is contained in:
parent
6f1f9c1d46
commit
d78aaac8bf
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
|||
2006-01-02 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* tools/pdbgen/pdb/context.pdb
|
||||
* libgimp/gimp.def: added gimp-context-get/set-paint-method which
|
||||
get/set the context's paint-info by name. Use these functions to
|
||||
stroke with any paint method (still only with its default paint
|
||||
options).
|
||||
|
||||
* app/pdb/context_cmds.c
|
||||
* app/pdb/internal_procs.c
|
||||
* libgimp/gimpcontext_pdb.[ch]: regenerated.
|
||||
|
||||
2006-01-02 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/gimpimage-convert-data.h
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
|
||||
static ProcRecord context_push_proc;
|
||||
static ProcRecord context_pop_proc;
|
||||
static ProcRecord context_get_paint_method_proc;
|
||||
static ProcRecord context_set_paint_method_proc;
|
||||
static ProcRecord context_get_foreground_proc;
|
||||
static ProcRecord context_set_foreground_proc;
|
||||
static ProcRecord context_get_background_proc;
|
||||
|
@ -63,6 +65,8 @@ register_context_procs (Gimp *gimp)
|
|||
{
|
||||
procedural_db_register (gimp, &context_push_proc);
|
||||
procedural_db_register (gimp, &context_pop_proc);
|
||||
procedural_db_register (gimp, &context_get_paint_method_proc);
|
||||
procedural_db_register (gimp, &context_set_paint_method_proc);
|
||||
procedural_db_register (gimp, &context_get_foreground_proc);
|
||||
procedural_db_register (gimp, &context_set_foreground_proc);
|
||||
procedural_db_register (gimp, &context_get_background_proc);
|
||||
|
@ -157,6 +161,108 @@ static ProcRecord context_pop_proc =
|
|||
{ { context_pop_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
context_get_paint_method_invoker (Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
Argument *return_args;
|
||||
GimpPaintInfo *paint_info;
|
||||
|
||||
success = (paint_info = gimp_context_get_paint_info (context)) != NULL;
|
||||
|
||||
return_args = procedural_db_return_args (&context_get_paint_method_proc, success);
|
||||
|
||||
if (success)
|
||||
return_args[1].value.pdb_pointer = g_strdup (gimp_object_get_name (GIMP_OBJECT (paint_info)));
|
||||
|
||||
return return_args;
|
||||
}
|
||||
|
||||
static ProcArg context_get_paint_method_outargs[] =
|
||||
{
|
||||
{
|
||||
GIMP_PDB_STRING,
|
||||
"name",
|
||||
"The name of the active paint method"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord context_get_paint_method_proc =
|
||||
{
|
||||
"gimp-context-get-paint-method",
|
||||
"gimp-context-get-paint-method",
|
||||
"Retrieve the currently active paint method.",
|
||||
"This procedure returns the name of the currently active paint method.",
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"2005",
|
||||
NULL,
|
||||
GIMP_INTERNAL,
|
||||
0,
|
||||
NULL,
|
||||
1,
|
||||
context_get_paint_method_outargs,
|
||||
{ { context_get_paint_method_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
context_set_paint_method_invoker (Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
Argument *args)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
gchar *name;
|
||||
GimpPaintInfo *paint_info;
|
||||
|
||||
name = (gchar *) args[0].value.pdb_pointer;
|
||||
if (name == NULL || !g_utf8_validate (name, -1, NULL))
|
||||
success = FALSE;
|
||||
|
||||
if (success)
|
||||
{
|
||||
paint_info = (GimpPaintInfo *)
|
||||
gimp_container_get_child_by_name (gimp->paint_info_list, name);
|
||||
|
||||
if (paint_info)
|
||||
gimp_context_set_paint_info (context, paint_info);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&context_set_paint_method_proc, success);
|
||||
}
|
||||
|
||||
static ProcArg context_set_paint_method_inargs[] =
|
||||
{
|
||||
{
|
||||
GIMP_PDB_STRING,
|
||||
"name",
|
||||
"The name of the paint method"
|
||||
}
|
||||
};
|
||||
|
||||
static ProcRecord context_set_paint_method_proc =
|
||||
{
|
||||
"gimp-context-set-paint-method",
|
||||
"gimp-context-set-paint-method",
|
||||
"Set the specified paint method as the active paint method.",
|
||||
"This procedure allows the active paint method to be set by specifying its name. The name is simply a string which corresponds to one of the names of the available paint methods. If there is no matching method found, this procedure will return an error. Otherwise, the specified method becomes active and will be used in all subsequent paint operations.",
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"2005",
|
||||
NULL,
|
||||
GIMP_INTERNAL,
|
||||
1,
|
||||
context_set_paint_method_inargs,
|
||||
0,
|
||||
NULL,
|
||||
{ { context_set_paint_method_invoker } }
|
||||
};
|
||||
|
||||
static Argument *
|
||||
context_get_foreground_invoker (Gimp *gimp,
|
||||
GimpContext *context,
|
||||
|
@ -595,7 +701,7 @@ static ProcRecord context_get_brush_proc =
|
|||
"gimp-context-get-brush",
|
||||
"gimp-context-get-brush",
|
||||
"Retrieve the currently active brush.",
|
||||
"This procedure returns the nme of the currently active brush. All paint operations and stroke operations use this brush to control the application of paint to the image.",
|
||||
"This procedure returns the name of the currently active brush. All paint operations and stroke operations use this brush to control the application of paint to the image.",
|
||||
"Michael Natterer <mitch@gimp.org> & Sven Neumann <sven@gimp.org>",
|
||||
"Michael Natterer & Sven Neumann",
|
||||
"2004",
|
||||
|
@ -641,7 +747,7 @@ static ProcArg context_set_brush_inargs[] =
|
|||
{
|
||||
GIMP_PDB_STRING,
|
||||
"name",
|
||||
"The name o the brush"
|
||||
"The name of the brush"
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ void register_undo_procs (Gimp *gimp);
|
|||
void register_unit_procs (Gimp *gimp);
|
||||
void register_vectors_procs (Gimp *gimp);
|
||||
|
||||
/* 521 procedures registered total */
|
||||
/* 523 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (Gimp *gimp)
|
||||
|
|
|
@ -72,6 +72,7 @@ EXPORTS
|
|||
gimp_context_get_foreground
|
||||
gimp_context_get_gradient
|
||||
gimp_context_get_opacity
|
||||
gimp_context_get_paint_method
|
||||
gimp_context_get_paint_mode
|
||||
gimp_context_get_palette
|
||||
gimp_context_get_pattern
|
||||
|
@ -84,6 +85,7 @@ EXPORTS
|
|||
gimp_context_set_foreground
|
||||
gimp_context_set_gradient
|
||||
gimp_context_set_opacity
|
||||
gimp_context_set_paint_method
|
||||
gimp_context_set_paint_mode
|
||||
gimp_context_set_palette
|
||||
gimp_context_set_pattern
|
||||
|
|
|
@ -86,6 +86,73 @@ gimp_context_pop (void)
|
|||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_context_get_paint_method:
|
||||
*
|
||||
* Retrieve the currently active paint method.
|
||||
*
|
||||
* This procedure returns the name of the currently active paint
|
||||
* method.
|
||||
*
|
||||
* Returns: The name of the active paint method.
|
||||
*
|
||||
* Since: GIMP 2.4
|
||||
*/
|
||||
gchar *
|
||||
gimp_context_get_paint_method (void)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gchar *name = NULL;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-context-get-paint-method",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_END);
|
||||
|
||||
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
|
||||
name = g_strdup (return_vals[1].data.d_string);
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_context_set_paint_method:
|
||||
* @name: The name of the paint method.
|
||||
*
|
||||
* Set the specified paint method as the active paint method.
|
||||
*
|
||||
* This procedure allows the active paint method to be set by
|
||||
* specifying its name. The name is simply a string which corresponds
|
||||
* to one of the names of the available paint methods. If there is no
|
||||
* matching method found, this procedure will return an error.
|
||||
* Otherwise, the specified method becomes active and will be used in
|
||||
* all subsequent paint operations.
|
||||
*
|
||||
* Returns: TRUE on success.
|
||||
*
|
||||
* Since: GIMP 2.4
|
||||
*/
|
||||
gboolean
|
||||
gimp_context_set_paint_method (const gchar *name)
|
||||
{
|
||||
GimpParam *return_vals;
|
||||
gint nreturn_vals;
|
||||
gboolean success = TRUE;
|
||||
|
||||
return_vals = gimp_run_procedure ("gimp-context-set-paint-method",
|
||||
&nreturn_vals,
|
||||
GIMP_PDB_STRING, name,
|
||||
GIMP_PDB_END);
|
||||
|
||||
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
|
||||
|
||||
gimp_destroy_params (return_vals, nreturn_vals);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_context_get_foreground:
|
||||
* @foreground: The foreground color.
|
||||
|
@ -416,7 +483,7 @@ gimp_context_set_paint_mode (GimpLayerModeEffects paint_mode)
|
|||
*
|
||||
* Retrieve the currently active brush.
|
||||
*
|
||||
* This procedure returns the nme of the currently active brush. All
|
||||
* This procedure returns the name of the currently active brush. All
|
||||
* paint operations and stroke operations use this brush to control the
|
||||
* application of paint to the image.
|
||||
*
|
||||
|
@ -445,7 +512,7 @@ gimp_context_get_brush (void)
|
|||
|
||||
/**
|
||||
* gimp_context_set_brush:
|
||||
* @name: The name o the brush.
|
||||
* @name: The name of the brush.
|
||||
*
|
||||
* Set the specified brush as the active brush.
|
||||
*
|
||||
|
|
|
@ -31,6 +31,8 @@ G_BEGIN_DECLS
|
|||
|
||||
gboolean gimp_context_push (void);
|
||||
gboolean gimp_context_pop (void);
|
||||
gchar* gimp_context_get_paint_method (void);
|
||||
gboolean gimp_context_set_paint_method (const gchar *name);
|
||||
gboolean gimp_context_get_foreground (GimpRGB *foreground);
|
||||
gboolean gimp_context_set_foreground (const GimpRGB *foreground);
|
||||
gboolean gimp_context_get_background (GimpRGB *background);
|
||||
|
|
|
@ -24,6 +24,13 @@ sub pdb_misc {
|
|||
$since = '2.2';
|
||||
}
|
||||
|
||||
sub mitch_misc {
|
||||
$author = 'Michael Natterer <mitch@gimp.org>';
|
||||
$copyright = 'Michael Natterer';
|
||||
$date = '2005';
|
||||
$since = '2.4';
|
||||
}
|
||||
|
||||
sub context_push {
|
||||
$blurb = 'Pushes a context to the top of the plug-in\'s context stack.';
|
||||
|
||||
|
@ -77,6 +84,63 @@ CODE
|
|||
);
|
||||
}
|
||||
|
||||
sub context_get_paint_method {
|
||||
$blurb = 'Retrieve the currently active paint method.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure returns the name of the currently active paint method.
|
||||
HELP
|
||||
|
||||
&mitch_misc;
|
||||
|
||||
@outargs = (
|
||||
{ name => 'name', type => 'string',
|
||||
desc => 'The name of the active paint method',
|
||||
alias => 'g_strdup (gimp_object_get_name (GIMP_OBJECT (paint_info)))',
|
||||
no_declare => 1 }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'GimpPaintInfo *paint_info' ],
|
||||
code => 'success = (paint_info = gimp_context_get_paint_info (context)) != NULL;'
|
||||
);
|
||||
}
|
||||
|
||||
sub context_set_paint_method {
|
||||
$blurb = 'Set the specified paint method as the active paint method.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure allows the active paint method to be set by specifying
|
||||
its name. The name is simply a string which corresponds to one of the
|
||||
names of the available paint methods. If there is no matching method
|
||||
found, this procedure will return an error. Otherwise, the specified
|
||||
method becomes active and will be used in all subsequent paint
|
||||
operations.
|
||||
HELP
|
||||
|
||||
&mitch_misc;
|
||||
|
||||
@inargs = (
|
||||
{ name => 'name', type => 'string',
|
||||
desc => 'The name of the paint method' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
vars => [ 'GimpPaintInfo *paint_info' ],
|
||||
code => <<'CODE'
|
||||
{
|
||||
paint_info = (GimpPaintInfo *)
|
||||
gimp_container_get_child_by_name (gimp->paint_info_list, name);
|
||||
|
||||
if (paint_info)
|
||||
gimp_context_set_paint_info (context, paint_info);
|
||||
else
|
||||
success = FALSE;
|
||||
}
|
||||
CODE
|
||||
);
|
||||
}
|
||||
|
||||
sub context_get_foreground {
|
||||
$blurb = "Get the current GIMP foreground color.";
|
||||
|
||||
|
@ -275,7 +339,7 @@ sub context_get_brush {
|
|||
$blurb = 'Retrieve the currently active brush.';
|
||||
|
||||
$help = <<'HELP';
|
||||
This procedure returns the nme of the currently active brush.
|
||||
This procedure returns the name of the currently active brush.
|
||||
All paint operations and stroke operations use this brush to control
|
||||
the application of paint to the image.
|
||||
HELP
|
||||
|
@ -310,7 +374,7 @@ HELP
|
|||
|
||||
@inargs = (
|
||||
{ name => 'name', type => 'string',
|
||||
desc => 'The name o the brush' }
|
||||
desc => 'The name of the brush' }
|
||||
);
|
||||
|
||||
%invoke = (
|
||||
|
@ -560,6 +624,7 @@ CODE
|
|||
"plug-in/plug-in.h" "plug-in/plug-in-context.h");
|
||||
|
||||
@procs = qw(context_push context_pop
|
||||
context_get_paint_method context_set_paint_method
|
||||
context_get_foreground context_set_foreground
|
||||
context_get_background context_set_background
|
||||
context_set_default_colors context_swap_colors
|
||||
|
|
Loading…
Reference in New Issue