Added PDB procedure gimp-context-set-defaults to reset context settings

This commit is contained in:
Kevin Cozens 2011-04-07 21:57:22 -04:00
parent 0d617dabea
commit bf1eca22a6
5 changed files with 92 additions and 2 deletions

View File

@ -22,6 +22,7 @@
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"
#include "libgimpconfig/gimpconfig.h"
#include "pdb-types.h"
@ -80,6 +81,19 @@ context_pop_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GValueArray *
context_set_defaults_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gimp_config_reset (GIMP_CONFIG (context));
return gimp_procedure_get_return_values (procedure, TRUE, NULL);
}
static GValueArray *
context_list_paint_methods_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -1217,6 +1231,23 @@ register_context_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-defaults
*/
procedure = gimp_procedure_new (context_set_defaults_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-defaults");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-defaults",
"Reset context settings to their default values.",
"This procedure resets context settings used by various procedures to their default value. This procedure will usually be called after a context push so that a script which calls procedures affected by context settings will not be affected by changes in the global context.",
"Kevin Cozens <kcozens@svn.gnome.org>",
"Kevin Cozens",
"2011",
NULL);
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-list-paint-methods
*/

View File

@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 629 procedures registered total */
/* 630 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)

View File

@ -97,6 +97,39 @@ gimp_context_pop (void)
return success;
}
/**
* gimp_context_set_defaults:
*
* Reset context settings to their default values.
*
* This procedure resets context settings used by various procedures to
* their default value. This procedure will usually be called after a
* context push so that a script which calls procedures affected by
* context settings will not be affected by changes in the global
* context.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
**/
gboolean
gimp_context_set_defaults (void)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-defaults",
&nreturn_vals,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_context_list_paint_methods:
* @num_paint_methods: The number of the available paint methods.

View File

@ -30,6 +30,7 @@ G_BEGIN_DECLS
gboolean gimp_context_push (void);
gboolean gimp_context_pop (void);
gboolean gimp_context_set_defaults (void);
gboolean gimp_context_list_paint_methods (gint *num_paint_methods,
gchar ***paint_methods);
gchar* gimp_context_get_paint_method (void);

View File

@ -73,6 +73,30 @@ CODE
);
}
sub context_set_defaults {
$blurb = 'Reset context settings to their default values.';
$help = <<'HELP';
This procedure resets context settings used by various procedures to their
default value. This procedure will usually be called after a context push
so that a script which calls procedures affected by context settings will
not be affected by changes in the global context.
HELP
$author = 'Kevin Cozens <kcozens@svn.gnome.org>';
$copyright = 'Kevin Cozens';
$date = '2011';
$since = '2.8';
%invoke = (
code => <<'CODE'
{
gimp_config_reset (GIMP_CONFIG (context));
}
CODE
);
}
sub context_get_paint_method {
$blurb = 'Retrieve the currently active paint method.';
@ -1411,13 +1435,14 @@ CODE
@headers = qw("core/gimp.h"
"core/gimpcontainer.h"
"core/gimpdatafactory.h"
"libgimpconfig/gimpconfig.h"
"plug-in/gimpplugin.h"
"plug-in/gimpplugin-context.h"
"plug-in/gimppluginmanager.h"
"gimppdb-utils.h"
"gimppdbcontext.h");
@procs = qw(context_push context_pop
@procs = qw(context_push context_pop context_set_defaults
context_list_paint_methods
context_get_paint_method context_set_paint_method
context_get_foreground context_set_foreground