diff --git a/libgimp/Makefile.gi b/libgimp/Makefile.gi index 5b2147c69d..6c387ca8a1 100644 --- a/libgimp/Makefile.gi +++ b/libgimp/Makefile.gi @@ -111,6 +111,7 @@ libgimp_introspectable_headers = \ ${PDB_WRAPPERS_H} \ ../libgimp/gimpbrushselect.h \ ../libgimp/gimpchannel.h \ + ../libgimp/gimpdisplay.h \ ../libgimp/gimpdrawable.h \ ../libgimp/gimpfileprocedure.h \ ../libgimp/gimpfontselect.h \ @@ -121,6 +122,7 @@ libgimp_introspectable_headers = \ ../libgimp/gimpimageprocedure.h \ ../libgimp/gimpitem.h \ ../libgimp/gimplayer.h \ + ../libgimp/gimplayermask.h \ ../libgimp/gimploadprocedure.h \ ../libgimp/gimppaletteselect.h \ ../libgimp/gimpparamspecs.h \ @@ -131,7 +133,8 @@ libgimp_introspectable_headers = \ ../libgimp/gimpprogress.h \ ../libgimp/gimpsaveprocedure.h \ ../libgimp/gimpselection.h \ - ../libgimp/gimpthumbnailprocedure.h + ../libgimp/gimpthumbnailprocedure.h \ + ../libgimp/gimpvectors.h libgimp_introspectable = \ $(libgimp_introspectable_headers) \ @@ -140,6 +143,7 @@ libgimp_introspectable = \ ${PDB_WRAPPERS_C} \ ../libgimp/gimpbrushselect.c \ ../libgimp/gimpchannel.c \ + ../libgimp/gimpdisplay.c \ ../libgimp/gimpdrawable.c \ ../libgimp/gimpfileprocedure.c \ ../libgimp/gimpfontselect.c \ @@ -150,6 +154,7 @@ libgimp_introspectable = \ ../libgimp/gimpimageprocedure.c \ ../libgimp/gimpitem.c \ ../libgimp/gimplayer.c \ + ../libgimp/gimplayermask.c \ ../libgimp/gimploadprocedure.c \ ../libgimp/gimppaletteselect.c \ ../libgimp/gimpparamspecs.c \ @@ -160,7 +165,8 @@ libgimp_introspectable = \ ../libgimp/gimpprogress.c \ ../libgimp/gimpsaveprocedure.c \ ../libgimp/gimpselection.c \ - ../libgimp/gimpthumbnailprocedure.c + ../libgimp/gimpthumbnailprocedure.c \ + ../libgimp/gimpvectors.c libgimpui_introspectable_headers = \ ../libgimp/gimpui.h \ diff --git a/libgimp/gimp.h b/libgimp/gimp.h index 8d3bc6171d..5a3631a5ba 100644 --- a/libgimp/gimp.h +++ b/libgimp/gimp.h @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -46,6 +47,7 @@ #include #include #include +#include #include #include #include @@ -58,6 +60,7 @@ #include #include #include +#include #include diff --git a/libgimp/gimpchannel.c b/libgimp/gimpchannel.c index 2fd111b6c0..b81b204244 100644 --- a/libgimp/gimpchannel.c +++ b/libgimp/gimpchannel.c @@ -23,6 +23,24 @@ #include "gimp.h" +G_DEFINE_TYPE (GimpChannel, gimp_channel, GIMP_TYPE_DRAWABLE) + +#define parent_class gimp_drawable_parent_class + +static void +gimp_channel_class_init (GimpChannelClass *klass) +{ +} + +static void +gimp_channel_init (GimpChannel *channel) +{ +} + + +/* Public API. */ + + /** * gimp_channel_new: * @image: The image to which to add the channel. diff --git a/libgimp/gimpchannel.h b/libgimp/gimpchannel.h index 1771e6f2c4..73b7b6c775 100644 --- a/libgimp/gimpchannel.h +++ b/libgimp/gimpchannel.h @@ -29,6 +29,41 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ +#include + +#define GIMP_TYPE_CHANNEL (gimp_channel_get_type ()) +#define GIMP_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CHANNEL, GimpChannel)) +#define GIMP_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CHANNEL, GimpChannelClass)) +#define GIMP_IS_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CHANNEL)) +#define GIMP_IS_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CHANNEL)) +#define GIMP_CHANNEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CHANNEL, GimpChannelClass)) + + +typedef struct _GimpChannelClass GimpChannelClass; + +struct _GimpChannel +{ + GimpDrawable parent_instance; +}; + +struct _GimpChannelClass +{ + GimpDrawableClass parent_class; + + /* Padding for future expansion */ + void (*_gimp_reserved1) (void); + void (*_gimp_reserved2) (void); + void (*_gimp_reserved3) (void); + void (*_gimp_reserved4) (void); + void (*_gimp_reserved5) (void); + void (*_gimp_reserved6) (void); + void (*_gimp_reserved7) (void); + void (*_gimp_reserved8) (void); + void (*_gimp_reserved9) (void); +}; + +GType gimp_channel_get_type (void) G_GNUC_CONST; + #ifndef GIMP_DEPRECATED_REPLACE_NEW_API diff --git a/libgimp/gimpchannel_pdb.c b/libgimp/gimpchannel_pdb.c index dad21df6ea..ca4302d3a4 100644 --- a/libgimp/gimpchannel_pdb.c +++ b/libgimp/gimpchannel_pdb.c @@ -53,9 +53,9 @@ * explicit procedure calls. * The channel's contents are undefined initially. * - * Returns: The newly created channel. + * Returns: (transfer full): The newly created channel. **/ -gint32 +GimpChannel * _gimp_channel_new (GimpImage *image, gint width, gint height, @@ -66,7 +66,7 @@ _gimp_channel_new (GimpImage *image, GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 channel_ID = -1; + GimpChannel *channel = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -87,11 +87,11 @@ _gimp_channel_new (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - channel_ID = gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)); + channel = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return channel_ID; + return channel; } /** @@ -168,11 +168,11 @@ __gimp_channel_new (gint32 image_ID, * Other attributes, such as channel visibility, should be set with * explicit procedure calls. * - * Returns: The newly created channel. + * Returns: (transfer full): The newly created channel. * * Since: 2.4 **/ -gint32 +GimpChannel * gimp_channel_new_from_component (GimpImage *image, GimpChannelType component, const gchar *name) @@ -180,7 +180,7 @@ gimp_channel_new_from_component (GimpImage *image, GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 channel_ID = -1; + GimpChannel *channel = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -198,11 +198,11 @@ gimp_channel_new_from_component (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - channel_ID = gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)); + channel = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return channel_ID; + return channel; } /** @@ -258,6 +258,47 @@ _gimp_channel_new_from_component (gint32 image_ID, /** * gimp_channel_copy: + * @channel: The channel to copy. + * + * Copy a channel. + * + * This procedure copies the specified channel and returns the copy. + * 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(). + * + * Returns: (transfer full): The newly copied channel. + **/ +GimpChannel * +gimp_channel_copy (GimpChannel *channel) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + GimpChannel *channel_copy = NULL; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (channel)), + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-channel-copy", + args); + else + return_vals = gimp_run_procedure_array ("gimp-channel-copy", + args); + gimp_value_array_unref (args); + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + channel_copy = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)))); + + gimp_value_array_unref (return_vals); + + return channel_copy; +} + +/** + * _gimp_channel_copy: (skip) * @channel_ID: The channel to copy. * * Copy a channel. @@ -269,7 +310,7 @@ _gimp_channel_new_from_component (gint32 image_ID, * Returns: The newly copied channel. **/ gint32 -gimp_channel_copy (gint32 channel_ID) +_gimp_channel_copy (gint32 channel_ID) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -299,6 +340,57 @@ gimp_channel_copy (gint32 channel_ID) /** * gimp_channel_combine_masks: + * @channel1: The channel1. + * @channel2: The channel2. + * @operation: The selection operation. + * @offx: x offset between upper left corner of channels: (second - first). + * @offy: y offset between upper left corner of channels: (second - first). + * + * Combine two channel masks. + * + * This procedure combines two channel masks. The result is stored in + * the first channel. + * + * Returns: TRUE on success. + **/ +gboolean +gimp_channel_combine_masks (GimpChannel *channel1, + GimpChannel *channel2, + GimpChannelOps operation, + gint offx, + gint offy) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (channel1)), + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (channel2)), + GIMP_TYPE_CHANNEL_OPS, operation, + G_TYPE_INT, offx, + G_TYPE_INT, offy, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-channel-combine-masks", + args); + else + return_vals = gimp_run_procedure_array ("gimp-channel-combine-masks", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_channel_combine_masks: (skip) * @channel1_ID: The channel1. * @channel2_ID: The channel2. * @operation: The selection operation. @@ -313,11 +405,11 @@ gimp_channel_copy (gint32 channel_ID) * Returns: TRUE on success. **/ gboolean -gimp_channel_combine_masks (gint32 channel1_ID, - gint32 channel2_ID, - GimpChannelOps operation, - gint offx, - gint offy) +_gimp_channel_combine_masks (gint32 channel1_ID, + gint32 channel2_ID, + GimpChannelOps operation, + gint offx, + gint offy) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -350,6 +442,47 @@ gimp_channel_combine_masks (gint32 channel1_ID, /** * gimp_channel_get_show_masked: + * @channel: The channel. + * + * Get the composite method of the specified channel. + * + * This procedure returns the specified channel's composite method. If + * it is TRUE, then the channel is composited with the image so that + * masked regions are shown. Otherwise, selected regions are shown. + * + * Returns: The channel composite method. + **/ +gboolean +gimp_channel_get_show_masked (GimpChannel *channel) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean show_masked = FALSE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (channel)), + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-channel-get-show-masked", + args); + else + return_vals = gimp_run_procedure_array ("gimp-channel-get-show-masked", + args); + gimp_value_array_unref (args); + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + show_masked = g_value_get_boolean (gimp_value_array_index (return_vals, 1)); + + gimp_value_array_unref (return_vals); + + return show_masked; +} + +/** + * _gimp_channel_get_show_masked: (skip) * @channel_ID: The channel. * * Get the composite method of the specified channel. @@ -361,7 +494,7 @@ gimp_channel_combine_masks (gint32 channel1_ID, * Returns: The channel composite method. **/ gboolean -gimp_channel_get_show_masked (gint32 channel_ID) +_gimp_channel_get_show_masked (gint32 channel_ID) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -391,6 +524,49 @@ gimp_channel_get_show_masked (gint32 channel_ID) /** * gimp_channel_set_show_masked: + * @channel: The channel. + * @show_masked: The new channel composite method. + * + * Set the composite method of the specified channel. + * + * This procedure sets the specified channel's composite method. If it + * is TRUE, then the channel is composited with the image so that + * masked regions are shown. Otherwise, selected regions are shown. + * + * Returns: TRUE on success. + **/ +gboolean +gimp_channel_set_show_masked (GimpChannel *channel, + gboolean show_masked) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (channel)), + G_TYPE_BOOLEAN, show_masked, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-channel-set-show-masked", + args); + else + return_vals = gimp_run_procedure_array ("gimp-channel-set-show-masked", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_channel_set_show_masked: (skip) * @channel_ID: The channel. * @show_masked: The new channel composite method. * @@ -403,8 +579,8 @@ gimp_channel_get_show_masked (gint32 channel_ID) * Returns: TRUE on success. **/ gboolean -gimp_channel_set_show_masked (gint32 channel_ID, - gboolean show_masked) +_gimp_channel_set_show_masked (gint32 channel_ID, + gboolean show_masked) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -434,6 +610,45 @@ gimp_channel_set_show_masked (gint32 channel_ID, /** * gimp_channel_get_opacity: + * @channel: The channel. + * + * Get the opacity of the specified channel. + * + * This procedure returns the specified channel's opacity. + * + * Returns: The channel opacity. + **/ +gdouble +gimp_channel_get_opacity (GimpChannel *channel) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gdouble opacity = 0.0; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (channel)), + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-channel-get-opacity", + args); + else + return_vals = gimp_run_procedure_array ("gimp-channel-get-opacity", + args); + gimp_value_array_unref (args); + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + opacity = g_value_get_double (gimp_value_array_index (return_vals, 1)); + + gimp_value_array_unref (return_vals); + + return opacity; +} + +/** + * _gimp_channel_get_opacity: (skip) * @channel_ID: The channel. * * Get the opacity of the specified channel. @@ -443,7 +658,7 @@ gimp_channel_set_show_masked (gint32 channel_ID, * Returns: The channel opacity. **/ gdouble -gimp_channel_get_opacity (gint32 channel_ID) +_gimp_channel_get_opacity (gint32 channel_ID) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -473,6 +688,47 @@ gimp_channel_get_opacity (gint32 channel_ID) /** * gimp_channel_set_opacity: + * @channel: The channel. + * @opacity: The new channel opacity. + * + * Set the opacity of the specified channel. + * + * This procedure sets the specified channel's opacity. + * + * Returns: TRUE on success. + **/ +gboolean +gimp_channel_set_opacity (GimpChannel *channel, + gdouble opacity) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (channel)), + G_TYPE_DOUBLE, opacity, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-channel-set-opacity", + args); + else + return_vals = gimp_run_procedure_array ("gimp-channel-set-opacity", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_channel_set_opacity: (skip) * @channel_ID: The channel. * @opacity: The new channel opacity. * @@ -483,8 +739,8 @@ gimp_channel_get_opacity (gint32 channel_ID) * Returns: TRUE on success. **/ gboolean -gimp_channel_set_opacity (gint32 channel_ID, - gdouble opacity) +_gimp_channel_set_opacity (gint32 channel_ID, + gdouble opacity) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -514,6 +770,49 @@ gimp_channel_set_opacity (gint32 channel_ID, /** * gimp_channel_get_color: + * @channel: The channel. + * @color: (out caller-allocates): The channel compositing color. + * + * Get the compositing color of the specified channel. + * + * This procedure returns the specified channel's compositing color. + * + * Returns: TRUE on success. + **/ +gboolean +gimp_channel_get_color (GimpChannel *channel, + GimpRGB *color) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (channel)), + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-channel-get-color", + args); + else + return_vals = gimp_run_procedure_array ("gimp-channel-get-color", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + if (success) + gimp_value_get_rgb (gimp_value_array_index (return_vals, 1), &*color); + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_channel_get_color: (skip) * @channel_ID: The channel. * @color: (out caller-allocates): The channel compositing color. * @@ -524,8 +823,8 @@ gimp_channel_set_opacity (gint32 channel_ID, * Returns: TRUE on success. **/ gboolean -gimp_channel_get_color (gint32 channel_ID, - GimpRGB *color) +_gimp_channel_get_color (gint32 channel_ID, + GimpRGB *color) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -557,6 +856,47 @@ gimp_channel_get_color (gint32 channel_ID, /** * gimp_channel_set_color: + * @channel: The channel. + * @color: The new channel compositing color. + * + * Set the compositing color of the specified channel. + * + * This procedure sets the specified channel's compositing color. + * + * Returns: TRUE on success. + **/ +gboolean +gimp_channel_set_color (GimpChannel *channel, + const GimpRGB *color) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (channel)), + GIMP_TYPE_RGB, color, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-channel-set-color", + args); + else + return_vals = gimp_run_procedure_array ("gimp-channel-set-color", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_channel_set_color: (skip) * @channel_ID: The channel. * @color: The new channel compositing color. * @@ -567,8 +907,8 @@ gimp_channel_get_color (gint32 channel_ID, * Returns: TRUE on success. **/ gboolean -gimp_channel_set_color (gint32 channel_ID, - const GimpRGB *color) +_gimp_channel_set_color (gint32 channel_ID, + const GimpRGB *color) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; diff --git a/libgimp/gimpchannel_pdb.h b/libgimp/gimpchannel_pdb.h index f6ac448117..2136e26909 100644 --- a/libgimp/gimpchannel_pdb.h +++ b/libgimp/gimpchannel_pdb.h @@ -32,39 +32,48 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gint32 gimp_channel_copy (gint32 channel_ID); -gboolean gimp_channel_combine_masks (gint32 channel1_ID, - gint32 channel2_ID, - GimpChannelOps operation, - gint offx, - gint offy); -gboolean gimp_channel_get_show_masked (gint32 channel_ID); -gboolean gimp_channel_set_show_masked (gint32 channel_ID, - gboolean show_masked); -gdouble gimp_channel_get_opacity (gint32 channel_ID); -gboolean gimp_channel_set_opacity (gint32 channel_ID, - gdouble opacity); -gboolean gimp_channel_get_color (gint32 channel_ID, - GimpRGB *color); -gboolean gimp_channel_set_color (gint32 channel_ID, - const GimpRGB *color); + #ifndef GIMP_DEPRECATED_REPLACE_NEW_API -G_GNUC_INTERNAL gint32 _gimp_channel_new (GimpImage *image, - gint width, - gint height, - const gchar *name, - gdouble opacity, - const GimpRGB *color); -gint32 gimp_channel_new_from_component (GimpImage *image, - GimpChannelType component, - const gchar *name); +G_GNUC_INTERNAL GimpChannel* _gimp_channel_new (GimpImage *image, + gint width, + gint height, + const gchar *name, + gdouble opacity, + const GimpRGB *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); +gboolean gimp_channel_get_color (GimpChannel *channel, + GimpRGB *color); +gboolean gimp_channel_set_color (GimpChannel *channel, + const GimpRGB *color); #else /* GIMP_DEPRECATED_REPLACE_NEW_API */ #define _gimp_channel_new __gimp_channel_new #define gimp_channel_new_from_component _gimp_channel_new_from_component +#define gimp_channel_copy _gimp_channel_copy +#define gimp_channel_combine_masks _gimp_channel_combine_masks +#define gimp_channel_get_show_masked _gimp_channel_get_show_masked +#define gimp_channel_set_show_masked _gimp_channel_set_show_masked +#define gimp_channel_get_opacity _gimp_channel_get_opacity +#define gimp_channel_set_opacity _gimp_channel_set_opacity +#define gimp_channel_get_color _gimp_channel_get_color +#define gimp_channel_set_color _gimp_channel_set_color #endif /* GIMP_DEPRECATED_REPLACE_NEW_API */ @@ -73,15 +82,31 @@ gint32 gimp_channel_new_from_component (GimpImage *image, * They are not marked internal as a trick to keep the old API alive for now. */ -gint32 __gimp_channel_new (gint32 image_ID, - gint width, - gint height, - const gchar *name, - gdouble opacity, - const GimpRGB *color); -gint32 _gimp_channel_new_from_component (gint32 image_ID, - GimpChannelType component, - const gchar *name); +gint32 __gimp_channel_new (gint32 image_ID, + gint width, + gint height, + const gchar *name, + gdouble opacity, + const GimpRGB *color); +gint32 _gimp_channel_new_from_component (gint32 image_ID, + GimpChannelType component, + const gchar *name); +gint32 _gimp_channel_copy (gint32 channel_ID); +gboolean _gimp_channel_combine_masks (gint32 channel1_ID, + gint32 channel2_ID, + GimpChannelOps operation, + gint offx, + gint offy); +gboolean _gimp_channel_get_show_masked (gint32 channel_ID); +gboolean _gimp_channel_set_show_masked (gint32 channel_ID, + gboolean show_masked); +gdouble _gimp_channel_get_opacity (gint32 channel_ID); +gboolean _gimp_channel_set_opacity (gint32 channel_ID, + gdouble opacity); +gboolean _gimp_channel_get_color (gint32 channel_ID, + GimpRGB *color); +gboolean _gimp_channel_set_color (gint32 channel_ID, + const GimpRGB *color); G_END_DECLS diff --git a/libgimp/gimpdisplay.c b/libgimp/gimpdisplay.c new file mode 100644 index 0000000000..ff85fc99eb --- /dev/null +++ b/libgimp/gimpdisplay.c @@ -0,0 +1,160 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball + * + * gimpdisplay.c + * Copyright (C) Jehan + * + * This library is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include "config.h" + +#include "gimp.h" + +#include "gimppixbuf.h" + +enum +{ + PROP_0, + PROP_ID, + N_PROPS +}; + +struct _GimpDisplayPrivate +{ + gint id; +}; + +static void gimp_display_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gimp_display_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); + +G_DEFINE_TYPE_WITH_PRIVATE (GimpDisplay, gimp_display, G_TYPE_OBJECT) + +#define parent_class gimp_display_parent_class + +static GParamSpec *props[N_PROPS] = { NULL, }; + +static void +gimp_display_class_init (GimpDisplayClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->set_property = gimp_display_set_property; + object_class->get_property = gimp_display_get_property; + + props[PROP_ID] = + g_param_spec_int ("id", + "The display id", + "The display id for internal use", + 0, G_MAXINT32, 0, + GIMP_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY); + + g_object_class_install_properties (object_class, N_PROPS, props); +} + +static void +gimp_display_init (GimpDisplay *display) +{ + display->priv = gimp_display_get_instance_private (display); +} + +static void +gimp_display_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + GimpDisplay *display = GIMP_DISPLAY (object); + + switch (property_id) + { + case PROP_ID: + display->priv->id = g_value_get_int (value); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +gimp_display_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec) +{ + GimpDisplay *display = GIMP_DISPLAY (object); + + switch (property_id) + { + case PROP_ID: + g_value_set_int (value, display->priv->id); + break; + + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + + +/* Public API. */ + + +/** + * gimp_display_get_id: + * @display: The display. + * + * Returns: the display ID. + * + * Since: 3.0 + **/ +gint32 +gimp_display_get_id (GimpDisplay *display) +{ + return display->priv->id; +} + +/** + * gimp_display_new_by_id: + * @display_id: The display id. + * + * Creates a #GimpDisplay representing @display_id. + * + * Returns: (nullable) (transfer full): a #GimpDisplay for @display_id or + * %NULL if @display_id does not represent a valid display. + * + * Since: 3.0 + **/ +GimpDisplay * +gimp_display_new_by_id (gint32 display_id) +{ + GimpDisplay *display = NULL; + + if (_gimp_display_is_valid (display_id)) + display = g_object_new (GIMP_TYPE_DISPLAY, + "id", display_id, + NULL); + + return display; +} diff --git a/libgimp/gimpdisplay.h b/libgimp/gimpdisplay.h new file mode 100644 index 0000000000..043311478f --- /dev/null +++ b/libgimp/gimpdisplay.h @@ -0,0 +1,75 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball + * + * gimpdisplay.h + * Copyright (C) Jehan + * + * This library is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __GIMP_DISPLAY_H__ +#define __GIMP_DISPLAY_H__ + +G_BEGIN_DECLS + +/* For information look into the C source or the html documentation */ + +#define GIMP_TYPE_DISPLAY (gimp_display_get_type ()) +#define GIMP_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_DISPLAY, GimpDisplay)) +#define GIMP_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DISPLAY, GimpDisplayClass)) +#define GIMP_IS_DISPLAY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_DISPLAY)) +#define GIMP_IS_DISPLAY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DISPLAY)) +#define GIMP_DISPLAY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_DISPLAY, GimpDisplayClass)) + + +typedef struct _GimpDisplayClass GimpDisplayClass; +typedef struct _GimpDisplayPrivate GimpDisplayPrivate; + +struct _GimpDisplay +{ + GObject parent_instance; + + GimpDisplayPrivate *priv; +}; + +struct _GimpDisplayClass +{ + GObjectClass parent_class; + + /* Padding for future expansion */ + void (*_gimp_reserved1) (void); + void (*_gimp_reserved2) (void); + void (*_gimp_reserved3) (void); + void (*_gimp_reserved4) (void); + void (*_gimp_reserved5) (void); + void (*_gimp_reserved6) (void); + void (*_gimp_reserved7) (void); + void (*_gimp_reserved8) (void); + void (*_gimp_reserved9) (void); +}; + +GType gimp_display_get_type (void) G_GNUC_CONST; + +gint32 gimp_display_get_id (GimpDisplay *display); +GimpDisplay * gimp_display_new_by_id (gint32 display_id); + + +G_END_DECLS + +#endif /* __GIMP_DISPLAY_H__ */ diff --git a/libgimp/gimpdisplay_pdb.c b/libgimp/gimpdisplay_pdb.c index 1f88c8ad1c..0089d0cfc2 100644 --- a/libgimp/gimpdisplay_pdb.c +++ b/libgimp/gimpdisplay_pdb.c @@ -36,6 +36,48 @@ /** * gimp_display_is_valid: + * @display: The display to check. + * + * Returns TRUE if the display is valid. + * + * This procedure checks if the given display ID is valid and refers to + * an existing display. + * + * Returns: Whether the display ID is valid. + * + * Since: 2.4 + **/ +gboolean +gimp_display_is_valid (GimpDisplay *display) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean valid = FALSE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_DISPLAY_ID, gimp_display_get_id (display), + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-display-is-valid", + args); + else + return_vals = gimp_run_procedure_array ("gimp-display-is-valid", + args); + gimp_value_array_unref (args); + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + valid = g_value_get_boolean (gimp_value_array_index (return_vals, 1)); + + gimp_value_array_unref (return_vals); + + return valid; +} + +/** + * _gimp_display_is_valid: (skip) * @display_ID: The display to check. * * Returns TRUE if the display is valid. @@ -48,7 +90,7 @@ * Since: 2.4 **/ gboolean -gimp_display_is_valid (gint32 display_ID) +_gimp_display_is_valid (gint32 display_ID) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -89,15 +131,15 @@ gimp_display_is_valid (gint32 display_ID) * procedure only makes sense for use with the GIMP UI, and will result * in an execution error if called when GIMP has no UI. * - * Returns: The new display. + * Returns: (transfer full): The new display. **/ -gint32 +GimpDisplay * gimp_display_new (GimpImage *image) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 display_ID = -1; + GimpDisplay *display = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -113,11 +155,11 @@ gimp_display_new (GimpImage *image) gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - display_ID = gimp_value_get_display_id (gimp_value_array_index (return_vals, 1)); + display = gimp_display_new_by_id (gimp_value_get_display_id (gimp_value_array_index (return_vals, 1))); gimp_value_array_unref (return_vals); - return display_ID; + return display; } /** @@ -166,6 +208,48 @@ _gimp_display_new (gint32 image_ID) /** * gimp_display_delete: + * @display: The display to delete. + * + * Delete the specified display. + * + * This procedure removes the specified display. If this is the last + * remaining display for the underlying image, then the image is + * deleted also. Note that the display is closed no matter if the image + * is dirty or not. Better save the image before calling this + * procedure. + * + * Returns: TRUE on success. + **/ +gboolean +gimp_display_delete (GimpDisplay *display) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_DISPLAY_ID, gimp_display_get_id (display), + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-display-delete", + args); + else + return_vals = gimp_run_procedure_array ("gimp-display-delete", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_display_delete: (skip) * @display_ID: The display to delete. * * Delete the specified display. @@ -179,7 +263,7 @@ _gimp_display_new (gint32 image_ID) * Returns: TRUE on success. **/ gboolean -gimp_display_delete (gint32 display_ID) +_gimp_display_delete (gint32 display_ID) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -208,6 +292,51 @@ gimp_display_delete (gint32 display_ID) /** * gimp_display_get_window_handle: + * @display: The display to get the window handle from. + * + * Get a handle to the native window for an image display. + * + * This procedure returns a handle to the native window for a given + * image display. For example in the X backend of GDK, a native window + * handle is an Xlib XID. A value of 0 is returned for an invalid + * display or if this function is unimplemented for the windowing + * system that is being used. + * + * Returns: The native window handle or 0. + * + * Since: 2.4 + **/ +gint +gimp_display_get_window_handle (GimpDisplay *display) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gint window = 0; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_DISPLAY_ID, gimp_display_get_id (display), + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-display-get-window-handle", + args); + else + return_vals = gimp_run_procedure_array ("gimp-display-get-window-handle", + args); + gimp_value_array_unref (args); + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + window = g_value_get_int (gimp_value_array_index (return_vals, 1)); + + gimp_value_array_unref (return_vals); + + return window; +} + +/** + * _gimp_display_get_window_handle: (skip) * @display_ID: The display to get the window handle from. * * Get a handle to the native window for an image display. @@ -223,7 +352,7 @@ gimp_display_delete (gint32 display_ID) * Since: 2.4 **/ gint -gimp_display_get_window_handle (gint32 display_ID) +_gimp_display_get_window_handle (gint32 display_ID) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; diff --git a/libgimp/gimpdisplay_pdb.h b/libgimp/gimpdisplay_pdb.h index 9df129fa59..2bfb981ec5 100644 --- a/libgimp/gimpdisplay_pdb.h +++ b/libgimp/gimpdisplay_pdb.h @@ -32,20 +32,23 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gboolean gimp_display_is_valid (gint32 display_ID); -gboolean gimp_display_delete (gint32 display_ID); -gint gimp_display_get_window_handle (gint32 display_ID); -gboolean gimp_displays_flush (void); +gboolean gimp_displays_flush (void); #ifndef GIMP_DEPRECATED_REPLACE_NEW_API -gint32 gimp_display_new (GimpImage *image); -gboolean gimp_displays_reconnect (GimpImage *old_image, - GimpImage *new_image); +gboolean gimp_display_is_valid (GimpDisplay *display); +GimpDisplay* gimp_display_new (GimpImage *image); +gboolean gimp_display_delete (GimpDisplay *display); +gint gimp_display_get_window_handle (GimpDisplay *display); +gboolean gimp_displays_reconnect (GimpImage *old_image, + GimpImage *new_image); #else /* GIMP_DEPRECATED_REPLACE_NEW_API */ +#define gimp_display_is_valid _gimp_display_is_valid #define gimp_display_new _gimp_display_new +#define gimp_display_delete _gimp_display_delete +#define gimp_display_get_window_handle _gimp_display_get_window_handle #define gimp_displays_reconnect _gimp_displays_reconnect @@ -55,9 +58,12 @@ gboolean gimp_displays_reconnect (GimpImage *old_image, * They are not marked internal as a trick to keep the old API alive for now. */ -gint32 _gimp_display_new (gint32 image_ID); -gboolean _gimp_displays_reconnect (gint32 old_image_ID, - gint32 new_image_ID); +gboolean _gimp_display_is_valid (gint32 display_ID); +gint32 _gimp_display_new (gint32 image_ID); +gboolean _gimp_display_delete (gint32 display_ID); +gint _gimp_display_get_window_handle (gint32 display_ID); +gboolean _gimp_displays_reconnect (gint32 old_image_ID, + gint32 new_image_ID); G_END_DECLS diff --git a/libgimp/gimpimage_pdb.c b/libgimp/gimpimage_pdb.c index 4221e39cc6..9da6806816 100644 --- a/libgimp/gimpimage_pdb.c +++ b/libgimp/gimpimage_pdb.c @@ -2214,8 +2214,8 @@ _gimp_image_thaw_layers (gint32 image_ID) /** * gimp_image_insert_channel: * @image: The image. - * @channel_ID: The channel. - * @parent_ID: The parent channel. + * @channel: The channel. + * @parent: The parent channel. * @position: The channel position. * * Add the specified channel to the image. @@ -2230,10 +2230,10 @@ _gimp_image_thaw_layers (gint32 image_ID) * Returns: TRUE on success. **/ gboolean -gimp_image_insert_channel (GimpImage *image, - gint32 channel_ID, - gint32 parent_ID, - gint position) +gimp_image_insert_channel (GimpImage *image, + GimpChannel *channel, + GimpChannel *parent, + gint position) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -2242,8 +2242,8 @@ gimp_image_insert_channel (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - GIMP_TYPE_CHANNEL_ID, channel_ID, - GIMP_TYPE_CHANNEL_ID, parent_ID, + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (channel)), + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (parent)), G_TYPE_INT, position, G_TYPE_NONE); @@ -2318,7 +2318,7 @@ _gimp_image_insert_channel (gint32 image_ID, /** * gimp_image_remove_channel: * @image: The image. - * @channel_ID: The channel. + * @channel: The channel. * * Remove the specified channel from the image. * @@ -2328,8 +2328,8 @@ _gimp_image_insert_channel (gint32 image_ID, * Returns: TRUE on success. **/ gboolean -gimp_image_remove_channel (GimpImage *image, - gint32 channel_ID) +gimp_image_remove_channel (GimpImage *image, + GimpChannel *channel) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -2338,7 +2338,7 @@ gimp_image_remove_channel (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - GIMP_TYPE_CHANNEL_ID, channel_ID, + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (channel)), G_TYPE_NONE); if (pdb) @@ -2584,8 +2584,8 @@ _gimp_image_thaw_channels (gint32 image_ID) /** * gimp_image_insert_vectors: * @image: The image. - * @vectors_ID: The vectors. - * @parent_ID: The parent vectors. + * @vectors: The vectors. + * @parent: The parent vectors. * @position: The vectors position. * * Add the specified vectors to the image. @@ -2600,10 +2600,10 @@ _gimp_image_thaw_channels (gint32 image_ID) * Returns: TRUE on success. **/ gboolean -gimp_image_insert_vectors (GimpImage *image, - gint32 vectors_ID, - gint32 parent_ID, - gint position) +gimp_image_insert_vectors (GimpImage *image, + GimpVectors *vectors, + GimpVectors *parent, + gint position) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -2612,8 +2612,8 @@ gimp_image_insert_vectors (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - GIMP_TYPE_VECTORS_ID, vectors_ID, - GIMP_TYPE_VECTORS_ID, parent_ID, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (parent)), G_TYPE_INT, position, G_TYPE_NONE); @@ -2688,7 +2688,7 @@ _gimp_image_insert_vectors (gint32 image_ID, /** * gimp_image_remove_vectors: * @image: The image. - * @vectors_ID: The vectors object. + * @vectors: The vectors object. * * Remove the specified path from the image. * @@ -2700,8 +2700,8 @@ _gimp_image_insert_vectors (gint32 image_ID, * Since: 2.4 **/ gboolean -gimp_image_remove_vectors (GimpImage *image, - gint32 vectors_ID) +gimp_image_remove_vectors (GimpImage *image, + GimpVectors *vectors) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -2710,7 +2710,7 @@ gimp_image_remove_vectors (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - GIMP_TYPE_VECTORS_ID, vectors_ID, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), G_TYPE_NONE); if (pdb) @@ -4637,15 +4637,15 @@ _gimp_image_set_active_layer (gint32 image_ID, * If there is an active channel, this will return the channel ID, * otherwise, -1. * - * Returns: The active channel. + * Returns: (transfer full): The active channel. **/ -gint32 +GimpChannel * gimp_image_get_active_channel (GimpImage *image) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 active_channel_ID = -1; + GimpChannel *active_channel = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -4661,11 +4661,11 @@ gimp_image_get_active_channel (GimpImage *image) gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - active_channel_ID = gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)); + active_channel = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return active_channel_ID; + return active_channel; } /** @@ -4711,7 +4711,7 @@ _gimp_image_get_active_channel (gint32 image_ID) /** * gimp_image_set_active_channel: * @image: The image. - * @active_channel_ID: The new image active channel. + * @active_channel: The new image active channel. * * Sets the specified image's active channel. * @@ -4723,8 +4723,8 @@ _gimp_image_get_active_channel (gint32 image_ID) * Returns: TRUE on success. **/ gboolean -gimp_image_set_active_channel (GimpImage *image, - gint32 active_channel_ID) +gimp_image_set_active_channel (GimpImage *image, + GimpChannel *active_channel) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -4733,7 +4733,7 @@ gimp_image_set_active_channel (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - GIMP_TYPE_CHANNEL_ID, active_channel_ID, + GIMP_TYPE_CHANNEL_ID, gimp_item_get_id (GIMP_ITEM (active_channel)), G_TYPE_NONE); if (pdb) @@ -4804,15 +4804,15 @@ _gimp_image_set_active_channel (gint32 image_ID, * * If there is an active path, its ID will be returned, otherwise, -1. * - * Returns: The active vectors. + * Returns: (transfer full): The active vectors. **/ -gint32 +GimpVectors * gimp_image_get_active_vectors (GimpImage *image) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 active_vectors_ID = -1; + GimpVectors *active_vectors = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -4828,11 +4828,11 @@ gimp_image_get_active_vectors (GimpImage *image) gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - active_vectors_ID = gimp_value_get_vectors_id (gimp_value_array_index (return_vals, 1)); + active_vectors = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return active_vectors_ID; + return active_vectors; } /** @@ -4877,7 +4877,7 @@ _gimp_image_get_active_vectors (gint32 image_ID) /** * gimp_image_set_active_vectors: * @image: The image. - * @active_vectors_ID: The new image active vectors. + * @active_vectors: The new image active vectors. * * Sets the specified image's active vectors. * @@ -4886,8 +4886,8 @@ _gimp_image_get_active_vectors (gint32 image_ID) * Returns: TRUE on success. **/ gboolean -gimp_image_set_active_vectors (GimpImage *image, - gint32 active_vectors_ID) +gimp_image_set_active_vectors (GimpImage *image, + GimpVectors *active_vectors) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -4896,7 +4896,7 @@ gimp_image_set_active_vectors (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - GIMP_TYPE_VECTORS_ID, active_vectors_ID, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (active_vectors)), G_TYPE_NONE); if (pdb) @@ -4965,15 +4965,15 @@ _gimp_image_set_active_vectors (gint32 image_ID, * This will always return a valid ID for a selection -- which is * represented as a channel internally. * - * Returns: The selection channel. + * Returns: (transfer full): The selection channel. **/ -gint32 +GimpSelection * gimp_image_get_selection (GimpImage *image) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 selection_ID = -1; + GimpSelection *selection = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -4989,11 +4989,11 @@ gimp_image_get_selection (GimpImage *image) gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - selection_ID = gimp_value_get_selection_id (gimp_value_array_index (return_vals, 1)); + selection = GIMP_SELECTION (gimp_item_new_by_id (gimp_value_get_selection_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return selection_ID; + return selection; } /** @@ -6682,16 +6682,16 @@ _gimp_image_get_layer_by_tattoo (gint32 image_ID, * This procedure returns the channel with the given tattoo in the * specified image. * - * Returns: The channel with the specified tattoo. + * Returns: (transfer full): The channel with the specified tattoo. **/ -gint32 +GimpChannel * gimp_image_get_channel_by_tattoo (GimpImage *image, guint tattoo) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 channel_ID = -1; + GimpChannel *channel = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -6708,11 +6708,11 @@ gimp_image_get_channel_by_tattoo (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - channel_ID = gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)); + channel = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return channel_ID; + return channel; } /** @@ -6768,18 +6768,18 @@ _gimp_image_get_channel_by_tattoo (gint32 image_ID, * This procedure returns the vectors with the given tattoo in the * specified image. * - * Returns: The vectors with the specified tattoo. + * Returns: (transfer full): The vectors with the specified tattoo. * * Since: 2.6 **/ -gint32 +GimpVectors * gimp_image_get_vectors_by_tattoo (GimpImage *image, guint tattoo) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 vectors_ID = -1; + GimpVectors *vectors = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -6796,11 +6796,11 @@ gimp_image_get_vectors_by_tattoo (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - vectors_ID = gimp_value_get_vectors_id (gimp_value_array_index (return_vals, 1)); + vectors = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return vectors_ID; + return vectors; } /** @@ -6948,18 +6948,18 @@ _gimp_image_get_layer_by_name (gint32 image_ID, * This procedure returns the channel with the given name in the * specified image. * - * Returns: The channel with the specified name. + * Returns: (transfer full): The channel with the specified name. * * Since: 2.8 **/ -gint32 +GimpChannel * gimp_image_get_channel_by_name (GimpImage *image, const gchar *name) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 channel_ID = -1; + GimpChannel *channel = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -6976,11 +6976,11 @@ gimp_image_get_channel_by_name (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - channel_ID = gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)); + channel = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return channel_ID; + return channel; } /** @@ -7038,18 +7038,18 @@ _gimp_image_get_channel_by_name (gint32 image_ID, * This procedure returns the vectors with the given name in the * specified image. * - * Returns: The vectors with the specified name. + * Returns: (transfer full): The vectors with the specified name. * * Since: 2.8 **/ -gint32 +GimpVectors * gimp_image_get_vectors_by_name (GimpImage *image, const gchar *name) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 vectors_ID = -1; + GimpVectors *vectors = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -7066,11 +7066,11 @@ gimp_image_get_vectors_by_name (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - vectors_ID = gimp_value_get_vectors_id (gimp_value_array_index (return_vals, 1)); + vectors = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return vectors_ID; + return vectors; } /** diff --git a/libgimp/gimpimage_pdb.h b/libgimp/gimpimage_pdb.h index 53b0885ffd..0ade23a1f4 100644 --- a/libgimp/gimpimage_pdb.h +++ b/libgimp/gimpimage_pdb.h @@ -81,19 +81,19 @@ gboolean gimp_image_remove_layer (GimpImage gboolean gimp_image_freeze_layers (GimpImage *image); gboolean gimp_image_thaw_layers (GimpImage *image); gboolean gimp_image_insert_channel (GimpImage *image, - gint32 channel_ID, - gint32 parent_ID, + GimpChannel *channel, + GimpChannel *parent, gint position); gboolean gimp_image_remove_channel (GimpImage *image, - gint32 channel_ID); + GimpChannel *channel); gboolean gimp_image_freeze_channels (GimpImage *image); gboolean gimp_image_thaw_channels (GimpImage *image); gboolean gimp_image_insert_vectors (GimpImage *image, - gint32 vectors_ID, - gint32 parent_ID, + GimpVectors *vectors, + GimpVectors *parent, gint position); gboolean gimp_image_remove_vectors (GimpImage *image, - gint32 vectors_ID); + GimpVectors *vectors); gboolean gimp_image_freeze_vectors (GimpImage *image); gboolean gimp_image_thaw_vectors (GimpImage *image); gint gimp_image_get_item_position (GimpImage *image, @@ -137,13 +137,13 @@ G_GNUC_INTERNAL gboolean _gimp_image_thumbnail (GimpImage GimpLayer* gimp_image_get_active_layer (GimpImage *image); gboolean gimp_image_set_active_layer (GimpImage *image, GimpLayer *active_layer); -gint32 gimp_image_get_active_channel (GimpImage *image); +GimpChannel* gimp_image_get_active_channel (GimpImage *image); gboolean gimp_image_set_active_channel (GimpImage *image, - gint32 active_channel_ID); -gint32 gimp_image_get_active_vectors (GimpImage *image); + GimpChannel *active_channel); +GimpVectors* gimp_image_get_active_vectors (GimpImage *image); gboolean gimp_image_set_active_vectors (GimpImage *image, - gint32 active_vectors_ID); -gint32 gimp_image_get_selection (GimpImage *image); + GimpVectors *active_vectors); +GimpSelection* gimp_image_get_selection (GimpImage *image); gboolean gimp_image_get_component_active (GimpImage *image, GimpChannelType component); gboolean gimp_image_set_component_active (GimpImage *image, @@ -176,15 +176,15 @@ gboolean gimp_image_set_tattoo_state (GimpImage guint tattoo_state); GimpLayer* gimp_image_get_layer_by_tattoo (GimpImage *image, guint tattoo); -gint32 gimp_image_get_channel_by_tattoo (GimpImage *image, +GimpChannel* gimp_image_get_channel_by_tattoo (GimpImage *image, guint tattoo); -gint32 gimp_image_get_vectors_by_tattoo (GimpImage *image, +GimpVectors* gimp_image_get_vectors_by_tattoo (GimpImage *image, guint tattoo); GimpLayer* gimp_image_get_layer_by_name (GimpImage *image, const gchar *name); -gint32 gimp_image_get_channel_by_name (GimpImage *image, +GimpChannel* gimp_image_get_channel_by_name (GimpImage *image, const gchar *name); -gint32 gimp_image_get_vectors_by_name (GimpImage *image, +GimpVectors* gimp_image_get_vectors_by_name (GimpImage *image, const gchar *name); gboolean gimp_image_attach_parasite (GimpImage *image, const GimpParasite *parasite); diff --git a/libgimp/gimpimageguides_pdb.c b/libgimp/gimpimageguides_pdb.c index 84d027d58b..08b5c1b04a 100644 --- a/libgimp/gimpimageguides_pdb.c +++ b/libgimp/gimpimageguides_pdb.c @@ -47,14 +47,14 @@ * * Returns: The new guide. **/ -gint32 +guint gimp_image_add_hguide (GimpImage *image, gint yposition) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 guide_ID = -1; + guint guide = 0; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -71,11 +71,11 @@ gimp_image_add_hguide (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - guide_ID = g_value_get_uint (gimp_value_array_index (return_vals, 1)); + guide = g_value_get_uint (gimp_value_array_index (return_vals, 1)); gimp_value_array_unref (return_vals); - return guide_ID; + return guide; } /** @@ -135,14 +135,14 @@ _gimp_image_add_hguide (gint32 image_ID, * * Returns: The new guide. **/ -gint32 +guint gimp_image_add_vguide (GimpImage *image, gint xposition) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 guide_ID = -1; + guint guide = 0; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -159,11 +159,11 @@ gimp_image_add_vguide (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - guide_ID = g_value_get_uint (gimp_value_array_index (return_vals, 1)); + guide = g_value_get_uint (gimp_value_array_index (return_vals, 1)); gimp_value_array_unref (return_vals); - return guide_ID; + return guide; } /** @@ -213,7 +213,7 @@ _gimp_image_add_vguide (gint32 image_ID, /** * gimp_image_delete_guide: * @image: The image. - * @guide_ID: The ID of the guide to be removed. + * @guide: The ID of the guide to be removed. * * Deletes a guide from an image. * @@ -224,7 +224,7 @@ _gimp_image_add_vguide (gint32 image_ID, **/ gboolean gimp_image_delete_guide (GimpImage *image, - gint32 guide_ID) + guint guide) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -233,7 +233,7 @@ gimp_image_delete_guide (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - G_TYPE_UINT, guide_ID, + G_TYPE_UINT, guide, G_TYPE_NONE); if (pdb) @@ -297,7 +297,7 @@ _gimp_image_delete_guide (gint32 image_ID, /** * gimp_image_find_next_guide: * @image: The image. - * @guide_ID: The ID of the current guide (0 if first invocation). + * @guide: The ID of the current guide (0 if first invocation). * * Find next guide on an image. * @@ -309,18 +309,18 @@ _gimp_image_delete_guide (gint32 image_ID, * * Returns: The next guide's ID. **/ -gint32 +guint gimp_image_find_next_guide (GimpImage *image, - gint32 guide_ID) + guint guide) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 next_guide_ID = -1; + guint next_guide = 0; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - G_TYPE_UINT, guide_ID, + G_TYPE_UINT, guide, G_TYPE_NONE); if (pdb) @@ -333,11 +333,11 @@ gimp_image_find_next_guide (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - next_guide_ID = g_value_get_uint (gimp_value_array_index (return_vals, 1)); + next_guide = g_value_get_uint (gimp_value_array_index (return_vals, 1)); gimp_value_array_unref (return_vals); - return next_guide_ID; + return next_guide; } /** @@ -389,7 +389,7 @@ _gimp_image_find_next_guide (gint32 image_ID, /** * gimp_image_get_guide_orientation: * @image: The image. - * @guide_ID: The guide. + * @guide: The guide. * * Get orientation of a guide on an image. * @@ -400,7 +400,7 @@ _gimp_image_find_next_guide (gint32 image_ID, **/ GimpOrientationType gimp_image_get_guide_orientation (GimpImage *image, - gint32 guide_ID) + guint guide) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -409,7 +409,7 @@ gimp_image_get_guide_orientation (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - G_TYPE_UINT, guide_ID, + G_TYPE_UINT, guide, G_TYPE_NONE); if (pdb) @@ -475,7 +475,7 @@ _gimp_image_get_guide_orientation (gint32 image_ID, /** * gimp_image_get_guide_position: * @image: The image. - * @guide_ID: The guide. + * @guide: The guide. * * Get position of a guide on an image. * @@ -486,7 +486,7 @@ _gimp_image_get_guide_orientation (gint32 image_ID, **/ gint gimp_image_get_guide_position (GimpImage *image, - gint32 guide_ID) + guint guide) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -495,7 +495,7 @@ gimp_image_get_guide_position (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - G_TYPE_UINT, guide_ID, + G_TYPE_UINT, guide, G_TYPE_NONE); if (pdb) diff --git a/libgimp/gimpimageguides_pdb.h b/libgimp/gimpimageguides_pdb.h index c566bd7b04..91ab5e94e0 100644 --- a/libgimp/gimpimageguides_pdb.h +++ b/libgimp/gimpimageguides_pdb.h @@ -36,18 +36,18 @@ G_BEGIN_DECLS #ifndef GIMP_DEPRECATED_REPLACE_NEW_API -gint32 gimp_image_add_hguide (GimpImage *image, +guint gimp_image_add_hguide (GimpImage *image, gint yposition); -gint32 gimp_image_add_vguide (GimpImage *image, +guint gimp_image_add_vguide (GimpImage *image, gint xposition); gboolean gimp_image_delete_guide (GimpImage *image, - gint32 guide_ID); -gint32 gimp_image_find_next_guide (GimpImage *image, - gint32 guide_ID); + guint guide); +guint gimp_image_find_next_guide (GimpImage *image, + guint guide); GimpOrientationType gimp_image_get_guide_orientation (GimpImage *image, - gint32 guide_ID); + guint guide); gint gimp_image_get_guide_position (GimpImage *image, - gint32 guide_ID); + guint guide); #else /* GIMP_DEPRECATED_REPLACE_NEW_API */ diff --git a/libgimp/gimpimagesamplepoints_pdb.c b/libgimp/gimpimagesamplepoints_pdb.c index effb078a37..7394bc6de7 100644 --- a/libgimp/gimpimagesamplepoints_pdb.c +++ b/libgimp/gimpimagesamplepoints_pdb.c @@ -50,7 +50,7 @@ * * Since: 2.10 **/ -gint32 +guint gimp_image_add_sample_point (GimpImage *image, gint position_x, gint position_y) @@ -58,7 +58,7 @@ gimp_image_add_sample_point (GimpImage *image, GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 sample_point_ID = -1; + guint sample_point = 0; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -76,11 +76,11 @@ gimp_image_add_sample_point (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - sample_point_ID = g_value_get_uint (gimp_value_array_index (return_vals, 1)); + sample_point = g_value_get_uint (gimp_value_array_index (return_vals, 1)); gimp_value_array_unref (return_vals); - return sample_point_ID; + return sample_point; } /** @@ -135,7 +135,7 @@ _gimp_image_add_sample_point (gint32 image_ID, /** * gimp_image_delete_sample_point: * @image: The image. - * @sample_point_ID: The ID of the sample point to be removed. + * @sample_point: The ID of the sample point to be removed. * * Deletes a sample point from an image. * @@ -148,7 +148,7 @@ _gimp_image_add_sample_point (gint32 image_ID, **/ gboolean gimp_image_delete_sample_point (GimpImage *image, - gint32 sample_point_ID) + guint sample_point) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -157,7 +157,7 @@ gimp_image_delete_sample_point (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - G_TYPE_UINT, sample_point_ID, + G_TYPE_UINT, sample_point, G_TYPE_NONE); if (pdb) @@ -223,7 +223,7 @@ _gimp_image_delete_sample_point (gint32 image_ID, /** * gimp_image_find_next_sample_point: * @image: The image. - * @sample_point_ID: The ID of the current sample point (0 if first invocation). + * @sample_point: The ID of the current sample point (0 if first invocation). * * Find next sample point on an image. * @@ -238,18 +238,18 @@ _gimp_image_delete_sample_point (gint32 image_ID, * * Since: 2.10 **/ -gint32 +guint gimp_image_find_next_sample_point (GimpImage *image, - gint32 sample_point_ID) + guint sample_point) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 next_sample_point_ID = -1; + guint next_sample_point = 0; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - G_TYPE_UINT, sample_point_ID, + G_TYPE_UINT, sample_point, G_TYPE_NONE); if (pdb) @@ -262,11 +262,11 @@ gimp_image_find_next_sample_point (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - next_sample_point_ID = g_value_get_uint (gimp_value_array_index (return_vals, 1)); + next_sample_point = g_value_get_uint (gimp_value_array_index (return_vals, 1)); gimp_value_array_unref (return_vals); - return next_sample_point_ID; + return next_sample_point; } /** @@ -321,7 +321,7 @@ _gimp_image_find_next_sample_point (gint32 image_ID, /** * gimp_image_get_sample_point_position: * @image: The image. - * @sample_point_ID: The guide. + * @sample_point: The guide. * @position_y: (out): The sample points's position relative to top of image. * * Get position of a sample point on an image. @@ -336,7 +336,7 @@ _gimp_image_find_next_sample_point (gint32 image_ID, **/ gint gimp_image_get_sample_point_position (GimpImage *image, - gint32 sample_point_ID, + guint sample_point, gint *position_y) { GimpPDB *pdb = gimp_get_pdb (); @@ -346,7 +346,7 @@ gimp_image_get_sample_point_position (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - G_TYPE_UINT, sample_point_ID, + G_TYPE_UINT, sample_point, G_TYPE_NONE); if (pdb) diff --git a/libgimp/gimpimagesamplepoints_pdb.h b/libgimp/gimpimagesamplepoints_pdb.h index 3dd6252f5f..5700c08872 100644 --- a/libgimp/gimpimagesamplepoints_pdb.h +++ b/libgimp/gimpimagesamplepoints_pdb.h @@ -36,15 +36,15 @@ G_BEGIN_DECLS #ifndef GIMP_DEPRECATED_REPLACE_NEW_API -gint32 gimp_image_add_sample_point (GimpImage *image, +guint gimp_image_add_sample_point (GimpImage *image, gint position_x, gint position_y); gboolean gimp_image_delete_sample_point (GimpImage *image, - gint32 sample_point_ID); -gint32 gimp_image_find_next_sample_point (GimpImage *image, - gint32 sample_point_ID); + guint sample_point); +guint gimp_image_find_next_sample_point (GimpImage *image, + guint sample_point); gint gimp_image_get_sample_point_position (GimpImage *image, - gint32 sample_point_ID, + guint sample_point, gint *position_y); #else /* GIMP_DEPRECATED_REPLACE_NEW_API */ diff --git a/libgimp/gimplayer_pdb.c b/libgimp/gimplayer_pdb.c index e0cb6aa97e..658972ecd5 100644 --- a/libgimp/gimplayer_pdb.c +++ b/libgimp/gimplayer_pdb.c @@ -1118,16 +1118,16 @@ _gimp_layer_set_offsets (gint32 layer_ID, * 'ADD-ALPHA-TRANSFER-MASK' on a layer with no alpha channels, or with * 'ADD-SELECTION-MASK' when there is no selection on the image. * - * Returns: The newly created mask. + * Returns: (transfer full): The newly created mask. **/ -gint32 +GimpLayerMask * gimp_layer_create_mask (GimpLayer *layer, GimpAddMaskType mask_type) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 mask_ID = -1; + GimpLayerMask *mask = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_LAYER_ID, gimp_item_get_id (GIMP_ITEM (layer)), @@ -1144,11 +1144,11 @@ gimp_layer_create_mask (GimpLayer *layer, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - mask_ID = gimp_value_get_layer_mask_id (gimp_value_array_index (return_vals, 1)); + mask = GIMP_LAYER_MASK (gimp_item_new_by_id (gimp_value_get_layer_mask_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return mask_ID; + return mask; } /** @@ -1221,15 +1221,15 @@ _gimp_layer_create_mask (gint32 layer_ID, * This procedure returns the specified layer's mask, or -1 if none * exists. * - * Returns: The layer mask. + * Returns: (transfer full): The layer mask. **/ -gint32 +GimpLayerMask * gimp_layer_get_mask (GimpLayer *layer) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 mask_ID = -1; + GimpLayerMask *mask = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_LAYER_ID, gimp_item_get_id (GIMP_ITEM (layer)), @@ -1245,11 +1245,11 @@ gimp_layer_get_mask (GimpLayer *layer) gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - mask_ID = gimp_value_get_layer_mask_id (gimp_value_array_index (return_vals, 1)); + mask = GIMP_LAYER_MASK (gimp_item_new_by_id (gimp_value_get_layer_mask_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return mask_ID; + return mask; } /** @@ -1294,7 +1294,7 @@ _gimp_layer_get_mask (gint32 layer_ID) /** * gimp_layer_from_mask: - * @mask_ID: Mask for which to return the layer. + * @mask: Mask for which to return the layer. * * Get the specified mask's layer. * @@ -1306,7 +1306,7 @@ _gimp_layer_get_mask (gint32 layer_ID) * Since: 2.2 **/ GimpLayer * -gimp_layer_from_mask (gint32 mask_ID) +gimp_layer_from_mask (GimpLayerMask *mask) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -1314,7 +1314,7 @@ gimp_layer_from_mask (gint32 mask_ID) GimpLayer *layer = NULL; args = gimp_value_array_new_from_types (NULL, - GIMP_TYPE_LAYER_MASK_ID, mask_ID, + GIMP_TYPE_LAYER_MASK_ID, gimp_item_get_id (GIMP_ITEM (mask)), G_TYPE_NONE); if (pdb) @@ -1379,7 +1379,7 @@ _gimp_layer_from_mask (gint32 mask_ID) /** * gimp_layer_add_mask: * @layer: The layer to receive the mask. - * @mask_ID: The mask to add to the layer. + * @mask: The mask to add to the layer. * * Add a layer mask to the specified layer. * @@ -1394,8 +1394,8 @@ _gimp_layer_from_mask (gint32 mask_ID) * Returns: TRUE on success. **/ gboolean -gimp_layer_add_mask (GimpLayer *layer, - gint32 mask_ID) +gimp_layer_add_mask (GimpLayer *layer, + GimpLayerMask *mask) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -1404,7 +1404,7 @@ gimp_layer_add_mask (GimpLayer *layer, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_LAYER_ID, gimp_item_get_id (GIMP_ITEM (layer)), - GIMP_TYPE_LAYER_MASK_ID, mask_ID, + GIMP_TYPE_LAYER_MASK_ID, gimp_item_get_id (GIMP_ITEM (mask)), G_TYPE_NONE); if (pdb) diff --git a/libgimp/gimplayer_pdb.h b/libgimp/gimplayer_pdb.h index 3070256ff9..fd24228e62 100644 --- a/libgimp/gimplayer_pdb.h +++ b/libgimp/gimplayer_pdb.h @@ -66,12 +66,12 @@ gboolean gimp_layer_resize_to_image_size (GimpLayer gboolean gimp_layer_set_offsets (GimpLayer *layer, gint offx, gint offy); -gint32 gimp_layer_create_mask (GimpLayer *layer, +GimpLayerMask* gimp_layer_create_mask (GimpLayer *layer, GimpAddMaskType mask_type); -gint32 gimp_layer_get_mask (GimpLayer *layer); -GimpLayer* gimp_layer_from_mask (gint32 mask_ID); +GimpLayerMask* gimp_layer_get_mask (GimpLayer *layer); +GimpLayer* gimp_layer_from_mask (GimpLayerMask *mask); gboolean gimp_layer_add_mask (GimpLayer *layer, - gint32 mask_ID); + GimpLayerMask *mask); gboolean gimp_layer_remove_mask (GimpLayer *layer, GimpMaskApplyMode mode); gboolean gimp_layer_is_floating_sel (GimpLayer *layer); diff --git a/libgimp/gimplayermask.c b/libgimp/gimplayermask.c new file mode 100644 index 0000000000..dd04bb7476 --- /dev/null +++ b/libgimp/gimplayermask.c @@ -0,0 +1,39 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball + * + * gimplayermask.c + * Copyright (C) Jehan + * + * This library is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include "config.h" + +#include "gimp.h" + + +G_DEFINE_TYPE (GimpLayerMask, gimp_layer_mask, GIMP_TYPE_CHANNEL) + +#define parent_class gimp_layer_mask_parent_class + +static void +gimp_layer_mask_class_init (GimpLayerMaskClass *klass) +{ +} + +static void +gimp_layer_mask_init (GimpLayerMask *layer_mask) +{ +} diff --git a/libgimp/gimplayermask.h b/libgimp/gimplayermask.h new file mode 100644 index 0000000000..8796841d93 --- /dev/null +++ b/libgimp/gimplayermask.h @@ -0,0 +1,70 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball + * + * gimplayermask.h + * Copyright (C) Jehan + * + * This library is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __GIMP_LAYER_MASK_H__ +#define __GIMP_LAYER_MASK_H__ + +G_BEGIN_DECLS + +/* For information look into the C source or the html documentation */ + +#define GIMP_TYPE_LAYER_MASK (gimp_layer_mask_get_type ()) +#define GIMP_LAYER_MASK(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_LAYER_MASK, GimpLayerMask)) +#define GIMP_LAYER_MASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_LAYER_MASK, GimpLayerMaskClass)) +#define GIMP_IS_LAYER_MASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_LAYER_MASK)) +#define GIMP_IS_LAYER_MASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_LAYER_MASK)) +#define GIMP_LAYER_MASK_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_LAYER_MASK, GimpLayerMaskClass)) + + +typedef struct _GimpLayerMaskClass GimpLayerMaskClass; +typedef struct _GimpLayerMaskPrivate GimpLayerMaskPrivate; + +struct _GimpLayerMask +{ + GimpChannel parent_instance; +}; + +struct _GimpLayerMaskClass +{ + GimpChannelClass parent_class; + + /* Padding for future expansion */ + void (*_gimp_reserved1) (void); + void (*_gimp_reserved2) (void); + void (*_gimp_reserved3) (void); + void (*_gimp_reserved4) (void); + void (*_gimp_reserved5) (void); + void (*_gimp_reserved6) (void); + void (*_gimp_reserved7) (void); + void (*_gimp_reserved8) (void); + void (*_gimp_reserved9) (void); +}; + +GType gimp_layer_mask_get_type (void) G_GNUC_CONST; + + +G_END_DECLS + +#endif /* __GIMP_LAYER_MASK_H__ */ diff --git a/libgimp/gimpprogress_pdb.c b/libgimp/gimpprogress_pdb.c index dc476a785c..0ff8a45d86 100644 --- a/libgimp/gimpprogress_pdb.c +++ b/libgimp/gimpprogress_pdb.c @@ -37,7 +37,7 @@ /** * _gimp_progress_init: * @message: Message to use in the progress dialog. - * @gdisplay_ID: GimpDisplay to update progressbar in, or -1 for a separate window. + * @gdisplay: GimpDisplay to update progressbar in, or -1 for a separate window. * * Initializes the progress bar for the current plug-in. * @@ -48,7 +48,49 @@ **/ gboolean _gimp_progress_init (const gchar *message, - gint32 gdisplay_ID) + GimpDisplay *gdisplay) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + G_TYPE_STRING, message, + GIMP_TYPE_DISPLAY_ID, gimp_display_get_id (gdisplay), + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-progress-init", + args); + else + return_vals = gimp_run_procedure_array ("gimp-progress-init", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * __gimp_progress_init: (skip) + * @message: Message to use in the progress dialog. + * @gdisplay_ID: GimpDisplay to update progressbar in, or -1 for a separate window. + * + * Initializes the progress bar for the current plug-in. + * + * Initializes the progress bar for the current plug-in. It is only + * valid to call this procedure from a plug-in. + * + * Returns: TRUE on success. + **/ +gboolean +__gimp_progress_init (const gchar *message, + gint32 gdisplay_ID) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; diff --git a/libgimp/gimpprogress_pdb.h b/libgimp/gimpprogress_pdb.h index c06908f64a..2870d9c057 100644 --- a/libgimp/gimpprogress_pdb.h +++ b/libgimp/gimpprogress_pdb.h @@ -32,8 +32,6 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -G_GNUC_INTERNAL gboolean _gimp_progress_init (const gchar *message, - gint32 gdisplay_ID); G_GNUC_INTERNAL gboolean _gimp_progress_update (gdouble percentage); gboolean gimp_progress_pulse (void); gboolean gimp_progress_set_text (const gchar *message); @@ -45,10 +43,12 @@ gboolean gimp_progress_cancel (const gchar *progress_ #ifndef GIMP_DEPRECATED_REPLACE_NEW_API - +G_GNUC_INTERNAL gboolean _gimp_progress_init (const gchar *message, + GimpDisplay *gdisplay); #else /* GIMP_DEPRECATED_REPLACE_NEW_API */ +#define _gimp_progress_init __gimp_progress_init #endif /* GIMP_DEPRECATED_REPLACE_NEW_API */ @@ -57,7 +57,8 @@ gboolean gimp_progress_cancel (const gchar *progress_ * They are not marked internal as a trick to keep the old API alive for now. */ - +gboolean __gimp_progress_init (const gchar *message, + gint32 gdisplay_ID); G_END_DECLS diff --git a/libgimp/gimpselection.c b/libgimp/gimpselection.c index 58bc224366..b5c0bb4c31 100644 --- a/libgimp/gimpselection.c +++ b/libgimp/gimpselection.c @@ -22,6 +22,20 @@ #include "gimp.h" + +G_DEFINE_TYPE (GimpSelection, gimp_selection, GIMP_TYPE_CHANNEL) + +#define parent_class gimp_selection_parent_class + +static void +gimp_selection_class_init (GimpSelectionClass *klass) +{ +} + +static void +gimp_selection_init (GimpSelection *selection) +{ +} /** * gimp_selection_float: * @image: ignored diff --git a/libgimp/gimpselection.h b/libgimp/gimpselection.h index 5073b43228..6911e424ee 100644 --- a/libgimp/gimpselection.h +++ b/libgimp/gimpselection.h @@ -30,6 +30,39 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ +#define GIMP_TYPE_SELECTION (gimp_selection_get_type ()) +#define GIMP_SELECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_SELECTION, GimpSelection)) +#define GIMP_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_SELECTION, GimpSelectionClass)) +#define GIMP_IS_SELECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_SELECTION)) +#define GIMP_IS_SELECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_SELECTION)) +#define GIMP_SELECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_SELECTION, GimpSelectionClass)) + + +typedef struct _GimpSelectionClass GimpSelectionClass; + +struct _GimpSelection +{ + GimpChannel parent_instance; +}; + +struct _GimpSelectionClass +{ + GimpChannelClass parent_class; + + /* Padding for future expansion */ + void (*_gimp_reserved1) (void); + void (*_gimp_reserved2) (void); + void (*_gimp_reserved3) (void); + void (*_gimp_reserved4) (void); + void (*_gimp_reserved5) (void); + void (*_gimp_reserved6) (void); + void (*_gimp_reserved7) (void); + void (*_gimp_reserved8) (void); + void (*_gimp_reserved9) (void); +}; + +GType gimp_selection_get_type (void) G_GNUC_CONST; + #ifndef GIMP_DEPRECATED_REPLACE_NEW_API GimpLayer * gimp_selection_float (GimpImage *image, diff --git a/libgimp/gimpselection_pdb.c b/libgimp/gimpselection_pdb.c index bfdd3e315e..c85c2d9f54 100644 --- a/libgimp/gimpselection_pdb.c +++ b/libgimp/gimpselection_pdb.c @@ -1294,15 +1294,15 @@ _gimp_selection_flood (gint32 image_ID) * new channel. The new channel is automatically inserted into the * image's list of channels. * - * Returns: The new channel. + * Returns: (transfer full): The new channel. **/ -gint32 +GimpChannel * gimp_selection_save (GimpImage *image) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 channel_ID = -1; + GimpChannel *channel = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -1318,11 +1318,11 @@ gimp_selection_save (GimpImage *image) gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - channel_ID = gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)); + channel = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return channel_ID; + return channel; } /** diff --git a/libgimp/gimpselection_pdb.h b/libgimp/gimpselection_pdb.h index 62e190e295..eca4fc82f8 100644 --- a/libgimp/gimpselection_pdb.h +++ b/libgimp/gimpselection_pdb.h @@ -65,7 +65,7 @@ gboolean gimp_selection_grow (GimpImage *image, gboolean gimp_selection_shrink (GimpImage *image, gint steps); gboolean gimp_selection_flood (GimpImage *image); -gint32 gimp_selection_save (GimpImage *image); +GimpChannel* gimp_selection_save (GimpImage *image); #else /* GIMP_DEPRECATED_REPLACE_NEW_API */ diff --git a/libgimp/gimptypes.h b/libgimp/gimptypes.h index 49d827b310..03ce8dab47 100644 --- a/libgimp/gimptypes.h +++ b/libgimp/gimptypes.h @@ -41,6 +41,12 @@ typedef struct _GimpImage GimpImage; typedef struct _GimpItem GimpItem; typedef struct _GimpDrawable GimpDrawable; typedef struct _GimpLayer GimpLayer; +typedef struct _GimpChannel GimpChannel; +typedef struct _GimpLayerMask GimpLayerMask; +typedef struct _GimpSelection GimpSelection; +typedef struct _GimpVectors GimpVectors; + +typedef struct _GimpDisplay GimpDisplay; /* FIXME move somewhere else */ diff --git a/libgimp/gimpvectors.c b/libgimp/gimpvectors.c new file mode 100644 index 0000000000..034e00c0e8 --- /dev/null +++ b/libgimp/gimpvectors.c @@ -0,0 +1,39 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball + * + * gimpvectors.c + * Copyright (C) Jehan + * + * This library is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#include "config.h" + +#include "gimp.h" + + +G_DEFINE_TYPE (GimpVectors, gimp_vectors, GIMP_TYPE_ITEM) + +#define parent_class gimp_vectors_parent_class + +static void +gimp_vectors_class_init (GimpVectorsClass *klass) +{ +} + +static void +gimp_vectors_init (GimpVectors *vectors) +{ +} diff --git a/libgimp/gimpvectors.h b/libgimp/gimpvectors.h new file mode 100644 index 0000000000..bb26d5b457 --- /dev/null +++ b/libgimp/gimpvectors.h @@ -0,0 +1,70 @@ +/* LIBGIMP - The GIMP Library + * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball + * + * gimpvectors.h + * Copyright (C) Jehan + * + * This library is free software: you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library. If not, see + * . + */ + +#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION) +#error "Only can be included directly." +#endif + +#ifndef __GIMP_VECTORS_H__ +#define __GIMP_VECTORS_H__ + +G_BEGIN_DECLS + +/* For information look into the C source or the html documentation */ + +#define GIMP_TYPE_VECTORS (gimp_vectors_get_type ()) +#define GIMP_VECTORS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_VECTORS, GimpVectors)) +#define GIMP_VECTORS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_VECTORS, GimpVectorsClass)) +#define GIMP_IS_VECTORS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_VECTORS)) +#define GIMP_IS_VECTORS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_VECTORS)) +#define GIMP_VECTORS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_VECTORS, GimpVectorsClass)) + + +typedef struct _GimpVectorsClass GimpVectorsClass; +typedef struct _GimpVectorsPrivate GimpVectorsPrivate; + +struct _GimpVectors +{ + GimpItem parent_instance; +}; + +struct _GimpVectorsClass +{ + GimpItemClass parent_class; + + /* Padding for future expansion */ + void (*_gimp_reserved1) (void); + void (*_gimp_reserved2) (void); + void (*_gimp_reserved3) (void); + void (*_gimp_reserved4) (void); + void (*_gimp_reserved5) (void); + void (*_gimp_reserved6) (void); + void (*_gimp_reserved7) (void); + void (*_gimp_reserved8) (void); + void (*_gimp_reserved9) (void); +}; + +GType gimp_vectors_get_type (void) G_GNUC_CONST; + + +G_END_DECLS + +#endif /* __GIMP_VECTORS_H__ */ diff --git a/libgimp/gimpvectors_pdb.c b/libgimp/gimpvectors_pdb.c index 4589f516b6..fe380a5b86 100644 --- a/libgimp/gimpvectors_pdb.c +++ b/libgimp/gimpvectors_pdb.c @@ -44,18 +44,19 @@ * Creates a new empty vectors object. The vectors object needs to be * added to the image using gimp_image_insert_vectors(). * - * Returns: the current vector object, 0 if no vector exists in the image. + * Returns: (transfer full): + * the current vector object, 0 if no vector exists in the image. * * Since: 2.4 **/ -gint32 +GimpVectors * gimp_vectors_new (GimpImage *image, const gchar *name) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 vectors_ID = -1; + GimpVectors *vectors = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -72,11 +73,11 @@ gimp_vectors_new (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - vectors_ID = gimp_value_get_vectors_id (gimp_value_array_index (return_vals, 1)); + vectors = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return vectors_ID; + return vectors; } /** @@ -134,18 +135,18 @@ _gimp_vectors_new (gint32 image_ID, * Creates a new vectors object from a text layer. The vectors object * needs to be added to the image using gimp_image_insert_vectors(). * - * Returns: The vectors of the text layer. + * Returns: (transfer full): The vectors of the text layer. * * Since: 2.6 **/ -gint32 +GimpVectors * gimp_vectors_new_from_text_layer (GimpImage *image, GimpLayer *layer) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; GimpValueArray *return_vals; - gint32 vectors_ID = -1; + GimpVectors *vectors = NULL; args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), @@ -162,11 +163,11 @@ gimp_vectors_new_from_text_layer (GimpImage *image, gimp_value_array_unref (args); if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) - vectors_ID = gimp_value_get_vectors_id (gimp_value_array_index (return_vals, 1)); + vectors = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id (gimp_value_array_index (return_vals, 1)))); gimp_value_array_unref (return_vals); - return vectors_ID; + return vectors; } /** @@ -216,6 +217,48 @@ _gimp_vectors_new_from_text_layer (gint32 image_ID, /** * gimp_vectors_copy: + * @vectors: The vectors object to copy. + * + * Copy a vectors object. + * + * This procedure copies the specified vectors object and returns the + * copy. + * + * Returns: (transfer full): The newly copied vectors object. + * + * Since: 2.6 + **/ +GimpVectors * +gimp_vectors_copy (GimpVectors *vectors) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + GimpVectors *vectors_copy = NULL; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-copy", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-copy", + args); + gimp_value_array_unref (args); + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + vectors_copy = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id (gimp_value_array_index (return_vals, 1)))); + + gimp_value_array_unref (return_vals); + + return vectors_copy; +} + +/** + * _gimp_vectors_copy: (skip) * @vectors_ID: The vectors object to copy. * * Copy a vectors object. @@ -228,7 +271,7 @@ _gimp_vectors_new_from_text_layer (gint32 image_ID, * Since: 2.6 **/ gint32 -gimp_vectors_copy (gint32 vectors_ID) +_gimp_vectors_copy (gint32 vectors_ID) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -258,7 +301,7 @@ gimp_vectors_copy (gint32 vectors_ID) /** * gimp_vectors_get_strokes: - * @vectors_ID: The vectors object. + * @vectors: The vectors object. * @num_strokes: (out): The number of strokes returned. * * List the strokes associated with the passed path. @@ -273,8 +316,59 @@ gimp_vectors_copy (gint32 vectors_ID) * Since: 2.4 **/ gint * -gimp_vectors_get_strokes (gint32 vectors_ID, - gint *num_strokes) +gimp_vectors_get_strokes (GimpVectors *vectors, + gint *num_strokes) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gint *stroke_ids = NULL; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-get-strokes", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-get-strokes", + args); + gimp_value_array_unref (args); + + *num_strokes = 0; + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + { + *num_strokes = g_value_get_int (gimp_value_array_index (return_vals, 1)); + stroke_ids = gimp_value_dup_int32_array (gimp_value_array_index (return_vals, 2)); + } + + gimp_value_array_unref (return_vals); + + return stroke_ids; +} + +/** + * _gimp_vectors_get_strokes: (skip) + * @vectors_ID: The vectors object. + * @num_strokes: (out): The number of strokes returned. + * + * List the strokes associated with the passed path. + * + * Returns an Array with the stroke-IDs associated with the passed + * path. + * + * Returns: (array length=num_strokes): + * List of the strokes belonging to the path. + * The returned value must be freed with g_free(). + * + * Since: 2.4 + **/ +gint * +_gimp_vectors_get_strokes (gint32 vectors_ID, + gint *num_strokes) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -309,6 +403,53 @@ gimp_vectors_get_strokes (gint32 vectors_ID, /** * gimp_vectors_stroke_get_length: + * @vectors: The vectors object. + * @stroke_id: The stroke ID. + * @precision: The precision used for the approximation. + * + * Measure the length of the given stroke. + * + * Measure the length of the given stroke. + * + * Returns: The length (in pixels) of the given stroke. + * + * Since: 2.4 + **/ +gdouble +gimp_vectors_stroke_get_length (GimpVectors *vectors, + gint stroke_id, + gdouble precision) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gdouble length = 0.0; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_DOUBLE, precision, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-stroke-get-length", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-stroke-get-length", + args); + gimp_value_array_unref (args); + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + length = g_value_get_double (gimp_value_array_index (return_vals, 1)); + + gimp_value_array_unref (return_vals); + + return length; +} + +/** + * _gimp_vectors_stroke_get_length: (skip) * @vectors_ID: The vectors object. * @stroke_id: The stroke ID. * @precision: The precision used for the approximation. @@ -322,9 +463,9 @@ gimp_vectors_get_strokes (gint32 vectors_ID, * Since: 2.4 **/ gdouble -gimp_vectors_stroke_get_length (gint32 vectors_ID, - gint stroke_id, - gdouble precision) +_gimp_vectors_stroke_get_length (gint32 vectors_ID, + gint stroke_id, + gdouble precision) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -356,6 +497,81 @@ gimp_vectors_stroke_get_length (gint32 vectors_ID, /** * gimp_vectors_stroke_get_point_at_dist: + * @vectors: The vectors object. + * @stroke_id: The stroke ID. + * @dist: The given distance. + * @precision: The precision used for the approximation. + * @x_point: (out): The x position of the point. + * @y_point: (out): The y position of the point. + * @slope: (out): The slope (dy / dx) at the specified point. + * @valid: (out): Indicator for the validity of the returned data. + * + * Get point at a specified distance along the stroke. + * + * This will return the x,y position of a point at a given distance + * along the stroke. The distance will be obtained by first digitizing + * the curve internally and then walking along the curve. For a closed + * stroke the start of the path is the first point on the path that was + * created. This might not be obvious. If the stroke is not long + * enough, a \"valid\" flag will be FALSE. + * + * Returns: TRUE on success. + * + * Since: 2.4 + **/ +gboolean +gimp_vectors_stroke_get_point_at_dist (GimpVectors *vectors, + gint stroke_id, + gdouble dist, + gdouble precision, + gdouble *x_point, + gdouble *y_point, + gdouble *slope, + gboolean *valid) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_DOUBLE, dist, + G_TYPE_DOUBLE, precision, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-stroke-get-point-at-dist", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-stroke-get-point-at-dist", + args); + gimp_value_array_unref (args); + + *x_point = 0.0; + *y_point = 0.0; + *slope = 0.0; + *valid = FALSE; + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + if (success) + { + *x_point = g_value_get_double (gimp_value_array_index (return_vals, 1)); + *y_point = g_value_get_double (gimp_value_array_index (return_vals, 2)); + *slope = g_value_get_double (gimp_value_array_index (return_vals, 3)); + *valid = g_value_get_boolean (gimp_value_array_index (return_vals, 4)); + } + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_vectors_stroke_get_point_at_dist: (skip) * @vectors_ID: The vectors object. * @stroke_id: The stroke ID. * @dist: The given distance. @@ -379,14 +595,14 @@ gimp_vectors_stroke_get_length (gint32 vectors_ID, * Since: 2.4 **/ gboolean -gimp_vectors_stroke_get_point_at_dist (gint32 vectors_ID, - gint stroke_id, - gdouble dist, - gdouble precision, - gdouble *x_point, - gdouble *y_point, - gdouble *slope, - gboolean *valid) +_gimp_vectors_stroke_get_point_at_dist (gint32 vectors_ID, + gint stroke_id, + gdouble dist, + gdouble precision, + gdouble *x_point, + gdouble *y_point, + gdouble *slope, + gboolean *valid) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -431,6 +647,49 @@ gimp_vectors_stroke_get_point_at_dist (gint32 vectors_ID, /** * gimp_vectors_remove_stroke: + * @vectors: The vectors object. + * @stroke_id: The stroke ID. + * + * remove the stroke from a vectors object. + * + * Remove the stroke from a vectors object. + * + * Returns: TRUE on success. + * + * Since: 2.4 + **/ +gboolean +gimp_vectors_remove_stroke (GimpVectors *vectors, + gint stroke_id) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-remove-stroke", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-remove-stroke", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_vectors_remove_stroke: (skip) * @vectors_ID: The vectors object. * @stroke_id: The stroke ID. * @@ -443,8 +702,8 @@ gimp_vectors_stroke_get_point_at_dist (gint32 vectors_ID, * Since: 2.4 **/ gboolean -gimp_vectors_remove_stroke (gint32 vectors_ID, - gint stroke_id) +_gimp_vectors_remove_stroke (gint32 vectors_ID, + gint stroke_id) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -474,6 +733,49 @@ gimp_vectors_remove_stroke (gint32 vectors_ID, /** * gimp_vectors_stroke_close: + * @vectors: The vectors object. + * @stroke_id: The stroke ID. + * + * closes the specified stroke. + * + * Closes the specified stroke. + * + * Returns: TRUE on success. + * + * Since: 2.4 + **/ +gboolean +gimp_vectors_stroke_close (GimpVectors *vectors, + gint stroke_id) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-stroke-close", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-stroke-close", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_vectors_stroke_close: (skip) * @vectors_ID: The vectors object. * @stroke_id: The stroke ID. * @@ -486,8 +788,8 @@ gimp_vectors_remove_stroke (gint32 vectors_ID, * Since: 2.4 **/ gboolean -gimp_vectors_stroke_close (gint32 vectors_ID, - gint stroke_id) +_gimp_vectors_stroke_close (gint32 vectors_ID, + gint stroke_id) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -517,6 +819,55 @@ gimp_vectors_stroke_close (gint32 vectors_ID, /** * gimp_vectors_stroke_translate: + * @vectors: The vectors object. + * @stroke_id: The stroke ID. + * @off_x: Offset in x direction. + * @off_y: Offset in y direction. + * + * translate the given stroke. + * + * Translate the given stroke. + * + * Returns: TRUE on success. + * + * Since: 2.4 + **/ +gboolean +gimp_vectors_stroke_translate (GimpVectors *vectors, + gint stroke_id, + gint off_x, + gint off_y) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_INT, off_x, + G_TYPE_INT, off_y, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-stroke-translate", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-stroke-translate", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_vectors_stroke_translate: (skip) * @vectors_ID: The vectors object. * @stroke_id: The stroke ID. * @off_x: Offset in x direction. @@ -531,10 +882,10 @@ gimp_vectors_stroke_close (gint32 vectors_ID, * Since: 2.4 **/ gboolean -gimp_vectors_stroke_translate (gint32 vectors_ID, - gint stroke_id, - gint off_x, - gint off_y) +_gimp_vectors_stroke_translate (gint32 vectors_ID, + gint stroke_id, + gint off_x, + gint off_y) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -566,6 +917,55 @@ gimp_vectors_stroke_translate (gint32 vectors_ID, /** * gimp_vectors_stroke_scale: + * @vectors: The vectors object. + * @stroke_id: The stroke ID. + * @scale_x: Scale factor in x direction. + * @scale_y: Scale factor in y direction. + * + * scales the given stroke. + * + * Scale the given stroke. + * + * Returns: TRUE on success. + * + * Since: 2.4 + **/ +gboolean +gimp_vectors_stroke_scale (GimpVectors *vectors, + gint stroke_id, + gdouble scale_x, + gdouble scale_y) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_DOUBLE, scale_x, + G_TYPE_DOUBLE, scale_y, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-stroke-scale", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-stroke-scale", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_vectors_stroke_scale: (skip) * @vectors_ID: The vectors object. * @stroke_id: The stroke ID. * @scale_x: Scale factor in x direction. @@ -580,10 +980,10 @@ gimp_vectors_stroke_translate (gint32 vectors_ID, * Since: 2.4 **/ gboolean -gimp_vectors_stroke_scale (gint32 vectors_ID, - gint stroke_id, - gdouble scale_x, - gdouble scale_y) +_gimp_vectors_stroke_scale (gint32 vectors_ID, + gint stroke_id, + gdouble scale_x, + gdouble scale_y) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -615,6 +1015,58 @@ gimp_vectors_stroke_scale (gint32 vectors_ID, /** * gimp_vectors_stroke_rotate: + * @vectors: The vectors object. + * @stroke_id: The stroke ID. + * @center_x: X coordinate of the rotation center. + * @center_y: Y coordinate of the rotation center. + * @angle: angle to rotate about. + * + * rotates the given stroke. + * + * Rotates the given stroke around given center by angle (in degrees). + * + * Returns: TRUE on success. + * + * Since: 2.4 + **/ +gboolean +gimp_vectors_stroke_rotate (GimpVectors *vectors, + gint stroke_id, + gdouble center_x, + gdouble center_y, + gdouble angle) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_DOUBLE, center_x, + G_TYPE_DOUBLE, center_y, + G_TYPE_DOUBLE, angle, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-stroke-rotate", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-stroke-rotate", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_vectors_stroke_rotate: (skip) * @vectors_ID: The vectors object. * @stroke_id: The stroke ID. * @center_x: X coordinate of the rotation center. @@ -630,11 +1082,11 @@ gimp_vectors_stroke_scale (gint32 vectors_ID, * Since: 2.4 **/ gboolean -gimp_vectors_stroke_rotate (gint32 vectors_ID, - gint stroke_id, - gdouble center_x, - gdouble center_y, - gdouble angle) +_gimp_vectors_stroke_rotate (gint32 vectors_ID, + gint stroke_id, + gdouble center_x, + gdouble center_y, + gdouble angle) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -667,6 +1119,55 @@ gimp_vectors_stroke_rotate (gint32 vectors_ID, /** * gimp_vectors_stroke_flip: + * @vectors: The vectors object. + * @stroke_id: The stroke ID. + * @flip_type: Flip orientation, either vertical or horizontal. + * @axis: axis coordinate about which to flip, in pixels. + * + * flips the given stroke. + * + * Rotates the given stroke around given center by angle (in degrees). + * + * Returns: TRUE on success. + * + * Since: 2.4 + **/ +gboolean +gimp_vectors_stroke_flip (GimpVectors *vectors, + gint stroke_id, + GimpOrientationType flip_type, + gdouble axis) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + GIMP_TYPE_ORIENTATION_TYPE, flip_type, + G_TYPE_DOUBLE, axis, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-stroke-flip", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-stroke-flip", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_vectors_stroke_flip: (skip) * @vectors_ID: The vectors object. * @stroke_id: The stroke ID. * @flip_type: Flip orientation, either vertical or horizontal. @@ -681,10 +1182,10 @@ gimp_vectors_stroke_rotate (gint32 vectors_ID, * Since: 2.4 **/ gboolean -gimp_vectors_stroke_flip (gint32 vectors_ID, - gint stroke_id, - GimpOrientationType flip_type, - gdouble axis) +_gimp_vectors_stroke_flip (gint32 vectors_ID, + gint stroke_id, + GimpOrientationType flip_type, + gdouble axis) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -716,6 +1217,63 @@ gimp_vectors_stroke_flip (gint32 vectors_ID, /** * gimp_vectors_stroke_flip_free: + * @vectors: The vectors object. + * @stroke_id: The stroke ID. + * @x1: X coordinate of the first point of the flipping axis. + * @y1: Y coordinate of the first point of the flipping axis. + * @x2: X coordinate of the second point of the flipping axis. + * @y2: Y coordinate of the second point of the flipping axis. + * + * flips the given stroke about an arbitrary axis. + * + * Flips the given stroke about an arbitrary axis. Axis is defined by + * two coordinates in the image (in pixels), through which the flipping + * axis passes. + * + * Returns: TRUE on success. + * + * Since: 2.4 + **/ +gboolean +gimp_vectors_stroke_flip_free (GimpVectors *vectors, + gint stroke_id, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_DOUBLE, x1, + G_TYPE_DOUBLE, y1, + G_TYPE_DOUBLE, x2, + G_TYPE_DOUBLE, y2, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-stroke-flip-free", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-stroke-flip-free", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_vectors_stroke_flip_free: (skip) * @vectors_ID: The vectors object. * @stroke_id: The stroke ID. * @x1: X coordinate of the first point of the flipping axis. @@ -734,12 +1292,12 @@ gimp_vectors_stroke_flip (gint32 vectors_ID, * Since: 2.4 **/ gboolean -gimp_vectors_stroke_flip_free (gint32 vectors_ID, - gint stroke_id, - gdouble x1, - gdouble y1, - gdouble x2, - gdouble y2) +_gimp_vectors_stroke_flip_free (gint32 vectors_ID, + gint stroke_id, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -773,7 +1331,7 @@ gimp_vectors_stroke_flip_free (gint32 vectors_ID, /** * gimp_vectors_stroke_get_points: - * @vectors_ID: The vectors object. + * @vectors: The vectors object. * @stroke_id: The stroke ID. * @num_points: (out): The number of floats returned. * @controlpoints: (out) (array length=num_points) (element-type gdouble) (transfer full): List of the control points for the stroke (x0, y0, x1, y1, ...). @@ -791,11 +1349,71 @@ gimp_vectors_stroke_flip_free (gint32 vectors_ID, * Since: 2.4 **/ GimpVectorsStrokeType -gimp_vectors_stroke_get_points (gint32 vectors_ID, - gint stroke_id, - gint *num_points, - gdouble **controlpoints, - gboolean *closed) +gimp_vectors_stroke_get_points (GimpVectors *vectors, + gint stroke_id, + gint *num_points, + gdouble **controlpoints, + gboolean *closed) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + GimpVectorsStrokeType type = 0; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-stroke-get-points", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-stroke-get-points", + args); + gimp_value_array_unref (args); + + *num_points = 0; + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + { + type = g_value_get_enum (gimp_value_array_index (return_vals, 1)); + *num_points = g_value_get_int (gimp_value_array_index (return_vals, 2)); + *controlpoints = gimp_value_dup_float_array (gimp_value_array_index (return_vals, 3)); + *closed = g_value_get_boolean (gimp_value_array_index (return_vals, 4)); + } + + gimp_value_array_unref (return_vals); + + return type; +} + +/** + * _gimp_vectors_stroke_get_points: (skip) + * @vectors_ID: The vectors object. + * @stroke_id: The stroke ID. + * @num_points: (out): The number of floats returned. + * @controlpoints: (out) (array length=num_points): List of the control points for the stroke (x0, y0, x1, y1, ...). + * @closed: (out): Whether the stroke is closed or not. + * + * returns the control points of a stroke. + * + * returns the control points of a stroke. The interpretation of the + * coordinates returned depends on the type of the stroke. For Gimp 2.4 + * this is always a bezier stroke, where the coordinates are the + * control points. + * + * Returns: type of the stroke (always GIMP_VECTORS_STROKE_TYPE_BEZIER for now). + * + * Since: 2.4 + **/ +GimpVectorsStrokeType +_gimp_vectors_stroke_get_points (gint32 vectors_ID, + gint stroke_id, + gint *num_points, + gdouble **controlpoints, + gboolean *closed) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -833,6 +1451,67 @@ gimp_vectors_stroke_get_points (gint32 vectors_ID, /** * gimp_vectors_stroke_new_from_points: + * @vectors: The vectors object. + * @type: type of the stroke (always GIMP_VECTORS_STROKE_TYPE_BEZIER for now). + * @num_points: The number of elements in the array, i.e. the number of controlpoints in the stroke * 2 (x- and y-coordinate). + * @controlpoints: (array length=num_points) (element-type gdouble): List of the x- and y-coordinates of the control points. + * @closed: Whether the stroke is to be closed or not. + * + * Adds a stroke of a given type to the vectors object. + * + * Adds a stroke of a given type to the vectors object. The coordinates + * of the control points can be specified. For now only strokes of the + * type GIMP_VECTORS_STROKE_TYPE_BEZIER are supported. The control + * points are specified as a pair of float values for the x- and + * y-coordinate. The Bezier stroke type needs a multiple of three + * control points. Each Bezier segment endpoint (anchor, A) has two + * additional control points (C) associated. They are specified in the + * order CACCACCAC... + * + * Returns: The stroke ID of the newly created stroke. + * + * Since: 2.4 + **/ +gint +gimp_vectors_stroke_new_from_points (GimpVectors *vectors, + GimpVectorsStrokeType type, + gint num_points, + const gdouble *controlpoints, + gboolean closed) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gint stroke_id = 0; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + GIMP_TYPE_VECTORS_STROKE_TYPE, type, + G_TYPE_INT, num_points, + GIMP_TYPE_FLOAT_ARRAY, NULL, + G_TYPE_BOOLEAN, closed, + G_TYPE_NONE); + gimp_value_set_float_array (gimp_value_array_index (args, 3), controlpoints, num_points); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-stroke-new-from-points", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-stroke-new-from-points", + args); + gimp_value_array_unref (args); + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + stroke_id = g_value_get_int (gimp_value_array_index (return_vals, 1)); + + gimp_value_array_unref (return_vals); + + return stroke_id; +} + +/** + * _gimp_vectors_stroke_new_from_points: (skip) * @vectors_ID: The vectors object. * @type: type of the stroke (always GIMP_VECTORS_STROKE_TYPE_BEZIER for now). * @num_points: The number of elements in the array, i.e. the number of controlpoints in the stroke * 2 (x- and y-coordinate). @@ -855,11 +1534,11 @@ gimp_vectors_stroke_get_points (gint32 vectors_ID, * Since: 2.4 **/ gint -gimp_vectors_stroke_new_from_points (gint32 vectors_ID, - GimpVectorsStrokeType type, - gint num_points, - const gdouble *controlpoints, - gboolean closed) +_gimp_vectors_stroke_new_from_points (gint32 vectors_ID, + GimpVectorsStrokeType type, + gint num_points, + const gdouble *controlpoints, + gboolean closed) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -894,7 +1573,7 @@ gimp_vectors_stroke_new_from_points (gint32 vectors_ID, /** * gimp_vectors_stroke_interpolate: - * @vectors_ID: The vectors object. + * @vectors: The vectors object. * @stroke_id: The stroke ID. * @precision: The precision used for the approximation. * @num_coords: (out): The number of floats returned. @@ -911,11 +1590,70 @@ gimp_vectors_stroke_new_from_points (gint32 vectors_ID, * Since: 2.4 **/ gdouble * -gimp_vectors_stroke_interpolate (gint32 vectors_ID, - gint stroke_id, - gdouble precision, - gint *num_coords, - gboolean *closed) +gimp_vectors_stroke_interpolate (GimpVectors *vectors, + gint stroke_id, + gdouble precision, + gint *num_coords, + gboolean *closed) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gdouble *coords = NULL; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_DOUBLE, precision, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-stroke-interpolate", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-stroke-interpolate", + args); + gimp_value_array_unref (args); + + *num_coords = 0; + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + { + *num_coords = g_value_get_int (gimp_value_array_index (return_vals, 1)); + coords = gimp_value_dup_float_array (gimp_value_array_index (return_vals, 2)); + *closed = g_value_get_boolean (gimp_value_array_index (return_vals, 3)); + } + + gimp_value_array_unref (return_vals); + + return coords; +} + +/** + * _gimp_vectors_stroke_interpolate: (skip) + * @vectors_ID: The vectors object. + * @stroke_id: The stroke ID. + * @precision: The precision used for the approximation. + * @num_coords: (out): The number of floats returned. + * @closed: (out): Whether the stroke is closed or not. + * + * returns polygonal approximation of the stroke. + * + * returns polygonal approximation of the stroke. + * + * Returns: (array length=num_coords): + * List of the coords along the path (x0, y0, x1, y1, ...). + * The returned value must be freed with g_free(). + * + * Since: 2.4 + **/ +gdouble * +_gimp_vectors_stroke_interpolate (gint32 vectors_ID, + gint stroke_id, + gdouble precision, + gint *num_coords, + gboolean *closed) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -953,6 +1691,53 @@ gimp_vectors_stroke_interpolate (gint32 vectors_ID, /** * gimp_vectors_bezier_stroke_new_moveto: + * @vectors: The vectors object. + * @x0: The x-coordinate of the moveto. + * @y0: The y-coordinate of the moveto. + * + * Adds a bezier stroke with a single moveto to the vectors object. + * + * Adds a bezier stroke with a single moveto to the vectors object. + * + * Returns: The resulting stroke. + * + * Since: 2.4 + **/ +gint +gimp_vectors_bezier_stroke_new_moveto (GimpVectors *vectors, + gdouble x0, + gdouble y0) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gint stroke_id = 0; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_DOUBLE, x0, + G_TYPE_DOUBLE, y0, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-bezier-stroke-new-moveto", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-bezier-stroke-new-moveto", + args); + gimp_value_array_unref (args); + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + stroke_id = g_value_get_int (gimp_value_array_index (return_vals, 1)); + + gimp_value_array_unref (return_vals); + + return stroke_id; +} + +/** + * _gimp_vectors_bezier_stroke_new_moveto: (skip) * @vectors_ID: The vectors object. * @x0: The x-coordinate of the moveto. * @y0: The y-coordinate of the moveto. @@ -966,9 +1751,9 @@ gimp_vectors_stroke_interpolate (gint32 vectors_ID, * Since: 2.4 **/ gint -gimp_vectors_bezier_stroke_new_moveto (gint32 vectors_ID, - gdouble x0, - gdouble y0) +_gimp_vectors_bezier_stroke_new_moveto (gint32 vectors_ID, + gdouble x0, + gdouble y0) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -1000,6 +1785,55 @@ gimp_vectors_bezier_stroke_new_moveto (gint32 vectors_ID, /** * gimp_vectors_bezier_stroke_lineto: + * @vectors: The vectors object. + * @stroke_id: The stroke ID. + * @x0: The x-coordinate of the lineto. + * @y0: The y-coordinate of the lineto. + * + * Extends a bezier stroke with a lineto. + * + * Extends a bezier stroke with a lineto. + * + * Returns: TRUE on success. + * + * Since: 2.4 + **/ +gboolean +gimp_vectors_bezier_stroke_lineto (GimpVectors *vectors, + gint stroke_id, + gdouble x0, + gdouble y0) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_DOUBLE, x0, + G_TYPE_DOUBLE, y0, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-bezier-stroke-lineto", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-bezier-stroke-lineto", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_vectors_bezier_stroke_lineto: (skip) * @vectors_ID: The vectors object. * @stroke_id: The stroke ID. * @x0: The x-coordinate of the lineto. @@ -1014,10 +1848,10 @@ gimp_vectors_bezier_stroke_new_moveto (gint32 vectors_ID, * Since: 2.4 **/ gboolean -gimp_vectors_bezier_stroke_lineto (gint32 vectors_ID, - gint stroke_id, - gdouble x0, - gdouble y0) +_gimp_vectors_bezier_stroke_lineto (gint32 vectors_ID, + gint stroke_id, + gdouble x0, + gdouble y0) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -1049,6 +1883,63 @@ gimp_vectors_bezier_stroke_lineto (gint32 vectors_ID, /** * gimp_vectors_bezier_stroke_conicto: + * @vectors: The vectors object. + * @stroke_id: The stroke ID. + * @x0: The x-coordinate of the control point. + * @y0: The y-coordinate of the control point. + * @x1: The x-coordinate of the end point. + * @y1: The y-coordinate of the end point. + * + * Extends a bezier stroke with a conic bezier spline. + * + * Extends a bezier stroke with a conic bezier spline. Actually a cubic + * bezier spline gets added that realizes the shape of a conic bezier + * spline. + * + * Returns: TRUE on success. + * + * Since: 2.4 + **/ +gboolean +gimp_vectors_bezier_stroke_conicto (GimpVectors *vectors, + gint stroke_id, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_DOUBLE, x0, + G_TYPE_DOUBLE, y0, + G_TYPE_DOUBLE, x1, + G_TYPE_DOUBLE, y1, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-bezier-stroke-conicto", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-bezier-stroke-conicto", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_vectors_bezier_stroke_conicto: (skip) * @vectors_ID: The vectors object. * @stroke_id: The stroke ID. * @x0: The x-coordinate of the control point. @@ -1067,12 +1958,12 @@ gimp_vectors_bezier_stroke_lineto (gint32 vectors_ID, * Since: 2.4 **/ gboolean -gimp_vectors_bezier_stroke_conicto (gint32 vectors_ID, - gint stroke_id, - gdouble x0, - gdouble y0, - gdouble x1, - gdouble y1) +_gimp_vectors_bezier_stroke_conicto (gint32 vectors_ID, + gint stroke_id, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -1106,6 +1997,67 @@ gimp_vectors_bezier_stroke_conicto (gint32 vectors_ID, /** * gimp_vectors_bezier_stroke_cubicto: + * @vectors: The vectors object. + * @stroke_id: The stroke ID. + * @x0: The x-coordinate of the first control point. + * @y0: The y-coordinate of the first control point. + * @x1: The x-coordinate of the second control point. + * @y1: The y-coordinate of the second control point. + * @x2: The x-coordinate of the end point. + * @y2: The y-coordinate of the end point. + * + * Extends a bezier stroke with a cubic bezier spline. + * + * Extends a bezier stroke with a cubic bezier spline. + * + * Returns: TRUE on success. + * + * Since: 2.4 + **/ +gboolean +gimp_vectors_bezier_stroke_cubicto (GimpVectors *vectors, + gint stroke_id, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gboolean success = TRUE; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_INT, stroke_id, + G_TYPE_DOUBLE, x0, + G_TYPE_DOUBLE, y0, + G_TYPE_DOUBLE, x1, + G_TYPE_DOUBLE, y1, + G_TYPE_DOUBLE, x2, + G_TYPE_DOUBLE, y2, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-bezier-stroke-cubicto", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-bezier-stroke-cubicto", + args); + gimp_value_array_unref (args); + + success = g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS; + + gimp_value_array_unref (return_vals); + + return success; +} + +/** + * _gimp_vectors_bezier_stroke_cubicto: (skip) * @vectors_ID: The vectors object. * @stroke_id: The stroke ID. * @x0: The x-coordinate of the first control point. @@ -1124,14 +2076,14 @@ gimp_vectors_bezier_stroke_conicto (gint32 vectors_ID, * Since: 2.4 **/ gboolean -gimp_vectors_bezier_stroke_cubicto (gint32 vectors_ID, - gint stroke_id, - gdouble x0, - gdouble y0, - gdouble x1, - gdouble y1, - gdouble x2, - gdouble y2) +_gimp_vectors_bezier_stroke_cubicto (gint32 vectors_ID, + gint stroke_id, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -1167,6 +2119,62 @@ gimp_vectors_bezier_stroke_cubicto (gint32 vectors_ID, /** * gimp_vectors_bezier_stroke_new_ellipse: + * @vectors: The vectors object. + * @x0: The x-coordinate of the center. + * @y0: The y-coordinate of the center. + * @radius_x: The radius in x direction. + * @radius_y: The radius in y direction. + * @angle: The angle the x-axis of the ellipse (radians, counterclockwise). + * + * Adds a bezier stroke describing an ellipse the vectors object. + * + * Adds a bezier stroke describing an ellipse the vectors object. + * + * Returns: The resulting stroke. + * + * Since: 2.4 + **/ +gint +gimp_vectors_bezier_stroke_new_ellipse (GimpVectors *vectors, + gdouble x0, + gdouble y0, + gdouble radius_x, + gdouble radius_y, + gdouble angle) +{ + GimpPDB *pdb = gimp_get_pdb (); + GimpValueArray *args; + GimpValueArray *return_vals; + gint stroke_id = 0; + + args = gimp_value_array_new_from_types (NULL, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), + G_TYPE_DOUBLE, x0, + G_TYPE_DOUBLE, y0, + G_TYPE_DOUBLE, radius_x, + G_TYPE_DOUBLE, radius_y, + G_TYPE_DOUBLE, angle, + G_TYPE_NONE); + + if (pdb) + return_vals = gimp_pdb_run_procedure_array (pdb, + "gimp-vectors-bezier-stroke-new-ellipse", + args); + else + return_vals = gimp_run_procedure_array ("gimp-vectors-bezier-stroke-new-ellipse", + args); + gimp_value_array_unref (args); + + if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS) + stroke_id = g_value_get_int (gimp_value_array_index (return_vals, 1)); + + gimp_value_array_unref (return_vals); + + return stroke_id; +} + +/** + * _gimp_vectors_bezier_stroke_new_ellipse: (skip) * @vectors_ID: The vectors object. * @x0: The x-coordinate of the center. * @y0: The y-coordinate of the center. @@ -1183,12 +2191,12 @@ gimp_vectors_bezier_stroke_cubicto (gint32 vectors_ID, * Since: 2.4 **/ gint -gimp_vectors_bezier_stroke_new_ellipse (gint32 vectors_ID, - gdouble x0, - gdouble y0, - gdouble radius_x, - gdouble radius_y, - gdouble angle) +_gimp_vectors_bezier_stroke_new_ellipse (gint32 vectors_ID, + gdouble x0, + gdouble y0, + gdouble radius_x, + gdouble radius_y, + gdouble angle) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -1485,7 +2493,7 @@ _gimp_vectors_import_from_string (gint32 image_ID, * gimp_vectors_export_to_file: * @image: The image. * @filename: The name of the SVG file to create. - * @vectors_ID: The vectors object to be saved, or 0 for all in the image. + * @vectors: The vectors object to be saved, or 0 for all in the image. * * save a path as an SVG file. * @@ -1501,7 +2509,7 @@ _gimp_vectors_import_from_string (gint32 image_ID, gboolean gimp_vectors_export_to_file (GimpImage *image, const gchar *filename, - gint32 vectors_ID) + GimpVectors *vectors) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -1511,7 +2519,7 @@ gimp_vectors_export_to_file (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), G_TYPE_STRING, filename, - GIMP_TYPE_VECTORS_ID, vectors_ID, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), G_TYPE_NONE); if (pdb) @@ -1582,7 +2590,7 @@ _gimp_vectors_export_to_file (gint32 image_ID, /** * gimp_vectors_export_to_string: * @image: The image. - * @vectors_ID: The vectors object to save, or 0 for all in the image. + * @vectors: The vectors object to save, or 0 for all in the image. * * Save a path as an SVG string. * @@ -1598,8 +2606,8 @@ _gimp_vectors_export_to_file (gint32 image_ID, * Since: 2.6 **/ gchar * -gimp_vectors_export_to_string (GimpImage *image, - gint32 vectors_ID) +gimp_vectors_export_to_string (GimpImage *image, + GimpVectors *vectors) { GimpPDB *pdb = gimp_get_pdb (); GimpValueArray *args; @@ -1608,7 +2616,7 @@ gimp_vectors_export_to_string (GimpImage *image, args = gimp_value_array_new_from_types (NULL, GIMP_TYPE_IMAGE_ID, gimp_image_get_id (image), - GIMP_TYPE_VECTORS_ID, vectors_ID, + GIMP_TYPE_VECTORS_ID, gimp_item_get_id (GIMP_ITEM (vectors)), G_TYPE_NONE); if (pdb) diff --git a/libgimp/gimpvectors_pdb.h b/libgimp/gimpvectors_pdb.h index e12c21c795..932553f4fd 100644 --- a/libgimp/gimpvectors_pdb.h +++ b/libgimp/gimpvectors_pdb.h @@ -32,13 +32,21 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gint32 gimp_vectors_copy (gint32 vectors_ID); -gint* gimp_vectors_get_strokes (gint32 vectors_ID, + + +#ifndef GIMP_DEPRECATED_REPLACE_NEW_API + +GimpVectors* gimp_vectors_new (GimpImage *image, + const gchar *name); +GimpVectors* gimp_vectors_new_from_text_layer (GimpImage *image, + GimpLayer *layer); +GimpVectors* gimp_vectors_copy (GimpVectors *vectors); +gint* gimp_vectors_get_strokes (GimpVectors *vectors, gint *num_strokes); -gdouble gimp_vectors_stroke_get_length (gint32 vectors_ID, +gdouble gimp_vectors_stroke_get_length (GimpVectors *vectors, gint stroke_id, gdouble precision); -gboolean gimp_vectors_stroke_get_point_at_dist (gint32 vectors_ID, +gboolean gimp_vectors_stroke_get_point_at_dist (GimpVectors *vectors, gint stroke_id, gdouble dist, gdouble precision, @@ -46,62 +54,62 @@ gboolean gimp_vectors_stroke_get_point_at_dist (gint32 gdouble *y_point, gdouble *slope, gboolean *valid); -gboolean gimp_vectors_remove_stroke (gint32 vectors_ID, +gboolean gimp_vectors_remove_stroke (GimpVectors *vectors, gint stroke_id); -gboolean gimp_vectors_stroke_close (gint32 vectors_ID, +gboolean gimp_vectors_stroke_close (GimpVectors *vectors, gint stroke_id); -gboolean gimp_vectors_stroke_translate (gint32 vectors_ID, +gboolean gimp_vectors_stroke_translate (GimpVectors *vectors, gint stroke_id, gint off_x, gint off_y); -gboolean gimp_vectors_stroke_scale (gint32 vectors_ID, +gboolean gimp_vectors_stroke_scale (GimpVectors *vectors, gint stroke_id, gdouble scale_x, gdouble scale_y); -gboolean gimp_vectors_stroke_rotate (gint32 vectors_ID, +gboolean gimp_vectors_stroke_rotate (GimpVectors *vectors, gint stroke_id, gdouble center_x, gdouble center_y, gdouble angle); -gboolean gimp_vectors_stroke_flip (gint32 vectors_ID, +gboolean gimp_vectors_stroke_flip (GimpVectors *vectors, gint stroke_id, GimpOrientationType flip_type, gdouble axis); -gboolean gimp_vectors_stroke_flip_free (gint32 vectors_ID, +gboolean gimp_vectors_stroke_flip_free (GimpVectors *vectors, gint stroke_id, gdouble x1, gdouble y1, gdouble x2, gdouble y2); -GimpVectorsStrokeType gimp_vectors_stroke_get_points (gint32 vectors_ID, +GimpVectorsStrokeType gimp_vectors_stroke_get_points (GimpVectors *vectors, gint stroke_id, gint *num_points, gdouble **controlpoints, gboolean *closed); -gint gimp_vectors_stroke_new_from_points (gint32 vectors_ID, +gint gimp_vectors_stroke_new_from_points (GimpVectors *vectors, GimpVectorsStrokeType type, gint num_points, const gdouble *controlpoints, gboolean closed); -gdouble* gimp_vectors_stroke_interpolate (gint32 vectors_ID, +gdouble* gimp_vectors_stroke_interpolate (GimpVectors *vectors, gint stroke_id, gdouble precision, gint *num_coords, gboolean *closed); -gint gimp_vectors_bezier_stroke_new_moveto (gint32 vectors_ID, +gint gimp_vectors_bezier_stroke_new_moveto (GimpVectors *vectors, gdouble x0, gdouble y0); -gboolean gimp_vectors_bezier_stroke_lineto (gint32 vectors_ID, +gboolean gimp_vectors_bezier_stroke_lineto (GimpVectors *vectors, gint stroke_id, gdouble x0, gdouble y0); -gboolean gimp_vectors_bezier_stroke_conicto (gint32 vectors_ID, +gboolean gimp_vectors_bezier_stroke_conicto (GimpVectors *vectors, gint stroke_id, gdouble x0, gdouble y0, gdouble x1, gdouble y1); -gboolean gimp_vectors_bezier_stroke_cubicto (gint32 vectors_ID, +gboolean gimp_vectors_bezier_stroke_cubicto (GimpVectors *vectors, gint stroke_id, gdouble x0, gdouble y0, @@ -109,42 +117,54 @@ gboolean gimp_vectors_bezier_stroke_cubicto (gint32 gdouble y1, gdouble x2, gdouble y2); -gint gimp_vectors_bezier_stroke_new_ellipse (gint32 vectors_ID, +gint gimp_vectors_bezier_stroke_new_ellipse (GimpVectors *vectors, gdouble x0, gdouble y0, gdouble radius_x, gdouble radius_y, gdouble angle); - -#ifndef GIMP_DEPRECATED_REPLACE_NEW_API - -gint32 gimp_vectors_new (GimpImage *image, - const gchar *name); -gint32 gimp_vectors_new_from_text_layer (GimpImage *image, - GimpLayer *layer); -gboolean gimp_vectors_import_from_file (GimpImage *image, - const gchar *filename, - gboolean merge, - gboolean scale, - gint *num_vectors, - gint **vectors_ids); -gboolean gimp_vectors_import_from_string (GimpImage *image, - const gchar *string, - gint length, - gboolean merge, - gboolean scale, - gint *num_vectors, - gint **vectors_ids); -gboolean gimp_vectors_export_to_file (GimpImage *image, - const gchar *filename, - gint32 vectors_ID); -gchar* gimp_vectors_export_to_string (GimpImage *image, - gint32 vectors_ID); +gboolean gimp_vectors_import_from_file (GimpImage *image, + const gchar *filename, + gboolean merge, + gboolean scale, + gint *num_vectors, + gint **vectors_ids); +gboolean gimp_vectors_import_from_string (GimpImage *image, + const gchar *string, + gint length, + gboolean merge, + gboolean scale, + gint *num_vectors, + gint **vectors_ids); +gboolean gimp_vectors_export_to_file (GimpImage *image, + const gchar *filename, + GimpVectors *vectors); +gchar* gimp_vectors_export_to_string (GimpImage *image, + GimpVectors *vectors); #else /* GIMP_DEPRECATED_REPLACE_NEW_API */ #define gimp_vectors_new _gimp_vectors_new #define gimp_vectors_new_from_text_layer _gimp_vectors_new_from_text_layer +#define gimp_vectors_copy _gimp_vectors_copy +#define gimp_vectors_get_strokes _gimp_vectors_get_strokes +#define gimp_vectors_stroke_get_length _gimp_vectors_stroke_get_length +#define gimp_vectors_stroke_get_point_at_dist _gimp_vectors_stroke_get_point_at_dist +#define gimp_vectors_remove_stroke _gimp_vectors_remove_stroke +#define gimp_vectors_stroke_close _gimp_vectors_stroke_close +#define gimp_vectors_stroke_translate _gimp_vectors_stroke_translate +#define gimp_vectors_stroke_scale _gimp_vectors_stroke_scale +#define gimp_vectors_stroke_rotate _gimp_vectors_stroke_rotate +#define gimp_vectors_stroke_flip _gimp_vectors_stroke_flip +#define gimp_vectors_stroke_flip_free _gimp_vectors_stroke_flip_free +#define gimp_vectors_stroke_get_points _gimp_vectors_stroke_get_points +#define gimp_vectors_stroke_new_from_points _gimp_vectors_stroke_new_from_points +#define gimp_vectors_stroke_interpolate _gimp_vectors_stroke_interpolate +#define gimp_vectors_bezier_stroke_new_moveto _gimp_vectors_bezier_stroke_new_moveto +#define gimp_vectors_bezier_stroke_lineto _gimp_vectors_bezier_stroke_lineto +#define gimp_vectors_bezier_stroke_conicto _gimp_vectors_bezier_stroke_conicto +#define gimp_vectors_bezier_stroke_cubicto _gimp_vectors_bezier_stroke_cubicto +#define gimp_vectors_bezier_stroke_new_ellipse _gimp_vectors_bezier_stroke_new_ellipse #define gimp_vectors_import_from_file _gimp_vectors_import_from_file #define gimp_vectors_import_from_string _gimp_vectors_import_from_string #define gimp_vectors_export_to_file _gimp_vectors_export_to_file @@ -157,28 +177,111 @@ gchar* gimp_vectors_export_to_string (GimpImage *image, * They are not marked internal as a trick to keep the old API alive for now. */ -gint32 _gimp_vectors_new (gint32 image_ID, - const gchar *name); -gint32 _gimp_vectors_new_from_text_layer (gint32 image_ID, - gint32 layer_ID); -gboolean _gimp_vectors_import_from_file (gint32 image_ID, - const gchar *filename, - gboolean merge, - gboolean scale, - gint *num_vectors, - gint **vectors_ids); -gboolean _gimp_vectors_import_from_string (gint32 image_ID, - const gchar *string, - gint length, - gboolean merge, - gboolean scale, - gint *num_vectors, - gint **vectors_ids); -gboolean _gimp_vectors_export_to_file (gint32 image_ID, - const gchar *filename, - gint32 vectors_ID); -gchar* _gimp_vectors_export_to_string (gint32 image_ID, - gint32 vectors_ID); +gint32 _gimp_vectors_new (gint32 image_ID, + const gchar *name); +gint32 _gimp_vectors_new_from_text_layer (gint32 image_ID, + gint32 layer_ID); +gint32 _gimp_vectors_copy (gint32 vectors_ID); +gint* _gimp_vectors_get_strokes (gint32 vectors_ID, + gint *num_strokes); +gdouble _gimp_vectors_stroke_get_length (gint32 vectors_ID, + gint stroke_id, + gdouble precision); +gboolean _gimp_vectors_stroke_get_point_at_dist (gint32 vectors_ID, + gint stroke_id, + gdouble dist, + gdouble precision, + gdouble *x_point, + gdouble *y_point, + gdouble *slope, + gboolean *valid); +gboolean _gimp_vectors_remove_stroke (gint32 vectors_ID, + gint stroke_id); +gboolean _gimp_vectors_stroke_close (gint32 vectors_ID, + gint stroke_id); +gboolean _gimp_vectors_stroke_translate (gint32 vectors_ID, + gint stroke_id, + gint off_x, + gint off_y); +gboolean _gimp_vectors_stroke_scale (gint32 vectors_ID, + gint stroke_id, + gdouble scale_x, + gdouble scale_y); +gboolean _gimp_vectors_stroke_rotate (gint32 vectors_ID, + gint stroke_id, + gdouble center_x, + gdouble center_y, + gdouble angle); +gboolean _gimp_vectors_stroke_flip (gint32 vectors_ID, + gint stroke_id, + GimpOrientationType flip_type, + gdouble axis); +gboolean _gimp_vectors_stroke_flip_free (gint32 vectors_ID, + gint stroke_id, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2); +GimpVectorsStrokeType _gimp_vectors_stroke_get_points (gint32 vectors_ID, + gint stroke_id, + gint *num_points, + gdouble **controlpoints, + gboolean *closed); +gint _gimp_vectors_stroke_new_from_points (gint32 vectors_ID, + GimpVectorsStrokeType type, + gint num_points, + const gdouble *controlpoints, + gboolean closed); +gdouble* _gimp_vectors_stroke_interpolate (gint32 vectors_ID, + gint stroke_id, + gdouble precision, + gint *num_coords, + gboolean *closed); +gint _gimp_vectors_bezier_stroke_new_moveto (gint32 vectors_ID, + gdouble x0, + gdouble y0); +gboolean _gimp_vectors_bezier_stroke_lineto (gint32 vectors_ID, + gint stroke_id, + gdouble x0, + gdouble y0); +gboolean _gimp_vectors_bezier_stroke_conicto (gint32 vectors_ID, + gint stroke_id, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1); +gboolean _gimp_vectors_bezier_stroke_cubicto (gint32 vectors_ID, + gint stroke_id, + gdouble x0, + gdouble y0, + gdouble x1, + gdouble y1, + gdouble x2, + gdouble y2); +gint _gimp_vectors_bezier_stroke_new_ellipse (gint32 vectors_ID, + gdouble x0, + gdouble y0, + gdouble radius_x, + gdouble radius_y, + gdouble angle); +gboolean _gimp_vectors_import_from_file (gint32 image_ID, + const gchar *filename, + gboolean merge, + gboolean scale, + gint *num_vectors, + gint **vectors_ids); +gboolean _gimp_vectors_import_from_string (gint32 image_ID, + const gchar *string, + gint length, + gboolean merge, + gboolean scale, + gint *num_vectors, + gint **vectors_ids); +gboolean _gimp_vectors_export_to_file (gint32 image_ID, + const gchar *filename, + gint32 vectors_ID); +gchar* _gimp_vectors_export_to_string (gint32 image_ID, + gint32 vectors_ID); G_END_DECLS diff --git a/pdb/app.pl b/pdb/app.pl index 870b5bbf3e..dc55dd7070 100644 --- a/pdb/app.pl +++ b/pdb/app.pl @@ -82,10 +82,20 @@ sub declare_args { unless (exists $_->{no_declare} || exists $_->{dead}) { if ($outargs) { - $result .= " $arg->{type}$_->{name} = $arg->{init_value}"; + if (exists $arg->{app_type}) { + $result .= " $arg->{app_type}$_->{name} = $arg->{init_value}"; + } + else { + $result .= " $arg->{type}$_->{name} = $arg->{init_value}"; + } } else { - $result .= " $arg->{const_type}$_->{name}"; + if (exists $arg->{app_const_type}) { + $result .= " $arg->{app_const_type}$_->{name}"; + } + else { + $result .= " $arg->{const_type}$_->{name}"; + } } $result .= ";\n"; diff --git a/pdb/lib.pl b/pdb/lib.pl index 9ff9460859..706635d14d 100644 --- a/pdb/lib.pl +++ b/pdb/lib.pl @@ -45,15 +45,6 @@ sub desc_wrap { return $wrapped; } -sub is_id_arg { - my ($arg) = @_; - - return ($arg->{name} eq 'IMAGE' || - $arg->{name} eq 'ITEM' || - $arg->{name} eq 'DRAWABLE' || - $arg->{name} eq 'LAYER'); -} - sub generate_fun { my ($proc, $out, $api_deprecated, $has_id_arg) = @_; my @inargs = @{$proc->{inargs}} if (defined $proc->{inargs}); @@ -67,11 +58,7 @@ sub generate_fun { my $argtype = $arg_types{$type}; my $rettype = ''; - if ($api_deprecated && is_id_arg($argtype)) { - return 'gint32 '; - } - - if (exists $argtype->{id}) { + if ($api_deprecated && exists $argtype->{id}) { return 'gint32 '; } @@ -220,7 +207,7 @@ sub generate_fun { my $desc = exists $_->{desc} ? $_->{desc} : ""; my $var_len; my $value; - my $is_id = ($arg->{id} || ($api_deprecated && is_id_arg($arg))); + my $is_id = $arg->{id} && $api_deprecated; $var .= '_ID' if $is_id; @@ -318,7 +305,7 @@ sub generate_fun { my ($type) = &arg_parse($_->{type}); my $arg = $arg_types{$type}; my $var; - my $is_id = ($arg->{id} || ($api_deprecated && is_id_arg($arg))); + my $is_id = $arg->{id} && $api_deprecated; $return_marshal = "" unless $once++; @@ -399,7 +386,7 @@ CODE my ($type) = &arg_parse($_->{type}); my $desc = exists $_->{desc} ? $_->{desc} : ""; my $arg = $arg_types{$type}; - my $is_id = ($arg->{id} || ($api_deprecated && is_id_arg($arg))); + my $is_id = $arg->{id} && $api_deprecated; my $var; # The return value variable @@ -733,7 +720,7 @@ sub generate { foreach (@outargs) { my ($type, @typeinfo) = &arg_parse($_->{type}); my $arg = $arg_types{$type}; - if (is_id_arg($arg)) { + if (exists $arg->{id}) { $has_id_arg = 1; last; } @@ -742,7 +729,7 @@ sub generate { foreach (@inargs) { my ($type, @typeinfo) = &arg_parse($_->{type}); my $arg = $arg_types{$type}; - if (is_id_arg($arg)) { + if (exists $arg->{id}) { $has_id_arg = 1; last; } diff --git a/pdb/pdb.pl b/pdb/pdb.pl index 0775c55e48..41e52a8ebe 100644 --- a/pdb/pdb.pl +++ b/pdb/pdb.pl @@ -150,19 +150,25 @@ package Gimp::CodeGen::pdb; display => { name => 'DISPLAY', gtype => 'GIMP_TYPE_DISPLAY_ID', - type => 'GimpObject *', - const_type => 'GimpObject *', + type => 'GimpDisplay *', + const_type => 'GimpDisplay *', + app_type => 'GimpObject *', + app_const_type => 'GimpObject *', id => 1, init_value => 'NULL', + out_annotate => '(transfer full)', get_value_func => '$var = gimp_value_get_display ($value, gimp)', - dup_value_func => '$var = gimp_value_get_display_id ($value)', - set_value_func => 'gimp_value_set_display_id ($value, $var)', - take_value_func => 'gimp_value_set_display ($value, $var)' }, + dup_value_func => '$var = gimp_display_new_by_id (gimp_value_get_display_id ($value))', + dup_value_func_d=> '$var = gimp_value_get_display_id ($value)', + set_value_func => 'gimp_value_set_display_id ($value, gimp_display_get_id ($var))', + take_value_func => 'gimp_value_set_display ($value, $var)' , + convert_func => 'gimp_display_get_id ($var)'}, image => { name => 'IMAGE', gtype => 'GIMP_TYPE_IMAGE_ID', type => 'GimpImage *', const_type => 'GimpImage *', + id => 1, init_value => 'NULL', out_annotate => '(transfer full)', get_value_func => '$var = gimp_value_get_image ($value, gimp)', @@ -177,6 +183,7 @@ package Gimp::CodeGen::pdb; gtype => 'GIMP_TYPE_ITEM_ID', type => 'GimpItem *', const_type => 'GimpItem *', + id => 1, init_value => 'NULL', out_annotate => '(transfer full)', get_value_func => '$var = gimp_value_get_item ($value, gimp)', @@ -191,6 +198,7 @@ package Gimp::CodeGen::pdb; gtype => 'GIMP_TYPE_LAYER_ID', type => 'GimpLayer *', const_type => 'GimpLayer *', + id => 1, init_value => 'NULL', out_annotate => '(transfer full)', get_value_func => '$var = gimp_value_get_layer ($value, gimp)', @@ -207,16 +215,20 @@ package Gimp::CodeGen::pdb; const_type => 'GimpChannel *', id => 1, init_value => 'NULL', + out_annotate => '(transfer full)', get_value_func => '$var = gimp_value_get_channel ($value, gimp)', - dup_value_func => '$var = gimp_value_get_channel_id ($value)', + dup_value_func => '$var = GIMP_CHANNEL (gimp_item_new_by_id (gimp_value_get_channel_id ($value)))', + dup_value_func_d=> '$var = gimp_value_get_channel_id ($value)', set_value_func => 'gimp_value_set_channel_id ($value, $var)', take_value_func => 'gimp_value_set_channel ($value, $var)', + convert_func => 'gimp_item_get_id (GIMP_ITEM ($var))', headers => [ qw("core/gimpchannel.h") ] }, drawable => { name => 'DRAWABLE', gtype => 'GIMP_TYPE_DRAWABLE_ID', type => 'GimpDrawable *', const_type => 'GimpDrawable *', + id => 1, init_value => 'NULL', out_annotate => '(transfer full)', get_value_func => '$var = gimp_value_get_drawable ($value, gimp)', @@ -233,10 +245,13 @@ package Gimp::CodeGen::pdb; const_type => 'GimpSelection *', id => 1, init_value => 'NULL', + out_annotate => '(transfer full)', get_value_func => '$var = gimp_value_get_selection ($value, gimp)', - dup_value_func => '$var = gimp_value_get_selection_id ($value)', + dup_value_func => '$var = GIMP_SELECTION (gimp_item_new_by_id (gimp_value_get_selection_id ($value)))', + dup_value_func_d=> '$var = gimp_value_get_selection_id ($value)', set_value_func => 'gimp_value_set_selection_id ($value, $var)', take_value_func => 'gimp_value_set_selection ($value, $var)', + convert_func => 'gimp_item_get_id (GIMP_ITEM ($var))', headers => [ qw("core/gimpselection.h") ] }, layer_mask => { name => 'CHANNEL', @@ -245,10 +260,13 @@ package Gimp::CodeGen::pdb; const_type => 'GimpLayerMask *', id => 1, init_value => 'NULL', + out_annotate => '(transfer full)', get_value_func => '$var = gimp_value_get_layer_mask ($value, gimp)', - dup_value_func => '$var = gimp_value_get_layer_mask_id ($value)', + dup_value_func => '$var = GIMP_LAYER_MASK (gimp_item_new_by_id (gimp_value_get_layer_mask_id ($value)))', + dup_value_func_d=> '$var = gimp_value_get_layer_mask_id ($value)', set_value_func => 'gimp_value_set_layer_mask_id ($value, $var)', take_value_func => 'gimp_value_set_layer_mask ($value, $var)', + convert_func => 'gimp_item_get_id (GIMP_ITEM ($var))', headers => [ qw("core/gimplayermask.h") ] }, vectors => { name => 'VECTORS', @@ -257,10 +275,13 @@ package Gimp::CodeGen::pdb; const_type => 'GimpVectors *', id => 1, init_value => 'NULL', + out_annotate => '(transfer full)', get_value_func => '$var = gimp_value_get_vectors ($value, gimp)', - dup_value_func => '$var = gimp_value_get_vectors_id ($value)', + dup_value_func => '$var = GIMP_VECTORS (gimp_item_new_by_id (gimp_value_get_vectors_id ($value)))', + dup_value_func_d=> '$var = gimp_value_get_vectors_id ($value)', set_value_func => 'gimp_value_set_vectors_id ($value, $var)', take_value_func => 'gimp_value_set_vectors ($value, $var)', + convert_func => 'gimp_item_get_id (GIMP_ITEM ($var))', headers => [ qw("vectors/gimpvectors.h") ] }, parasite => { name => 'PARASITE',