Commit 17a40b04 authored by Jehan's avatar Jehan

libgimp: generate functions both for old and new GimpImage APIs.

This way, it would still be possible to use the old API. WIP.
parent 688c3230
......@@ -94,6 +94,66 @@ _gimp_channel_new (GimpImage *image,
return channel_ID;
}
/**
* __gimp_channel_new: (skip)
* @image_ID: The image to which to add the channel.
* @width: The channel width.
* @height: The channel height.
* @name: The channel name.
* @opacity: The channel opacity.
* @color: The channel compositing color.
*
* Create a new channel.
*
* This procedure creates a new channel with the specified width,
* height, name, opacity and color.
* The new channel still needs to be added to the image, as this is not
* automatic. Add the new channel with gimp_image_insert_channel().
* Other attributes, such as channel visibility, should be set with
* explicit procedure calls.
* The channel's contents are undefined initially.
*
* Returns: The newly created channel.
**/
gint32
__gimp_channel_new (gint32 image_ID,
gint width,
gint height,
const gchar *name,
gdouble opacity,
const GimpRGB *color)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gint32 channel_ID = -1;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, image_ID,
G_TYPE_INT, width,
G_TYPE_INT, height,
G_TYPE_STRING, name,
G_TYPE_DOUBLE, opacity,
GIMP_TYPE_RGB, color,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-channel-new",
args);
else
return_vals = gimp_run_procedure_array ("gimp-channel-new",
args);
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));
gimp_value_array_unref (return_vals);
return channel_ID;
}
/**
* gimp_channel_new_from_component:
* @image: The image to which to add the channel.
......@@ -145,6 +205,57 @@ gimp_channel_new_from_component (GimpImage *image,
return channel_ID;
}
/**
* _gimp_channel_new_from_component: (skip)
* @image_ID: The image to which to add the channel.
* @component: The image component.
* @name: The channel name.
*
* Create a new channel from a color component
*
* This procedure creates a new channel from a color component.
* The new channel still needs to be added to the image, as this is not
* automatic. Add the new channel with gimp_image_insert_channel().
* Other attributes, such as channel visibility, should be set with
* explicit procedure calls.
*
* Returns: The newly created channel.
*
* Since: 2.4
**/
gint32
_gimp_channel_new_from_component (gint32 image_ID,
GimpChannelType component,
const gchar *name)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gint32 channel_ID = -1;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, image_ID,
GIMP_TYPE_CHANNEL_TYPE, component,
G_TYPE_STRING, name,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-channel-new-from-component",
args);
else
return_vals = gimp_run_procedure_array ("gimp-channel-new-from-component",
args);
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));
gimp_value_array_unref (return_vals);
return channel_ID;
}
/**
* gimp_channel_copy:
* @channel_ID: The channel to copy.
......
......@@ -32,31 +32,42 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
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);
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_GNUC_INTERNAL gint32 _gimp_channel_new (GimpImage *image,
gint width,
gint height,
const gchar *name,
gdouble opacity,
const GimpRGB *color);
GIMP_DEPRECATED_FOR(_gimp_channel_new)
G_GNUC_INTERNAL 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 (GimpImage *image,
GimpChannelType component,
const gchar *name);
GIMP_DEPRECATED_FOR(gimp_channel_new_from_component)
G_GNUC_INTERNAL 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
......
......@@ -120,6 +120,50 @@ gimp_display_new (GimpImage *image)
return display_ID;
}
/**
* _gimp_display_new: (skip)
* @image_ID: The image.
*
* Create a new display for the specified image.
*
* Creates a new display for the specified image. If the image already
* has a display, another is added. Multiple displays are handled
* transparently by GIMP. The newly created display is returned and can
* be subsequently destroyed with a call to gimp_display_delete(). This
* 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.
**/
gint32
_gimp_display_new (gint32 image_ID)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gint32 display_ID = -1;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, image_ID,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-display-new",
args);
else
return_vals = gimp_run_procedure_array ("gimp-display-new",
args);
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));
gimp_value_array_unref (return_vals);
return display_ID;
}
/**
* gimp_display_delete:
* @display_ID: The display to delete.
......@@ -289,3 +333,47 @@ gimp_displays_reconnect (GimpImage *old_image,
return success;
}
/**
* _gimp_displays_reconnect: (skip)
* @old_image_ID: The old image (must have at least one display).
* @new_image_ID: The new image (must not have a display).
*
* Reconnect displays from one image to another image.
*
* This procedure connects all displays of the old_image to the
* new_image. If the old_image has no display or new_image already has
* a display the reconnect is not performed and the procedure returns
* without success. You should rarely need to use this function.
*
* Returns: TRUE on success.
**/
gboolean
_gimp_displays_reconnect (gint32 old_image_ID,
gint32 new_image_ID)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean success = TRUE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, old_image_ID,
GIMP_TYPE_IMAGE_ID, new_image_ID,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-displays-reconnect",
args);
else
return_vals = gimp_run_procedure_array ("gimp-displays-reconnect",
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;
}
......@@ -32,13 +32,18 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean gimp_display_is_valid (gint32 display_ID);
gint32 gimp_display_new (GimpImage *image);
gboolean gimp_display_delete (gint32 display_ID);
gint gimp_display_get_window_handle (gint32 display_ID);
gboolean gimp_displays_flush (void);
gboolean gimp_displays_reconnect (GimpImage *old_image,
GimpImage *new_image);
gboolean gimp_display_is_valid (gint32 display_ID);
gint32 gimp_display_new (GimpImage *image);
GIMP_DEPRECATED_FOR(gimp_display_new)
G_GNUC_INTERNAL 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_flush (void);
gboolean gimp_displays_reconnect (GimpImage *old_image,
GimpImage *new_image);
GIMP_DEPRECATED_FOR(gimp_displays_reconnect)
G_GNUC_INTERNAL gboolean _gimp_displays_reconnect (gint32 old_image_ID,
gint32 new_image_ID);
G_END_DECLS
......
......@@ -172,6 +172,52 @@ gimp_edit_copy_visible (GimpImage *image)
return non_empty;
}
/**
* _gimp_edit_copy_visible: (skip)
* @image_ID: The image to copy from.
*
* Copy from the projection.
*
* If there is a selection in the image, then the area specified by the
* selection is copied from the projection and placed in an internal
* GIMP edit buffer. It can subsequently be retrieved using the
* gimp_edit_paste() command. If there is no selection, then the
* projection's contents will be stored in the internal GIMP edit
* buffer.
*
* Returns: TRUE if the copy was successful.
*
* Since: 2.2
**/
gboolean
_gimp_edit_copy_visible (gint32 image_ID)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean non_empty = FALSE;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, image_ID,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-edit-copy-visible",
args);
else
return_vals = gimp_run_procedure_array ("gimp-edit-copy-visible",
args);
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
non_empty = g_value_get_boolean (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
return non_empty;
}
/**
* gimp_edit_paste:
* @drawable_ID: The drawable to paste to.
......@@ -263,13 +309,55 @@ gimp_edit_paste_as_new_image (void)
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
image = gimp_image_new_by_id (g_value_get_int (gimp_value_array_index (return_vals, 1)));
image = gimp_image_new_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
gimp_value_array_unref (return_vals);
return image;
}
/**
* _gimp_edit_paste_as_new_image: (skip)
*
* Paste buffer to a new image.
*
* This procedure pastes a copy of the internal GIMP edit buffer to a
* new image. The GIMP edit buffer will be empty unless a call was
* previously made to either gimp_edit_cut() or gimp_edit_copy(). This
* procedure returns the new image or -1 if the edit buffer was empty.
*
* Returns: The new image.
*
* Since: 2.10
**/
gint32
_gimp_edit_paste_as_new_image (void)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gint32 image_ID = -1;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-edit-paste-as-new-image",
args);
else
return_vals = gimp_run_procedure_array ("gimp-edit-paste-as-new-image",
args);
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
image_ID = gimp_value_get_image_id (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
return image_ID;
}
/**
* gimp_edit_named_cut:
* @drawable_ID: The drawable to cut from.
......@@ -417,6 +505,54 @@ gimp_edit_named_copy_visible (GimpImage *image,
return real_name;
}
/**
* _gimp_edit_named_copy_visible: (skip)
* @image_ID: The image to copy from.
* @buffer_name: The name of the buffer to create.
*
* Copy from the projection into a named buffer.
*
* This procedure works like gimp_edit_copy_visible(), but additionally
* stores the copied buffer into a named buffer that will stay
* available for later pasting, regardless of any intermediate copy or
* cut operations.
*
* Returns: The real name given to the buffer, or NULL if the copy failed.
* The returned value must be freed with g_free().
*
* Since: 2.4
**/
gchar *
_gimp_edit_named_copy_visible (gint32 image_ID,
const gchar *buffer_name)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gchar *real_name = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE_ID, image_ID,
G_TYPE_STRING, buffer_name,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-edit-named-copy-visible",
args);
else
return_vals = gimp_run_procedure_array ("gimp-edit-named-copy-visible",
args);
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
real_name = g_value_dup_string (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
return real_name;
}
/**
* gimp_edit_named_paste:
* @drawable_ID: The drawable to paste to.
......@@ -500,9 +636,51 @@ gimp_edit_named_paste_as_new_image (const gchar *buffer_name)
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
image = gimp_image_new_by_id (g_value_get_int (gimp_value_array_index (return_vals, 1)));
image = gimp_image_new_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
gimp_value_array_unref (return_vals);
return image;
}
/**
* _gimp_edit_named_paste_as_new_image: (skip)
* @buffer_name: The name of the buffer to paste.
*
* Paste named buffer to a new image.
*
* This procedure works like gimp_edit_paste_as_new_image() but pastes
* a named buffer instead of the global buffer.
*
* Returns: The new image.
*
* Since: 2.10
**/
gint32
_gimp_edit_named_paste_as_new_image (const gchar *buffer_name)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gint32 image_ID = -1;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_STRING, buffer_name,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-edit-named-paste-as-new-image",
args);
else
return_vals = gimp_run_procedure_array ("gimp-edit-named-paste-as-new-image",
args);
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
image_ID = gimp_value_get_image_id (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
return image_ID;
}
......@@ -32,22 +32,31 @@ G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
gboolean gimp_edit_cut (gint32 drawable_ID);
gboolean gimp_edit_copy (gint32 drawable_ID);
gboolean gimp_edit_copy_visible (GimpImage *image);
gint32 gimp_edit_paste (gint32 drawable_ID,
gboolean paste_into);
GimpImage* gimp_edit_paste_as_new_image (void);
gchar* gimp_edit_named_cut (gint32 drawable_ID,
const gchar *buffer_name);
gchar* gimp_edit_named_copy (gint32 drawable_ID,
const gchar *buffer_name);
gchar* gimp_edit_named_copy_visible (GimpImage *image,
const gchar *buffer_name);
gint32 gimp_edit_named_paste (gint32 drawable_ID,
const gchar *buffer_name,
gboolean paste_into);
GimpImage* gimp_edit_named_paste_as_new_image (const gchar *buffer_name);
gboolean gimp_edit_cut (gint32 drawable_ID);
gboolean gimp_edit_copy (gint32 drawable_ID);
gboolean gimp_edit_copy_visible (GimpImage *image);
GIMP_DEPRECATED_FOR(gimp_edit_copy_visible)
G_GNUC_INTERNAL gboolean _gimp_edit_copy_visible (gint32 image_ID);
gint32 gimp_edit_paste (gint32 drawable_ID,
gboolean paste_into);
GimpImage* gimp_edit_paste_as_new_image (void);
GIMP_DEPRECATED_FOR(gimp_edit_paste_as_new_image)
G_GNUC_INTERNAL gint32 _gimp_edit_paste_as_new_image (void);
gchar* gimp_edit_named_cut (gint32 drawable_ID,
const gchar *buffer_name);
gchar* gimp_edit_named_copy (gint32 drawable_ID,
const gchar *buffer_name);
gchar* gimp_edit_named_copy_visible (GimpImage *image,
const gchar *buffer_name);
GIMP_DEPRECATED_FOR(gimp_edit_named_copy_visible)
G_GNUC_INTERNAL gchar* _gimp_edit_named_copy_visible (gint32 image_ID,
const gchar *buffer_name);
gint32 gimp_edit_named_paste (gint32 drawable_ID,
const gchar *buffer_name,
gboolean paste_into);
GimpImage* gimp_edit_named_paste_as_new_image (const gchar *buffer_name);
GIMP_DEPRECATED_FOR(gimp_edit_named_paste_as_new_image)
G_GNUC_INTERNAL gint32 _gimp_edit_named_paste_as_new_image (const gchar *buffer_name);
G_END_DECLS
......
......@@ -78,13 +78,64 @@ gimp_file_load (GimpRunMode run_mode,
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
image = gimp_image_new_by_id (g_value_get_int (gimp_value_array_index (return_vals, 1)));
image = gimp_image_new_by_id (gimp_value_get_image_id (gimp_value_array_index (return_vals, 1)));
gimp_value_array_unref (return_vals);
return image;
}
/**
* _gimp_file_load: (skip)
* @run_mode: The run mode.
* @filename: The name of the file to load.
* @raw_filename: The name as entered by the user.
*
* Loads an image file by invoking the right load handler.
*
* This procedure invokes the correct file load handler using magic if
* possible, and falling back on the file's extension and/or prefix if
* not. The name of the file to load is typically a full pathname, and
* the name entered is what the user actually typed before prepending a
* directory path. The reason for this is that if the user types
* https://www.gimp.org/foo.png he wants to fetch a URL, and the full
* pathname will not look like a URL.
*
* Returns: The output image.
**/
gint32
_gimp_file_load (GimpRunMode run_mode,
const gchar *filename,
const gchar *raw_filename)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gint32 image_ID = -1;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_RUN_MODE, run_mode,
G_TYPE_STRING, filename,
G_TYPE_STRING, raw_filename,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-file-load",
args);
else
return_vals = gimp_run_procedure_array ("gimp-file-load",
args);
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
image_ID = gimp_value_get_image_id (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
return image_ID;
}
/**
* gimp_file_load_layer:
* @run_mode: The run mode.
......@@ -135,6 +186,56 @@ gimp_file_load_layer (GimpRunMode run_mode,
return layer_ID;
}
/**
* _gimp_file_load_layer: (skip)
* @run_mode: The run mode.
* @image_ID: Destination image.
* @filename: The name of the file to load.
*
* Loads an image file as a layer for an existing image.
*
* This procedure behaves like the file-load procedure but opens the
* specified image as a layer for an existing image. The returned layer
* needs to be added to the existing image with
* gimp_image_insert_layer().
*
* Returns: The layer created when loading the image file.
*
* Since: 2.4
**/
gint32
_gimp_file_load_layer (GimpRunMode run_mode,
gint32 image_ID,
const gchar *filename)
{
GimpPDB *pdb = gimp_get_pdb ();
GimpValueArray *args;
GimpValueArray *return_vals;
gint32 layer_ID = -1;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_RUN_MODE, run_mode,
GIMP_TYPE_IMAGE_ID, image_ID,
G_TYPE_STRING, filename,
G_TYPE_NONE);
if (pdb)
return_vals = gimp_pdb_run_procedure_array (pdb,
"gimp-file-load-layer",
args);
else
return_vals = gimp_run_procedure_array ("gimp-file-load-layer",
args);
gimp_value_array_unref (args);
if (g_value_get_enum (gimp_value_array_index (return_vals, 0)) == GIMP_PDB_SUCCESS)
layer_ID = gimp_value_get_layer_id (gimp_value_array_index (return_vals, 1));
gimp_value_array_unref (return_vals);
return layer_ID;
}
/**
* gimp_file_load_layers:
* @run_mode: The run mode.
......@@ -194,6 +295,64 @@ gimp_file_load_layers (GimpRunMode run_mode,
return layer_ids;
}
/**
* _gimp_file_load_layers: (skip)
* @run_mode: The run mode.
* @image_ID: Destination image.
* @filename: The name of the file to load.