diff --git a/libgimp/gimpaspectpreview.c b/libgimp/gimpaspectpreview.c index 378af78f09..c2441bacff 100644 --- a/libgimp/gimpaspectpreview.c +++ b/libgimp/gimpaspectpreview.c @@ -291,15 +291,15 @@ gimp_aspect_preview_draw_buffer (GimpPreview *preview, { GimpAspectPreviewPrivate *priv = GET_PRIVATE (preview); GtkWidget *area = gimp_preview_get_area (preview); + GimpImage *image; gint width; gint height; - gint32 image_ID; gimp_preview_get_size (preview, &width, &height); - image_ID = gimp_item_get_image (priv->drawable_ID); + image = gimp_item_get_image (priv->drawable_ID); - if (gimp_selection_is_empty (image_ID)) + if (gimp_selection_is_empty (image)) { gimp_preview_area_draw (GIMP_PREVIEW_AREA (area), 0, 0, @@ -316,7 +316,7 @@ gimp_aspect_preview_draw_buffer (GimpPreview *preview, gint w, h; gint bpp; - selection_ID = gimp_image_get_selection (image_ID); + selection_ID = gimp_image_get_selection (image); w = width; h = height; @@ -336,6 +336,7 @@ gimp_aspect_preview_draw_buffer (GimpPreview *preview, g_free (sel); g_free (src); } + g_object_unref (image); } static void diff --git a/libgimp/gimpchannel.c b/libgimp/gimpchannel.c index 00a45f2ef7..b8fca7cb00 100644 --- a/libgimp/gimpchannel.c +++ b/libgimp/gimpchannel.c @@ -25,12 +25,12 @@ /** * gimp_channel_new: - * @image_ID: The image to which to add the channel. - * @name: The channel name. - * @width: The channel width. - * @height: The channel height. + * @image: The image to which to add the channel. + * @name: The channel name. + * @width: The channel width. + * @height: The channel height. * @opacity: The channel opacity. - * @color: The channel compositing color. + * @color: The channel compositing color. * * Create a new channel. * @@ -45,14 +45,14 @@ * Returns: The newly created channel. */ gint32 -gimp_channel_new (gint32 image_ID, +gimp_channel_new (GimpImage *image, const gchar *name, guint width, guint height, gdouble opacity, const GimpRGB *color) { - return _gimp_channel_new (image_ID, + return _gimp_channel_new (image, width, height, name, diff --git a/libgimp/gimpchannel.h b/libgimp/gimpchannel.h index 62b168ef8a..54a3179408 100644 --- a/libgimp/gimpchannel.h +++ b/libgimp/gimpchannel.h @@ -30,7 +30,7 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gint32 gimp_channel_new (gint32 image_ID, +gint32 gimp_channel_new (GimpImage *image, const gchar *name, guint width, guint height, diff --git a/libgimp/gimpdrawable.c b/libgimp/gimpdrawable.c index 31d9060ad7..da9b5c332a 100644 --- a/libgimp/gimpdrawable.c +++ b/libgimp/gimpdrawable.c @@ -270,12 +270,12 @@ gimp_drawable_get_format (gint32 drawable_ID) if (format_str) { - gint32 image_ID = gimp_item_get_image (drawable_ID); - const Babl *space = NULL; + const Babl *space = NULL; + GimpImage *image = gimp_item_get_image (drawable_ID); if (gimp_item_is_layer (drawable_ID)) { - GimpColorProfile *profile = gimp_image_get_color_profile (image_ID); + GimpColorProfile *profile = gimp_image_get_color_profile (image); if (profile) { @@ -313,7 +313,7 @@ gimp_drawable_get_format (gint32 drawable_ID) else format = palette; - colormap = gimp_image_get_colormap (image_ID, &n_colors); + colormap = gimp_image_get_colormap (image, &n_colors); if (colormap) { @@ -329,6 +329,7 @@ gimp_drawable_get_format (gint32 drawable_ID) format = babl_format_with_space (format_str, space); } + g_object_unref (image); g_free (format_str); } diff --git a/libgimp/gimpdrawablepreview.c b/libgimp/gimpdrawablepreview.c index c88a02eda7..973e6890a3 100644 --- a/libgimp/gimpdrawablepreview.c +++ b/libgimp/gimpdrawablepreview.c @@ -406,16 +406,16 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview, GimpDrawablePreviewPrivate *priv = GET_PRIVATE (preview); GimpPreview *gimp_preview = GIMP_PREVIEW (preview); GtkWidget *area = gimp_preview_get_area (gimp_preview); + GimpImage *image; gint xmin, ymin; gint xoff, yoff; - gint32 image_ID; gimp_preview_get_bounds (gimp_preview, &xmin, &ymin, NULL, NULL); gimp_preview_get_offsets (gimp_preview, &xoff, &yoff); - image_ID = gimp_item_get_image (priv->drawable_ID); + image = gimp_item_get_image (priv->drawable_ID); - if (gimp_selection_is_empty (image_ID)) + if (gimp_selection_is_empty (image)) { gimp_preview_area_draw (GIMP_PREVIEW_AREA (area), x - xoff - xmin, @@ -457,7 +457,7 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview, s_w = draw_width; s_h = draw_height; - selection_ID = gimp_image_get_selection (image_ID); + selection_ID = gimp_image_get_selection (image); src = gimp_drawable_get_sub_thumbnail_data (priv->drawable_ID, draw_x, draw_y, @@ -481,6 +481,7 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview, default: g_free (sel); g_free (src); + g_object_unref (image); return; } @@ -501,6 +502,7 @@ gimp_drawable_preview_draw_area (GimpDrawablePreview *preview, g_free (src); } } + g_object_unref (image); } static void @@ -538,14 +540,15 @@ gimp_drawable_preview_set_drawable_id (GimpDrawablePreview *drawable_preview, if (gimp_drawable_is_indexed (drawable_ID)) { - guint32 image_ID = gimp_item_get_image (drawable_ID); - GtkWidget *area = gimp_preview_get_area (preview); + GimpImage *image = gimp_item_get_image (drawable_ID); + GtkWidget *area = gimp_preview_get_area (preview); guchar *cmap; gint num_colors; - cmap = gimp_image_get_colormap (image_ID, &num_colors); + cmap = gimp_image_get_colormap (image, &num_colors); gimp_preview_area_set_colormap (GIMP_PREVIEW_AREA (area), cmap, num_colors); + g_object_unref (image); g_free (cmap); } } diff --git a/libgimp/gimpexport.c b/libgimp/gimpexport.c index 3a99f786dc..02dce6ad18 100644 --- a/libgimp/gimpexport.c +++ b/libgimp/gimpexport.c @@ -51,8 +51,8 @@ **/ -typedef void (* ExportFunc) (gint32 imageID, - gint32 *drawable_ID); +typedef void (* ExportFunc) (GimpImage *image, + gint32 *drawable_ID); /* the export action structure */ @@ -69,8 +69,8 @@ typedef struct /* the functions that do the actual export */ static void -export_merge (gint32 image_ID, - gint32 *drawable_ID) +export_merge (GimpImage *image, + gint32 *drawable_ID) { gint32 nlayers; gint32 nvisible = 0; @@ -79,7 +79,7 @@ export_merge (gint32 image_ID, gint32 merged; gint32 transp; - layers = gimp_image_get_layers (image_ID, &nlayers); + layers = gimp_image_get_layers (image, &nlayers); for (i = 0; i < nlayers; i++) { if (gimp_item_get_visible (layers[i])) @@ -93,13 +93,13 @@ export_merge (gint32 image_ID, * merge that follows will ensure that the offset, opacity and * size are correct */ - transp = gimp_layer_new (image_ID, "-", - gimp_image_width (image_ID), - gimp_image_height (image_ID), + transp = gimp_layer_new (image, "-", + gimp_image_width (image), + gimp_image_height (image), gimp_drawable_type (*drawable_ID) | 1, 100.0, GIMP_LAYER_MODE_NORMAL); - gimp_image_insert_layer (image_ID, transp, -1, 1); - gimp_selection_none (image_ID); + gimp_image_insert_layer (image, transp, -1, 1); + gimp_selection_none (image); gimp_drawable_edit_clear (transp); nvisible++; } @@ -107,25 +107,25 @@ export_merge (gint32 image_ID, if (nvisible > 1) { g_free (layers); - merged = gimp_image_merge_visible_layers (image_ID, GIMP_CLIP_TO_IMAGE); + merged = gimp_image_merge_visible_layers (image, GIMP_CLIP_TO_IMAGE); if (merged != -1) *drawable_ID = merged; else return; /* shouldn't happen */ - layers = gimp_image_get_layers (image_ID, &nlayers); + layers = gimp_image_get_layers (image, &nlayers); /* make sure that the merged drawable matches the image size */ - if (gimp_drawable_width (merged) != gimp_image_width (image_ID) || - gimp_drawable_height (merged) != gimp_image_height (image_ID)) + if (gimp_drawable_width (merged) != gimp_image_width (image) || + gimp_drawable_height (merged) != gimp_image_height (image)) { gint off_x, off_y; gimp_drawable_offsets (merged, &off_x, &off_y); gimp_layer_resize (merged, - gimp_image_width (image_ID), - gimp_image_height (image_ID), + gimp_image_width (image), + gimp_image_height (image), off_x, off_y); } } @@ -134,32 +134,32 @@ export_merge (gint32 image_ID, for (i = 0; i < nlayers; i++) { if (layers[i] != *drawable_ID) - gimp_image_remove_layer (image_ID, layers[i]); + gimp_image_remove_layer (image, layers[i]); } g_free (layers); } static void -export_flatten (gint32 image_ID, - gint32 *drawable_ID) +export_flatten (GimpImage *image, + gint32 *drawable_ID) { gint32 flattened; - flattened = gimp_image_flatten (image_ID); + flattened = gimp_image_flatten (image); if (flattened != -1) *drawable_ID = flattened; } static void -export_remove_alpha (gint32 image_ID, - gint32 *drawable_ID) +export_remove_alpha (GimpImage *image, + gint32 *drawable_ID) { gint32 n_layers; gint32 *layers; gint i; - layers = gimp_image_get_layers (image_ID, &n_layers); + layers = gimp_image_get_layers (image, &n_layers); for (i = 0; i < n_layers; i++) { @@ -171,14 +171,14 @@ export_remove_alpha (gint32 image_ID, } static void -export_apply_masks (gint32 image_ID, - gint *drawable_ID) +export_apply_masks (GimpImage *image, + gint *drawable_ID) { gint32 n_layers; gint32 *layers; gint i; - layers = gimp_image_get_layers (image_ID, &n_layers); + layers = gimp_image_get_layers (image, &n_layers); for (i = 0; i < n_layers; i++) { @@ -190,61 +190,61 @@ export_apply_masks (gint32 image_ID, } static void -export_convert_rgb (gint32 image_ID, - gint32 *drawable_ID) +export_convert_rgb (GimpImage *image, + gint32 *drawable_ID) { - gimp_image_convert_rgb (image_ID); + gimp_image_convert_rgb (image); } static void -export_convert_grayscale (gint32 image_ID, - gint32 *drawable_ID) +export_convert_grayscale (GimpImage *image, + gint32 *drawable_ID) { - gimp_image_convert_grayscale (image_ID); + gimp_image_convert_grayscale (image); } static void -export_convert_indexed (gint32 image_ID, - gint32 *drawable_ID) +export_convert_indexed (GimpImage *image, + gint32 *drawable_ID) { gint32 nlayers; /* check alpha */ - g_free (gimp_image_get_layers (image_ID, &nlayers)); + g_free (gimp_image_get_layers (image, &nlayers)); if (nlayers > 1 || gimp_drawable_has_alpha (*drawable_ID)) - gimp_image_convert_indexed (image_ID, + gimp_image_convert_indexed (image, GIMP_CONVERT_DITHER_NONE, GIMP_CONVERT_PALETTE_GENERATE, 255, FALSE, FALSE, ""); else - gimp_image_convert_indexed (image_ID, + gimp_image_convert_indexed (image, GIMP_CONVERT_DITHER_NONE, GIMP_CONVERT_PALETTE_GENERATE, 256, FALSE, FALSE, ""); } static void -export_convert_bitmap (gint32 image_ID, - gint32 *drawable_ID) +export_convert_bitmap (GimpImage *image, + gint32 *drawable_ID) { - if (gimp_image_base_type (image_ID) == GIMP_INDEXED) - gimp_image_convert_rgb (image_ID); + if (gimp_image_base_type (image) == GIMP_INDEXED) + gimp_image_convert_rgb (image); - gimp_image_convert_indexed (image_ID, + gimp_image_convert_indexed (image, GIMP_CONVERT_DITHER_FS, GIMP_CONVERT_PALETTE_GENERATE, 2, FALSE, FALSE, ""); } static void -export_add_alpha (gint32 image_ID, - gint32 *drawable_ID) +export_add_alpha (GimpImage *image, + gint32 *drawable_ID) { gint32 nlayers; gint32 i; gint32 *layers; - layers = gimp_image_get_layers (image_ID, &nlayers); + layers = gimp_image_get_layers (image, &nlayers); for (i = 0; i < nlayers; i++) { if (!gimp_drawable_has_alpha (layers[i])) @@ -254,8 +254,8 @@ export_add_alpha (gint32 image_ID, } static void -export_void (gint32 image_ID, - gint32 *drawable_ID) +export_void (GimpImage *image, + gint32 *drawable_ID) { /* do nothing */ } @@ -431,10 +431,10 @@ export_action_get_func (const ExportAction *action) static void export_action_perform (const ExportAction *action, - gint32 image_ID, + GimpImage *image, gint32 *drawable_ID) { - export_action_get_func (action) (image_ID, drawable_ID); + export_action_get_func (action) (image, drawable_ID); } @@ -694,9 +694,9 @@ export_dialog (GSList *actions, /** * gimp_export_image: - * @image_ID: Pointer to the image_ID. - * @drawable_ID: Pointer to the drawable_ID. - * @format_name: The (short) name of the image_format (e.g. JPEG or GIF). + * @image: Pointer to the image. + * @drawable_ID: Pointer to the drawable_ID. + * @format_name: The (short) name of the image_format (e.g. JPEG or GIF). * @capabilities: What can the image_format do? * * Takes an image and a drawable to be saved together with a @@ -706,16 +706,16 @@ export_dialog (GSList *actions, * to be exported and offers to do the necessary conversions. * * If the user chooses to export the image, a copy is created. - * This copy is then converted, the image_ID and drawable_ID - * are changed to point to the new image and the procedure returns - * GIMP_EXPORT_EXPORT. The save_plugin has to take care of deleting the - * created image using gimp_image_delete() when it has saved it. + * This copy is then converted, @image and @drawable_ID are changed to + * point to the new image and the procedure returns GIMP_EXPORT_EXPORT. + * The save_plugin has to take care of deleting the created image using + * gimp_image_delete() when it has saved it. * - * If the user chooses to Ignore the export problem, the image_ID - * and drawable_ID is not altered, GIMP_EXPORT_IGNORE is returned and - * the save_plugin should try to save the original image. If the - * user chooses Cancel, GIMP_EXPORT_CANCEL is returned and the - * save_plugin should quit itself with status %GIMP_PDB_CANCEL. + * If the user chooses to Ignore the export problem, @image and + * @drawable_ID are not altered, GIMP_EXPORT_IGNORE is returned and the + * save_plugin should try to save the original image. If the user + * chooses Cancel, GIMP_EXPORT_CANCEL is returned and the save_plugin + * should quit itself with status %GIMP_PDB_CANCEL. * * If @format_name is NULL, no dialogs will be shown and this function * will behave as if the user clicked on the 'Export' button, if a @@ -724,7 +724,7 @@ export_dialog (GSList *actions, * Returns: An enum of #GimpExportReturn describing the user_action. **/ GimpExportReturn -gimp_export_image (gint32 *image_ID, +gimp_export_image (GimpImage **image, gint32 *drawable_ID, const gchar *format_name, GimpExportCapabilities capabilities) @@ -740,7 +740,7 @@ gimp_export_image (gint32 *image_ID, gboolean background_has_alpha = TRUE; GimpExportReturn retval = GIMP_EXPORT_CANCEL; - g_return_val_if_fail (*image_ID > -1 && *drawable_ID > -1, FALSE); + g_return_val_if_fail (gimp_image_is_valid (*image) && *drawable_ID > -1, FALSE); /* do some sanity checks */ if (capabilities & GIMP_EXPORT_NEEDS_ALPHA) @@ -785,7 +785,7 @@ gimp_export_image (gint32 *image_ID, /* check alpha and layer masks */ - layers = gimp_image_get_layers (*image_ID, &n_layers); + layers = gimp_image_get_layers (*image, &n_layers); for (i = 0; i < n_layers; i++) { @@ -850,9 +850,9 @@ gimp_export_image (gint32 *image_ID, gimp_drawable_offsets (*drawable_ID, &offset_x, &offset_y); if ((gimp_layer_get_opacity (*drawable_ID) < 100.0) || - (gimp_image_width (*image_ID) != + (gimp_image_width (*image) != gimp_drawable_width (*drawable_ID)) || - (gimp_image_height (*image_ID) != + (gimp_image_height (*image) != gimp_drawable_height (*drawable_ID)) || offset_x || offset_y) { @@ -916,7 +916,7 @@ gimp_export_image (gint32 *image_ID, g_free (layers); /* check the image type */ - type = gimp_image_base_type (*image_ID); + type = gimp_image_base_type (*image); switch (type) { case GIMP_RGB: @@ -974,7 +974,7 @@ gimp_export_image (gint32 *image_ID, { gint n_colors; - g_free (gimp_image_get_colormap (*image_ID, &n_colors)); + g_free (gimp_image_get_colormap (*image, &n_colors)); if (n_colors > 2) actions = g_slist_prepend (actions, @@ -1002,14 +1002,14 @@ gimp_export_image (gint32 *image_ID, { GSList *list; - *image_ID = gimp_image_duplicate (*image_ID); - *drawable_ID = gimp_image_get_active_layer (*image_ID); + *image = gimp_image_duplicate (*image); + *drawable_ID = gimp_image_get_active_layer (*image); - gimp_image_undo_disable (*image_ID); + gimp_image_undo_disable (*image); for (list = actions; list; list = list->next) { - export_action_perform (list->data, *image_ID, drawable_ID); + export_action_perform (list->data, *image, drawable_ID); } } diff --git a/libgimp/gimpexport.h b/libgimp/gimpexport.h index ab63d4171b..eda0debe5d 100644 --- a/libgimp/gimpexport.h +++ b/libgimp/gimpexport.h @@ -75,7 +75,7 @@ typedef enum } GimpExportReturn; -GimpExportReturn gimp_export_image (gint32 *image_ID, +GimpExportReturn gimp_export_image (GimpImage **image, gint32 *drawable_ID, const gchar *format_name, GimpExportCapabilities capabilities); diff --git a/libgimp/gimpimage.c b/libgimp/gimpimage.c index 64b5bc5295..20c39693ee 100644 --- a/libgimp/gimpimage.c +++ b/libgimp/gimpimage.c @@ -136,7 +136,7 @@ gimp_image_get_id (GimpImage *image) /** * gimp_image_get_colormap: - * @image_ID: The image. + * @image: The image. * @num_colors: Returns the number of colors in the colormap array. * * Returns the image's colormap @@ -148,13 +148,13 @@ gimp_image_get_id (GimpImage *image) * Returns: The image's colormap. */ guchar * -gimp_image_get_colormap (gint32 image_ID, - gint *num_colors) +gimp_image_get_colormap (GimpImage *image, + gint *num_colors) { gint num_bytes; guchar *cmap; - cmap = _gimp_image_get_colormap (image_ID, &num_bytes); + cmap = _gimp_image_get_colormap (image, &num_bytes); if (num_colors) *num_colors = num_bytes / 3; @@ -164,7 +164,7 @@ gimp_image_get_colormap (gint32 image_ID, /** * gimp_image_set_colormap: - * @image_ID: The image. + * @image: The image. * @colormap: The new colormap values. * @num_colors: Number of colors in the colormap array. * @@ -178,19 +178,19 @@ gimp_image_get_colormap (gint32 image_ID, * Returns: TRUE on success. */ gboolean -gimp_image_set_colormap (gint32 image_ID, +gimp_image_set_colormap (GimpImage *image, const guchar *colormap, gint num_colors) { - return _gimp_image_set_colormap (image_ID, num_colors * 3, colormap); + return _gimp_image_set_colormap (image, num_colors * 3, colormap); } /** * gimp_image_get_thumbnail_data: - * @image_ID: The image. - * @width: (inout): The requested thumbnail width. - * @height: (inout): The requested thumbnail height. - * @bpp: (out): The previews bpp. + * @image: The image. + * @width: (inout): The requested thumbnail width. + * @height: (inout): The requested thumbnail height. + * @bpp: (out): The previews bpp. * * Get a thumbnail of an image. * @@ -202,17 +202,17 @@ gimp_image_set_colormap (gint32 image_ID, * Returns: (transfer full): the thumbnail data. **/ guchar * -gimp_image_get_thumbnail_data (gint32 image_ID, - gint *width, - gint *height, - gint *bpp) +gimp_image_get_thumbnail_data (GimpImage *image, + gint *width, + gint *height, + gint *bpp) { gint ret_width; gint ret_height; guchar *image_data; gint data_size; - _gimp_image_thumbnail (image_ID, + _gimp_image_thumbnail (image, *width, *height, &ret_width, @@ -229,12 +229,12 @@ gimp_image_get_thumbnail_data (gint32 image_ID, /** * gimp_image_get_thumbnail: - * @image_ID: the image ID - * @width: the requested thumbnail width (<= 1024 pixels) - * @height: the requested thumbnail height (<= 1024 pixels) - * @alpha: how to handle an alpha channel + * @image: the image ID + * @width: the requested thumbnail width (<= 1024 pixels) + * @height: the requested thumbnail height (<= 1024 pixels) + * @alpha: how to handle an alpha channel * - * Retrieves a thumbnail pixbuf for the image identified by @image_ID. + * Retrieves a thumbnail pixbuf for the image identified by @image->priv->id. * The thumbnail will be not larger than the requested size. * * Returns: (transfer full): a new #GdkPixbuf @@ -242,7 +242,7 @@ gimp_image_get_thumbnail_data (gint32 image_ID, * Since: 2.2 **/ GdkPixbuf * -gimp_image_get_thumbnail (gint32 image_ID, +gimp_image_get_thumbnail (GimpImage *image, gint width, gint height, GimpPixbufTransparency alpha) @@ -255,7 +255,7 @@ gimp_image_get_thumbnail (gint32 image_ID, g_return_val_if_fail (width > 0 && width <= 1024, NULL); g_return_val_if_fail (height > 0 && height <= 1024, NULL); - data = gimp_image_get_thumbnail_data (image_ID, + data = gimp_image_get_thumbnail_data (image, &thumb_width, &thumb_height, &thumb_bpp); @@ -269,7 +269,7 @@ gimp_image_get_thumbnail (gint32 image_ID, /** * gimp_image_get_metadata: - * @image_ID: The image. + * @image: The image. * * Returns the image's metadata. * @@ -281,12 +281,12 @@ gimp_image_get_thumbnail (gint32 image_ID, * Since: 2.10 **/ GimpMetadata * -gimp_image_get_metadata (gint32 image_ID) +gimp_image_get_metadata (GimpImage *image) { GimpMetadata *metadata = NULL; gchar *metadata_string; - metadata_string = _gimp_image_get_metadata (image_ID); + metadata_string = _gimp_image_get_metadata (image); if (metadata_string) { metadata = gimp_metadata_deserialize (metadata_string); @@ -298,7 +298,7 @@ gimp_image_get_metadata (gint32 image_ID) /** * gimp_image_set_metadata: - * @image_ID: The image. + * @image: The image. * @metadata: The exif/ptc/xmp metadata. * * Set the image's metadata. @@ -311,7 +311,7 @@ gimp_image_get_metadata (gint32 image_ID) * Since: 2.10 **/ gboolean -gimp_image_set_metadata (gint32 image_ID, +gimp_image_set_metadata (GimpImage *image, GimpMetadata *metadata) { gchar *metadata_string = NULL; @@ -320,7 +320,7 @@ gimp_image_set_metadata (gint32 image_ID, if (metadata) metadata_string = gimp_metadata_serialize (metadata); - success = _gimp_image_set_metadata (image_ID, metadata_string); + success = _gimp_image_set_metadata (image, metadata_string); if (metadata_string) g_free (metadata_string); diff --git a/libgimp/gimpimage.h b/libgimp/gimpimage.h index 468cc7bc39..f10f2e0ed8 100644 --- a/libgimp/gimpimage.h +++ b/libgimp/gimpimage.h @@ -67,23 +67,23 @@ GType gimp_image_get_type (void) G_GNUC_CONST; gint32 gimp_image_get_id (GimpImage *image); -guchar * gimp_image_get_colormap (gint32 image_ID, +guchar * gimp_image_get_colormap (GimpImage *image, gint *num_colors); -gboolean gimp_image_set_colormap (gint32 image_ID, +gboolean gimp_image_set_colormap (GimpImage *image, const guchar *colormap, gint num_colors); -guchar * gimp_image_get_thumbnail_data (gint32 image_ID, +guchar * gimp_image_get_thumbnail_data (GimpImage *image, gint *width, gint *height, gint *bpp); -GdkPixbuf * gimp_image_get_thumbnail (gint32 image_ID, +GdkPixbuf * gimp_image_get_thumbnail (GimpImage *image, gint width, gint height, GimpPixbufTransparency alpha); -GimpMetadata * gimp_image_get_metadata (gint32 image_ID); -gboolean gimp_image_set_metadata (gint32 image_ID, +GimpMetadata * gimp_image_get_metadata (GimpImage *image); +gboolean gimp_image_set_metadata (GimpImage *image, GimpMetadata *metadata); diff --git a/libgimp/gimpimagecolorprofile.c b/libgimp/gimpimagecolorprofile.c index d2ffb7bb4a..bb22bd5ce8 100644 --- a/libgimp/gimpimagecolorprofile.c +++ b/libgimp/gimpimagecolorprofile.c @@ -25,7 +25,7 @@ /** * gimp_image_get_color_profile: - * @image_ID: The image. + * @image: The image. * * Returns the image's color profile * @@ -38,12 +38,12 @@ * Since: 2.10 **/ GimpColorProfile * -gimp_image_get_color_profile (gint32 image_ID) +gimp_image_get_color_profile (GimpImage *image) { guint8 *data; gint length; - data = _gimp_image_get_color_profile (image_ID, &length); + data = _gimp_image_get_color_profile (image, &length); if (data) { @@ -60,8 +60,8 @@ gimp_image_get_color_profile (gint32 image_ID) /** * gimp_image_set_color_profile: - * @image_ID: The image. - * @profile: A #GimpColorProfile, or %NULL. + * @image: The image. + * @profile: A #GimpColorProfile, or %NULL. * * Sets the image's color profile * @@ -72,7 +72,7 @@ gimp_image_get_color_profile (gint32 image_ID) * Since: 2.10 **/ gboolean -gimp_image_set_color_profile (gint32 image_ID, +gimp_image_set_color_profile (GimpImage *image, GimpColorProfile *profile) { const guint8 *data = NULL; @@ -89,12 +89,12 @@ gimp_image_set_color_profile (gint32 image_ID, length = l; } - return _gimp_image_set_color_profile (image_ID, length, data); + return _gimp_image_set_color_profile (image, length, data); } /** * gimp_image_get_effective_color_profile: - * @image_ID: The image. + * @image: The image. * * Returns the color profile that is used for the image. * @@ -111,12 +111,12 @@ gimp_image_set_color_profile (gint32 image_ID, * Since: 2.10 **/ GimpColorProfile * -gimp_image_get_effective_color_profile (gint32 image_ID) +gimp_image_get_effective_color_profile (GimpImage *image) { guint8 *data; gint length; - data = _gimp_image_get_effective_color_profile (image_ID, &length); + data = _gimp_image_get_effective_color_profile (image, &length); if (data) { @@ -133,10 +133,10 @@ gimp_image_get_effective_color_profile (gint32 image_ID) /** * gimp_image_convert_color_profile: - * @image_ID: The image. - * @profile: The color profile to convert to. - * @intent: Rendering intent. - * @bpc: Black point compensation. + * @image: The image. + * @profile: The color profile to convert to. + * @intent: Rendering intent. + * @bpc: Black point compensation. * * Convert the image's layers to a color profile * @@ -149,7 +149,7 @@ gimp_image_get_effective_color_profile (gint32 image_ID) * Since: 2.10 **/ gboolean -gimp_image_convert_color_profile (gint32 image_ID, +gimp_image_convert_color_profile (GimpImage *image, GimpColorProfile *profile, GimpColorRenderingIntent intent, gboolean bpc) @@ -168,6 +168,6 @@ gimp_image_convert_color_profile (gint32 image_ID, length = l; } - return _gimp_image_convert_color_profile (image_ID, length, data, + return _gimp_image_convert_color_profile (image, length, data, intent, bpc); } diff --git a/libgimp/gimpimagecolorprofile.h b/libgimp/gimpimagecolorprofile.h index 15defccd1e..63ae015f04 100644 --- a/libgimp/gimpimagecolorprofile.h +++ b/libgimp/gimpimagecolorprofile.h @@ -30,13 +30,13 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -GimpColorProfile * gimp_image_get_color_profile (gint32 image_ID); -gboolean gimp_image_set_color_profile (gint32 image_ID, +GimpColorProfile * gimp_image_get_color_profile (GimpImage *image); +gboolean gimp_image_set_color_profile (GimpImage *image, GimpColorProfile *profile); -GimpColorProfile * gimp_image_get_effective_color_profile (gint32 image_ID); +GimpColorProfile * gimp_image_get_effective_color_profile (GimpImage *image); -gboolean gimp_image_convert_color_profile (gint32 image_ID, +gboolean gimp_image_convert_color_profile (GimpImage *image, GimpColorProfile *profile, GimpColorRenderingIntent intent, gboolean bpc); diff --git a/libgimp/gimpimagecombobox.c b/libgimp/gimpimagecombobox.c index cc5bf6530e..de6ee5ad97 100644 --- a/libgimp/gimpimagecombobox.c +++ b/libgimp/gimpimagecombobox.c @@ -207,9 +207,12 @@ gimp_image_combo_box_model_add (GtkListStore *store, for (i = 0; i < num_images; i++) { - if (! constraint || (* constraint) (images[i], data)) + GimpImage *image; + + image = g_object_new (GIMP_TYPE_IMAGE, "id", images[i], NULL); + if (! constraint || (* constraint) (image, data)) { - gchar *image_name = gimp_image_get_name (images[i]); + gchar *image_name = gimp_image_get_name (image); gchar *label; GdkPixbuf *thumb; @@ -217,7 +220,7 @@ gimp_image_combo_box_model_add (GtkListStore *store, g_free (image_name); - thumb = gimp_image_get_thumbnail (images[i], + thumb = gimp_image_get_thumbnail (image, THUMBNAIL_SIZE, THUMBNAIL_SIZE, GIMP_PIXBUF_SMALL_CHECKS); @@ -233,6 +236,7 @@ gimp_image_combo_box_model_add (GtkListStore *store, g_free (label); } + g_object_unref (image); } } @@ -280,7 +284,10 @@ gimp_image_combo_box_changed (GimpImageComboBox *combo_box) if (gimp_int_combo_box_get_active (GIMP_INT_COMBO_BOX (combo_box), &image_ID)) { - if (! gimp_image_is_valid (image_ID)) + GimpImage *image; + + image = g_object_new (GIMP_TYPE_IMAGE, "id", image_ID, NULL); + if (! gimp_image_is_valid (image)) { GtkTreeModel *model; @@ -291,5 +298,6 @@ gimp_image_combo_box_changed (GimpImageComboBox *combo_box) gtk_list_store_clear (GTK_LIST_STORE (model)); gimp_image_combo_box_populate (combo_box); } + g_object_unref (image); } } diff --git a/libgimp/gimpimagecombobox.h b/libgimp/gimpimagecombobox.h index 150720f241..28f4bd8fd3 100644 --- a/libgimp/gimpimagecombobox.h +++ b/libgimp/gimpimagecombobox.h @@ -36,8 +36,8 @@ G_BEGIN_DECLS #define GIMP_IS_IMAGE_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_IMAGE_COMBO_BOX) -typedef gboolean (* GimpImageConstraintFunc) (gint32 image_id, - gpointer data); +typedef gboolean (* GimpImageConstraintFunc) (GimpImage *image, + gpointer data); GType gimp_image_combo_box_get_type (void) G_GNUC_CONST; diff --git a/libgimp/gimpimagemetadata.c b/libgimp/gimpimagemetadata.c index 125d94d39f..8445489afa 100644 --- a/libgimp/gimpimagemetadata.c +++ b/libgimp/gimpimagemetadata.c @@ -40,15 +40,15 @@ typedef struct } XmpStructs; -static void gimp_image_metadata_rotate (gint32 image_ID, +static void gimp_image_metadata_rotate (GimpImage *image, GExiv2Orientation orientation); static GdkPixbuf * gimp_image_metadata_rotate_pixbuf (GdkPixbuf *pixbuf, GExiv2Orientation orientation); -static void gimp_image_metadata_rotate_query (gint32 image_ID, +static void gimp_image_metadata_rotate_query (GimpImage *image, const gchar *mime_type, GimpMetadata *metadata, gboolean interactive); -static gboolean gimp_image_metadata_rotate_dialog (gint32 image_ID, +static gboolean gimp_image_metadata_rotate_dialog (GimpImage *image, GExiv2Orientation orientation, const gchar *parasite_name); @@ -57,7 +57,7 @@ static gboolean gimp_image_metadata_rotate_dialog (gint32 image_I /** * gimp_image_metadata_load_prepare: - * @image_ID: The image + * @image: The image * @mime_type: The loaded file's mime-type * @file: The file to load the metadata from * @error: Return location for error @@ -70,14 +70,14 @@ static gboolean gimp_image_metadata_rotate_dialog (gint32 image_I * Since: 2.10 */ GimpMetadata * -gimp_image_metadata_load_prepare (gint32 image_ID, +gimp_image_metadata_load_prepare (GimpImage *image, const gchar *mime_type, GFile *file, GError **error) { GimpMetadata *metadata; - g_return_val_if_fail (image_ID > 0, NULL); + g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (mime_type != NULL, NULL); g_return_val_if_fail (G_IS_FILE (file), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); @@ -94,7 +94,7 @@ gimp_image_metadata_load_prepare (gint32 image_ID, /** * gimp_image_metadata_load_finish: - * @image_ID: The image + * @image: The image * @mime_type: The loaded file's mime-type * @metadata: The metadata to set on the image * @flags: Flags to specify what of the metadata to apply to the image @@ -107,13 +107,13 @@ gimp_image_metadata_load_prepare (gint32 image_ID, * Since: 2.10 */ void -gimp_image_metadata_load_finish (gint32 image_ID, +gimp_image_metadata_load_finish (GimpImage *image, const gchar *mime_type, GimpMetadata *metadata, GimpMetadataLoadFlags flags, gboolean interactive) { - g_return_if_fail (image_ID > 0); + g_return_if_fail (GIMP_IS_IMAGE (image)); g_return_if_fail (mime_type != NULL); g_return_if_fail (GEXIV2_IS_METADATA (metadata)); @@ -137,7 +137,7 @@ gimp_image_metadata_load_finish (gint32 image_ID, comment); g_free (comment); - gimp_image_attach_parasite (image_ID, parasite); + gimp_image_attach_parasite (image, parasite); gimp_parasite_free (parasite); } } @@ -150,20 +150,20 @@ gimp_image_metadata_load_finish (gint32 image_ID, if (gimp_metadata_get_resolution (metadata, &xres, &yres, &unit)) { - gimp_image_set_resolution (image_ID, xres, yres); - gimp_image_set_unit (image_ID, unit); + gimp_image_set_resolution (image, xres, yres); + gimp_image_set_unit (image, unit); } } if (flags & GIMP_METADATA_LOAD_ORIENTATION) { - gimp_image_metadata_rotate_query (image_ID, mime_type, + gimp_image_metadata_rotate_query (image, mime_type, metadata, interactive); } if (flags & GIMP_METADATA_LOAD_COLORSPACE) { - GimpColorProfile *profile = gimp_image_get_color_profile (image_ID); + GimpColorProfile *profile = gimp_image_get_color_profile (image); /* only look for colorspace information from metadata if the * image didn't contain an embedded color profile @@ -188,19 +188,19 @@ gimp_image_metadata_load_finish (gint32 image_ID, } if (profile) - gimp_image_set_color_profile (image_ID, profile); + gimp_image_set_color_profile (image, profile); } if (profile) g_object_unref (profile); } - gimp_image_set_metadata (image_ID, metadata); + gimp_image_set_metadata (image, metadata); } /** * gimp_image_metadata_save_prepare: - * @image_ID: The image + * @image: The image * @mime_type: The saved file's mime-type * @suggested_flags: Suggested default values for the @flags passed to * gimp_image_metadata_save_finish() @@ -225,19 +225,19 @@ gimp_image_metadata_load_finish (gint32 image_ID, * Since: 2.10 */ GimpMetadata * -gimp_image_metadata_save_prepare (gint32 image_ID, +gimp_image_metadata_save_prepare (GimpImage *image, const gchar *mime_type, GimpMetadataSaveFlags *suggested_flags) { GimpMetadata *metadata; - g_return_val_if_fail (image_ID > 0, NULL); + g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (mime_type != NULL, NULL); g_return_val_if_fail (suggested_flags != NULL, NULL); *suggested_flags = GIMP_METADATA_SAVE_ALL; - metadata = gimp_image_get_metadata (image_ID); + metadata = gimp_image_get_metadata (image); if (metadata) { @@ -251,12 +251,12 @@ gimp_image_metadata_save_prepare (gint32 image_ID, gchar buffer[32]; GExiv2Metadata *g2metadata = GEXIV2_METADATA (metadata); - image_width = gimp_image_width (image_ID); - image_height = gimp_image_height (image_ID); + image_width = gimp_image_width (image); + image_height = gimp_image_height (image); datetime = g_date_time_new_now_local (); - comment_parasite = gimp_image_get_parasite (image_ID, "gimp-comment"); + comment_parasite = gimp_image_get_parasite (image, "gimp-comment"); if (comment_parasite) comment = gimp_parasite_data (comment_parasite); @@ -295,9 +295,9 @@ gimp_image_metadata_save_prepare (gint32 image_ID, gimp_metadata_set_pixel_size (metadata, image_width, image_height); - gimp_image_get_resolution (image_ID, &xres, &yres); + gimp_image_get_resolution (image, &xres, &yres); gimp_metadata_set_resolution (metadata, xres, yres, - gimp_image_get_unit (image_ID)); + gimp_image_get_unit (image)); /* XMP */ @@ -406,7 +406,7 @@ gimp_image_metadata_copy_tag (GExiv2Metadata *src, /** * gimp_image_metadata_save_finish: - * @image_ID: The image + * @image: The image * @mime_type: The saved file's mime-type * @metadata: The metadata to set on the image * @flags: Flags to specify what of the metadata to save @@ -422,7 +422,7 @@ gimp_image_metadata_copy_tag (GExiv2Metadata *src, * Since: 2.10 */ gboolean -gimp_image_metadata_save_finish (gint32 image_ID, +gimp_image_metadata_save_finish (GimpImage *image, const gchar *mime_type, GimpMetadata *metadata, GimpMetadataSaveFlags flags, @@ -437,7 +437,7 @@ gimp_image_metadata_save_finish (gint32 image_ID, gboolean success = FALSE; gint i; - g_return_val_if_fail (image_ID > 0, FALSE); + g_return_val_if_fail (GIMP_IS_IMAGE (image), FALSE); g_return_val_if_fail (mime_type != NULL, FALSE); g_return_val_if_fail (GEXIV2_IS_METADATA (metadata), FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE); @@ -590,8 +590,8 @@ gimp_image_metadata_save_finish (gint32 image_ID, #define EXIF_THUMBNAIL_SIZE 256 - image_width = gimp_image_width (image_ID); - image_height = gimp_image_height (image_ID); + image_width = gimp_image_width (image); + image_height = gimp_image_height (image); if (image_width > image_height) { @@ -604,7 +604,7 @@ gimp_image_metadata_save_finish (gint32 image_ID, thumbw = EXIF_THUMBNAIL_SIZE * image_width / image_height; } - thumb_pixbuf = gimp_image_get_thumbnail (image_ID, thumbw, thumbh, + thumb_pixbuf = gimp_image_get_thumbnail (image, thumbw, thumbh, GIMP_PIXBUF_KEEP_ALPHA); if (gdk_pixbuf_save_to_buffer (thumb_pixbuf, &thumb_buffer, &count, @@ -659,7 +659,16 @@ gimp_image_metadata_save_finish (gint32 image_ID, return success; } -gint32 +/** + * gimp_image_metadata_load_thumbnail: + * @file: A #GFile image + * @error: Return location for error message + * + * Retrieves a thumbnail from metadata if present. + * + * Returns: (transfer full) (nullable): a #GimpImage of the @file thumbnail. + */ +GimpImage * gimp_image_metadata_load_thumbnail (GFile *file, GError **error) { @@ -668,21 +677,21 @@ gimp_image_metadata_load_thumbnail (GFile *file, GdkPixbuf *pixbuf; guint8 *thumbnail_buffer; gint thumbnail_size; - gint32 image_ID = -1; + GimpImage *image = NULL; - g_return_val_if_fail (G_IS_FILE (file), -1); - g_return_val_if_fail (error == NULL || *error == NULL, -1); + g_return_val_if_fail (G_IS_FILE (file), NULL); + g_return_val_if_fail (error == NULL || *error == NULL, NULL); metadata = gimp_metadata_load_from_file (file, error); if (! metadata) - return -1; + return NULL; if (! gexiv2_metadata_get_exif_thumbnail (GEXIV2_METADATA (metadata), &thumbnail_buffer, &thumbnail_size)) { g_object_unref (metadata); - return -1; + return NULL; } input_stream = g_memory_input_stream_new_from_data (thumbnail_buffer, @@ -695,34 +704,34 @@ gimp_image_metadata_load_thumbnail (GFile *file, { gint32 layer_ID; - image_ID = gimp_image_new (gdk_pixbuf_get_width (pixbuf), + image = gimp_image_new (gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), GIMP_RGB); - gimp_image_undo_disable (image_ID); + gimp_image_undo_disable (image); - layer_ID = gimp_layer_new_from_pixbuf (image_ID, _("Background"), + layer_ID = gimp_layer_new_from_pixbuf (image, _("Background"), pixbuf, 100.0, - gimp_image_get_default_new_layer_mode (image_ID), + gimp_image_get_default_new_layer_mode (image), 0.0, 0.0); g_object_unref (pixbuf); - gimp_image_insert_layer (image_ID, layer_ID, -1, 0); + gimp_image_insert_layer (image, layer_ID, -1, 0); - gimp_image_metadata_rotate (image_ID, + gimp_image_metadata_rotate (image, gexiv2_metadata_get_orientation (GEXIV2_METADATA (metadata))); } g_object_unref (metadata); - return image_ID; + return image; } /* private functions */ static void -gimp_image_metadata_rotate (gint32 image_ID, +gimp_image_metadata_rotate (GimpImage *image, GExiv2Orientation orientation) { switch (orientation) @@ -732,33 +741,33 @@ gimp_image_metadata_rotate (gint32 image_ID, break; case GEXIV2_ORIENTATION_HFLIP: - gimp_image_flip (image_ID, GIMP_ORIENTATION_HORIZONTAL); + gimp_image_flip (image, GIMP_ORIENTATION_HORIZONTAL); break; case GEXIV2_ORIENTATION_ROT_180: - gimp_image_rotate (image_ID, GIMP_ROTATE_180); + gimp_image_rotate (image, GIMP_ROTATE_180); break; case GEXIV2_ORIENTATION_VFLIP: - gimp_image_flip (image_ID, GIMP_ORIENTATION_VERTICAL); + gimp_image_flip (image, GIMP_ORIENTATION_VERTICAL); break; case GEXIV2_ORIENTATION_ROT_90_HFLIP: /* flipped diagonally around '\' */ - gimp_image_rotate (image_ID, GIMP_ROTATE_90); - gimp_image_flip (image_ID, GIMP_ORIENTATION_HORIZONTAL); + gimp_image_rotate (image, GIMP_ROTATE_90); + gimp_image_flip (image, GIMP_ORIENTATION_HORIZONTAL); break; case GEXIV2_ORIENTATION_ROT_90: /* 90 CW */ - gimp_image_rotate (image_ID, GIMP_ROTATE_90); + gimp_image_rotate (image, GIMP_ROTATE_90); break; case GEXIV2_ORIENTATION_ROT_90_VFLIP: /* flipped diagonally around '/' */ - gimp_image_rotate (image_ID, GIMP_ROTATE_90); - gimp_image_flip (image_ID, GIMP_ORIENTATION_VERTICAL); + gimp_image_rotate (image, GIMP_ROTATE_90); + gimp_image_flip (image, GIMP_ORIENTATION_VERTICAL); break; case GEXIV2_ORIENTATION_ROT_270: /* 90 CCW */ - gimp_image_rotate (image_ID, GIMP_ROTATE_270); + gimp_image_rotate (image, GIMP_ROTATE_270); break; default: /* shouldn't happen */ @@ -820,7 +829,7 @@ gimp_image_metadata_rotate_pixbuf (GdkPixbuf *pixbuf, } static void -gimp_image_metadata_rotate_query (gint32 image_ID, +gimp_image_metadata_rotate_query (GimpImage *image, const gchar *mime_type, GimpMetadata *metadata, gboolean interactive) @@ -858,7 +867,7 @@ gimp_image_metadata_rotate_query (gint32 image_ID, gimp_parasite_free (parasite); } - if (query && ! gimp_image_metadata_rotate_dialog (image_ID, + if (query && ! gimp_image_metadata_rotate_dialog (image, orientation, parasite_name)) { @@ -868,13 +877,13 @@ gimp_image_metadata_rotate_query (gint32 image_ID, g_free (parasite_name); - gimp_image_metadata_rotate (image_ID, orientation); + gimp_image_metadata_rotate (image, orientation); gexiv2_metadata_set_orientation (GEXIV2_METADATA (metadata), GEXIV2_ORIENTATION_NORMAL); } static gboolean -gimp_image_metadata_rotate_dialog (gint32 image_ID, +gimp_image_metadata_rotate_dialog (GimpImage *image, GExiv2Orientation orientation, const gchar *parasite_name) { @@ -888,7 +897,7 @@ gimp_image_metadata_rotate_dialog (gint32 image_ID, gchar *title; gint response; - name = gimp_image_get_name (image_ID); + name = gimp_image_get_name (image); title = g_strdup_printf (_("Rotate %s?"), name); g_free (name); @@ -918,7 +927,7 @@ gimp_image_metadata_rotate_dialog (gint32 image_ID, #define THUMBNAIL_SIZE 128 - pixbuf = gimp_image_get_thumbnail (image_ID, + pixbuf = gimp_image_get_thumbnail (image, THUMBNAIL_SIZE, THUMBNAIL_SIZE, GIMP_PIXBUF_SMALL_CHECKS); diff --git a/libgimp/gimpimagemetadata.h b/libgimp/gimpimagemetadata.h index e8de269240..2445716119 100644 --- a/libgimp/gimpimagemetadata.h +++ b/libgimp/gimpimagemetadata.h @@ -30,20 +30,20 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -GimpMetadata * gimp_image_metadata_load_prepare (gint32 image_ID, +GimpMetadata * gimp_image_metadata_load_prepare (GimpImage *image, const gchar *mime_type, GFile *file, GError **error); -void gimp_image_metadata_load_finish (gint32 image_ID, +void gimp_image_metadata_load_finish (GimpImage *image, const gchar *mime_type, GimpMetadata *metadata, GimpMetadataLoadFlags flags, gboolean interactive); -GimpMetadata * gimp_image_metadata_save_prepare (gint32 image_ID, +GimpMetadata * gimp_image_metadata_save_prepare (GimpImage *image, const gchar *mime_type, GimpMetadataSaveFlags *suggested_flags); -gboolean gimp_image_metadata_save_finish (gint32 image_ID, +gboolean gimp_image_metadata_save_finish (GimpImage *image, const gchar *mime_type, GimpMetadata *metadata, GimpMetadataSaveFlags flags, @@ -53,7 +53,7 @@ gboolean gimp_image_metadata_save_finish (gint32 image_ID /* this is experimental API, to be finished for 2.10 */ -gint32 gimp_image_metadata_load_thumbnail (GFile *file, +GimpImage * gimp_image_metadata_load_thumbnail (GFile *file, GError **error); G_END_DECLS diff --git a/libgimp/gimpitemcombobox.c b/libgimp/gimpitemcombobox.c index 4c2993323c..413ceb54f7 100644 --- a/libgimp/gimpitemcombobox.c +++ b/libgimp/gimpitemcombobox.c @@ -116,7 +116,7 @@ static GtkWidget * gimp_item_combo_box_new (GType type, static void gimp_item_combo_box_populate (GimpIntComboBox *combo_box); static void gimp_item_combo_box_model_add (GimpIntComboBox *combo_box, GtkListStore *store, - gint32 image, + GimpImage *image, gint num_items, gint32 *items, gint tree_level); @@ -397,37 +397,39 @@ gimp_item_combo_box_populate (GimpIntComboBox *combo_box) for (i = 0; i < num_images; i++) { - gint32 *items; - gint num_items; + GimpImage *image; + gint32 *items; + gint num_items; + + image = g_object_new (GIMP_TYPE_IMAGE, "id", images[i], NULL); if (GIMP_IS_DRAWABLE_COMBO_BOX (combo_box) || GIMP_IS_LAYER_COMBO_BOX (combo_box)) { - items = gimp_image_get_layers (images[i], &num_items); + items = gimp_image_get_layers (image, &num_items); gimp_item_combo_box_model_add (combo_box, GTK_LIST_STORE (model), - images[i], - num_items, items, 0); + image, num_items, items, 0); g_free (items); } if (GIMP_IS_DRAWABLE_COMBO_BOX (combo_box) || GIMP_IS_CHANNEL_COMBO_BOX (combo_box)) { - items = gimp_image_get_channels (images[i], &num_items); + items = gimp_image_get_channels (image, &num_items); gimp_item_combo_box_model_add (combo_box, GTK_LIST_STORE (model), - images[i], - num_items, items, 0); + image, num_items, items, 0); g_free (items); } if (GIMP_IS_VECTORS_COMBO_BOX (combo_box)) { - items = gimp_image_get_vectors (images[i], &num_items); + items = gimp_image_get_vectors (image, &num_items); gimp_item_combo_box_model_add (combo_box, GTK_LIST_STORE (model), - images[i], - num_items, items, 0); + image, num_items, items, 0); g_free (items); } + + g_object_unref (image); } g_free (images); @@ -439,7 +441,7 @@ gimp_item_combo_box_populate (GimpIntComboBox *combo_box) static void gimp_item_combo_box_model_add (GimpIntComboBox *combo_box, GtkListStore *store, - gint32 image, + GimpImage *image, gint num_items, gint32 *items, gint tree_level) @@ -472,7 +474,8 @@ gimp_item_combo_box_model_add (GimpIntComboBox *combo_box, GdkPixbuf *thumb; label = g_strdup_printf ("%s%s-%d / %s-%d", - indent, image_name, image, + indent, image_name, + gimp_image_get_id (image), item_name, items[i]); g_free (item_name); diff --git a/libgimp/gimpitemcombobox.h b/libgimp/gimpitemcombobox.h index 1949a91df8..013179f9b1 100644 --- a/libgimp/gimpitemcombobox.h +++ b/libgimp/gimpitemcombobox.h @@ -49,9 +49,9 @@ G_BEGIN_DECLS #define GIMP_IS_VECTORS_COMBO_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_VECTORS_COMBO_BOX)) -typedef gboolean (* GimpItemConstraintFunc) (gint32 image_id, - gint32 item_id, - gpointer data); +typedef gboolean (* GimpItemConstraintFunc) (GimpImage *image, + gint32 item_id, + gpointer data); GType gimp_drawable_combo_box_get_type (void) G_GNUC_CONST; diff --git a/libgimp/gimplayer.c b/libgimp/gimplayer.c index 7c6ce1e5a6..64f8b41a5d 100644 --- a/libgimp/gimplayer.c +++ b/libgimp/gimplayer.c @@ -27,13 +27,13 @@ /** * gimp_layer_new: - * @image_ID: The image to which to add the layer. - * @name: The layer name. - * @width: The layer width. - * @height: The layer height. - * @type: The layer type. + * @image: The image to which to add the layer. + * @name: The layer name. + * @width: The layer width. + * @height: The layer height. + * @type: The layer type. * @opacity: The layer opacity. - * @mode: The layer combination mode. + * @mode: The layer combination mode. * * Create a new layer. * @@ -47,7 +47,7 @@ * Returns: The newly created layer. */ gint32 -gimp_layer_new (gint32 image_ID, +gimp_layer_new (GimpImage *image, const gchar *name, gint width, gint height, @@ -55,7 +55,7 @@ gimp_layer_new (gint32 image_ID, gdouble opacity, GimpLayerMode mode) { - return _gimp_layer_new (image_ID, + return _gimp_layer_new (image, width, height, type, @@ -84,7 +84,7 @@ gimp_layer_copy (gint32 layer_ID) /** * gimp_layer_new_from_pixbuf: - * @image_ID: The RGB image to which to add the layer. + * @image: The RGB image to which to add the layer. * @name: The layer name. * @pixbuf: A GdkPixbuf. * @opacity: The layer opacity. @@ -107,7 +107,7 @@ gimp_layer_copy (gint32 layer_ID) * Since: 2.4 */ gint32 -gimp_layer_new_from_pixbuf (gint32 image_ID, +gimp_layer_new_from_pixbuf (GimpImage *image, const gchar *name, GdkPixbuf *pixbuf, gdouble opacity, @@ -124,7 +124,7 @@ gimp_layer_new_from_pixbuf (gint32 image_ID, g_return_val_if_fail (GDK_IS_PIXBUF (pixbuf), -1); - if (gimp_image_base_type (image_ID) != GIMP_RGB) + if (gimp_image_base_type (image) != GIMP_RGB) { g_warning ("gimp_layer_new_from_pixbuf() needs an RGB image"); return -1; @@ -140,7 +140,7 @@ gimp_layer_new_from_pixbuf (gint32 image_ID, height = gdk_pixbuf_get_height (pixbuf); bpp = gdk_pixbuf_get_n_channels (pixbuf); - layer = gimp_layer_new (image_ID, name, width, height, + layer = gimp_layer_new (image, name, width, height, bpp == 3 ? GIMP_RGB_IMAGE : GIMP_RGBA_IMAGE, opacity, mode); @@ -164,7 +164,7 @@ gimp_layer_new_from_pixbuf (gint32 image_ID, /** * gimp_layer_new_from_surface: - * @image_ID: The RGB image to which to add the layer. + * @image: The RGB image to which to add the layer. * @name: The layer name. * @surface: A Cairo image surface. * @progress_start: start of progress @@ -185,7 +185,7 @@ gimp_layer_new_from_pixbuf (gint32 image_ID, * Since: 2.8 */ gint32 -gimp_layer_new_from_surface (gint32 image_ID, +gimp_layer_new_from_surface (GimpImage *image, const gchar *name, cairo_surface_t *surface, gdouble progress_start, @@ -203,7 +203,7 @@ gimp_layer_new_from_surface (gint32 image_ID, g_return_val_if_fail (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_IMAGE, -1); - if (gimp_image_base_type (image_ID) != GIMP_RGB) + if (gimp_image_base_type (image) != GIMP_RGB) { g_warning ("gimp_layer_new_from_surface() needs an RGB image"); return -1; @@ -220,11 +220,11 @@ gimp_layer_new_from_surface (gint32 image_ID, return -1; } - layer = gimp_layer_new (image_ID, name, width, height, + layer = gimp_layer_new (image, name, width, height, format == CAIRO_FORMAT_RGB24 ? GIMP_RGB_IMAGE : GIMP_RGBA_IMAGE, 100.0, - gimp_image_get_default_new_layer_mode (image_ID)); + gimp_image_get_default_new_layer_mode (image)); if (layer == -1) return -1; diff --git a/libgimp/gimplayer.h b/libgimp/gimplayer.h index f620685a9a..df3e6059c4 100644 --- a/libgimp/gimplayer.h +++ b/libgimp/gimplayer.h @@ -30,7 +30,7 @@ G_BEGIN_DECLS /* For information look into the C source or the html documentation */ -gint32 gimp_layer_new (gint32 image_ID, +gint32 gimp_layer_new (GimpImage *image, const gchar *name, gint width, gint height, @@ -39,14 +39,14 @@ gint32 gimp_layer_new (gint32 image_ID, GimpLayerMode mode); gint32 gimp_layer_copy (gint32 layer_ID); -gint32 gimp_layer_new_from_pixbuf (gint32 image_ID, +gint32 gimp_layer_new_from_pixbuf (GimpImage *image, const gchar *name, GdkPixbuf *pixbuf, gdouble opacity, GimpLayerMode mode, gdouble progress_start, gdouble progress_end); -gint32 gimp_layer_new_from_surface (gint32 image_ID, +gint32 gimp_layer_new_from_surface (GimpImage *image, const gchar *name, cairo_surface_t *surface, gdouble progress_start, diff --git a/libgimp/gimpparamspecs.c b/libgimp/gimpparamspecs.c index 5b5f7b25a3..63a4239f50 100644 --- a/libgimp/gimpparamspecs.c +++ b/libgimp/gimpparamspecs.c @@ -116,16 +116,20 @@ gimp_param_image_id_validate (GParamSpec *pspec, GValue *value) { GimpParamSpecImageID *ispec = GIMP_PARAM_SPEC_IMAGE_ID (pspec); + GimpImage *image; gint image_id = value->data[0].v_int; if (ispec->none_ok && (image_id == 0 || image_id == -1)) return FALSE; - if (! gimp_image_is_valid (image_id)) + image = g_object_new (GIMP_TYPE_IMAGE, "id", image_id, NULL); + if (! gimp_image_is_valid (image)) { value->data[0].v_int = -1; + g_object_unref (image); return TRUE; } + g_object_unref (image); return FALSE; } diff --git a/libgimp/gimpzoompreview.c b/libgimp/gimpzoompreview.c index 536156c34f..8dcae1f7a8 100644 --- a/libgimp/gimpzoompreview.c +++ b/libgimp/gimpzoompreview.c @@ -498,14 +498,14 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview, { GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW (preview)->priv; GtkWidget *area = gimp_preview_get_area (preview); + GimpImage *image; gint width; gint height; - gint32 image_ID; gimp_preview_get_size (preview, &width, &height); - image_ID = gimp_item_get_image (priv->drawable_ID); + image = gimp_item_get_image (priv->drawable_ID); - if (gimp_selection_is_empty (image_ID)) + if (gimp_selection_is_empty (image)) { gimp_preview_area_draw (GIMP_PREVIEW_AREA (area), 0, 0, @@ -528,7 +528,7 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview, gint offsx = 0; gint offsy = 0; - selection_ID = gimp_image_get_selection (image_ID); + selection_ID = gimp_image_get_selection (image); w = width; h = height; @@ -558,6 +558,7 @@ gimp_zoom_preview_draw_buffer (GimpPreview *preview, g_free (src); } + g_object_unref (image); } static void