mirror of https://github.com/GNOME/gimp.git
app, libgimp, pdb: all resource (and subtype) array PDB types as GimpCoreObjectArray.
This commit is contained in:
parent
59c040323c
commit
64f9c71ad5
|
@ -110,7 +110,6 @@ fonts_get_by_name_invoker (GimpProcedure *procedure,
|
|||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
const gchar *name;
|
||||
gint num_fonts = 0;
|
||||
GimpFont **fonts = NULL;
|
||||
|
||||
name = g_value_get_string (gimp_value_array_index (args, 0));
|
||||
|
@ -118,6 +117,8 @@ fonts_get_by_name_invoker (GimpProcedure *procedure,
|
|||
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);
|
||||
|
||||
|
@ -125,16 +126,11 @@ fonts_get_by_name_invoker (GimpProcedure *procedure,
|
|||
success = FALSE;
|
||||
|
||||
num_fonts = g_list_length (list);
|
||||
fonts = g_new0 (GimpFont *, num_fonts + 1);
|
||||
|
||||
if (num_fonts > 0)
|
||||
{
|
||||
gint i = 0;
|
||||
for (GList *iter = list; i < num_fonts; i++, iter = g_list_next (iter))
|
||||
fonts[i] = iter->data;
|
||||
|
||||
fonts = g_new (GimpFont *, num_fonts);
|
||||
|
||||
for (GList *iter = list; i < num_fonts; i++, iter = g_list_next (iter))
|
||||
fonts[i] = g_object_ref (iter->data);
|
||||
}
|
||||
g_list_free (list);
|
||||
}
|
||||
|
||||
|
@ -142,10 +138,7 @@ fonts_get_by_name_invoker (GimpProcedure *procedure,
|
|||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
{
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 1), num_fonts);
|
||||
gimp_value_take_object_array (gimp_value_array_index (return_vals, 2), GIMP_TYPE_FONT, (GObject **) fonts, num_fonts);
|
||||
}
|
||||
g_value_take_boxed (gimp_value_array_index (return_vals, 1), fonts);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
@ -243,17 +236,11 @@ register_font_procs (GimpPDB *pdb)
|
|||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("num-fonts",
|
||||
"num fonts",
|
||||
"The number of fonts with the given name",
|
||||
0, G_MAXINT32, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_object_array ("fonts",
|
||||
"fonts",
|
||||
"The fonts with the given name",
|
||||
GIMP_TYPE_FONT,
|
||||
GIMP_PARAM_READWRITE));
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -118,21 +118,18 @@ gimp_font_get_by_name (const gchar *name)
|
|||
/**
|
||||
* gimp_fonts_get_by_name:
|
||||
* @name: The name of the font.
|
||||
* @num_fonts: (out): The number of fonts with the given name.
|
||||
*
|
||||
* Returns the fonts with the given name.
|
||||
*
|
||||
* Returns the fonts with the given name. There may be more than one.
|
||||
*
|
||||
* Returns: (array length=num_fonts) (element-type GimpFont) (transfer container):
|
||||
* 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,
|
||||
gint *num_fonts)
|
||||
gimp_fonts_get_by_name (const gchar *name)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
|
@ -147,13 +144,8 @@ gimp_fonts_get_by_name (const gchar *name,
|
|||
args);
|
||||
gimp_value_array_unref (args);
|
||||
|
||||
*num_fonts = 0;
|
||||
|
||||
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
||||
{
|
||||
*num_fonts = GIMP_VALUES_GET_INT (return_vals, 1);
|
||||
{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index (return_vals, 2)); if (a) fonts = g_memdup2 (a->data, a->length * sizeof (gpointer)); };
|
||||
}
|
||||
fonts = g_value_dup_boxed (gimp_value_array_index (return_vals, 1));
|
||||
|
||||
gimp_value_array_unref (return_vals);
|
||||
|
||||
|
|
|
@ -34,8 +34,7 @@ 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,
|
||||
gint *num_fonts);
|
||||
GimpFont** gimp_fonts_get_by_name (const gchar *name);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
60
pdb/app.pl
60
pdb/app.pl
|
@ -736,56 +736,56 @@ CODE
|
|||
}
|
||||
elsif ($pdbtype eq 'resourcearray') {
|
||||
$pspec = <<CODE;
|
||||
gimp_param_spec_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_RESOURCE,
|
||||
$flags)
|
||||
gimp_param_spec_core_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_RESOURCE,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'brusharray') {
|
||||
$pspec = <<CODE;
|
||||
gimp_param_spec_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_BRUSH,
|
||||
$flags)
|
||||
gimp_param_spec_core_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_BRUSH,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'fontarray') {
|
||||
$pspec = <<CODE;
|
||||
gimp_param_spec_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_FONT,
|
||||
$flags)
|
||||
gimp_param_spec_core_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_FONT,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'gradientarray') {
|
||||
$pspec = <<CODE;
|
||||
gimp_param_spec_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_GRADIENT,
|
||||
$flags)
|
||||
gimp_param_spec_core_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_GRADIENT,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'palettearray') {
|
||||
$pspec = <<CODE;
|
||||
gimp_param_spec_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_PALETTE,
|
||||
$flags)
|
||||
gimp_param_spec_core_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_PALETTE,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
elsif ($pdbtype eq 'patternarray') {
|
||||
$pspec = <<CODE;
|
||||
gimp_param_spec_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_PATTERN,
|
||||
$flags)
|
||||
gimp_param_spec_core_object_array ("$name",
|
||||
"$nick",
|
||||
"$blurb",
|
||||
GIMP_TYPE_PATTERN,
|
||||
$flags)
|
||||
CODE
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -32,15 +32,15 @@ sub fonts_get_by_name {
|
|||
|
||||
@outargs = (
|
||||
{ name => 'fonts', type => 'fontarray', non_empty => 0,
|
||||
desc => 'The fonts with the given name',
|
||||
array => { name => 'num_fonts',
|
||||
desc => 'The number of fonts with the given name' } }
|
||||
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);
|
||||
|
||||
|
@ -48,16 +48,11 @@ sub fonts_get_by_name {
|
|||
success = FALSE;
|
||||
|
||||
num_fonts = g_list_length (list);
|
||||
fonts = g_new0 (GimpFont *, num_fonts + 1);
|
||||
|
||||
if (num_fonts > 0)
|
||||
{
|
||||
gint i = 0;
|
||||
for (GList *iter = list; i < num_fonts; i++, iter = g_list_next (iter))
|
||||
fonts[i] = iter->data;
|
||||
|
||||
fonts = g_new (GimpFont *, num_fonts);
|
||||
|
||||
for (GList *iter = list; i < num_fonts; i++, iter = g_list_next (iter))
|
||||
fonts[i] = g_object_ref (iter->data);
|
||||
}
|
||||
g_list_free (list);
|
||||
}
|
||||
CODE
|
||||
|
|
90
pdb/pdb.pl
90
pdb/pdb.pl
|
@ -183,82 +183,76 @@ package Gimp::CodeGen::pdb;
|
|||
take_value_func => 'g_value_take_boxed ($value, $var)' },
|
||||
|
||||
resourcearray => { name => 'RESOURCEARRAY',
|
||||
gtype => 'GIMP_TYPE_OBJECT_ARRAY',
|
||||
gtype => 'GIMP_TYPE_CORE_OBJECT_ARRAY',
|
||||
type => 'GimpResource **',
|
||||
const_type => 'const GimpResource **',
|
||||
array => 1,
|
||||
init_value => 'NULL',
|
||||
in_annotate => '(element-type GimpResource)',
|
||||
out_annotate => '(element-type GimpResource) (transfer container)',
|
||||
get_value_func => '$var = (const GimpResource **) gimp_value_get_object_array ($value)',
|
||||
dup_value_func => '{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index ($value)); if (a) $var = g_memdup2 (a->data, a->length * sizeof (gpointer)); }',
|
||||
set_value_func => 'gimp_value_set_object_array ($value, GIMP_TYPE_RESOURCE, (GObject **) $var, $var_len)',
|
||||
take_value_func => 'gimp_value_take_object_array ($value, GIMP_TYPE_RESOURCE, (GObject **) $var, $var_len)' },
|
||||
in_annotate => '(element-type GimpResource) (array zero-terminated=1)',
|
||||
out_annotate => '(element-type GimpResource) (array zero-terminated=1) (transfer container)',
|
||||
get_value_func => '$var = g_value_get_boxed ($value)',
|
||||
dup_value_func => '$var = g_value_dup_boxed (gimp_value_array_index ($value))',
|
||||
set_value_func => 'g_value_set_boxed ($value, $var)',
|
||||
take_value_func => 'g_value_take_boxed ($value, $var)' },
|
||||
|
||||
brusharray => { name => 'BRUSHARRAY',
|
||||
gtype => 'GIMP_TYPE_OBJECT_ARRAY',
|
||||
gtype => 'GIMP_TYPE_CORE_OBJECT_ARRAY',
|
||||
type => 'GimpBrush **',
|
||||
const_type => 'const GimpBrush **',
|
||||
array => 1,
|
||||
init_value => 'NULL',
|
||||
in_annotate => '(element-type GimpBrush)',
|
||||
out_annotate => '(element-type GimpBrush) (transfer container)',
|
||||
get_value_func => '$var = (const GimpBrush **) gimp_value_get_object_array ($value)',
|
||||
dup_value_func => '{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index ($value)); if (a) $var = g_memdup2 (a->data, a->length * sizeof (gpointer)); }',
|
||||
set_value_func => 'gimp_value_set_object_array ($value, GIMP_TYPE_BRUSH, (GObject **) $var, $var_len)',
|
||||
take_value_func => 'gimp_value_take_object_array ($value, GIMP_TYPE_BRUSH, (GObject **) $var, $var_len)' },
|
||||
in_annotate => '(element-type GimpBrush) (array zero-terminated=1)',
|
||||
out_annotate => '(element-type GimpBrush) (array zero-terminated=1) (transfer container)',
|
||||
get_value_func => '$var = g_value_get_boxed ($value)',
|
||||
dup_value_func => '$var = g_value_dup_boxed (gimp_value_array_index ($value))',
|
||||
set_value_func => 'g_value_set_boxed ($value, $var)',
|
||||
take_value_func => 'g_value_take_boxed ($value, $var)' },
|
||||
|
||||
fontarray => { name => 'FONTARRAY',
|
||||
gtype => 'GIMP_TYPE_OBJECT_ARRAY',
|
||||
gtype => 'GIMP_TYPE_CORE_OBJECT_ARRAY',
|
||||
type => 'GimpFont **',
|
||||
const_type => 'const GimpFont **',
|
||||
array => 1,
|
||||
init_value => 'NULL',
|
||||
in_annotate => '(element-type GimpFont)',
|
||||
out_annotate => '(element-type GimpFont) (transfer container)',
|
||||
get_value_func => '$var = (const GimpFont **) gimp_value_get_object_array ($value)',
|
||||
dup_value_func => '{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index ($value)); if (a) $var = g_memdup2 (a->data, a->length * sizeof (gpointer)); }',
|
||||
set_value_func => 'gimp_value_set_object_array ($value, GIMP_TYPE_FONT, (GObject **) $var, $var_len)',
|
||||
take_value_func => 'gimp_value_take_object_array ($value, GIMP_TYPE_FONT, (GObject **) $var, $var_len)' },
|
||||
in_annotate => '(element-type GimpFont) (array zero-terminated=1)',
|
||||
out_annotate => '(element-type GimpFont) (array zero-terminated=1) (transfer container)',
|
||||
get_value_func => '$var = g_value_get_boxed ($value)',
|
||||
dup_value_func => '$var = g_value_dup_boxed (gimp_value_array_index ($value))',
|
||||
set_value_func => 'g_value_set_boxed ($value, $var)',
|
||||
take_value_func => 'g_value_take_boxed ($value, $var)' },
|
||||
|
||||
gradientarray => { name => 'GRADIENTARRAY',
|
||||
gtype => 'GIMP_TYPE_OBJECT_ARRAY',
|
||||
gtype => 'GIMP_TYPE_CORE_OBJECT_ARRAY',
|
||||
type => 'GimpGradient **',
|
||||
const_type => 'const GimpGradient **',
|
||||
array => 1,
|
||||
init_value => 'NULL',
|
||||
in_annotate => '(element-type GimpGradient)',
|
||||
out_annotate => '(element-type GimpGradient) (transfer container)',
|
||||
get_value_func => '$var = (const GimpGradient **) gimp_value_get_object_array ($value)',
|
||||
dup_value_func => '{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index ($value)); if (a) $var = g_memdup2 (a->data, a->length * sizeof (gpointer)); }',
|
||||
set_value_func => 'gimp_value_set_object_array ($value, GIMP_TYPE_GRADIENT, (GObject **) $var, $var_len)',
|
||||
take_value_func => 'gimp_value_take_object_array ($value, GIMP_TYPE_GRADIENT, (GObject **) $var, $var_len)' },
|
||||
in_annotate => '(element-type GimpGradient) (array zero-terminated=1)',
|
||||
out_annotate => '(element-type GimpGradient) (array zero-terminated=1) (transfer container)',
|
||||
get_value_func => '$var = g_value_get_boxed ($value)',
|
||||
dup_value_func => '$var = g_value_dup_boxed (gimp_value_array_index ($value))',
|
||||
set_value_func => 'g_value_set_boxed ($value, $var)',
|
||||
take_value_func => 'g_value_take_boxed ($value, $var)' },
|
||||
|
||||
palettearray => { name => 'PALETTEARRAY',
|
||||
gtype => 'GIMP_TYPE_OBJECT_ARRAY',
|
||||
gtype => 'GIMP_TYPE_CORE_OBJECT_ARRAY',
|
||||
type => 'GimpPalette **',
|
||||
const_type => 'const GimpPalette **',
|
||||
array => 1,
|
||||
init_value => 'NULL',
|
||||
in_annotate => '(element-type GimpPalette)',
|
||||
out_annotate => '(element-type GimpPalette) (transfer container)',
|
||||
get_value_func => '$var = (const GimpPalette **) gimp_value_get_object_array ($value)',
|
||||
dup_value_func => '{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index ($value)); if (a) $var = g_memdup2 (a->data, a->length * sizeof (gpointer)); }',
|
||||
set_value_func => 'gimp_value_set_object_array ($value, GIMP_TYPE_PALETTE, (GObject **) $var, $var_len)',
|
||||
take_value_func => 'gimp_value_take_object_array ($value, GIMP_TYPE_PALETTE, (GObject **) $var, $var_len)' },
|
||||
in_annotate => '(element-type GimpPalette) (array zero-terminated=1)',
|
||||
out_annotate => '(element-type GimpPalette) (array zero-terminated=1) (transfer container)',
|
||||
get_value_func => '$var = g_value_get_boxed ($value)',
|
||||
dup_value_func => '$var = g_value_dup_boxed (gimp_value_array_index ($value))',
|
||||
set_value_func => 'g_value_set_boxed ($value, $var)',
|
||||
take_value_func => 'g_value_take_boxed ($value, $var)' },
|
||||
|
||||
patternarray => { name => 'PATTERNARRAY',
|
||||
gtype => 'GIMP_TYPE_OBJECT_ARRAY',
|
||||
gtype => 'GIMP_TYPE_CORE_OBJECT_ARRAY',
|
||||
type => 'GimpPattern **',
|
||||
const_type => 'const GimpPattern **',
|
||||
array => 1,
|
||||
init_value => 'NULL',
|
||||
in_annotate => '(element-type GimpPattern)',
|
||||
out_annotate => '(element-type GimpPattern) (transfer container)',
|
||||
get_value_func => '$var = (const GimpPattern **) gimp_value_get_object_array ($value)',
|
||||
dup_value_func => '{ GimpObjectArray *a = g_value_get_boxed (gimp_value_array_index ($value)); if (a) $var = g_memdup2 (a->data, a->length * sizeof (gpointer)); }',
|
||||
set_value_func => 'gimp_value_set_object_array ($value, GIMP_TYPE_PATTERN, (GObject **) $var, $var_len)',
|
||||
take_value_func => 'gimp_value_take_object_array ($value, GIMP_TYPE_PATTERN, (GObject **) $var, $var_len)' },
|
||||
in_annotate => '(element-type GimpPattern) (array zero-terminated=1)',
|
||||
out_annotate => '(element-type GimpPattern) (array zero-terminated=1) (transfer container)',
|
||||
get_value_func => '$var = g_value_get_boxed ($value)',
|
||||
dup_value_func => '$var = g_value_dup_boxed (gimp_value_array_index ($value))',
|
||||
set_value_func => 'g_value_set_boxed ($value, $var)',
|
||||
take_value_func => 'g_value_take_boxed ($value, $var)' },
|
||||
|
||||
geglcolor => { name => 'GEGLCOLOR',
|
||||
gtype => 'GEGL_TYPE_COLOR',
|
||||
|
|
Loading…
Reference in New Issue