Commit cdc3f6e7 authored by Sven Neumann's avatar Sven Neumann

more export stuff


--Sven
parent 29d55756
1999-10-04 Sven Neumann <sven@gimp.org>
* app/tool_options.c: backed out a change from last weekend that was
never supposed to get into CVS
* libgimp/gimpexport.[ch]: added a third button.
Now "Export" performs the conversion, "Ignore" skips it and continues
and "Cancel" cancels the save.
* plug-ins/bmp/bmp.c
* plug-ins/common/gif.c
* plug-ins/common/jpeg.c
* plug-ins/common/png.c
* plug-ins/common/ps.c
* plug-ins/common/tiff.c
* plug-ins/print/print.c: sync with the new interface.
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/tga.c
* plug-ins/common/xpm.c: two more save plug-ins that know about export.
* plug-ins/script-fu/script-fu.c: include script-fu-constants.h
1999-10-03 Olof S Kylander <olof@frozenriver.com>
* app/airbrush_blob.c
......
......@@ -846,7 +846,7 @@ paint_pressure_options_new (ToolType tool_type)
case DODGEBURN:
case SMUDGE:
case ERASER:
/* case PAINTBRUSH: */
case PAINTBRUSH:
pressure->pressure_w =
gtk_check_button_new_with_label (_("Pressure"));
gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w);
......
......@@ -846,7 +846,7 @@ paint_pressure_options_new (ToolType tool_type)
case DODGEBURN:
case SMUDGE:
case ERASER:
/* case PAINTBRUSH: */
case PAINTBRUSH:
pressure->pressure_w =
gtk_check_button_new_with_label (_("Pressure"));
gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w);
......
......@@ -846,7 +846,7 @@ paint_pressure_options_new (ToolType tool_type)
case DODGEBURN:
case SMUDGE:
case ERASER:
/* case PAINTBRUSH: */
case PAINTBRUSH:
pressure->pressure_w =
gtk_check_button_new_with_label (_("Pressure"));
gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w);
......
......@@ -167,22 +167,30 @@ static ExportAction export_action_convert_indexed_or_grayscale =
/* dialog functions */
static GtkWidget *dialog = NULL;
static gboolean dialog_return = FALSE;
static GtkWidget *dialog = NULL;
static GimpExportReturnType dialog_return = EXPORT_CANCEL;
static void
export_export_callback (GtkWidget *widget,
gpointer data)
{
gtk_widget_destroy (dialog);
dialog_return = TRUE;
dialog_return = EXPORT_EXPORT;
}
static void
export_skip_callback (GtkWidget *widget,
gpointer data)
{
gtk_widget_destroy (dialog);
dialog_return = EXPORT_IGNORE;
}
static void
export_cancel_callback (GtkWidget *widget,
gpointer data)
{
dialog_return = FALSE;
dialog_return = EXPORT_CANCEL;
dialog = NULL;
gtk_main_quit ();
}
......@@ -212,8 +220,8 @@ export_dialog (GList *actions,
gchar *text;
ExportAction *action;
dialog_return = FALSE;
g_return_val_if_fail (actions != NULL && format != NULL, FALSE);
dialog_return = EXPORT_CANCEL;
g_return_val_if_fail (actions != NULL && format != NULL, dialog_return);
/*
* Plug-ins have called gtk_init () before calling gimp_export ().
......@@ -246,6 +254,13 @@ export_dialog (GList *actions,
gtk_widget_grab_default (button);
gtk_widget_show (button);
button = gtk_button_new_with_label (_("Ignore"));
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) export_skip_callback, NULL);
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
gtk_widget_show (button);
button = gtk_button_new_with_label (_("Cancel"));
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
......@@ -314,7 +329,7 @@ export_dialog (GList *actions,
}
/* the footline */
label = gtk_label_new (_("The export conversion won't modify your image."));
label = gtk_label_new (_("The export conversion won't modify your original image."));
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE, TRUE, 4);
gtk_widget_show (label);
......@@ -325,7 +340,7 @@ export_dialog (GList *actions,
}
gboolean
GimpExportReturnType
gimp_export_image (gint32 *image_ID_ptr,
gint32 *drawable_ID_ptr,
gchar *format,
......@@ -403,7 +418,7 @@ gimp_export_image (gint32 *image_ID_ptr,
if (actions)
dialog_return = export_dialog (actions, format);
if (dialog_return)
if (dialog_return == EXPORT_EXPORT)
{
*image_ID_ptr = gimp_image_duplicate (*image_ID_ptr);
*drawable_ID_ptr = gimp_image_get_active_layer (*image_ID_ptr);
......@@ -416,10 +431,9 @@ gimp_export_image (gint32 *image_ID_ptr,
else if (action->choice == 1 && action->alt_action)
action->alt_action (*image_ID_ptr, drawable_ID_ptr);
}
return (TRUE);
}
return (FALSE);
return (dialog_return);
}
......
......@@ -29,13 +29,17 @@
#define CAN_HANDLE_LAYERS 1 << 4
#define CAN_HANDLE_LAYERS_AS_ANIMATION 1 << 5
gboolean gimp_export_image (gint32*, /* image_ID */
gint32*, /* drawable_ID */
gchar*, /* format name */
gint); /* plug_in_capabilities */
typedef enum
{
EXPORT_CANCEL,
EXPORT_IGNORE,
EXPORT_EXPORT
} GimpExportReturnType;
GimpExportReturnType gimp_export_image (gint32*, /* image_ID */
gint32*, /* drawable_ID */
gchar*, /* format name */
gint); /* plug_in_capabilities */
#endif
......
......@@ -143,7 +143,7 @@ run (char *name,
GRunModeType run_mode;
gint32 image_ID;
gint32 drawable_ID;
gboolean export = FALSE;
GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32;
......@@ -202,6 +202,12 @@ run (char *name,
init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "BMP",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED));
if (export == EXPORT_CANCEL)
{
*nreturn_vals = 1;
values[0].data.d_status = STATUS_EXECUTION_ERROR;
return;
}
break;
default:
break;
......@@ -236,7 +242,7 @@ run (char *name,
else
values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export)
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
}
}
......
......@@ -999,6 +999,7 @@ tga_SOURCES = \
tga.c
tga_LDADD = \
$(top_builddir)/libgimp/libgimpui.la \
$(top_builddir)/libgimp/libgimp.la \
$(GTK_LIBS) \
$(INTLLIBS)
......@@ -1131,6 +1132,7 @@ xpm_SOURCES = \
xpm.c
xpm_LDADD = \
$(top_builddir)/libgimp/libgimpui.la \
$(top_builddir)/libgimp/libgimp.la \
$(LIBXPM) \
$(GTK_LIBS) \
......
......@@ -420,7 +420,7 @@ run (char *name,
gint32 image_ID;
gint32 drawable_ID;
gint32 orig_image_ID;
gboolean export = FALSE;
GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32;
......@@ -445,6 +445,12 @@ run (char *name,
export = gimp_export_image (&image_ID, &drawable_ID, "GIF",
(CAN_HANDLE_INDEXED | CAN_HANDLE_GRAY |
CAN_HANDLE_ALPHA | CAN_HANDLE_LAYERS_AS_ANIMATION));
if (export == EXPORT_CANCEL)
{
*nreturn_vals = 1;
values[0].data.d_status = STATUS_EXECUTION_ERROR;
return;
}
break;
default:
break;
......@@ -527,7 +533,7 @@ run (char *name,
values[0].data.d_status = STATUS_EXECUTION_ERROR;
}
if (export)
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
}
}
......
......@@ -357,7 +357,7 @@ run (char *name,
Parasite *parasite;
#endif /* GIMP_HAVE_PARASITES */
int err;
gboolean export = FALSE;
GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32;
......@@ -399,10 +399,19 @@ run (char *name,
init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
if (export)
switch (export)
{
case EXPORT_EXPORT:
display_ID = gimp_display_new (image_ID);
gimp_displays_flush ();
break;
case EXPORT_IGNORE:
break;
case EXPORT_CANCEL:
*nreturn_vals = 1;
values[0].data.d_status = STATUS_EXECUTION_ERROR;
return;
break;
}
break;
default:
......@@ -475,7 +484,7 @@ run (char *name,
/* First acquire information with a dialog */
err = save_dialog ();
if (!export)
if (export != EXPORT_EXPORT)
{
/* thaw undo saving and end the undo_group. */
gimp_image_thaw_undo (image_ID);
......@@ -565,10 +574,10 @@ run (char *name,
else
values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export)
if (export == EXPORT_EXPORT)
{
/* if the image was exported, delete the new display */
/* according to the documentation, this should also delete the image */
/* If the image was exported, delete the new display. */
/* This also deletes the image. */
if (display_ID > -1)
gimp_display_delete (display_ID);
......@@ -591,7 +600,7 @@ run (char *name,
image_comment);
gimp_image_attach_parasite (orig_image_ID, parasite);
parasite_free (parasite);
}
}
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);
......
......@@ -101,7 +101,7 @@
'spheredesigner' => { libdep => 'gtk' },
'spread' => { libdep => 'gtk' },
'sunras' => { libdep => 'gtk' },
'tga' => { libdep => 'gtk' },
'tga' => { libdep => 'gtk', ui => 1 },
'threshold_alpha' => { libdep => 'gtk' },
'tiff' => { libdep => 'gtk', ui => 1, optional => 1 },
'tile' => { libdep => 'gtk' },
......@@ -117,7 +117,7 @@
'wind' => { libdep => 'gtk' },
'wmf' => { libdep => 'gtk' },
'xbm' => { libdep => 'gtk' },
'xpm' => { libdep => 'gtk', optional => 1 },
'xpm' => { libdep => 'gtk', ui => 1, optional => 1 },
'xwd' => { libdep => 'glib' },
'zealouscrop' => { libdep => 'glib' }
);
......
......@@ -185,8 +185,7 @@ run (char *name, /* I - Name of filter program. */
gint32 orig_image_ID;
GRunModeType run_mode;
GParam *values; /* Return values */
gboolean export = FALSE;
GimpExportReturnType export = EXPORT_CANCEL;
/*
* Initialize parameter data...
......@@ -236,6 +235,12 @@ run (char *name, /* I - Name of filter program. */
init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "PNG",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED | CAN_HANDLE_ALPHA));
if (export == EXPORT_CANCEL)
{
*nreturn_vals = 1;
values[0].data.d_status = STATUS_EXECUTION_ERROR;
return;
}
break;
default:
break;
......@@ -298,7 +303,7 @@ run (char *name, /* I - Name of filter program. */
else
values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export)
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
}
......
......@@ -42,9 +42,9 @@
* Ghostview may hang when displaying the files.
* V 1.07, PK, 14-Sep-99: Add resolution to image
*/
#define VERSIO 1.07
static char dversio[] = "v1.07 14-Sep-99";
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.07 14-Sep-99";
#define VERSIO 1.07
static char dversio[] = "v1.07 14-Sep-99";
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.07 14-Sep-99";
#include "config.h"
#include <stdio.h>
......@@ -409,7 +409,7 @@ run (char *name,
gint32 image_ID = -1;
gint32 drawable_ID = -1;
gint32 orig_image_ID = -1;
gboolean export = FALSE;
GimpExportReturnType export = EXPORT_CANCEL;
int k;
l_run_mode = run_mode = param[0].data.d_int32;
......@@ -481,6 +481,12 @@ run (char *name,
init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "PS",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED));
if (export == EXPORT_CANCEL)
{
*nreturn_vals = 1;
values[0].data.d_status = STATUS_EXECUTION_ERROR;
return;
}
break;
default:
break;
......@@ -543,17 +549,17 @@ run (char *name,
#endif
check_save_vals ();
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
{
/* Store psvals data */
gimp_set_data ("file_ps_save", &psvals, sizeof (PSSaveVals));
}
{
/* Store psvals data */
gimp_set_data ("file_ps_save", &psvals, sizeof (PSSaveVals));
}
else
{
status = STATUS_EXECUTION_ERROR;
}
}
if (export)
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
values[0].data.d_status = status;
......
......@@ -42,9 +42,9 @@
* Ghostview may hang when displaying the files.
* V 1.07, PK, 14-Sep-99: Add resolution to image
*/
#define VERSIO 1.07
static char dversio[] = "v1.07 14-Sep-99";
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.07 14-Sep-99";
#define VERSIO 1.07
static char dversio[] = "v1.07 14-Sep-99";
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.07 14-Sep-99";
#include "config.h"
#include <stdio.h>
......@@ -409,7 +409,7 @@ run (char *name,
gint32 image_ID = -1;
gint32 drawable_ID = -1;
gint32 orig_image_ID = -1;
gboolean export = FALSE;
GimpExportReturnType export = EXPORT_CANCEL;
int k;
l_run_mode = run_mode = param[0].data.d_int32;
......@@ -481,6 +481,12 @@ run (char *name,
init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "PS",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED));
if (export == EXPORT_CANCEL)
{
*nreturn_vals = 1;
values[0].data.d_status = STATUS_EXECUTION_ERROR;
return;
}
break;
default:
break;
......@@ -543,17 +549,17 @@ run (char *name,
#endif
check_save_vals ();
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
{
/* Store psvals data */
gimp_set_data ("file_ps_save", &psvals, sizeof (PSSaveVals));
}
{
/* Store psvals data */
gimp_set_data ("file_ps_save", &psvals, sizeof (PSSaveVals));
}
else
{
status = STATUS_EXECUTION_ERROR;
}
}
if (export)
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
values[0].data.d_status = status;
......
......@@ -82,6 +82,7 @@
#endif
#include <gtk/gtk.h>
#include "libgimp/gimp.h"
#include "libgimp/gimpui.h"
/* Round up a division to the nearest integer. */
#define ROUNDUP_DIVIDE(n,d) (((n) + (d - 1)) / (d))
......@@ -112,12 +113,12 @@ struct tga_header
guint8 colorMapType;
/* The image type. */
#define TGA_TYPE_MAPPED 1
#define TGA_TYPE_COLOR 2
#define TGA_TYPE_GRAY 3
#define TGA_TYPE_MAPPED_RLE 9
#define TGA_TYPE_COLOR_RLE 10
#define TGA_TYPE_GRAY_RLE 11
#define TGA_TYPE_MAPPED 1
#define TGA_TYPE_COLOR 2
#define TGA_TYPE_GRAY 3
#define TGA_TYPE_MAPPED_RLE 9
#define TGA_TYPE_COLOR_RLE 10
#define TGA_TYPE_GRAY_RLE 11
guint8 imageType;
/* Color Map Specification. */
......@@ -142,9 +143,9 @@ struct tga_header
5: top-to-bottom ordering
7-6: zero
*/
#define TGA_DESC_ABITS 0x0f
#define TGA_DESC_ABITS 0x0f
#define TGA_DESC_HORIZONTAL 0x10
#define TGA_DESC_VERTICAL 0x20
#define TGA_DESC_VERTICAL 0x20
guint8 descriptor;
};
......@@ -161,19 +162,20 @@ static struct
/* Declare some local functions.
*/
static void query (void);
static void run (char *name,
int nparams,
GParam *param,
int *nreturn_vals,
GParam **return_vals);
static gint32 load_image (char *filename);
static gint save_image (char *filename,
gint32 image_ID,
gint32 drawable_ID);
static gint save_dialog ();
static void query (void);
static void run (char *name,
int nparams,
GParam *param,
int *nreturn_vals,
GParam **return_vals);
static gint32 load_image (char *filename);
static gint save_image (char *filename,
gint32 image_ID,
gint32 drawable_ID);
static void init_gtk (void);
static gint save_dialog (void);
static void save_close_callback (GtkWidget *widget,
gpointer data);
static void save_ok_callback (GtkWidget *widget,
......@@ -266,6 +268,8 @@ run (char *name,
GStatusType status = STATUS_SUCCESS;
GRunModeType run_mode;
gint32 image_ID;
gint32 drawable_ID;
GimpExportReturnType export = EXPORT_CANCEL;
#ifdef PROFILE
struct tms tbuf1, tbuf2;
......@@ -304,6 +308,30 @@ run (char *name,
}
else if (strcmp (name, "file_tga_save") == 0)
{
init_gtk ();
image_ID = param[1].data.d_int32;
drawable_ID = param[1].data.d_int32;
/* eventually export the image */
switch (run_mode)
{
case RUN_INTERACTIVE:
case RUN_WITH_LAST_VALS:
export = gimp_export_image (&image_ID, &drawable_ID, "TGA",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED |
CAN_HANDLE_ALPHA));
if (export == EXPORT_CANCEL)
{
*nreturn_vals = 1;
values[0].data.d_status = STATUS_EXECUTION_ERROR;
return;
}
break;
default:
break;
}
switch (run_mode)
{
case RUN_INTERACTIVE:
......@@ -339,7 +367,7 @@ run (char *name,
times (&tbuf1);
#endif
*nreturn_vals = 1;
if (save_image (param[3].data.d_string, param[1].data.d_int32, param[2].data.d_int32))
if (save_image (param[3].data.d_string, image_ID, drawable_ID))
{
/* Store psvals data */
gimp_set_data ("file_tga_save", &tsvals, sizeof (tsvals));
......@@ -348,6 +376,9 @@ run (char *name,
}
else
values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
}
#ifdef PROFILE
......@@ -424,7 +455,10 @@ static int totbytes = 0;
#endif
static int
std_fread (guchar *buf, int datasize, int nelems, FILE *fp)
std_fread (guchar *buf,
int datasize,
int nelems,
FILE *fp)
{
#ifdef VERBOSE
if (verbose > 1)
......@@ -439,7 +473,10 @@ std_fread (guchar *buf, int datasize, int nelems, FILE *fp)
}
static int