diff --git a/app/pdb/font-cmds.c b/app/pdb/font-cmds.c index 8ecf9f1d39..2df547de13 100644 --- a/app/pdb/font-cmds.c +++ b/app/pdb/font-cmds.c @@ -99,50 +99,6 @@ font_get_by_name_invoker (GimpProcedure *procedure, return return_vals; } -static GimpValueArray * -fonts_get_by_name_invoker (GimpProcedure *procedure, - Gimp *gimp, - GimpContext *context, - GimpProgress *progress, - const GimpValueArray *args, - GError **error) -{ - gboolean success = TRUE; - GimpValueArray *return_vals; - const gchar *name; - GimpFont **fonts = NULL; - - name = g_value_get_string (gimp_value_array_index (args, 0)); - - if (success) - { - GList *list; - gsize num_fonts; - gint i = 0; - - list = gimp_pdb_get_resources (gimp, GIMP_TYPE_FONT, name, GIMP_PDB_DATA_ACCESS_READ, error); - - if (list == NULL) - success = FALSE; - - num_fonts = g_list_length (list); - fonts = g_new0 (GimpFont *, num_fonts + 1); - - for (GList *iter = list; i < num_fonts; i++, iter = g_list_next (iter)) - fonts[i] = iter->data; - - g_list_free (list); - } - - return_vals = gimp_procedure_get_return_values (procedure, success, - error ? *error : NULL); - - if (success) - g_value_take_boxed (gimp_value_array_index (return_vals, 1), fonts); - - return return_vals; -} - void register_font_procs (GimpPDB *pdb) { @@ -189,7 +145,7 @@ register_font_procs (GimpPDB *pdb) gimp_procedure_set_static_help (procedure, "Returns a font with the given name.", "If several fonts are named identically, the one which is returned by this function should be considered random. This can be used when you know you won't have multiple fonts of this name or that you don't want to choose (non-interactive scripts, etc.).\n" - "If you need more control, you should use 'gimp-fonts-get-by-name' instead.\n" + "If you need more control, you should use [func@fonts_get_list] instead.\n" "Returns %NULL when no font exists of that name.", NULL); gimp_procedure_set_static_attribution (procedure, @@ -213,34 +169,4 @@ register_font_procs (GimpPDB *pdb) GIMP_PARAM_READWRITE)); gimp_pdb_register_procedure (pdb, procedure); g_object_unref (procedure); - - /* - * gimp-fonts-get-by-name - */ - procedure = gimp_procedure_new (fonts_get_by_name_invoker); - gimp_object_set_static_name (GIMP_OBJECT (procedure), - "gimp-fonts-get-by-name"); - gimp_procedure_set_static_help (procedure, - "Returns the fonts with the given name.", - "Returns the fonts with the given name. There may be more than one.", - NULL); - gimp_procedure_set_static_attribution (procedure, - "Jehan", - "Jehan", - "2023"); - gimp_procedure_add_argument (procedure, - gimp_param_spec_string ("name", - "name", - "The name of the font", - FALSE, FALSE, TRUE, - NULL, - GIMP_PARAM_READWRITE)); - gimp_procedure_add_return_value (procedure, - gimp_param_spec_core_object_array ("fonts", - "fonts", - "The fonts with the given name", - GIMP_TYPE_FONT, - 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 bc4f62a403..bae603f7a4 100644 --- a/app/pdb/internal-procs.c +++ b/app/pdb/internal-procs.c @@ -30,7 +30,7 @@ #include "internal-procs.h" -/* 776 procedures registered total */ +/* 775 procedures registered total */ void internal_procs_init (GimpPDB *pdb) diff --git a/libgimp/gimp.def b/libgimp/gimp.def index dcb56567f6..b00e20494a 100644 --- a/libgimp/gimp.def +++ b/libgimp/gimp.def @@ -318,7 +318,6 @@ EXPORTS gimp_font_get_pango_font_description gimp_font_get_type gimp_fonts_close_popup - gimp_fonts_get_by_name gimp_fonts_get_list gimp_fonts_popup gimp_fonts_refresh diff --git a/libgimp/gimpfont_pdb.c b/libgimp/gimpfont_pdb.c index 306e683f05..33423fd11c 100644 --- a/libgimp/gimpfont_pdb.c +++ b/libgimp/gimpfont_pdb.c @@ -83,7 +83,7 @@ _gimp_font_get_lookup_name (GimpFont *font) * this function should be considered random. This can be used when you * know you won't have multiple fonts of this name or that you don't * want to choose (non-interactive scripts, etc.). - * If you need more control, you should use gimp_fonts_get_by_name() + * If you need more control, you should use [func@fonts_get_list] * instead. * Returns %NULL when no font exists of that name. * @@ -114,41 +114,3 @@ gimp_font_get_by_name (const gchar *name) return font; } - -/** - * gimp_fonts_get_by_name: - * @name: The name of the font. - * - * Returns the fonts with the given name. - * - * Returns the fonts with the given name. There may be more than one. - * - * Returns: (element-type GimpFont) (array zero-terminated=1) (transfer container): - * The fonts with the given name. - * The returned value must be freed with g_free(). - * - * Since: 3.0 - **/ -GimpFont ** -gimp_fonts_get_by_name (const gchar *name) -{ - GimpValueArray *args; - GimpValueArray *return_vals; - GimpFont **fonts = NULL; - - args = gimp_value_array_new_from_types (NULL, - G_TYPE_STRING, name, - G_TYPE_NONE); - - return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (), - "gimp-fonts-get-by-name", - args); - gimp_value_array_unref (args); - - if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS) - fonts = g_value_dup_boxed (gimp_value_array_index (return_vals, 1)); - - gimp_value_array_unref (return_vals); - - return fonts; -} diff --git a/libgimp/gimpfont_pdb.h b/libgimp/gimpfont_pdb.h index 5236623cf5..1ea45b3a1c 100644 --- a/libgimp/gimpfont_pdb.h +++ b/libgimp/gimpfont_pdb.h @@ -34,7 +34,6 @@ G_BEGIN_DECLS G_GNUC_INTERNAL gchar* _gimp_font_get_lookup_name (GimpFont *font); GimpFont* gimp_font_get_by_name (const gchar *name); -GimpFont** gimp_fonts_get_by_name (const gchar *name); G_END_DECLS diff --git a/pdb/groups/font.pdb b/pdb/groups/font.pdb index 92ab356f2a..51f06d6adc 100644 --- a/pdb/groups/font.pdb +++ b/pdb/groups/font.pdb @@ -19,55 +19,15 @@ # The invoke code is compiled on the app side. # The invoke code must assign to each result var -sub fonts_get_by_name { - $blurb = "Returns the fonts with the given name."; - $help = "Returns the fonts with the given name. There may be more than one."; - - &jehan_pdb_misc('2023', '3.0'); - - @inargs = ( - { name => 'name', type => 'string', non_empty => 1, - desc => 'The name of the font' } - ); - - @outargs = ( - { name => 'fonts', type => 'fontarray', non_empty => 0, - desc => 'The fonts with the given name' } - ); - - %invoke = ( - code => <<'CODE' -{ - GList *list; - gsize num_fonts; - gint i = 0; - - list = gimp_pdb_get_resources (gimp, GIMP_TYPE_FONT, name, GIMP_PDB_DATA_ACCESS_READ, error); - - if (list == NULL) - success = FALSE; - - num_fonts = g_list_length (list); - fonts = g_new0 (GimpFont *, num_fonts + 1); - - for (GList *iter = list; i < num_fonts; i++, iter = g_list_next (iter)) - fonts[i] = iter->data; - - g_list_free (list); -} -CODE - ); -} - sub font_get_by_name { $blurb = "Returns a font with the given name."; - $help = < [@procs], lib => [@procs]); diff --git a/pdb/groups/fonts.pdb b/pdb/groups/fonts.pdb index fd3746921b..c6f5c17498 100644 --- a/pdb/groups/fonts.pdb +++ b/pdb/groups/fonts.pdb @@ -73,6 +73,51 @@ CODE ); } +# This PDB function is disabled for now, because I realized it is +# redundant with fonts_get_list, except that it is an exact name search +# and not a regexp (nor a substring) which might also easier of use. +# Nevertheless it's easier to add later a PDB function than removing +# one. So removing this for now. +sub fonts_get_by_name { + $blurb = "Returns the fonts with the given name."; + $help = "Returns the fonts with the given name. There may be more than one."; + + &jehan_pdb_misc('2023', '3.0'); + + @inargs = ( + { name => 'name', type => 'string', non_empty => 1, + desc => 'The name of the font' } + ); + + @outargs = ( + { name => 'fonts', type => 'fontarray', non_empty => 0, + desc => 'The fonts with the given name' } + ); + + %invoke = ( + code => <<'CODE' +{ + GList *list; + gsize num_fonts; + gint i = 0; + + list = gimp_pdb_get_resources (gimp, GIMP_TYPE_FONT, name, GIMP_PDB_DATA_ACCESS_READ, error); + + if (list == NULL) + success = FALSE; + + num_fonts = g_list_length (list); + fonts = g_new0 (GimpFont *, num_fonts + 1); + + for (GList *iter = list; i < num_fonts; i++, iter = g_list_next (iter)) + fonts[i] = iter->data; + + g_list_free (list); +} +CODE + ); +} + sub fonts_get_custom_configs { $blurb = 'Retrieve custom configs.';