Commit bf1eca22 authored by Kevin Cozens's avatar Kevin Cozens

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

parent 0d617dab
......@@ -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
*/
......
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 629 procedures registered total */
/* 630 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -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.
......
......@@ -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);
......
......@@ -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
......
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