diff --git a/app/pdb/context-cmds.c b/app/pdb/context-cmds.c index d987298814..0c5e689b14 100644 --- a/app/pdb/context-cmds.c +++ b/app/pdb/context-cmds.c @@ -22,6 +22,7 @@ #include #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 ", + "Kevin Cozens", + "2011", + NULL); + gimp_pdb_register_procedure (pdb, procedure); + g_object_unref (procedure); + /* * gimp-context-list-paint-methods */ diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c index a16da7549f..85277f1393 100644 --- a/app/pdb/internal-procs.c +++ b/app/pdb/internal-procs.c @@ -28,7 +28,7 @@ #include "internal-procs.h" -/* 629 procedures registered total */ +/* 630 procedures registered total */ void internal_procs_init (GimpPDB *pdb) diff --git a/libgimp/gimpcontext_pdb.c b/libgimp/gimpcontext_pdb.c index 90dc7e916f..778ae179c7 100644 --- a/libgimp/gimpcontext_pdb.c +++ b/libgimp/gimpcontext_pdb.c @@ -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. diff --git a/libgimp/gimpcontext_pdb.h b/libgimp/gimpcontext_pdb.h index 060c048e4d..165f17201c 100644 --- a/libgimp/gimpcontext_pdb.h +++ b/libgimp/gimpcontext_pdb.h @@ -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); diff --git a/tools/pdbgen/pdb/context.pdb b/tools/pdbgen/pdb/context.pdb index b45b7ed0d6..0bd8d76dbd 100644 --- a/tools/pdbgen/pdb/context.pdb +++ b/tools/pdbgen/pdb/context.pdb @@ -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 '; + $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