[gimp] Added PDB procedure gimp-context-set-defaults to reset context settings
- From: Kevin Cozens <kcozens src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Added PDB procedure gimp-context-set-defaults to reset context settings
- Date: Fri, 8 Apr 2011 03:16:24 +0000 (UTC)
commit bf1eca22a6ae9a06f5a91635eef3277c1a0d8ba7
Author: Kevin Cozens <kcozens cvs gnome org>
Date: Thu Apr 7 21:57:22 2011 -0400
Added PDB procedure gimp-context-set-defaults to reset context settings
app/pdb/context-cmds.c | 31 +++++++++++++++++++++++++++++++
app/pdb/internal-procs.c | 2 +-
libgimp/gimpcontext_pdb.c | 33 +++++++++++++++++++++++++++++++++
libgimp/gimpcontext_pdb.h | 1 +
tools/pdbgen/pdb/context.pdb | 27 ++++++++++++++++++++++++++-
5 files changed, 92 insertions(+), 2 deletions(-)
---
diff --git a/app/pdb/context-cmds.c b/app/pdb/context-cmds.c
index d987298..0c5e689 100644
--- a/app/pdb/context-cmds.c
+++ b/app/pdb/context-cmds.c
@@ -22,6 +22,7 @@
#include <gegl.h>
#include "libgimpcolor/gimpcolor.h"
+#include "libgimpconfig/gimpconfig.h"
#include "pdb-types.h"
@@ -81,6 +82,19 @@ context_pop_invoker (GimpProcedure *procedure,
}
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,
GimpContext *context,
@@ -1218,6 +1232,23 @@ register_context_procs (GimpPDB *pdb)
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
*/
procedure = gimp_procedure_new (context_list_paint_methods_invoker);
diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c
index a16da75..85277f1 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 90dc7e9..778ae17 100644
--- a/libgimp/gimpcontext_pdb.c
+++ b/libgimp/gimpcontext_pdb.c
@@ -98,6 +98,39 @@ gimp_context_pop (void)
}
/**
+ * 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.
* @paint_methods: The names of the available paint methods.
diff --git a/libgimp/gimpcontext_pdb.h b/libgimp/gimpcontext_pdb.h
index 060c048..165f172 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 b45b7ed..0bd8d76 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 <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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]