From 6541e4d8dac39df1c310619a089c88c04baee3b8 Mon Sep 17 00:00:00 2001 From: Jehan Date: Sun, 3 Nov 2024 16:36:47 +0100 Subject: [PATCH] app, libgimp, pdb: gimp_*_get_list() for various resource types return a resource array. There are 2 *_get_list() for buffers and dynamics but since we don't have clases for these, they still just return a list of names for now. I opened #12268 for further thinking on these. --- app/core/gimpcontainer-filter.c | 37 +++++++++++++++++++++++++++++++-- app/core/gimpcontainer-filter.h | 19 +++++++++-------- app/pdb/brushes-cmds.c | 21 ++++++++++--------- app/pdb/fonts-cmds.c | 22 ++++++++++---------- app/pdb/gradients-cmds.c | 19 +++++++++-------- app/pdb/palettes-cmds.c | 19 +++++++++-------- app/pdb/patterns-cmds.c | 19 +++++++++-------- libgimp/gimpbrushes_pdb.c | 15 ++++++------- libgimp/gimpbrushes_pdb.h | 4 ++-- libgimp/gimpfonts_pdb.c | 13 +++++++----- libgimp/gimpfonts_pdb.h | 2 +- libgimp/gimpgradients_pdb.c | 17 ++++++++------- libgimp/gimpgradients_pdb.h | 4 ++-- libgimp/gimppalettes_pdb.c | 16 +++++++------- libgimp/gimppalettes_pdb.h | 4 ++-- libgimp/gimppatterns_pdb.c | 17 ++++++++------- libgimp/gimppatterns_pdb.h | 4 ++-- pdb/groups/brushes.pdb | 15 ++++++------- pdb/groups/fonts.pdb | 13 ++++++------ pdb/groups/gradients.pdb | 12 +++++------ pdb/groups/palettes.pdb | 13 ++++++------ pdb/groups/patterns.pdb | 13 ++++++------ 22 files changed, 183 insertions(+), 135 deletions(-) diff --git a/app/core/gimpcontainer-filter.c b/app/core/gimpcontainer-filter.c index 7eb4e273e3..4a7b99fec6 100644 --- a/app/core/gimpcontainer-filter.c +++ b/app/core/gimpcontainer-filter.c @@ -87,7 +87,6 @@ gimp_container_filter (GimpContainer *container, if (GIMP_IS_LIST (result)) gimp_list_reverse (GIMP_LIST (result)); - return result; } @@ -138,7 +137,6 @@ gimp_container_filter_by_name (GimpContainer *container, return result; } - gchar ** gimp_container_get_filtered_name_array (GimpContainer *container, const gchar *regexp) @@ -169,3 +167,38 @@ gimp_container_get_filtered_name_array (GimpContainer *container, return NULL; } } + +GimpObject ** +gimp_container_get_filtered_array (GimpContainer *container, + const gchar *regexp) +{ + GimpObject **retval = NULL; + GimpContainer *weak = NULL; + GError *error = NULL; + + g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL); + + if (regexp != NULL && strlen (regexp) > 0) + weak = gimp_container_filter_by_name (container, regexp, &error); + + if (error == NULL) + { + GList *list; + GList *iter; + gint i; + + list = GIMP_LIST (weak ? weak : container)->queue->head; + retval = g_new0 (GimpObject *, g_list_length (list) + 1); + for (iter = list, i = 0; iter; iter = iter->next, i++) + retval[i] = iter->data; + } + else + { + g_warning ("%s", error->message); + g_error_free (error); + } + + g_clear_object (&weak); + + return retval; +} diff --git a/app/core/gimpcontainer-filter.h b/app/core/gimpcontainer-filter.h index 1d7db9ae43..f45ebce9fe 100644 --- a/app/core/gimpcontainer-filter.h +++ b/app/core/gimpcontainer-filter.h @@ -22,16 +22,17 @@ #define __GIMP_CONTAINER_FILTER_H__ -GimpContainer * gimp_container_filter (GimpContainer *container, - GimpObjectFilterFunc filter, - gpointer user_data); -GimpContainer * gimp_container_filter_by_name (GimpContainer *container, - const gchar *regexp, - GError **error); +GimpContainer * gimp_container_filter (GimpContainer *container, + GimpObjectFilterFunc filter, + gpointer user_data); +GimpContainer * gimp_container_filter_by_name (GimpContainer *container, + const gchar *regexp, + GError **error); -gchar ** gimp_container_get_filtered_name_array - (GimpContainer *container, - const gchar *regexp); +gchar ** gimp_container_get_filtered_name_array (GimpContainer *container, + const gchar *regexp); +GimpObject ** gimp_container_get_filtered_array (GimpContainer *container, + const gchar *regexp); #endif /* __GIMP_CONTAINER_FILTER_H__ */ diff --git a/app/pdb/brushes-cmds.c b/app/pdb/brushes-cmds.c index 5d7c49e627..d92f46828e 100644 --- a/app/pdb/brushes-cmds.c +++ b/app/pdb/brushes-cmds.c @@ -69,14 +69,14 @@ brushes_get_list_invoker (GimpProcedure *procedure, gboolean success = TRUE; GimpValueArray *return_vals; const gchar *filter; - gchar **brush_list = NULL; + GimpBrush **brush_list = NULL; filter = g_value_get_string (gimp_value_array_index (args, 0)); if (success) { - brush_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->brush_factory), - filter); + brush_list = (GimpBrush **) gimp_container_get_filtered_array (gimp_data_factory_get_container (gimp->brush_factory), + filter); } return_vals = gimp_procedure_get_return_values (procedure, success, @@ -118,7 +118,8 @@ register_brushes_procs (GimpPDB *pdb) "gimp-brushes-get-list"); gimp_procedure_set_static_help (procedure, "Retrieve a complete listing of the available brushes.", - "This procedure returns a complete listing of available GIMP brushes. Each name returned can be used as input to the 'gimp-context-set-brush' procedure.", + "This procedure returns a complete listing of available GIMP brushes.\n" + "Each brush returned can be used as input to [func@Gimp.context_set_brush].", NULL); gimp_procedure_set_static_attribution (procedure, "Spencer Kimball & Peter Mattis", @@ -128,15 +129,15 @@ register_brushes_procs (GimpPDB *pdb) gimp_param_spec_string ("filter", "filter", "An optional regular expression used to filter the list", - FALSE, TRUE, FALSE, + FALSE, FALSE, FALSE, NULL, GIMP_PARAM_READWRITE)); gimp_procedure_add_return_value (procedure, - g_param_spec_boxed ("brush-list", - "brush list", - "The list of brush names", - G_TYPE_STRV, - GIMP_PARAM_READWRITE)); + gimp_param_spec_core_object_array ("brush-list", + "brush list", + "The list of brushes", + GIMP_TYPE_BRUSH, + GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); } diff --git a/app/pdb/fonts-cmds.c b/app/pdb/fonts-cmds.c index 431f085ec6..38a3a5d9bd 100644 --- a/app/pdb/fonts-cmds.c +++ b/app/pdb/fonts-cmds.c @@ -34,6 +34,7 @@ #include "core/gimpcontainer.h" #include "core/gimpdatafactory.h" #include "core/gimpparamspecs.h" +#include "text/gimpfont.h" #include "text/gimpfontfactory.h" #include "gimppdb.h" @@ -120,7 +121,7 @@ fonts_get_list_invoker (GimpProcedure *procedure, gboolean success = TRUE; GimpValueArray *return_vals; const gchar *filter; - gchar **font_list = NULL; + GimpFont **font_list = NULL; filter = g_value_get_string (gimp_value_array_index (args, 0)); @@ -130,10 +131,8 @@ fonts_get_list_invoker (GimpProcedure *procedure, success = FALSE; if (success) - { - font_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->font_factory), - filter); - } + font_list = (GimpFont **) gimp_container_get_filtered_array (gimp_data_factory_get_container (gimp->font_factory), + filter); } return_vals = gimp_procedure_get_return_values (procedure, success, @@ -219,7 +218,8 @@ register_fonts_procs (GimpPDB *pdb) "gimp-fonts-get-list"); gimp_procedure_set_static_help (procedure, "Retrieve the list of loaded fonts.", - "This procedure returns a list of the fonts that are currently available.", + "This procedure returns a list of the fonts that are currently available.\n" + "Each font returned can be used as input to [func@Gimp.context_set_font].", NULL); gimp_procedure_set_static_attribution (procedure, "Sven Neumann ", @@ -233,11 +233,11 @@ register_fonts_procs (GimpPDB *pdb) NULL, GIMP_PARAM_READWRITE)); gimp_procedure_add_return_value (procedure, - g_param_spec_boxed ("font-list", - "font list", - "The list of font names", - G_TYPE_STRV, - GIMP_PARAM_READWRITE)); + gimp_param_spec_core_object_array ("font-list", + "font list", + "The list of fonts", + GIMP_TYPE_FONT, + GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); } diff --git a/app/pdb/gradients-cmds.c b/app/pdb/gradients-cmds.c index 8eeb11b664..ae1d0ffe3f 100644 --- a/app/pdb/gradients-cmds.c +++ b/app/pdb/gradients-cmds.c @@ -68,14 +68,14 @@ gradients_get_list_invoker (GimpProcedure *procedure, gboolean success = TRUE; GimpValueArray *return_vals; const gchar *filter; - gchar **gradient_list = NULL; + GimpGradient **gradient_list = NULL; filter = g_value_get_string (gimp_value_array_index (args, 0)); if (success) { - gradient_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->gradient_factory), - filter); + gradient_list = (GimpGradient **) gimp_container_get_filtered_array (gimp_data_factory_get_container (gimp->gradient_factory), + filter); } return_vals = gimp_procedure_get_return_values (procedure, success, @@ -117,7 +117,8 @@ register_gradients_procs (GimpPDB *pdb) "gimp-gradients-get-list"); gimp_procedure_set_static_help (procedure, "Retrieve the list of loaded gradients.", - "This procedure returns a list of the gradients that are currently loaded. You can later use the 'gimp-context-set-gradient' function to set the active gradient.", + "This procedure returns a list of the gradients that are currently loaded.\n" + "Each gradient returned can be used as input to [func@Gimp.context_set_gradient].", NULL); gimp_procedure_set_static_attribution (procedure, "Federico Mena Quintero", @@ -131,11 +132,11 @@ register_gradients_procs (GimpPDB *pdb) NULL, GIMP_PARAM_READWRITE)); gimp_procedure_add_return_value (procedure, - g_param_spec_boxed ("gradient-list", - "gradient list", - "The list of gradient names", - G_TYPE_STRV, - GIMP_PARAM_READWRITE)); + gimp_param_spec_core_object_array ("gradient-list", + "gradient list", + "The list of gradients", + GIMP_TYPE_GRADIENT, + GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); } diff --git a/app/pdb/palettes-cmds.c b/app/pdb/palettes-cmds.c index 14ebcf572a..7b2b575125 100644 --- a/app/pdb/palettes-cmds.c +++ b/app/pdb/palettes-cmds.c @@ -68,14 +68,14 @@ palettes_get_list_invoker (GimpProcedure *procedure, gboolean success = TRUE; GimpValueArray *return_vals; const gchar *filter; - gchar **palette_list = NULL; + GimpPalette **palette_list = NULL; filter = g_value_get_string (gimp_value_array_index (args, 0)); if (success) { - palette_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->palette_factory), - filter); + palette_list = (GimpPalette **) gimp_container_get_filtered_array (gimp_data_factory_get_container (gimp->palette_factory), + filter); } return_vals = gimp_procedure_get_return_values (procedure, success, @@ -117,7 +117,8 @@ register_palettes_procs (GimpPDB *pdb) "gimp-palettes-get-list"); gimp_procedure_set_static_help (procedure, "Retrieves a list of all of the available palettes", - "This procedure returns a complete listing of available palettes. Each name returned can be used as input to the command 'gimp-context-set-palette'.", + "This procedure returns a complete listing of available palettes.\n" + "Each palette returned can be used as input to [func@Gimp.context_set_palette].", NULL); gimp_procedure_set_static_attribution (procedure, "Nathan Summers ", @@ -131,11 +132,11 @@ register_palettes_procs (GimpPDB *pdb) NULL, GIMP_PARAM_READWRITE)); gimp_procedure_add_return_value (procedure, - g_param_spec_boxed ("palette-list", - "palette list", - "The list of palette names", - G_TYPE_STRV, - GIMP_PARAM_READWRITE)); + gimp_param_spec_core_object_array ("palette-list", + "palette list", + "The list of palettes", + GIMP_TYPE_PALETTE, + GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); } diff --git a/app/pdb/patterns-cmds.c b/app/pdb/patterns-cmds.c index cf16f1dd03..dfd027ba17 100644 --- a/app/pdb/patterns-cmds.c +++ b/app/pdb/patterns-cmds.c @@ -69,14 +69,14 @@ patterns_get_list_invoker (GimpProcedure *procedure, gboolean success = TRUE; GimpValueArray *return_vals; const gchar *filter; - gchar **pattern_list = NULL; + GimpPattern **pattern_list = NULL; filter = g_value_get_string (gimp_value_array_index (args, 0)); if (success) { - pattern_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->pattern_factory), - filter); + pattern_list = (GimpPattern **) gimp_container_get_filtered_array (gimp_data_factory_get_container (gimp->pattern_factory), + filter); } return_vals = gimp_procedure_get_return_values (procedure, success, @@ -118,7 +118,8 @@ register_patterns_procs (GimpPDB *pdb) "gimp-patterns-get-list"); gimp_procedure_set_static_help (procedure, "Retrieve a complete listing of the available patterns.", - "This procedure returns a complete listing of available GIMP patterns. Each name returned can be used as input to the 'gimp-context-set-pattern'.", + "This procedure returns a complete listing of available GIMP patterns.\n" + "Each pattern returned can be used as input to [func@Gimp.context_set_pattern].", NULL); gimp_procedure_set_static_attribution (procedure, "Spencer Kimball & Peter Mattis", @@ -132,11 +133,11 @@ register_patterns_procs (GimpPDB *pdb) NULL, GIMP_PARAM_READWRITE)); gimp_procedure_add_return_value (procedure, - g_param_spec_boxed ("pattern-list", - "pattern list", - "The list of pattern names", - G_TYPE_STRV, - GIMP_PARAM_READWRITE)); + gimp_param_spec_core_object_array ("pattern-list", + "pattern list", + "The list of patterns", + GIMP_TYPE_PATTERN, + GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); } diff --git a/libgimp/gimpbrushes_pdb.c b/libgimp/gimpbrushes_pdb.c index 9598198a1a..2d985c7dfa 100644 --- a/libgimp/gimpbrushes_pdb.c +++ b/libgimp/gimpbrushes_pdb.c @@ -75,18 +75,19 @@ gimp_brushes_refresh (void) * Retrieve a complete listing of the available brushes. * * This procedure returns a complete listing of available GIMP brushes. - * Each name returned can be used as input to the - * gimp_context_set_brush() procedure. + * Each brush returned can be used as input to + * [func@Gimp.context_set_brush]. * - * Returns: (array zero-terminated=1) (transfer full): The list of brush names. - * The returned value must be freed with g_strfreev(). + * Returns: (element-type GimpBrush) (array zero-terminated=1) (transfer container): + * The list of brushes. + * The returned value must be freed with g_free(). **/ -gchar ** +GimpBrush ** gimp_brushes_get_list (const gchar *filter) { GimpValueArray *args; GimpValueArray *return_vals; - gchar **brush_list = NULL; + GimpBrush **brush_list = NULL; args = gimp_value_array_new_from_types (NULL, G_TYPE_STRING, filter, @@ -98,7 +99,7 @@ gimp_brushes_get_list (const gchar *filter) gimp_value_array_unref (args); if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) - brush_list = GIMP_VALUES_DUP_STRV (return_vals, 1); + brush_list = g_value_dup_boxed (gimp_value_array_index (return_vals, 1)); gimp_value_array_unref (return_vals); diff --git a/libgimp/gimpbrushes_pdb.h b/libgimp/gimpbrushes_pdb.h index 59c0d32e08..37127b90ee 100644 --- a/libgimp/gimpbrushes_pdb.h +++ b/libgimp/gimpbrushes_pdb.h @@ -32,8 +32,8 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gboolean gimp_brushes_refresh (void); -gchar** gimp_brushes_get_list (const gchar *filter); +gboolean gimp_brushes_refresh (void); +GimpBrush** gimp_brushes_get_list (const gchar *filter); G_END_DECLS diff --git a/libgimp/gimpfonts_pdb.c b/libgimp/gimpfonts_pdb.c index e6f079c046..86dd8d56a1 100644 --- a/libgimp/gimpfonts_pdb.c +++ b/libgimp/gimpfonts_pdb.c @@ -123,16 +123,19 @@ _gimp_fonts_get_custom_configs (gchar **sysconfig, * * This procedure returns a list of the fonts that are currently * available. + * Each font returned can be used as input to + * [func@Gimp.context_set_font]. * - * Returns: (array zero-terminated=1) (transfer full): The list of font names. - * The returned value must be freed with g_strfreev(). + * Returns: (element-type GimpFont) (array zero-terminated=1) (transfer container): + * The list of fonts. + * The returned value must be freed with g_free(). **/ -gchar ** +GimpFont ** gimp_fonts_get_list (const gchar *filter) { GimpValueArray *args; GimpValueArray *return_vals; - gchar **font_list = NULL; + GimpFont **font_list = NULL; args = gimp_value_array_new_from_types (NULL, G_TYPE_STRING, filter, @@ -144,7 +147,7 @@ gimp_fonts_get_list (const gchar *filter) gimp_value_array_unref (args); if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) - font_list = GIMP_VALUES_DUP_STRV (return_vals, 1); + font_list = g_value_dup_boxed (gimp_value_array_index (return_vals, 1)); gimp_value_array_unref (return_vals); diff --git a/libgimp/gimpfonts_pdb.h b/libgimp/gimpfonts_pdb.h index 2028214b4a..2e3ccb20ad 100644 --- a/libgimp/gimpfonts_pdb.h +++ b/libgimp/gimpfonts_pdb.h @@ -36,7 +36,7 @@ gboolean gimp_fonts_refresh (void); G_GNUC_INTERNAL gchar* _gimp_fonts_get_custom_configs (gchar **sysconfig, gchar **renaming_config, gchar ***dirs); -gchar** gimp_fonts_get_list (const gchar *filter); +GimpFont** gimp_fonts_get_list (const gchar *filter); G_END_DECLS diff --git a/libgimp/gimpgradients_pdb.c b/libgimp/gimpgradients_pdb.c index 3c31afa2f3..56697fa9a3 100644 --- a/libgimp/gimpgradients_pdb.c +++ b/libgimp/gimpgradients_pdb.c @@ -75,19 +75,20 @@ gimp_gradients_refresh (void) * Retrieve the list of loaded gradients. * * This procedure returns a list of the gradients that are currently - * loaded. You can later use the gimp_context_set_gradient() function - * to set the active gradient. + * loaded. + * Each gradient returned can be used as input to + * [func@Gimp.context_set_gradient]. * - * Returns: (array zero-terminated=1) (transfer full): - * The list of gradient names. - * The returned value must be freed with g_strfreev(). + * Returns: (element-type GimpGradient) (array zero-terminated=1) (transfer container): + * The list of gradients. + * The returned value must be freed with g_free(). **/ -gchar ** +GimpGradient ** gimp_gradients_get_list (const gchar *filter) { GimpValueArray *args; GimpValueArray *return_vals; - gchar **gradient_list = NULL; + GimpGradient **gradient_list = NULL; args = gimp_value_array_new_from_types (NULL, G_TYPE_STRING, filter, @@ -99,7 +100,7 @@ gimp_gradients_get_list (const gchar *filter) gimp_value_array_unref (args); if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) - gradient_list = GIMP_VALUES_DUP_STRV (return_vals, 1); + gradient_list = g_value_dup_boxed (gimp_value_array_index (return_vals, 1)); gimp_value_array_unref (return_vals); diff --git a/libgimp/gimpgradients_pdb.h b/libgimp/gimpgradients_pdb.h index f12d1f6627..0db2d9748f 100644 --- a/libgimp/gimpgradients_pdb.h +++ b/libgimp/gimpgradients_pdb.h @@ -32,8 +32,8 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gboolean gimp_gradients_refresh (void); -gchar** gimp_gradients_get_list (const gchar *filter); +gboolean gimp_gradients_refresh (void); +GimpGradient** gimp_gradients_get_list (const gchar *filter); G_END_DECLS diff --git a/libgimp/gimppalettes_pdb.c b/libgimp/gimppalettes_pdb.c index eceb9ee495..e43455a26a 100644 --- a/libgimp/gimppalettes_pdb.c +++ b/libgimp/gimppalettes_pdb.c @@ -75,19 +75,19 @@ gimp_palettes_refresh (void) * Retrieves a list of all of the available palettes * * This procedure returns a complete listing of available palettes. - * Each name returned can be used as input to the command - * gimp_context_set_palette(). + * Each palette returned can be used as input to + * [func@Gimp.context_set_palette]. * - * Returns: (array zero-terminated=1) (transfer full): - * The list of palette names. - * The returned value must be freed with g_strfreev(). + * Returns: (element-type GimpPalette) (array zero-terminated=1) (transfer container): + * The list of palettes. + * The returned value must be freed with g_free(). **/ -gchar ** +GimpPalette ** gimp_palettes_get_list (const gchar *filter) { GimpValueArray *args; GimpValueArray *return_vals; - gchar **palette_list = NULL; + GimpPalette **palette_list = NULL; args = gimp_value_array_new_from_types (NULL, G_TYPE_STRING, filter, @@ -99,7 +99,7 @@ gimp_palettes_get_list (const gchar *filter) gimp_value_array_unref (args); if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) - palette_list = GIMP_VALUES_DUP_STRV (return_vals, 1); + palette_list = g_value_dup_boxed (gimp_value_array_index (return_vals, 1)); gimp_value_array_unref (return_vals); diff --git a/libgimp/gimppalettes_pdb.h b/libgimp/gimppalettes_pdb.h index 18e975c359..c49207dc29 100644 --- a/libgimp/gimppalettes_pdb.h +++ b/libgimp/gimppalettes_pdb.h @@ -32,8 +32,8 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gboolean gimp_palettes_refresh (void); -gchar** gimp_palettes_get_list (const gchar *filter); +gboolean gimp_palettes_refresh (void); +GimpPalette** gimp_palettes_get_list (const gchar *filter); G_END_DECLS diff --git a/libgimp/gimppatterns_pdb.c b/libgimp/gimppatterns_pdb.c index b118f699ba..b79462c2bc 100644 --- a/libgimp/gimppatterns_pdb.c +++ b/libgimp/gimppatterns_pdb.c @@ -75,19 +75,20 @@ gimp_patterns_refresh (void) * Retrieve a complete listing of the available patterns. * * This procedure returns a complete listing of available GIMP - * patterns. Each name returned can be used as input to the - * gimp_context_set_pattern(). + * patterns. + * Each pattern returned can be used as input to + * [func@Gimp.context_set_pattern]. * - * Returns: (array zero-terminated=1) (transfer full): - * The list of pattern names. - * The returned value must be freed with g_strfreev(). + * Returns: (element-type GimpPattern) (array zero-terminated=1) (transfer container): + * The list of patterns. + * The returned value must be freed with g_free(). **/ -gchar ** +GimpPattern ** gimp_patterns_get_list (const gchar *filter) { GimpValueArray *args; GimpValueArray *return_vals; - gchar **pattern_list = NULL; + GimpPattern **pattern_list = NULL; args = gimp_value_array_new_from_types (NULL, G_TYPE_STRING, filter, @@ -99,7 +100,7 @@ gimp_patterns_get_list (const gchar *filter) gimp_value_array_unref (args); if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) - pattern_list = GIMP_VALUES_DUP_STRV (return_vals, 1); + pattern_list = g_value_dup_boxed (gimp_value_array_index (return_vals, 1)); gimp_value_array_unref (return_vals); diff --git a/libgimp/gimppatterns_pdb.h b/libgimp/gimppatterns_pdb.h index 592791d029..91e8156240 100644 --- a/libgimp/gimppatterns_pdb.h +++ b/libgimp/gimppatterns_pdb.h @@ -32,8 +32,8 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gboolean gimp_patterns_refresh (void); -gchar** gimp_patterns_get_list (const gchar *filter); +gboolean gimp_patterns_refresh (void); +GimpPattern** gimp_patterns_get_list (const gchar *filter); G_END_DECLS diff --git a/pdb/groups/brushes.pdb b/pdb/groups/brushes.pdb index f52deaa31e..a1cdd5ddca 100644 --- a/pdb/groups/brushes.pdb +++ b/pdb/groups/brushes.pdb @@ -40,28 +40,29 @@ sub brushes_get_list { $help = <<'HELP'; This procedure returns a complete listing of available GIMP -brushes. Each name returned can be used as input to the -gimp_context_set_brush() procedure. +brushes. + +Each brush returned can be used as input to [func@Gimp.context_set_brush]. HELP &std_pdb_misc; @inargs = ( - { name => 'filter', type => 'string', null_ok => 1, + { name => 'filter', type => 'string', desc => 'An optional regular expression used to filter the list' } ); @outargs = ( - { name => 'brush_list', type => 'strv', - desc => 'The list of brush names' } + { name => 'brush_list', type => 'brusharray', + desc => 'The list of brushes' } ); %invoke = ( headers => [ qw("core/gimpcontainer-filter.h") ], code => <<'CODE' { - brush_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->brush_factory), - filter); + brush_list = (GimpBrush **) gimp_container_get_filtered_array (gimp_data_factory_get_container (gimp->brush_factory), + filter); } CODE ); diff --git a/pdb/groups/fonts.pdb b/pdb/groups/fonts.pdb index c4b8652ff1..fd3746921b 100644 --- a/pdb/groups/fonts.pdb +++ b/pdb/groups/fonts.pdb @@ -42,6 +42,8 @@ sub fonts_get_list { $help = <<'HELP'; This procedure returns a list of the fonts that are currently available. + +Each font returned can be used as input to [func@Gimp.context_set_font]. HELP &neo_pdb_misc('2003'); @@ -52,8 +54,8 @@ HELP ); @outargs = ( - { name => 'font_list', type => 'strv', - desc => 'The list of font names' } + { name => 'font_list', type => 'fontarray', + desc => 'The list of fonts' } ); %invoke = ( @@ -64,10 +66,8 @@ HELP success = FALSE; if (success) - { - font_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->font_factory), - filter); - } + font_list = (GimpFont **) gimp_container_get_filtered_array (gimp_data_factory_get_container (gimp->font_factory), + filter); } CODE ); @@ -135,6 +135,7 @@ CODE @headers = qw("core/gimp.h" "core/gimpcontainer.h" "core/gimpdatafactory.h" + "text/gimpfont.h" "text/gimpfontfactory.h"); @procs = qw(fonts_refresh diff --git a/pdb/groups/gradients.pdb b/pdb/groups/gradients.pdb index 60a838a247..8f266a3c2e 100644 --- a/pdb/groups/gradients.pdb +++ b/pdb/groups/gradients.pdb @@ -40,8 +40,8 @@ sub gradients_get_list { $help = <<'HELP'; This procedure returns a list of the gradients that are currently loaded. -You can later use the gimp_context_set_gradient() function to -set the active gradient. + +Each gradient returned can be used as input to [func@Gimp.context_set_gradient]. HELP &federico_pdb_misc('1997'); @@ -52,16 +52,16 @@ HELP ); @outargs = ( - { name => 'gradient_list', type => 'strv', - desc => 'The list of gradient names' } + { name => 'gradient_list', type => 'gradientarray', + desc => 'The list of gradients' } ); %invoke = ( headers => [ qw("core/gimpcontainer-filter.h") ], code => <<'CODE' { - gradient_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->gradient_factory), - filter); + gradient_list = (GimpGradient **) gimp_container_get_filtered_array (gimp_data_factory_get_container (gimp->gradient_factory), + filter); } CODE ); diff --git a/pdb/groups/palettes.pdb b/pdb/groups/palettes.pdb index 309f48a4ba..a775cdaec5 100644 --- a/pdb/groups/palettes.pdb +++ b/pdb/groups/palettes.pdb @@ -39,8 +39,9 @@ sub palettes_get_list { $blurb = 'Retrieves a list of all of the available palettes'; $help = <<'HELP'; -This procedure returns a complete listing of available palettes. Each name -returned can be used as input to the command gimp_context_set_palette(). +This procedure returns a complete listing of available palettes. + +Each palette returned can be used as input to [func@Gimp.context_set_palette]. HELP &rock_pdb_misc('2001'); @@ -51,16 +52,16 @@ HELP ); @outargs = ( - { name => 'palette_list', type => 'strv', - desc => 'The list of palette names' } + { name => 'palette_list', type => 'palettearray', + desc => 'The list of palettes' } ); %invoke = ( headers => [ qw("core/gimpcontainer-filter.h") ], code => <<'CODE' { - palette_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->palette_factory), - filter); + palette_list = (GimpPalette **) gimp_container_get_filtered_array (gimp_data_factory_get_container (gimp->palette_factory), + filter); } CODE ); diff --git a/pdb/groups/patterns.pdb b/pdb/groups/patterns.pdb index 78399b08e8..f92fa33777 100644 --- a/pdb/groups/patterns.pdb +++ b/pdb/groups/patterns.pdb @@ -39,8 +39,9 @@ sub patterns_get_list { $blurb = 'Retrieve a complete listing of the available patterns.'; $help = <<'HELP'; -This procedure returns a complete listing of available GIMP patterns. Each name -returned can be used as input to the gimp_context_set_pattern(). +This procedure returns a complete listing of available GIMP patterns. + +Each pattern returned can be used as input to [func@Gimp.context_set_pattern]. HELP &std_pdb_misc; @@ -51,16 +52,16 @@ HELP ); @outargs = ( - { name => 'pattern_list', type => 'strv', - desc => 'The list of pattern names' } + { name => 'pattern_list', type => 'patternarray', + desc => 'The list of patterns' } ); %invoke = ( headers => [ qw("core/gimpcontainer-filter.h") ], code => <<'CODE' { - pattern_list = gimp_container_get_filtered_name_array (gimp_data_factory_get_container (gimp->pattern_factory), - filter); + pattern_list = (GimpPattern **) gimp_container_get_filtered_array (gimp_data_factory_get_container (gimp->pattern_factory), + filter); } CODE );