app, libgimp, pdb, plug-ins: merge gimp_channel_new() in libgimp and PDB.

Why have 2 functions if one is basically just redirecting to the other.
All we needed to do was to reorder the PDB args.
This commit is contained in:
Jehan 2024-09-27 17:10:46 +02:00
parent bd287d6f89
commit 3051796f3e
12 changed files with 82 additions and 117 deletions

View File

@ -57,17 +57,17 @@ channel_new_invoker (GimpProcedure *procedure,
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpImage *image;
const gchar *name;
gint width;
gint height;
const gchar *name;
gdouble opacity;
GeglColor *color;
GimpChannel *channel = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
width = g_value_get_int (gimp_value_array_index (args, 1));
height = g_value_get_int (gimp_value_array_index (args, 2));
name = g_value_get_string (gimp_value_array_index (args, 3));
name = g_value_get_string (gimp_value_array_index (args, 1));
width = g_value_get_int (gimp_value_array_index (args, 2));
height = g_value_get_int (gimp_value_array_index (args, 3));
opacity = g_value_get_double (gimp_value_array_index (args, 4));
color = g_value_get_object (gimp_value_array_index (args, 5));
@ -382,8 +382,12 @@ register_channel_procs (GimpPDB *pdb)
"gimp-channel-new");
gimp_procedure_set_static_help (procedure,
"Create a new channel.",
"This procedure creates a new channel with the specified width, height, name, opacity and color.\n"
"The new channel still needs to be added to the image, as this is not automatic. Add the new channel with 'gimp-image-insert-channel'. Other attributes, such as channel visibility, should be set with explicit procedure calls.\n"
"This procedure creates a new channel with the specified @width, @height, @name, @opacity and @color.\n"
"\n"
"Other attributes, such as channel visibility, should be set with explicit procedure calls.\n"
"\n"
"The new channel still needs to be added to the image, as this is not automatic. Add the new channel with [method@Gimp.Image.insert_channel].\n"
"\n"
"The channel's contents are undefined initially.",
NULL);
gimp_procedure_set_static_attribution (procedure,
@ -396,6 +400,13 @@ register_channel_procs (GimpPDB *pdb)
"The image to which to add the channel",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("name",
"name",
"The channel name",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_int ("width",
"width",
@ -408,13 +419,6 @@ register_channel_procs (GimpPDB *pdb)
"The channel height",
1, GIMP_MAX_IMAGE_SIZE, 1,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_string ("name",
"name",
"The channel name",
FALSE, FALSE, FALSE,
NULL,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
g_param_spec_double ("opacity",
"opacity",

View File

@ -63,41 +63,3 @@ gimp_channel_get_by_id (gint32 channel_id)
return NULL;
}
/**
* gimp_channel_new:
* @image: The image to which to add the channel.
* @name: The channel name.
* @width: The channel width.
* @height: The channel height.
* @opacity: The channel opacity.
* @color: The channel compositing color.
*
* Create a new channel.
*
* This procedure creates a new channel with the specified width and
* height. Name, opacity, and color are also supplied parameters. The
* new channel still needs to be added to the image, as this is not
* automatic. Add the new channel with the gimp_image_insert_channel()
* command. Other attributes such as channel show masked, should be
* set with explicit procedure calls. The channel's contents are
* undefined initially.
*
* Returns: (transfer none): The newly created channel.
* The object belongs to libgimp and you should not free it.
*/
GimpChannel *
gimp_channel_new (GimpImage *image,
const gchar *name,
guint width,
guint height,
gdouble opacity,
GeglColor *color)
{
return _gimp_channel_new (image,
width,
height,
name,
opacity,
color);
}

View File

@ -54,13 +54,6 @@ struct _GimpChannelClass
GimpChannel * gimp_channel_get_by_id (gint32 channel_id);
GimpChannel * gimp_channel_new (GimpImage *image,
const gchar *name,
guint width,
guint height,
gdouble opacity,
GeglColor *color);
G_END_DECLS

View File

@ -37,33 +37,37 @@
/**
* _gimp_channel_new:
* gimp_channel_new:
* @image: The image to which to add the channel.
* @name: The channel name.
* @width: The channel width.
* @height: The channel height.
* @name: The channel name.
* @opacity: The channel opacity.
* @color: The channel compositing color.
*
* Create a new channel.
*
* This procedure creates a new channel with the specified width,
* height, name, opacity and color.
* The new channel still needs to be added to the image, as this is not
* automatic. Add the new channel with gimp_image_insert_channel().
* This procedure creates a new channel with the specified @width,
* @height, @name, @opacity and @color.
*
* Other attributes, such as channel visibility, should be set with
* explicit procedure calls.
*
* The new channel still needs to be added to the image, as this is not
* automatic. Add the new channel with
* [method@Gimp.Image.insert_channel].
*
* The channel's contents are undefined initially.
*
* Returns: (transfer none): The newly created channel.
**/
GimpChannel *
_gimp_channel_new (GimpImage *image,
gint width,
gint height,
const gchar *name,
gdouble opacity,
GeglColor *color)
gimp_channel_new (GimpImage *image,
const gchar *name,
gint width,
gint height,
gdouble opacity,
GeglColor *color)
{
GimpValueArray *args;
GimpValueArray *return_vals;
@ -71,9 +75,9 @@ _gimp_channel_new (GimpImage *image,
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
G_TYPE_STRING, name,
G_TYPE_INT, width,
G_TYPE_INT, height,
G_TYPE_STRING, name,
G_TYPE_DOUBLE, opacity,
GEGL_TYPE_COLOR, color,
G_TYPE_NONE);

View File

@ -32,30 +32,30 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
G_GNUC_INTERNAL GimpChannel* _gimp_channel_new (GimpImage *image,
gint width,
gint height,
const gchar *name,
gdouble opacity,
GeglColor *color);
GimpChannel* gimp_channel_new_from_component (GimpImage *image,
GimpChannelType component,
const gchar *name);
GimpChannel* gimp_channel_copy (GimpChannel *channel);
gboolean gimp_channel_combine_masks (GimpChannel *channel1,
GimpChannel *channel2,
GimpChannelOps operation,
gint offx,
gint offy);
gboolean gimp_channel_get_show_masked (GimpChannel *channel);
gboolean gimp_channel_set_show_masked (GimpChannel *channel,
gboolean show_masked);
gdouble gimp_channel_get_opacity (GimpChannel *channel);
gboolean gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity);
GeglColor* gimp_channel_get_color (GimpChannel *channel);
gboolean gimp_channel_set_color (GimpChannel *channel,
GeglColor *color);
GimpChannel* gimp_channel_new (GimpImage *image,
const gchar *name,
gint width,
gint height,
gdouble opacity,
GeglColor *color);
GimpChannel* gimp_channel_new_from_component (GimpImage *image,
GimpChannelType component,
const gchar *name);
GimpChannel* gimp_channel_copy (GimpChannel *channel);
gboolean gimp_channel_combine_masks (GimpChannel *channel1,
GimpChannel *channel2,
GimpChannelOps operation,
gint offx,
gint offy);
gboolean gimp_channel_get_show_masked (GimpChannel *channel);
gboolean gimp_channel_set_show_masked (GimpChannel *channel,
gboolean show_masked);
gdouble gimp_channel_get_opacity (GimpChannel *channel);
gboolean gimp_channel_set_opacity (GimpChannel *channel,
gdouble opacity);
GeglColor* gimp_channel_get_color (GimpChannel *channel);
gboolean gimp_channel_set_color (GimpChannel *channel,
GeglColor *color);
G_END_DECLS

View File

@ -20,30 +20,32 @@ sub channel_new {
$blurb = 'Create a new channel.';
$help = <<'HELP';
This procedure creates a new channel with the specified width, height,
name, opacity and color.
This procedure creates a new channel with the specified @width, @height,
@name, @opacity and @color.
Other attributes, such as channel visibility, should be set with
explicit procedure calls.
The new channel still needs to be added to the image, as this is not
automatic. Add the new channel with gimp_image_insert_channel(). Other
attributes, such as channel visibility, should be set with explicit
procedure calls.
automatic. Add the new channel with [method@Gimp.Image.insert_channel].
The channel's contents are undefined initially.
HELP
&std_pdb_misc;
$lib_private = 1;
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image to which to add the channel' },
{ name => 'name', type => 'string',
desc => 'The channel name' },
{ name => 'width', type => '1 <= int32 <= GIMP_MAX_IMAGE_SIZE',
desc => 'The channel width' },
{ name => 'height', type => '1 <= int32 <= GIMP_MAX_IMAGE_SIZE',
desc => 'The channel height' },
{ name => 'name', type => 'string',
desc => 'The channel name' },
{ name => 'opacity', type => '0 <= float <= 100',
desc => 'The channel opacity' },
{ name => 'color', type => 'geglcolor',

View File

@ -55,7 +55,7 @@
(feather (carve-scale size 0.3))
(brush-size (carve-scale size 0.3))
(brush (car (gimp-brush-new "Carve It")))
(mask (car (gimp-channel-new img width height "Engraving Mask" 50 '(0 0 0))))
(mask (car (gimp-channel-new img "Engraving Mask" width height 50 '(0 0 0))))
(inset-gamma (calculate-inset-gamma (car (gimp-item-get-image src-layer)) src-layer))
(mask-fat 0)
(mask-emboss 0)

View File

@ -149,7 +149,7 @@
(feather (sota-scale size 0.5 chrome-factor))
(brush-size (sota-scale size 0.5 chrome-factor))
(brush (gimp-brush-new "Chrome It"))
(mask (gimp-channel-new img width height "Chrome Stencil" 50 '(0 0 0)))
(mask (gimp-channel-new img "Chrome Stencil" width height 50 '(0 0 0)))
(bg-layer (gimp-layer-new img width height GRAY-IMAGE _"Background" 100 LAYER-MODE-NORMAL))
(layer1 (gimp-layer-new img banding-width banding-height banding-type _"Layer 1" 100 LAYER-MODE-NORMAL))
(layer2 (gimp-layer-new img width height GRAYA-IMAGE _"Layer 2" 100 LAYER-MODE-DIFFERENCE))

View File

@ -11,9 +11,9 @@
(define testChannel
(gimp-channel-new
testImage ; image
23 24 ; width, height
testImage ; image
"Test Channel" ; name
23 24 ; width, height
50.0 ; opacity
"red" )) ; compositing color
@ -85,4 +85,4 @@
; TODO other item methods
(script-fu-use-v2)
(script-fu-use-v2)

View File

@ -14,9 +14,9 @@
; setup (not in an assert and not quoted)
; vectors-new succeeds
(define testChannel (car (gimp-channel-new
testImage ; image
23 24 ; width, height
testImage ; image
"Test Channel" ; name
23 24 ; width, height
50.0 ; opacity
"red" ))) ; compositing color
@ -91,9 +91,9 @@
; Can delete a new channel not yet added to image
(define testChannel2 (car (gimp-channel-new
testImage ; image
23 24 ; width, height
testImage ; image
"Test Channel" ; name
23 24 ; width, height
50.0 ; opacity
"red" ))) ; compositing color

View File

@ -26,9 +26,9 @@
; create test channel
; The test image has no channels (RGB are not considered channels.)
(define testChannel (car (gimp-channel-new
testImage ; image
23 24 ; width, height
testImage ; image
"Test Channel" ; name
23 24 ; width, height
50.0 ; opacity
"red" ))) ; compositing color
; a new channel is not in the image until added

View File

@ -148,9 +148,9 @@
31 ; fontsize
testFont )))
(define testChannel (car (gimp-channel-new
testImage ; image
23 24 ; width, height
testImage ; image
"Test Channel" ; name
23 24 ; width, height
50.0 ; opacity
"red" ))) ; compositing color
; must add to image