add PDB function to determine the available paint methods.

2007-09-11  Simon Budig  <simon@gimp.org>

	* tools/pdbgen/pdb/context.pdb: add PDB function to determine
	the available paint methods.

	* app/pdb/internal_procs.c
	* app/pdb/context_cmds.c
	* libgimp/gimpcontext_pdb.[ch]: regenerated.

	Fixes bug #473513


svn path=/trunk/; revision=23499
This commit is contained in:
Simon Budig 2007-09-11 13:18:41 +00:00 committed by Simon Budig
parent e65331332b
commit 318183ce1f
6 changed files with 148 additions and 13 deletions

View File

@ -1,3 +1,14 @@
2007-09-11 Simon Budig <simon@gimp.org>
* tools/pdbgen/pdb/context.pdb: add PDB function to determine
the available paint methods.
* app/pdb/internal_procs.c
* app/pdb/context_cmds.c
* libgimp/gimpcontext_pdb.[ch]: regenerated.
Fixes bug #473513
2007-09-11 Sven Neumann <sven@gimp.org>
* app/dialogs/file-open-dialog.c: don't reverse the order of URIs

View File

@ -129,6 +129,28 @@ context_set_paint_method_invoker (GimpProcedure *procedure,
return gimp_procedure_get_return_values (procedure, success);
}
static GValueArray *
context_list_paint_methods_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args)
{
GValueArray *return_vals;
gint32 num_paint_methods = 0;
gchar **paint_methods = NULL;
paint_methods = gimp_container_get_name_array (gimp->paint_info_list,
&num_paint_methods);
return_vals = gimp_procedure_get_return_values (procedure, TRUE);
g_value_set_int (&return_vals->values[1], num_paint_methods);
gimp_value_take_stringarray (&return_vals->values[2], paint_methods, num_paint_methods);
return return_vals;
}
static GValueArray *
context_get_foreground_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -650,6 +672,33 @@ register_context_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-list-paint-methods
*/
procedure = gimp_procedure_new (context_list_paint_methods_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure), "gimp-context-list-paint-methods");
gimp_procedure_set_static_strings (procedure,
"gimp-context-list-paint-methods",
"Lists the available paint methods.",
"This procedure lists the names of the available paint methods. Any of the results can be used for 'gimp-context-set-paint-method'.",
"Simon Budig",
"Simon Budig",
"2007",
NULL);
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32 ("num-paint-methods",
"num paint methods",
"The number of the available paint methods",
0, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_string_array ("paint-methods",
"paint methods",
"The names of the available paint methods",
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-foreground
*/

View File

@ -29,7 +29,7 @@
#include "internal_procs.h"
/* 550 procedures registered total */
/* 551 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)

View File

@ -155,6 +155,51 @@ gimp_context_set_paint_method (const gchar *name)
return success;
}
/**
* gimp_context_list_paint_methods:
* @num_paint_methods: The number of the available paint methods.
* @paint_methods: The names of the available paint methods.
*
* Lists the available paint methods.
*
* This procedure lists the names of the available paint methods. Any
* of the results can be used for gimp_context_set_paint_method().
*
* Returns: TRUE on success.
*
* Since: GIMP 2.4
*/
gboolean
gimp_context_list_paint_methods (gint *num_paint_methods,
gchar ***paint_methods)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
gint i;
return_vals = gimp_run_procedure ("gimp-context-list-paint-methods",
&nreturn_vals,
GIMP_PDB_END);
*num_paint_methods = 0;
*paint_methods = NULL;
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
if (success)
{
*num_paint_methods = return_vals[1].data.d_int32;
*paint_methods = g_new (gchar *, *num_paint_methods);
for (i = 0; i < *num_paint_methods; i++)
(*paint_methods)[i] = g_strdup (return_vals[2].data.d_stringarray[i]);
}
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_context_get_foreground:
* @foreground: The foreground color.

View File

@ -32,27 +32,29 @@ 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);
gboolean gimp_context_set_background (const GimpRGB *background);
gboolean gimp_context_set_paint_method (const gchar *name);
gboolean gimp_context_list_paint_methods (gint *num_paint_methods,
gchar ***paint_methods);
gboolean gimp_context_get_foreground (GimpRGB *foreground);
gboolean gimp_context_set_foreground (const GimpRGB *foreground);
gboolean gimp_context_get_background (GimpRGB *background);
gboolean gimp_context_set_background (const GimpRGB *background);
gboolean gimp_context_set_default_colors (void);
gboolean gimp_context_swap_colors (void);
gdouble gimp_context_get_opacity (void);
gboolean gimp_context_set_opacity (gdouble opacity);
gboolean gimp_context_set_opacity (gdouble opacity);
GimpLayerModeEffects gimp_context_get_paint_mode (void);
gboolean gimp_context_set_paint_mode (GimpLayerModeEffects paint_mode);
gboolean gimp_context_set_paint_mode (GimpLayerModeEffects paint_mode);
gchar* gimp_context_get_brush (void);
gboolean gimp_context_set_brush (const gchar *name);
gboolean gimp_context_set_brush (const gchar *name);
gchar* gimp_context_get_pattern (void);
gboolean gimp_context_set_pattern (const gchar *name);
gboolean gimp_context_set_pattern (const gchar *name);
gchar* gimp_context_get_gradient (void);
gboolean gimp_context_set_gradient (const gchar *name);
gboolean gimp_context_set_gradient (const gchar *name);
gchar* gimp_context_get_palette (void);
gboolean gimp_context_set_palette (const gchar *name);
gboolean gimp_context_set_palette (const gchar *name);
gchar* gimp_context_get_font (void);
gboolean gimp_context_set_font (const gchar *name);
gboolean gimp_context_set_font (const gchar *name);
G_END_DECLS

View File

@ -136,6 +136,33 @@ CODE
);
}
sub context_list_paint_methods {
$blurb = 'Lists the available paint methods.';
$help = <<'HELP';
This procedure lists the names of the available paint methods. Any
of the results can be used for gimp_context_set_paint_method().
HELP
&simon_pdb_misc('2007', '2.4');
@outargs = (
{ name => 'paint_methods', type => 'stringarray', void_ret => 1,
desc => 'The names of the available paint methods',
array => { desc => 'The number of the available paint methods' } }
);
%invoke = (
code => <<'CODE'
{
paint_methods = gimp_container_get_name_array (gimp->paint_info_list,
&num_paint_methods);
}
CODE
);
}
sub context_get_foreground {
$blurb = "Get the current GIMP foreground color.";
@ -696,6 +723,7 @@ CODE
@procs = qw(context_push context_pop
context_get_paint_method context_set_paint_method
context_list_paint_methods
context_get_foreground context_set_foreground
context_get_background context_set_background
context_set_default_colors context_swap_colors