app/core/Makefile.am app/core/core-types.h added filter functionality for

2003-09-04  Sven Neumann  <sven@gimp.org>

	* 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.
This commit is contained in:
Sven Neumann 2003-09-04 17:04:36 +00:00 committed by Sven Neumann
parent e6ab31060c
commit 85adefe7ba
35 changed files with 495 additions and 52 deletions

View file

@ -1,3 +1,37 @@
2003-09-04 Sven Neumann <sven@gimp.org>
* 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 <sven@gimp.org>
* app/core/gimpcontainer.[ch] (gimp_container_get_name_array):

View file

@ -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 \

View file

@ -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);

View file

@ -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 <sven@gimp.org>
*
* 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 <string.h>
#include <glib-object.h>
#ifdef HAVE_GLIBC_REGEX
#include <regex.h>
#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 (&regex, regexp, REG_ICASE | REG_NOSUB);
if (ret)
{
gsize error_len;
gchar *error_buf;
error_len = regerror (ret, &regex, NULL, 0);
error_buf = g_new (gchar, error_len);
regerror (ret, &regex, error_buf, error_len);
g_set_error (error, 0, 0, error_buf);
g_free (error_buf);
regfree (&regex);
return NULL;
}
result =
gimp_container_filter (container,
(GimpObjectFilterFunc) gimp_object_filter_by_name,
&regex);
regfree (&regex);
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;
}
}

View file

@ -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 <sven@gimp.org>
*
* 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__ */

View file

@ -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\" \

View file

@ -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 } }

View file

@ -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 } }

View file

@ -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 } }

View file

@ -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 } }

View file

@ -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 } }

View file

@ -1,3 +1,11 @@
2003-09-04 Sven Neumann <sven@gimp.org>
* 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 <sven@gimp.org>
* libgimp/libgimp-docs.sgml

View file

@ -27,6 +27,7 @@ Functions related to getting and setting brushes.
</para>
@filter:
@num_brushes:
@Returns:

View file

@ -27,6 +27,7 @@ Operations related to fonts.
</para>
@filter:
@num_fonts:
@Returns:

View file

@ -28,6 +28,7 @@ Operations related to gradients.
</para>
@filter:
@num_gradients:
@Returns:

View file

@ -27,6 +27,7 @@ gimppalettes
</para>
@filter:
@num_palettes:
@Returns:

View file

@ -28,6 +28,7 @@ Functions relating to patterns.
</para>
@filter:
@num_patterns:
@Returns:

View file

@ -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;

View file

@ -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);

View file

@ -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;

View file

@ -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

View file

@ -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;

View file

@ -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,

View file

@ -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;

View file

@ -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,

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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]));

View file

@ -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"
_"<Toolbox>/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)
)

View file

@ -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);'
);
}

View file

@ -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);'
);
}

View file

@ -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);'
);
}

View file

@ -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);'
);
}

View file

@ -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);'
);
}