[gimp/export-dialog-cleanup-tmp: 1/3] libgimp: Add gimp_export_prepare_image()
- From: Martin Nordholts <martinn src gnome org>
- To: svn-commits-list gnome org
- Subject: [gimp/export-dialog-cleanup-tmp: 1/3] libgimp: Add gimp_export_prepare_image()
- Date: Wed, 15 Jul 2009 10:49:53 +0000 (UTC)
commit caa40e618d662363f7721992a1df96ad54aff7ac
Author: Martin Nordholts <martinn src gnome org>
Date: Wed Jul 15 10:44:46 2009 +0200
libgimp: Add gimp_export_prepare_image()
Add gimp_export_prepare_image() which is identical to
gimp_export_image() but without the dialogs, it always does an export
if necessary.
libgimp/gimpexport.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++-
libgimp/gimpexport.h | 12 ++++++---
2 files changed, 67 insertions(+), 6 deletions(-)
---
diff --git a/libgimp/gimpexport.c b/libgimp/gimpexport.c
index 78723c1..218b52f 100644
--- a/libgimp/gimpexport.c
+++ b/libgimp/gimpexport.c
@@ -35,6 +35,14 @@ typedef void (* ExportFunc) (gint32 imageID,
gint32 *drawable_ID);
+static GimpExportReturn gimp_export_image_internal (gint32 *image_ID,
+ gint32 *drawable_ID,
+ const gchar *format_name,
+ GimpExportCapabilities capabilities,
+ gboolean ask_questions);
+
+
+
/* the export action structure */
typedef struct
{
@@ -665,6 +673,54 @@ gimp_export_image (gint32 *image_ID,
const gchar *format_name,
GimpExportCapabilities capabilities)
{
+ return gimp_export_image_internal (image_ID,
+ drawable_ID,
+ format_name,
+ capabilities,
+ TRUE);
+}
+
+/**
+ * gimp_export_prepare_image:
+ * @image_ID: Pointer to the image_ID.
+ * @drawable_ID: Pointer to the drawable_ID.
+ * @capabilities: What can the image_format do?
+ *
+ * Takes an image and a drawable to be saved together with a
+ * description of the capabilities of the image_format. If the type of
+ * image doesn't match the capabilities of the format 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.
+ *
+ * If no converson is done, 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.
+ *
+ * Returns: An enum of #GimpExportReturn describing the action.
+ *
+ * Since: GIMP 2.8
+ **/
+GimpExportReturn
+gimp_export_prepare_image (gint32 *image_ID,
+ gint32 *drawable_ID,
+ GimpExportCapabilities capabilities)
+{
+ return gimp_export_image_internal (image_ID,
+ drawable_ID,
+ NULL,
+ capabilities,
+ FALSE);
+}
+
+static GimpExportReturn
+gimp_export_image_internal (gint32 *image_ID,
+ gint32 *drawable_ID,
+ const gchar *format_name,
+ GimpExportCapabilities capabilities,
+ gboolean ask_questions)
+{
GSList *actions = NULL;
GimpImageBaseType type;
gint32 i;
@@ -691,7 +747,8 @@ gimp_export_image (gint32 *image_ID,
capabilities |= GIMP_EXPORT_CAN_HANDLE_ALPHA;
/* ask for confirmation if the user is not saving a layer (see bug #51114) */
- if (format_name &&
+ if (ask_questions &&
+ format_name &&
! gimp_drawable_is_layer (*drawable_ID) &&
! (capabilities & GIMP_EXPORT_CAN_HANDLE_LAYERS))
{
@@ -895,7 +952,7 @@ gimp_export_image (gint32 *image_ID,
{
actions = g_slist_reverse (actions);
- if (format_name)
+ if (ask_questions && format_name)
retval = export_dialog (actions, format_name);
else
retval = GIMP_EXPORT_EXPORT;
diff --git a/libgimp/gimpexport.h b/libgimp/gimpexport.h
index be3575c..d2dffee 100644
--- a/libgimp/gimpexport.h
+++ b/libgimp/gimpexport.h
@@ -47,10 +47,14 @@ typedef enum
GIMP_EXPORT_EXPORT
} GimpExportReturn;
-GimpExportReturn gimp_export_image (gint32 *image_ID,
- gint32 *drawable_ID,
- const gchar *format_name,
- GimpExportCapabilities capabilities);
+GimpExportReturn gimp_export_image (gint32 *image_ID,
+ gint32 *drawable_ID,
+ const gchar *format_name,
+ GimpExportCapabilities capabilities);
+
+GimpExportReturn gimp_export_prepare_image (gint32 *image_ID,
+ gint32 *drawable_ID,
+ GimpExportCapabilities capabilities);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]