From 85adefe7baeb42f0115ce30c82d9607f9cc67e32 Mon Sep 17 00:00:00 2001 From: Sven Neumann Date: Thu, 4 Sep 2003 17:04:36 +0000 Subject: [PATCH] app/core/Makefile.am app/core/core-types.h added filter functionality for 2003-09-04 Sven Neumann * app/core/Makefile.am * app/core/core-types.h * app/core/gimpcontainer-filter.[ch]: added filter functionality for GimpContainers. * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/fonts.pdb * tools/pdbgen/pdb/gradients.pdb * tools/pdbgen/pdb/palettes.pdb * tools/pdbgen/pdb/patterns.pdb: made the gimp_foo_get_list() PDB function somewhat useful by adding a filter parameter that allows to specify a regular expression to be used on the list. * app/pdb/Makefile.am: had to uglify the ugly hack even more :( * app/pdb/brushes_cmds.c * app/pdb/fonts_cmds.c * app/pdb/gradients_cmds.c * app/pdb/palettes_cmds.c * app/pdb/patterns_cmds.c * libgimp/gimpbrushes_pdb.[ch] * libgimp/gimpfonts_pdb.[ch] * libgimp/gimpgradients_pdb.[ch] * libgimp/gimppalettes_pdb.[ch] * libgimp/gimppatterns_pdb.[ch]: regenerated. * plug-ins/gflare/gflare.c * plug-ins/pygimp/gimpmodule.c: changed accordingly. * plug-ins/script-fu/scripts/font-map.scm: replaced the font list parameter with a more useful regexp filter on the available fonts. --- ChangeLog | 34 ++++ app/core/Makefile.am | 2 + app/core/core-types.h | 3 + app/core/gimpcontainer-filter.c | 196 +++++++++++++++++++++ app/core/gimpcontainer-filter.h | 39 ++++ app/pdb/Makefile.am | 2 +- app/pdb/brushes_cmds.c | 32 +++- app/pdb/fonts_cmds.c | 32 +++- app/pdb/gradients_cmds.c | 32 +++- app/pdb/palettes_cmds.c | 32 +++- app/pdb/patterns_cmds.c | 32 +++- devel-docs/ChangeLog | 8 + devel-docs/libgimp/tmpl/gimpbrushes.sgml | 1 + devel-docs/libgimp/tmpl/gimpfonts.sgml | 1 + devel-docs/libgimp/tmpl/gimpgradients.sgml | 1 + devel-docs/libgimp/tmpl/gimppalettes.sgml | 1 + devel-docs/libgimp/tmpl/gimppatterns.sgml | 1 + libgimp/gimpbrushes_pdb.c | 5 +- libgimp/gimpbrushes_pdb.h | 3 +- libgimp/gimpfonts_pdb.c | 5 +- libgimp/gimpfonts_pdb.h | 3 +- libgimp/gimpgradients_pdb.c | 5 +- libgimp/gimpgradients_pdb.h | 3 +- libgimp/gimppalettes_pdb.c | 5 +- libgimp/gimppalettes_pdb.h | 3 +- libgimp/gimppatterns_pdb.c | 5 +- libgimp/gimppatterns_pdb.h | 3 +- plug-ins/gflare/gflare.c | 2 +- plug-ins/pygimp/gimpmodule.c | 2 +- plug-ins/script-fu/scripts/font-map.scm | 9 +- tools/pdbgen/pdb/brushes.pdb | 9 +- tools/pdbgen/pdb/fonts.pdb | 9 +- tools/pdbgen/pdb/gradients.pdb | 9 +- tools/pdbgen/pdb/palettes.pdb | 9 +- tools/pdbgen/pdb/patterns.pdb | 9 +- 35 files changed, 495 insertions(+), 52 deletions(-) create mode 100644 app/core/gimpcontainer-filter.c create mode 100644 app/core/gimpcontainer-filter.h diff --git a/ChangeLog b/ChangeLog index 797801e90b..f0d8baa2e2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,37 @@ +2003-09-04 Sven Neumann + + * app/core/Makefile.am + * app/core/core-types.h + * app/core/gimpcontainer-filter.[ch]: added filter functionality + for GimpContainers. + + * tools/pdbgen/pdb/brushes.pdb + * tools/pdbgen/pdb/fonts.pdb + * tools/pdbgen/pdb/gradients.pdb + * tools/pdbgen/pdb/palettes.pdb + * tools/pdbgen/pdb/patterns.pdb: made the gimp_foo_get_list() + PDB function somewhat useful by adding a filter parameter that + allows to specify a regular expression to be used on the list. + + * app/pdb/Makefile.am: had to uglify the ugly hack even more :( + + * app/pdb/brushes_cmds.c + * app/pdb/fonts_cmds.c + * app/pdb/gradients_cmds.c + * app/pdb/palettes_cmds.c + * app/pdb/patterns_cmds.c + * libgimp/gimpbrushes_pdb.[ch] + * libgimp/gimpfonts_pdb.[ch] + * libgimp/gimpgradients_pdb.[ch] + * libgimp/gimppalettes_pdb.[ch] + * libgimp/gimppatterns_pdb.[ch]: regenerated. + + * plug-ins/gflare/gflare.c + * plug-ins/pygimp/gimpmodule.c: changed accordingly. + + * plug-ins/script-fu/scripts/font-map.scm: replaced the font list + parameter with a more useful regexp filter on the available fonts. + 2003-09-04 Sven Neumann * app/core/gimpcontainer.[ch] (gimp_container_get_name_array): diff --git a/app/core/Makefile.am b/app/core/Makefile.am index efe1d95f4a..9686b0c42b 100644 --- a/app/core/Makefile.am +++ b/app/core/Makefile.am @@ -47,6 +47,8 @@ libappcore_a_sources = \ gimpchannel-combine.h \ gimpcontainer.c \ gimpcontainer.h \ + gimpcontainer-filter.c \ + gimpcontainer-filter.h \ gimpcontext.c \ gimpcontext.h \ gimpdata.c \ diff --git a/app/core/core-types.h b/app/core/core-types.h index 62d5afc467..634db42cb1 100644 --- a/app/core/core-types.h +++ b/app/core/core-types.h @@ -143,6 +143,9 @@ typedef void (* GimpInitStatusFunc) (const gchar *text1, typedef GimpData * (* GimpDataObjectLoaderFunc) (const gchar *filename); +typedef gboolean (* GimpObjectFilterFunc) (const GimpObject *object, + gpointer user_data); + typedef gboolean (* GimpUndoPopFunc) (GimpUndo *undo, GimpUndoMode undo_mode, GimpUndoAccumulator *accum); diff --git a/app/core/gimpcontainer-filter.c b/app/core/gimpcontainer-filter.c new file mode 100644 index 0000000000..3036232e6f --- /dev/null +++ b/app/core/gimpcontainer-filter.c @@ -0,0 +1,196 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * gimpcontainer-filter.c + * Copyright (C) 2003 Sven Neumann + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "config.h" + +#include + +#include + +#ifdef HAVE_GLIBC_REGEX +#include +#else +#include "regexrepl/regex.h" +#endif + +#include "core-types.h" + +#include "gimpcontainer.h" +#include "gimpcontainer-filter.h" +#include "gimplist.h" + + +typedef struct +{ + GimpObjectFilterFunc filter; + GimpContainer *container; + gpointer user_data; +} GimpContainerFilterContext; + + +static void +gimp_container_filter_foreach_func (GimpObject *object, + GimpContainerFilterContext *context) +{ + if (context->filter (object, context->user_data)) + gimp_container_add (context->container, object); +} + +/** + * gimp_container_filter: + * @container: a #GimpContainer to filter + * @filter: a #GimpObjectFilterFunc + * @user_data: a pointer passed to @filter + * + * Calls the supplied @filter function on each object in @container. + * A return value of %TRUE is interpreted as a match. + * + * Returns: a weak #GimpContainer filled with matching objects. + **/ +GimpContainer * +gimp_container_filter (const GimpContainer *container, + GimpObjectFilterFunc filter, + gpointer user_data) +{ + GimpContainer *result; + GimpContainerFilterContext context; + + g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); + g_return_val_if_fail (filter != NULL, NULL); + + result = + g_object_new (G_TYPE_FROM_INSTANCE (container), + "children_type", gimp_container_children_type (container), + "policy", GIMP_CONTAINER_POLICY_WEAK, + NULL); + + context.filter = filter; + context.container = result; + context.user_data = user_data; + + gimp_container_foreach (container, + (GFunc) gimp_container_filter_foreach_func, + &context); + + /* This is somewhat ugly, but it keeps lists in the same order. */ + if (GIMP_IS_LIST (result)) + gimp_list_reverse (GIMP_LIST (result)); + + + return result; +} + + +static gboolean +gimp_object_filter_by_name (const GimpObject *object, + const regex_t *regex) +{ + return (regexec (regex, + gimp_object_get_name (object), 0, NULL, 0) != REG_NOMATCH); +} + +/** + * gimp_container_filter_by_name: + * @container: a #GimpContainer to filter + * @regexp: a regular expression (as a %NULL-terminated string) + * @error: error location to report errors or %NULL + * + * This function performs a case-insensitive regular expression search + * on the names of the GimpObjects in @container. + * + * Returns: a weak #GimpContainer filled with matching objects. + **/ +GimpContainer * +gimp_container_filter_by_name (const GimpContainer *container, + const gchar *regexp, + GError **error) +{ + GimpContainer *result; + gint ret; + regex_t regex; + + g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); + g_return_val_if_fail (regexp != NULL, NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); + + ret = regcomp (®ex, regexp, REG_ICASE | REG_NOSUB); + if (ret) + { + gsize error_len; + gchar *error_buf; + + error_len = regerror (ret, ®ex, NULL, 0); + error_buf = g_new (gchar, error_len); + + regerror (ret, ®ex, error_buf, error_len); + + g_set_error (error, 0, 0, error_buf); + + g_free (error_buf); + regfree (®ex); + + return NULL; + } + + result = + gimp_container_filter (container, + (GimpObjectFilterFunc) gimp_object_filter_by_name, + ®ex); + + regfree (®ex); + + return result; +} + + +gchar ** +gimp_container_get_filtered_name_array (const GimpContainer *container, + const gchar *regexp, + gint *length) +{ + GimpContainer *weak; + GError *error = NULL; + + g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); + g_return_val_if_fail (length != NULL, NULL); + + if (regexp == NULL || strlen (regexp) == 0) + return (gimp_container_get_name_array (container, length)); + + weak = gimp_container_filter_by_name (container, regexp, &error); + + if (weak) + { + gchar **retval = gimp_container_get_name_array (weak, length); + + g_object_unref (weak); + + return retval; + } + else + { + g_warning (error->message); + g_error_free (error); + + *length = 0; + return NULL; + } +} diff --git a/app/core/gimpcontainer-filter.h b/app/core/gimpcontainer-filter.h new file mode 100644 index 0000000000..a87a0498ce --- /dev/null +++ b/app/core/gimpcontainer-filter.h @@ -0,0 +1,39 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis + * + * gimpcontainer-filter.c + * Copyright (C) 2003 Sven Neumann + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifndef __GIMP_CONTAINER_FILTER_H__ +#define __GIMP_CONTAINER_FILTER_H__ + + +GimpContainer * gimp_container_filter (const GimpContainer *container, + GimpObjectFilterFunc filter, + gpointer user_data); +GimpContainer * gimp_container_filter_by_name (const GimpContainer *container, + const gchar *regexp, + GError **error); + +gchar ** gimp_container_get_filtered_name_array + (const GimpContainer *container, + const gchar *regexp, + gint *length); + + +#endif /* __GIMP_CONTAINER_FILTER_H__ */ diff --git a/app/pdb/Makefile.am b/app/pdb/Makefile.am index cae62e8661..194a6beccc 100644 --- a/app/pdb/Makefile.am +++ b/app/pdb/Makefile.am @@ -49,7 +49,7 @@ libapppdb_a_SOURCES = \ unit_cmds.c ## This is a truly ugly hack -libapppdb_a_LIBADD = ../gui/pattern-select.o ../gui/brush-select.o ../gui/font-select.o +libapppdb_a_LIBADD = ../core/gimpcontainer-filter.o ../gui/pattern-select.o ../gui/brush-select.o ../gui/font-select.o AM_CPPFLAGS = \ -DG_LOG_DOMAIN=\"Gimp-PDB\" \ diff --git a/app/pdb/brushes_cmds.c b/app/pdb/brushes_cmds.c index aaeadfb28e..208dd5d23e 100644 --- a/app/pdb/brushes_cmds.c +++ b/app/pdb/brushes_cmds.c @@ -32,6 +32,7 @@ #include "base/temp-buf.h" #include "core/gimp.h" #include "core/gimpbrush.h" +#include "core/gimpcontainer-filter.h" #include "core/gimpcontext.h" #include "core/gimpdatafactory.h" #include "core/gimplist.h" @@ -102,20 +103,39 @@ static Argument * brushes_get_list_invoker (Gimp *gimp, Argument *args) { + gboolean success = TRUE; Argument *return_args; + gchar *filter; gint32 num_brushes; gchar **brush_list; - brush_list = gimp_container_get_name_array (gimp->brush_factory->container, &num_brushes); + filter = (gchar *) args[0].value.pdb_pointer; + if (filter && !g_utf8_validate (filter, -1, NULL)) + success = FALSE; - return_args = procedural_db_return_args (&brushes_get_list_proc, TRUE); + if (success) + brush_list = gimp_container_get_filtered_name_array (gimp->brush_factory->container, filter, &num_brushes); - return_args[1].value.pdb_int = num_brushes; - return_args[2].value.pdb_pointer = brush_list; + return_args = procedural_db_return_args (&brushes_get_list_proc, success); + + if (success) + { + return_args[1].value.pdb_int = num_brushes; + return_args[2].value.pdb_pointer = brush_list; + } return return_args; } +static ProcArg brushes_get_list_inargs[] = +{ + { + GIMP_PDB_STRING, + "filter", + "An optional regular expression used to filter the list" + } +}; + static ProcArg brushes_get_list_outargs[] = { { @@ -139,8 +159,8 @@ static ProcRecord brushes_get_list_proc = "Spencer Kimball & Peter Mattis", "1995-1996", GIMP_INTERNAL, - 0, - NULL, + 1, + brushes_get_list_inargs, 2, brushes_get_list_outargs, { { brushes_get_list_invoker } } diff --git a/app/pdb/fonts_cmds.c b/app/pdb/fonts_cmds.c index 864063a1c7..74499a6d81 100644 --- a/app/pdb/fonts_cmds.c +++ b/app/pdb/fonts_cmds.c @@ -29,6 +29,7 @@ #include "procedural_db.h" #include "core/gimp.h" +#include "core/gimpcontainer-filter.h" #include "core/gimpcontainer.h" #include "text/gimpfonts.h" @@ -70,20 +71,39 @@ static Argument * fonts_get_list_invoker (Gimp *gimp, Argument *args) { + gboolean success = TRUE; Argument *return_args; + gchar *filter; gint32 num_fonts; gchar **font_list; - font_list = gimp_container_get_name_array (gimp->fonts, &num_fonts); + filter = (gchar *) args[0].value.pdb_pointer; + if (filter && !g_utf8_validate (filter, -1, NULL)) + success = FALSE; - return_args = procedural_db_return_args (&fonts_get_list_proc, TRUE); + if (success) + font_list = gimp_container_get_filtered_name_array (gimp->fonts, filter, &num_fonts); - return_args[1].value.pdb_int = num_fonts; - return_args[2].value.pdb_pointer = font_list; + return_args = procedural_db_return_args (&fonts_get_list_proc, success); + + if (success) + { + return_args[1].value.pdb_int = num_fonts; + return_args[2].value.pdb_pointer = font_list; + } return return_args; } +static ProcArg fonts_get_list_inargs[] = +{ + { + GIMP_PDB_STRING, + "filter", + "An optional regular expression used to filter the list" + } +}; + static ProcArg fonts_get_list_outargs[] = { { @@ -107,8 +127,8 @@ static ProcRecord fonts_get_list_proc = "Sven Neumann", "2003", GIMP_INTERNAL, - 0, - NULL, + 1, + fonts_get_list_inargs, 2, fonts_get_list_outargs, { { fonts_get_list_invoker } } diff --git a/app/pdb/gradients_cmds.c b/app/pdb/gradients_cmds.c index 8c768edbdf..a405e1ad12 100644 --- a/app/pdb/gradients_cmds.c +++ b/app/pdb/gradients_cmds.c @@ -30,6 +30,7 @@ #include "procedural_db.h" #include "core/gimp.h" +#include "core/gimpcontainer-filter.h" #include "core/gimpcontainer.h" #include "core/gimpcontext.h" #include "core/gimpdatafactory.h" @@ -85,20 +86,39 @@ static Argument * gradients_get_list_invoker (Gimp *gimp, Argument *args) { + gboolean success = TRUE; Argument *return_args; + gchar *filter; gint32 num_gradients; gchar **gradient_list; - gradient_list = gimp_container_get_name_array (gimp->gradient_factory->container, &num_gradients); + filter = (gchar *) args[0].value.pdb_pointer; + if (filter && !g_utf8_validate (filter, -1, NULL)) + success = FALSE; - return_args = procedural_db_return_args (&gradients_get_list_proc, TRUE); + if (success) + gradient_list = gimp_container_get_filtered_name_array (gimp->gradient_factory->container, filter, &num_gradients); - return_args[1].value.pdb_int = num_gradients; - return_args[2].value.pdb_pointer = gradient_list; + return_args = procedural_db_return_args (&gradients_get_list_proc, success); + + if (success) + { + return_args[1].value.pdb_int = num_gradients; + return_args[2].value.pdb_pointer = gradient_list; + } return return_args; } +static ProcArg gradients_get_list_inargs[] = +{ + { + GIMP_PDB_STRING, + "filter", + "An optional regular expression used to filter the list" + } +}; + static ProcArg gradients_get_list_outargs[] = { { @@ -122,8 +142,8 @@ static ProcRecord gradients_get_list_proc = "Federico Mena Quintero", "1997", GIMP_INTERNAL, - 0, - NULL, + 1, + gradients_get_list_inargs, 2, gradients_get_list_outargs, { { gradients_get_list_invoker } } diff --git a/app/pdb/palettes_cmds.c b/app/pdb/palettes_cmds.c index a5456cd09a..be7eac3e23 100644 --- a/app/pdb/palettes_cmds.c +++ b/app/pdb/palettes_cmds.c @@ -30,6 +30,7 @@ #include "procedural_db.h" #include "core/gimp.h" +#include "core/gimpcontainer-filter.h" #include "core/gimpcontext.h" #include "core/gimpdatafactory.h" #include "core/gimplist.h" @@ -91,20 +92,39 @@ static Argument * palettes_get_list_invoker (Gimp *gimp, Argument *args) { + gboolean success = TRUE; Argument *return_args; + gchar *filter; gint32 num_palettes; gchar **palette_list; - palette_list = gimp_container_get_name_array (gimp->palette_factory->container, &num_palettes); + filter = (gchar *) args[0].value.pdb_pointer; + if (filter && !g_utf8_validate (filter, -1, NULL)) + success = FALSE; - return_args = procedural_db_return_args (&palettes_get_list_proc, TRUE); + if (success) + palette_list = gimp_container_get_filtered_name_array (gimp->palette_factory->container, filter, &num_palettes); - return_args[1].value.pdb_int = num_palettes; - return_args[2].value.pdb_pointer = palette_list; + return_args = procedural_db_return_args (&palettes_get_list_proc, success); + + if (success) + { + return_args[1].value.pdb_int = num_palettes; + return_args[2].value.pdb_pointer = palette_list; + } return return_args; } +static ProcArg palettes_get_list_inargs[] = +{ + { + GIMP_PDB_STRING, + "filter", + "An optional regular expression used to filter the list" + } +}; + static ProcArg palettes_get_list_outargs[] = { { @@ -128,8 +148,8 @@ static ProcRecord palettes_get_list_proc = "Nathan Summers", "2001", GIMP_INTERNAL, - 0, - NULL, + 1, + palettes_get_list_inargs, 2, palettes_get_list_outargs, { { palettes_get_list_invoker } } diff --git a/app/pdb/patterns_cmds.c b/app/pdb/patterns_cmds.c index 3ac7db16fa..62917bade4 100644 --- a/app/pdb/patterns_cmds.c +++ b/app/pdb/patterns_cmds.c @@ -31,6 +31,7 @@ #include "base/temp-buf.h" #include "core/gimp.h" +#include "core/gimpcontainer-filter.h" #include "core/gimpcontext.h" #include "core/gimpdatafactory.h" #include "core/gimplist.h" @@ -81,20 +82,39 @@ static Argument * patterns_get_list_invoker (Gimp *gimp, Argument *args) { + gboolean success = TRUE; Argument *return_args; + gchar *filter; gint32 num_patterns; gchar **pattern_list; - pattern_list = gimp_container_get_name_array (gimp->pattern_factory->container, &num_patterns); + filter = (gchar *) args[0].value.pdb_pointer; + if (filter && !g_utf8_validate (filter, -1, NULL)) + success = FALSE; - return_args = procedural_db_return_args (&patterns_get_list_proc, TRUE); + if (success) + pattern_list = gimp_container_get_filtered_name_array (gimp->pattern_factory->container, filter, &num_patterns); - return_args[1].value.pdb_int = num_patterns; - return_args[2].value.pdb_pointer = pattern_list; + return_args = procedural_db_return_args (&patterns_get_list_proc, success); + + if (success) + { + return_args[1].value.pdb_int = num_patterns; + return_args[2].value.pdb_pointer = pattern_list; + } return return_args; } +static ProcArg patterns_get_list_inargs[] = +{ + { + GIMP_PDB_STRING, + "filter", + "An optional regular expression used to filter the list" + } +}; + static ProcArg patterns_get_list_outargs[] = { { @@ -118,8 +138,8 @@ static ProcRecord patterns_get_list_proc = "Spencer Kimball & Peter Mattis", "1995-1996", GIMP_INTERNAL, - 0, - NULL, + 1, + patterns_get_list_inargs, 2, patterns_get_list_outargs, { { patterns_get_list_invoker } } diff --git a/devel-docs/ChangeLog b/devel-docs/ChangeLog index 3fa9e611d6..b775f00f5b 100644 --- a/devel-docs/ChangeLog +++ b/devel-docs/ChangeLog @@ -1,3 +1,11 @@ +2003-09-04 Sven Neumann + + * libgimp/tmpl/gimpbrushes.sgml + * libgimp/tmpl/gimpfonts.sgml + * libgimp/tmpl/gimpgradients.sgml + * libgimp/tmpl/gimppalettes.sgml + * libgimp/tmpl/gimppatterns.sgml: updated after API change. + 2003-09-04 Sven Neumann * libgimp/libgimp-docs.sgml diff --git a/devel-docs/libgimp/tmpl/gimpbrushes.sgml b/devel-docs/libgimp/tmpl/gimpbrushes.sgml index 804dc03f8e..806f719e44 100644 --- a/devel-docs/libgimp/tmpl/gimpbrushes.sgml +++ b/devel-docs/libgimp/tmpl/gimpbrushes.sgml @@ -27,6 +27,7 @@ Functions related to getting and setting brushes. +@filter: @num_brushes: @Returns: diff --git a/devel-docs/libgimp/tmpl/gimpfonts.sgml b/devel-docs/libgimp/tmpl/gimpfonts.sgml index 008e95e536..9d18e17391 100644 --- a/devel-docs/libgimp/tmpl/gimpfonts.sgml +++ b/devel-docs/libgimp/tmpl/gimpfonts.sgml @@ -27,6 +27,7 @@ Operations related to fonts. +@filter: @num_fonts: @Returns: diff --git a/devel-docs/libgimp/tmpl/gimpgradients.sgml b/devel-docs/libgimp/tmpl/gimpgradients.sgml index e0e300e38a..319cd2d764 100644 --- a/devel-docs/libgimp/tmpl/gimpgradients.sgml +++ b/devel-docs/libgimp/tmpl/gimpgradients.sgml @@ -28,6 +28,7 @@ Operations related to gradients. +@filter: @num_gradients: @Returns: diff --git a/devel-docs/libgimp/tmpl/gimppalettes.sgml b/devel-docs/libgimp/tmpl/gimppalettes.sgml index 18d8ac3acb..1f9141c902 100644 --- a/devel-docs/libgimp/tmpl/gimppalettes.sgml +++ b/devel-docs/libgimp/tmpl/gimppalettes.sgml @@ -27,6 +27,7 @@ gimppalettes +@filter: @num_palettes: @Returns: diff --git a/devel-docs/libgimp/tmpl/gimppatterns.sgml b/devel-docs/libgimp/tmpl/gimppatterns.sgml index e2d06a5966..2b2b0fa0c8 100644 --- a/devel-docs/libgimp/tmpl/gimppatterns.sgml +++ b/devel-docs/libgimp/tmpl/gimppatterns.sgml @@ -28,6 +28,7 @@ Functions relating to patterns. +@filter: @num_patterns: @Returns: diff --git a/libgimp/gimpbrushes_pdb.c b/libgimp/gimpbrushes_pdb.c index 64c5971788..1de244ecc9 100644 --- a/libgimp/gimpbrushes_pdb.c +++ b/libgimp/gimpbrushes_pdb.c @@ -57,6 +57,7 @@ gimp_brushes_refresh (void) /** * gimp_brushes_get_list: + * @filter: An optional regular expression used to filter the list. * @num_brushes: The number of brushes in the brush list. * * Retrieve a complete listing of the available brushes. @@ -68,7 +69,8 @@ gimp_brushes_refresh (void) * Returns: The list of brush names. */ gchar ** -gimp_brushes_get_list (gint *num_brushes) +gimp_brushes_get_list (const gchar *filter, + gint *num_brushes) { GimpParam *return_vals; gint nreturn_vals; @@ -77,6 +79,7 @@ gimp_brushes_get_list (gint *num_brushes) return_vals = gimp_run_procedure ("gimp_brushes_get_list", &nreturn_vals, + GIMP_PDB_STRING, filter, GIMP_PDB_END); *num_brushes = 0; diff --git a/libgimp/gimpbrushes_pdb.h b/libgimp/gimpbrushes_pdb.h index b7234f07da..91afe53f7d 100644 --- a/libgimp/gimpbrushes_pdb.h +++ b/libgimp/gimpbrushes_pdb.h @@ -30,7 +30,8 @@ G_BEGIN_DECLS gboolean gimp_brushes_refresh (void); -gchar** gimp_brushes_get_list (gint *num_brushes); +gchar** gimp_brushes_get_list (const gchar *filter, + gint *num_brushes); gchar* gimp_brushes_get_brush (gint *width, gint *height, gint *spacing); diff --git a/libgimp/gimpfonts_pdb.c b/libgimp/gimpfonts_pdb.c index 34f237dde5..0f57c03e57 100644 --- a/libgimp/gimpfonts_pdb.c +++ b/libgimp/gimpfonts_pdb.c @@ -55,6 +55,7 @@ gimp_fonts_refresh (void) /** * gimp_fonts_get_list: + * @filter: An optional regular expression used to filter the list. * @num_fonts: The number of available fonts. * * Retrieve the list of loaded fonts. @@ -65,7 +66,8 @@ gimp_fonts_refresh (void) * Returns: The list of font names. */ gchar ** -gimp_fonts_get_list (gint *num_fonts) +gimp_fonts_get_list (const gchar *filter, + gint *num_fonts) { GimpParam *return_vals; gint nreturn_vals; @@ -74,6 +76,7 @@ gimp_fonts_get_list (gint *num_fonts) return_vals = gimp_run_procedure ("gimp_fonts_get_list", &nreturn_vals, + GIMP_PDB_STRING, filter, GIMP_PDB_END); *num_fonts = 0; diff --git a/libgimp/gimpfonts_pdb.h b/libgimp/gimpfonts_pdb.h index 4d9c096177..9568748560 100644 --- a/libgimp/gimpfonts_pdb.h +++ b/libgimp/gimpfonts_pdb.h @@ -30,7 +30,8 @@ G_BEGIN_DECLS gboolean gimp_fonts_refresh (void); -gchar** gimp_fonts_get_list (gint *num_fonts); +gchar** gimp_fonts_get_list (const gchar *filter, + gint *num_fonts); G_END_DECLS diff --git a/libgimp/gimpgradients_pdb.c b/libgimp/gimpgradients_pdb.c index 272f7074a0..8ef75fbcc5 100644 --- a/libgimp/gimpgradients_pdb.c +++ b/libgimp/gimpgradients_pdb.c @@ -57,6 +57,7 @@ gimp_gradients_refresh (void) /** * gimp_gradients_get_list: + * @filter: An optional regular expression used to filter the list. * @num_gradients: The number of loaded gradients. * * Retrieve the list of loaded gradients. @@ -68,7 +69,8 @@ gimp_gradients_refresh (void) * Returns: The list of gradient names. */ gchar ** -gimp_gradients_get_list (gint *num_gradients) +gimp_gradients_get_list (const gchar *filter, + gint *num_gradients) { GimpParam *return_vals; gint nreturn_vals; @@ -77,6 +79,7 @@ gimp_gradients_get_list (gint *num_gradients) return_vals = gimp_run_procedure ("gimp_gradients_get_list", &nreturn_vals, + GIMP_PDB_STRING, filter, GIMP_PDB_END); *num_gradients = 0; diff --git a/libgimp/gimpgradients_pdb.h b/libgimp/gimpgradients_pdb.h index 006bbbb992..45844462ef 100644 --- a/libgimp/gimpgradients_pdb.h +++ b/libgimp/gimpgradients_pdb.h @@ -30,7 +30,8 @@ G_BEGIN_DECLS gboolean gimp_gradients_refresh (void); -gchar** gimp_gradients_get_list (gint *num_gradients); +gchar** gimp_gradients_get_list (const gchar *filter, + gint *num_gradients); gchar* gimp_gradients_get_gradient (void); gboolean gimp_gradients_set_gradient (const gchar *name); gdouble* gimp_gradients_sample_uniform (gint num_samples, diff --git a/libgimp/gimppalettes_pdb.c b/libgimp/gimppalettes_pdb.c index 6a3782455f..15a25eb239 100644 --- a/libgimp/gimppalettes_pdb.c +++ b/libgimp/gimppalettes_pdb.c @@ -55,6 +55,7 @@ gimp_palettes_refresh (void) /** * gimp_palettes_get_list: + * @filter: An optional regular expression used to filter the list. * @num_palettes: The number of palettes in the list. * * Retrieves a list of all of the available palettes @@ -66,7 +67,8 @@ gimp_palettes_refresh (void) * Returns: The list of palette names. */ gchar ** -gimp_palettes_get_list (gint *num_palettes) +gimp_palettes_get_list (const gchar *filter, + gint *num_palettes) { GimpParam *return_vals; gint nreturn_vals; @@ -75,6 +77,7 @@ gimp_palettes_get_list (gint *num_palettes) return_vals = gimp_run_procedure ("gimp_palettes_get_list", &nreturn_vals, + GIMP_PDB_STRING, filter, GIMP_PDB_END); *num_palettes = 0; diff --git a/libgimp/gimppalettes_pdb.h b/libgimp/gimppalettes_pdb.h index 59e292ba78..2072a719eb 100644 --- a/libgimp/gimppalettes_pdb.h +++ b/libgimp/gimppalettes_pdb.h @@ -30,7 +30,8 @@ G_BEGIN_DECLS gboolean gimp_palettes_refresh (void); -gchar** gimp_palettes_get_list (gint *num_palettes); +gchar** gimp_palettes_get_list (const gchar *filter, + gint *num_palettes); gchar* gimp_palettes_get_palette (gint *num_colors); gboolean gimp_palettes_set_palette (const gchar *name); gchar* gimp_palettes_get_palette_entry (const gchar *name, diff --git a/libgimp/gimppatterns_pdb.c b/libgimp/gimppatterns_pdb.c index 33bb2dee3b..71f676485c 100644 --- a/libgimp/gimppatterns_pdb.c +++ b/libgimp/gimppatterns_pdb.c @@ -57,6 +57,7 @@ gimp_patterns_refresh (void) /** * gimp_patterns_get_list: + * @filter: An optional regular expression used to filter the list. * @num_patterns: The number of patterns in the pattern list. * * Retrieve a complete listing of the available patterns. @@ -68,7 +69,8 @@ gimp_patterns_refresh (void) * Returns: The list of pattern names. */ gchar ** -gimp_patterns_get_list (gint *num_patterns) +gimp_patterns_get_list (const gchar *filter, + gint *num_patterns) { GimpParam *return_vals; gint nreturn_vals; @@ -77,6 +79,7 @@ gimp_patterns_get_list (gint *num_patterns) return_vals = gimp_run_procedure ("gimp_patterns_get_list", &nreturn_vals, + GIMP_PDB_STRING, filter, GIMP_PDB_END); *num_patterns = 0; diff --git a/libgimp/gimppatterns_pdb.h b/libgimp/gimppatterns_pdb.h index 698b746f84..73ab6ebc91 100644 --- a/libgimp/gimppatterns_pdb.h +++ b/libgimp/gimppatterns_pdb.h @@ -30,7 +30,8 @@ G_BEGIN_DECLS gboolean gimp_patterns_refresh (void); -gchar** gimp_patterns_get_list (gint *num_patterns); +gchar** gimp_patterns_get_list (const gchar *filter, + gint *num_patterns); gchar* gimp_patterns_get_pattern (gint *width, gint *height); gboolean gimp_patterns_set_pattern (const gchar *name); diff --git a/plug-ins/gflare/gflare.c b/plug-ins/gflare/gflare.c index fb87b57f29..9ec0e4a5b2 100644 --- a/plug-ins/gflare/gflare.c +++ b/plug-ins/gflare/gflare.c @@ -4703,7 +4703,7 @@ gradient_get_list (gint *num_gradients) gint i, n; gradient_cache_flush (); - external_gradients = gimp_gradients_get_list (&external_ngradients); + external_gradients = gimp_gradients_get_list (NULL, &external_ngradients); *num_gradients = internal_ngradients + external_ngradients; gradients = g_new (gchar *, *num_gradients); diff --git a/plug-ins/pygimp/gimpmodule.c b/plug-ins/pygimp/gimpmodule.c index 806dbb27be..bdfb66852b 100644 --- a/plug-ins/pygimp/gimpmodule.c +++ b/plug-ins/pygimp/gimpmodule.c @@ -530,7 +530,7 @@ pygimp_gradients_get_list(PyObject *self) int num, i; PyObject *ret; - list = gimp_gradients_get_list(&num); + list = gimp_gradients_get_list(NULL, &num); ret = PyList_New(num); for (i = 0; i < num; i++) PyList_SetItem(ret, i, PyString_FromString(list[i])); diff --git a/plug-ins/script-fu/scripts/font-map.scm b/plug-ins/script-fu/scripts/font-map.scm index 7380fb71ad..925284b3ec 100644 --- a/plug-ins/script-fu/scripts/font-map.scm +++ b/plug-ins/script-fu/scripts/font-map.scm @@ -35,10 +35,11 @@ maxheight)) -(define (script-fu-font-map font-list font-size border) +(define (script-fu-font-map font-filter font-size border) (let* ((font "") (count 0) (text-fs 0) + (font-list (cadr (gimp-fonts-get-list font-filter))) (num-fonts (length font-list)) (maxheight (max-font-height font-list font-size)) (maxwidth (max-font-width font-list font-size)) @@ -68,12 +69,12 @@ (script-fu-register "script-fu-font-map" _"/Xtns/Script-Fu/Utils/_Font Map..." - "Generate a listing of the specified fonts" + "Generate a listing of fonts matching a filter" "Spencer Kimball" "Spencer Kimball" "1997" "" - SF-VALUE _"Fonts" "'(\"Agate\" \"AlfredDrake\" \"Becker\" \"Blippo\" \"Bodoni\" \"Dragonwick\" \"Engraver\" \"Futura_Poster\" \"RoostHeavy\")" + SF-STRING _"Filter (regexp)" "Sans" SF-ADJUSTMENT _"Font Size (pixels)" '(32 2 1000 1 10 0 1) - SF-ADJUSTMENT _"Border" '(10 0 150 1 10 0 1) + SF-ADJUSTMENT _"Border" '(10 0 150 1 10 0 1) ) diff --git a/tools/pdbgen/pdb/brushes.pdb b/tools/pdbgen/pdb/brushes.pdb index 29414d87f4..2f257a21e8 100644 --- a/tools/pdbgen/pdb/brushes.pdb +++ b/tools/pdbgen/pdb/brushes.pdb @@ -101,6 +101,12 @@ HELP &std_pdb_misc; + @inargs = ( + { name => 'filter', + type => 'string', null_ok => 1, + desc => 'An optional regular expression used to filter the list' } + ); + @outargs = ( { name => 'brush_list', type => 'stringarray', desc => 'The list of brush names', @@ -109,7 +115,8 @@ HELP ); %invoke = ( - code => 'brush_list = gimp_container_get_name_array (gimp->brush_factory->container, &num_brushes);' + headers => [ qw("core/gimpcontainer-filter.h") ], + code => 'brush_list = gimp_container_get_filtered_name_array (gimp->brush_factory->container, filter, &num_brushes);' ); } diff --git a/tools/pdbgen/pdb/fonts.pdb b/tools/pdbgen/pdb/fonts.pdb index 06286bef74..d6932ba62e 100644 --- a/tools/pdbgen/pdb/fonts.pdb +++ b/tools/pdbgen/pdb/fonts.pdb @@ -48,6 +48,12 @@ HELP &pdb_misc; + @inargs = ( + { name => 'filter', + type => 'string', null_ok => 1, + desc => 'An optional regular expression used to filter the list' } + ); + @outargs = ( { name => 'font_list', type => 'stringarray', desc => 'The list of font names', @@ -56,7 +62,8 @@ HELP ); %invoke = ( - code => 'font_list = gimp_container_get_name_array (gimp->fonts, &num_fonts);' + headers => [ qw("core/gimpcontainer-filter.h") ], + code => 'font_list = gimp_container_get_filtered_name_array (gimp->fonts, filter, &num_fonts);' ); } diff --git a/tools/pdbgen/pdb/gradients.pdb b/tools/pdbgen/pdb/gradients.pdb index f1f9479171..8d86fbe966 100644 --- a/tools/pdbgen/pdb/gradients.pdb +++ b/tools/pdbgen/pdb/gradients.pdb @@ -56,6 +56,12 @@ HELP &pdb_misc; + @inargs = ( + { name => 'filter', + type => 'string', null_ok => 1, + desc => 'An optional regular expression used to filter the list' } + ); + @outargs = ( { name => 'gradient_list', type => 'stringarray', desc => 'The list of gradient names', @@ -64,7 +70,8 @@ HELP ); %invoke = ( - code => 'gradient_list = gimp_container_get_name_array (gimp->gradient_factory->container, &num_gradients);' + headers => [ qw("core/gimpcontainer-filter.h") ], + code => 'gradient_list = gimp_container_get_filtered_name_array (gimp->gradient_factory->container, filter, &num_gradients);' ); } diff --git a/tools/pdbgen/pdb/palettes.pdb b/tools/pdbgen/pdb/palettes.pdb index 0808a03bba..77feeb5e87 100644 --- a/tools/pdbgen/pdb/palettes.pdb +++ b/tools/pdbgen/pdb/palettes.pdb @@ -97,6 +97,12 @@ HELP &rock_pdb_misc; + @inargs = ( + { name => 'filter', + type => 'string', null_ok => 1, + desc => 'An optional regular expression used to filter the list' } + ); + @outargs = ( { name => 'palette_list', type => 'stringarray', desc => 'The list of palette names', @@ -105,7 +111,8 @@ HELP ); %invoke = ( - code => 'palette_list = gimp_container_get_name_array (gimp->palette_factory->container, &num_palettes);' + headers => [ qw("core/gimpcontainer-filter.h") ], + code => 'palette_list = gimp_container_get_filtered_name_array (gimp->palette_factory->container, filter, &num_palettes);' ); } diff --git a/tools/pdbgen/pdb/patterns.pdb b/tools/pdbgen/pdb/patterns.pdb index dd019224e3..2d1668eb8a 100644 --- a/tools/pdbgen/pdb/patterns.pdb +++ b/tools/pdbgen/pdb/patterns.pdb @@ -79,6 +79,12 @@ HELP &std_pdb_misc; + @inargs = ( + { name => 'filter', + type => 'string', null_ok => 1, + desc => 'An optional regular expression used to filter the list' } + ); + @outargs = ( { name => 'pattern_list', type => 'stringarray', desc => 'The list of pattern names', @@ -87,7 +93,8 @@ HELP ); %invoke = ( - code => 'pattern_list = gimp_container_get_name_array (gimp->pattern_factory->container, &num_patterns);' + headers => [ qw("core/gimpcontainer-filter.h") ], + code => 'pattern_list = gimp_container_get_filtered_name_array (gimp->pattern_factory->container, filter, &num_patterns);' ); }