From 634cf6d6203db608450f61447b669291fd472dd5 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Mon, 31 Oct 2011 22:22:19 +0100 Subject: [PATCH] pdb: add gimp-dynamics-refresh and gimp-dynamics-get-list --- app/pdb/Makefile.am | 1 + app/pdb/dynamics-cmds.c | 140 ++++++++++++++++++++++++++++++++++ app/pdb/internal-procs.c | 3 +- app/pdb/internal-procs.h | 1 + libgimp/Makefile.am | 2 + libgimp/gimp.def | 2 + libgimp/gimp_pdb_headers.h | 1 + libgimp/gimpdynamics_pdb.c | 109 ++++++++++++++++++++++++++ libgimp/gimpdynamics_pdb.h | 42 ++++++++++ tools/pdbgen/Makefile.am | 1 + tools/pdbgen/groups.pl | 1 + tools/pdbgen/pdb/dynamics.pdb | 87 +++++++++++++++++++++ 12 files changed, 389 insertions(+), 1 deletion(-) create mode 100644 app/pdb/dynamics-cmds.c create mode 100644 libgimp/gimpdynamics_pdb.c create mode 100644 libgimp/gimpdynamics_pdb.h create mode 100644 tools/pdbgen/pdb/dynamics.pdb diff --git a/app/pdb/Makefile.am b/app/pdb/Makefile.am index d7c41af0d9..b146f6dc35 100644 --- a/app/pdb/Makefile.am +++ b/app/pdb/Makefile.am @@ -47,6 +47,7 @@ libappinternal_procs_a_SOURCES = \ display-cmds.c \ drawable-cmds.c \ drawable-transform-cmds.c \ + dynamics-cmds.c \ edit-cmds.c \ fileops-cmds.c \ floating-sel-cmds.c \ diff --git a/app/pdb/dynamics-cmds.c b/app/pdb/dynamics-cmds.c new file mode 100644 index 0000000000..9e895c45fa --- /dev/null +++ b/app/pdb/dynamics-cmds.c @@ -0,0 +1,140 @@ +/* GIMP - The GNU Image Manipulation Program + * Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* NOTE: This file is auto-generated by pdbgen.pl. */ + +#include "config.h" + +#include + +#include "pdb-types.h" + +#include "core/gimp.h" +#include "core/gimpcontainer-filter.h" +#include "core/gimpcontainer.h" +#include "core/gimpdatafactory.h" +#include "core/gimpparamspecs.h" + +#include "gimppdb.h" +#include "gimpprocedure.h" +#include "internal-procs.h" + + +static GValueArray * +dynamics_refresh_invoker (GimpProcedure *procedure, + Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const GValueArray *args, + GError **error) +{ + gimp_data_factory_data_refresh (gimp->dynamics_factory, context); + + return gimp_procedure_get_return_values (procedure, TRUE, NULL); +} + +static GValueArray * +dynamics_get_list_invoker (GimpProcedure *procedure, + Gimp *gimp, + GimpContext *context, + GimpProgress *progress, + const GValueArray *args, + GError **error) +{ + gboolean success = TRUE; + GValueArray *return_vals; + const gchar *filter; + gint32 num_dynamics = 0; + gchar **dynamics_list = NULL; + + filter = g_value_get_string (&args->values[0]); + + if (success) + { + dynamics_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->dynamics_factory), + filter, &num_dynamics); + } + + return_vals = gimp_procedure_get_return_values (procedure, success, + error ? *error : NULL); + + if (success) + { + g_value_set_int (&return_vals->values[1], num_dynamics); + gimp_value_take_stringarray (&return_vals->values[2], dynamics_list, num_dynamics); + } + + return return_vals; +} + +void +register_dynamics_procs (GimpPDB *pdb) +{ + GimpProcedure *procedure; + + /* + * gimp-dynamics-refresh + */ + procedure = gimp_procedure_new (dynamics_refresh_invoker); + gimp_object_set_static_name (GIMP_OBJECT (procedure), + "gimp-dynamics-refresh"); + gimp_procedure_set_static_strings (procedure, + "gimp-dynamics-refresh", + "Refresh current paint dynamics. This function always succeeds.", + "This procedure retrieves all paint dynamics currently in the user's paint dynamics path and updates the paint dynamics dialogs accordingly.", + "Michael Natterer ", + "Michael Natterer", + "2011", + NULL); + gimp_pdb_register_procedure (pdb, procedure); + g_object_unref (procedure); + + /* + * gimp-dynamics-get-list + */ + procedure = gimp_procedure_new (dynamics_get_list_invoker); + gimp_object_set_static_name (GIMP_OBJECT (procedure), + "gimp-dynamics-get-list"); + gimp_procedure_set_static_strings (procedure, + "gimp-dynamics-get-list", + "Retrieve the list of loaded paint dynamics.", + "This procedure returns a list of the paint dynamics that are currently available.", + "Michael Natterer ", + "Michael Natterer", + "2011", + NULL); + gimp_procedure_add_argument (procedure, + gimp_param_spec_string ("filter", + "filter", + "An optional regular expression used to filter the list", + FALSE, TRUE, FALSE, + NULL, + GIMP_PARAM_READWRITE)); + gimp_procedure_add_return_value (procedure, + gimp_param_spec_int32 ("num-dynamics", + "num dynamics", + "The number of available paint dynamics", + 0, G_MAXINT32, 0, + GIMP_PARAM_READWRITE)); + gimp_procedure_add_return_value (procedure, + gimp_param_spec_string_array ("dynamics-list", + "dynamics list", + "The list of paint dynamics names", + GIMP_PARAM_READWRITE)); + gimp_pdb_register_procedure (pdb, procedure); + g_object_unref (procedure); +} diff --git a/app/pdb/internal-procs.c b/app/pdb/internal-procs.c index ec3a289cc6..8534e58080 100644 --- a/app/pdb/internal-procs.c +++ b/app/pdb/internal-procs.c @@ -28,7 +28,7 @@ #include "internal-procs.h" -/* 638 procedures registered total */ +/* 640 procedures registered total */ void internal_procs_init (GimpPDB *pdb) @@ -46,6 +46,7 @@ internal_procs_init (GimpPDB *pdb) register_display_procs (pdb); register_drawable_procs (pdb); register_drawable_transform_procs (pdb); + register_dynamics_procs (pdb); register_edit_procs (pdb); register_fileops_procs (pdb); register_floating_sel_procs (pdb); diff --git a/app/pdb/internal-procs.h b/app/pdb/internal-procs.h index 95c4b1e75c..f569a8b8a8 100644 --- a/app/pdb/internal-procs.h +++ b/app/pdb/internal-procs.h @@ -35,6 +35,7 @@ void register_convert_procs (GimpPDB *pdb); void register_display_procs (GimpPDB *pdb); void register_drawable_procs (GimpPDB *pdb); void register_drawable_transform_procs (GimpPDB *pdb); +void register_dynamics_procs (GimpPDB *pdb); void register_edit_procs (GimpPDB *pdb); void register_fileops_procs (GimpPDB *pdb); void register_floating_sel_procs (GimpPDB *pdb); diff --git a/libgimp/Makefile.am b/libgimp/Makefile.am index 11e3969abd..45434d468d 100644 --- a/libgimp/Makefile.am +++ b/libgimp/Makefile.am @@ -81,6 +81,7 @@ PDB_WRAPPERS_C = \ gimpdisplay_pdb.c \ gimpdrawable_pdb.c \ gimpdrawabletransform_pdb.c \ + gimpdynamics_pdb.c \ gimpedit_pdb.c \ gimpfileops_pdb.c \ gimpfloatingsel_pdb.c \ @@ -133,6 +134,7 @@ PDB_WRAPPERS_H = \ gimpdisplay_pdb.h \ gimpdrawable_pdb.h \ gimpdrawabletransform_pdb.h \ + gimpdynamics_pdb.h \ gimpedit_pdb.h \ gimpfileops_pdb.h \ gimpfloatingsel_pdb.h \ diff --git a/libgimp/gimp.def b/libgimp/gimp.def index 31294523f4..37c1436000 100644 --- a/libgimp/gimp.def +++ b/libgimp/gimp.def @@ -211,6 +211,8 @@ EXPORTS gimp_drawable_type_with_alpha gimp_drawable_update gimp_drawable_width + gimp_dynamics_get_list + gimp_dynamics_refresh gimp_edit_blend gimp_edit_bucket_fill gimp_edit_bucket_fill_full diff --git a/libgimp/gimp_pdb_headers.h b/libgimp/gimp_pdb_headers.h index 0a868199bf..195c729917 100644 --- a/libgimp/gimp_pdb_headers.h +++ b/libgimp/gimp_pdb_headers.h @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include diff --git a/libgimp/gimpdynamics_pdb.c b/libgimp/gimpdynamics_pdb.c new file mode 100644 index 0000000000..14eb6cfe63 --- /dev/null +++ b/libgimp/gimpdynamics_pdb.c @@ -0,0 +1,109 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball + * + * gimpdynamics_pdb.c + * + * This library is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +/* NOTE: This file is auto-generated by pdbgen.pl */ + +#include "config.h" + +#include "gimp.h" + + +/** + * SECTION: gimpdynamics + * @title: gimpdynamics + * @short_description: Operations related to dynamics. + * + * Operations related to dynamics. + **/ + + +/** + * gimp_dynamics_refresh: + * + * Refresh current paint dynamics. This function always succeeds. + * + * This procedure retrieves all paint dynamics currently in the user's + * paint dynamics path and updates the paint dynamics dialogs + * accordingly. + * + * Returns: TRUE on success. + * + * Since: GIMP 2.8 + **/ +gboolean +gimp_dynamics_refresh (void) +{ + GimpParam *return_vals; + gint nreturn_vals; + gboolean success = TRUE; + + return_vals = gimp_run_procedure ("gimp-dynamics-refresh", + &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_dynamics_get_list: + * @filter: An optional regular expression used to filter the list. + * @num_dynamics: The number of available paint dynamics. + * + * Retrieve the list of loaded paint dynamics. + * + * This procedure returns a list of the paint dynamics that are + * currently available. + * + * Returns: The list of paint dynamics names. + * + * Since: GIMP 2.8 + **/ +gchar ** +gimp_dynamics_get_list (const gchar *filter, + gint *num_dynamics) +{ + GimpParam *return_vals; + gint nreturn_vals; + gchar **dynamics_list = NULL; + gint i; + + return_vals = gimp_run_procedure ("gimp-dynamics-get-list", + &nreturn_vals, + GIMP_PDB_STRING, filter, + GIMP_PDB_END); + + *num_dynamics = 0; + + if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS) + { + *num_dynamics = return_vals[1].data.d_int32; + dynamics_list = g_new (gchar *, *num_dynamics); + for (i = 0; i < *num_dynamics; i++) + dynamics_list[i] = g_strdup (return_vals[2].data.d_stringarray[i]); + } + + gimp_destroy_params (return_vals, nreturn_vals); + + return dynamics_list; +} diff --git a/libgimp/gimpdynamics_pdb.h b/libgimp/gimpdynamics_pdb.h new file mode 100644 index 0000000000..8365d86502 --- /dev/null +++ b/libgimp/gimpdynamics_pdb.h @@ -0,0 +1,42 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball + * + * gimpdynamics_pdb.h + * + * This library is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +/* NOTE: This file is auto-generated by pdbgen.pl */ + +#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __GIMP_DYNAMICS_PDB_H__ +#define __GIMP_DYNAMICS_PDB_H__ + +G_BEGIN_DECLS + +/* For information look into the C source or the html documentation */ + + +gboolean gimp_dynamics_refresh (void); +gchar** gimp_dynamics_get_list (const gchar *filter, + gint *num_dynamics); + + +G_END_DECLS + +#endif /* __GIMP_DYNAMICS_PDB_H__ */ diff --git a/tools/pdbgen/Makefile.am b/tools/pdbgen/Makefile.am index a324813c13..802740b3d2 100644 --- a/tools/pdbgen/Makefile.am +++ b/tools/pdbgen/Makefile.am @@ -13,6 +13,7 @@ pdb_sources = \ pdb/display.pdb \ pdb/drawable.pdb \ pdb/drawable_transform.pdb \ + pdb/dynamics.pdb \ pdb/edit.pdb \ pdb/fileops.pdb \ pdb/floating_sel.pdb \ diff --git a/tools/pdbgen/groups.pl b/tools/pdbgen/groups.pl index 4681c3d235..98f294baec 100644 --- a/tools/pdbgen/groups.pl +++ b/tools/pdbgen/groups.pl @@ -11,6 +11,7 @@ display drawable drawable_transform + dynamics edit fileops floating_sel diff --git a/tools/pdbgen/pdb/dynamics.pdb b/tools/pdbgen/pdb/dynamics.pdb new file mode 100644 index 0000000000..db79881b6c --- /dev/null +++ b/tools/pdbgen/pdb/dynamics.pdb @@ -0,0 +1,87 @@ +# GIMP - The GNU Image Manipulation Program +# Copyright (C) 1995 Spencer Kimball and Peter Mattis + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# "Perlized" from C source by Manish Singh + +sub dynamics_refresh { + $blurb = 'Refresh current paint dynamics. This function always succeeds.'; + + $help = <<'HELP'; +This procedure retrieves all paint dynamics currently in the user's +paint dynamics path and updates the paint dynamics dialogs +accordingly. +HELP + + &mitch_pdb_misc('2011', '2.8'); + + %invoke = ( + code => <<'CODE' +{ + gimp_data_factory_data_refresh (gimp->dynamics_factory, context); +} +CODE + ); +} + +sub dynamics_get_list { + $blurb = 'Retrieve the list of loaded paint dynamics.'; + + $help = <<'HELP'; +This procedure returns a list of the paint dynamics that are currently +available. +HELP + + &mitch_pdb_misc('2011', '2.8'); + + @inargs = ( + { name => 'filter', type => 'string', null_ok => 1, + desc => 'An optional regular expression used to filter the list' } + ); + + @outargs = ( + { name => 'dynamics_list', type => 'stringarray', + desc => 'The list of paint dynamics names', + array => { name => 'num_dynamics', + desc => 'The number of available paint dynamics' } } + ); + + %invoke = ( + headers => [ qw("core/gimpcontainer-filter.h") ], + code => <<'CODE' +{ + dynamics_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->dynamics_factory), + filter, &num_dynamics); +} +CODE + ); +} + + +@headers = qw("core/gimp.h" + "core/gimpcontainer.h" + "core/gimpdatafactory.h"); + +@procs = qw(dynamics_refresh + dynamics_get_list); + +%exports = (app => [@procs], lib => [@procs]); + +$desc = 'Paint Dynamics'; +$doc_title = 'gimpdynamics'; +$doc_short_desc = 'Operations related to paint dynamics.'; +$doc_long_desc = 'Operations related to paint dynamics.'; + +1;