mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 01:13:24 +00:00
app, libgimp, pdb: removing gimp_fonts_get_by_name().
I realized it is redundant with gimp_fonts_get_list() which is a bit more complicated to use but also more powerful. Let's see if we ever need the simpler utility function in the future.
This commit is contained in:
parent
a7064a18c3
commit
e9e7afa14f
7 changed files with 51 additions and 160 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 776 procedures registered total */
|
||||
/* 775 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 = <<HELP;
|
||||
$help = <<'HELP';
|
||||
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.).
|
||||
|
||||
If you need more control, you should use gimp_fonts_get_by_name() instead.
|
||||
If you need more control, you should use [func@fonts_get_list] instead.
|
||||
|
||||
Returns %NULL when no font exists of that name.
|
||||
HELP
|
||||
|
@ -131,7 +91,7 @@ CODE
|
|||
"text/gimpfont.h"
|
||||
"gimppdb-utils.h");
|
||||
|
||||
@procs = qw(font_get_lookup_name font_get_by_name fonts_get_by_name);
|
||||
@procs = qw(font_get_lookup_name font_get_by_name);
|
||||
|
||||
%exports = (app => [@procs], lib => [@procs]);
|
||||
|
||||
|
|
|
@ -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.';
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue