more export stuff

--Sven
This commit is contained in:
Sven Neumann 1999-10-03 23:48:33 +00:00
parent 29d5575655
commit cdc3f6e779
25 changed files with 511 additions and 285 deletions

View file

@ -1,3 +1,27 @@
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> 1999-10-03 Olof S Kylander <olof@frozenriver.com>
* app/airbrush_blob.c * app/airbrush_blob.c

View file

@ -846,7 +846,7 @@ paint_pressure_options_new (ToolType tool_type)
case DODGEBURN: case DODGEBURN:
case SMUDGE: case SMUDGE:
case ERASER: case ERASER:
/* case PAINTBRUSH: */ case PAINTBRUSH:
pressure->pressure_w = pressure->pressure_w =
gtk_check_button_new_with_label (_("Pressure")); gtk_check_button_new_with_label (_("Pressure"));
gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w); gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w);

View file

@ -846,7 +846,7 @@ paint_pressure_options_new (ToolType tool_type)
case DODGEBURN: case DODGEBURN:
case SMUDGE: case SMUDGE:
case ERASER: case ERASER:
/* case PAINTBRUSH: */ case PAINTBRUSH:
pressure->pressure_w = pressure->pressure_w =
gtk_check_button_new_with_label (_("Pressure")); gtk_check_button_new_with_label (_("Pressure"));
gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w); gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w);

View file

@ -846,7 +846,7 @@ paint_pressure_options_new (ToolType tool_type)
case DODGEBURN: case DODGEBURN:
case SMUDGE: case SMUDGE:
case ERASER: case ERASER:
/* case PAINTBRUSH: */ case PAINTBRUSH:
pressure->pressure_w = pressure->pressure_w =
gtk_check_button_new_with_label (_("Pressure")); gtk_check_button_new_with_label (_("Pressure"));
gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w); gtk_container_add (GTK_CONTAINER (hbox), pressure->pressure_w);

View file

@ -167,22 +167,30 @@ static ExportAction export_action_convert_indexed_or_grayscale =
/* dialog functions */ /* dialog functions */
static GtkWidget *dialog = NULL; static GtkWidget *dialog = NULL;
static gboolean dialog_return = FALSE; static GimpExportReturnType dialog_return = EXPORT_CANCEL;
static void static void
export_export_callback (GtkWidget *widget, export_export_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
gtk_widget_destroy (dialog); 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 static void
export_cancel_callback (GtkWidget *widget, export_cancel_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
dialog_return = FALSE; dialog_return = EXPORT_CANCEL;
dialog = NULL; dialog = NULL;
gtk_main_quit (); gtk_main_quit ();
} }
@ -212,8 +220,8 @@ export_dialog (GList *actions,
gchar *text; gchar *text;
ExportAction *action; ExportAction *action;
dialog_return = FALSE; dialog_return = EXPORT_CANCEL;
g_return_val_if_fail (actions != NULL && format != NULL, FALSE); g_return_val_if_fail (actions != NULL && format != NULL, dialog_return);
/* /*
* Plug-ins have called gtk_init () before calling gimp_export (). * 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_grab_default (button);
gtk_widget_show (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")); button = gtk_button_new_with_label (_("Cancel"));
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked", gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
@ -314,7 +329,7 @@ export_dialog (GList *actions,
} }
/* the footline */ /* 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_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE, TRUE, 4);
gtk_widget_show (label); gtk_widget_show (label);
@ -325,7 +340,7 @@ export_dialog (GList *actions,
} }
gboolean GimpExportReturnType
gimp_export_image (gint32 *image_ID_ptr, gimp_export_image (gint32 *image_ID_ptr,
gint32 *drawable_ID_ptr, gint32 *drawable_ID_ptr,
gchar *format, gchar *format,
@ -403,7 +418,7 @@ gimp_export_image (gint32 *image_ID_ptr,
if (actions) if (actions)
dialog_return = export_dialog (actions, format); dialog_return = export_dialog (actions, format);
if (dialog_return) if (dialog_return == EXPORT_EXPORT)
{ {
*image_ID_ptr = gimp_image_duplicate (*image_ID_ptr); *image_ID_ptr = gimp_image_duplicate (*image_ID_ptr);
*drawable_ID_ptr = gimp_image_get_active_layer (*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) else if (action->choice == 1 && action->alt_action)
action->alt_action (*image_ID_ptr, drawable_ID_ptr); action->alt_action (*image_ID_ptr, drawable_ID_ptr);
} }
return (TRUE);
} }
return (FALSE); return (dialog_return);
} }

View file

@ -29,13 +29,17 @@
#define CAN_HANDLE_LAYERS 1 << 4 #define CAN_HANDLE_LAYERS 1 << 4
#define CAN_HANDLE_LAYERS_AS_ANIMATION 1 << 5 #define CAN_HANDLE_LAYERS_AS_ANIMATION 1 << 5
typedef enum
{
EXPORT_CANCEL,
EXPORT_IGNORE,
EXPORT_EXPORT
} GimpExportReturnType;
gboolean gimp_export_image (gint32*, /* image_ID */ GimpExportReturnType gimp_export_image (gint32*, /* image_ID */
gint32*, /* drawable_ID */ gint32*, /* drawable_ID */
gchar*, /* format name */ gchar*, /* format name */
gint); /* plug_in_capabilities */ gint); /* plug_in_capabilities */
#endif #endif

View file

@ -143,7 +143,7 @@ run (char *name,
GRunModeType run_mode; GRunModeType run_mode;
gint32 image_ID; gint32 image_ID;
gint32 drawable_ID; gint32 drawable_ID;
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -202,6 +202,12 @@ run (char *name,
init_gtk (); init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "BMP", export = gimp_export_image (&image_ID, &drawable_ID, "BMP",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED)); (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; break;
default: default:
break; break;
@ -236,7 +242,7 @@ run (char *name,
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export) if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID); gimp_image_delete (image_ID);
} }
} }

View file

@ -999,6 +999,7 @@ tga_SOURCES = \
tga.c tga.c
tga_LDADD = \ tga_LDADD = \
$(top_builddir)/libgimp/libgimpui.la \
$(top_builddir)/libgimp/libgimp.la \ $(top_builddir)/libgimp/libgimp.la \
$(GTK_LIBS) \ $(GTK_LIBS) \
$(INTLLIBS) $(INTLLIBS)
@ -1131,6 +1132,7 @@ xpm_SOURCES = \
xpm.c xpm.c
xpm_LDADD = \ xpm_LDADD = \
$(top_builddir)/libgimp/libgimpui.la \
$(top_builddir)/libgimp/libgimp.la \ $(top_builddir)/libgimp/libgimp.la \
$(LIBXPM) \ $(LIBXPM) \
$(GTK_LIBS) \ $(GTK_LIBS) \

View file

@ -420,7 +420,7 @@ run (char *name,
gint32 image_ID; gint32 image_ID;
gint32 drawable_ID; gint32 drawable_ID;
gint32 orig_image_ID; gint32 orig_image_ID;
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -445,6 +445,12 @@ run (char *name,
export = gimp_export_image (&image_ID, &drawable_ID, "GIF", export = gimp_export_image (&image_ID, &drawable_ID, "GIF",
(CAN_HANDLE_INDEXED | CAN_HANDLE_GRAY | (CAN_HANDLE_INDEXED | CAN_HANDLE_GRAY |
CAN_HANDLE_ALPHA | CAN_HANDLE_LAYERS_AS_ANIMATION)); 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; break;
default: default:
break; break;
@ -527,7 +533,7 @@ run (char *name,
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
} }
if (export) if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID); gimp_image_delete (image_ID);
} }
} }

View file

@ -357,7 +357,7 @@ run (char *name,
Parasite *parasite; Parasite *parasite;
#endif /* GIMP_HAVE_PARASITES */ #endif /* GIMP_HAVE_PARASITES */
int err; int err;
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -399,10 +399,19 @@ run (char *name,
init_gtk (); init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG", export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY)); (CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
if (export) switch (export)
{ {
case EXPORT_EXPORT:
display_ID = gimp_display_new (image_ID); display_ID = gimp_display_new (image_ID);
gimp_displays_flush (); 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; break;
default: default:
@ -475,7 +484,7 @@ run (char *name,
/* First acquire information with a dialog */ /* First acquire information with a dialog */
err = save_dialog (); err = save_dialog ();
if (!export) if (export != EXPORT_EXPORT)
{ {
/* thaw undo saving and end the undo_group. */ /* thaw undo saving and end the undo_group. */
gimp_image_thaw_undo (image_ID); gimp_image_thaw_undo (image_ID);
@ -565,10 +574,10 @@ run (char *name,
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export) if (export == EXPORT_EXPORT)
{ {
/* if the image was exported, delete the new display */ /* If the image was exported, delete the new display. */
/* according to the documentation, this should also delete the image */ /* This also deletes the image. */
if (display_ID > -1) if (display_ID > -1)
gimp_display_delete (display_ID); gimp_display_delete (display_ID);
@ -591,7 +600,7 @@ run (char *name,
image_comment); image_comment);
gimp_image_attach_parasite (orig_image_ID, parasite); gimp_image_attach_parasite (orig_image_ID, parasite);
parasite_free (parasite); parasite_free (parasite);
} }
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options"); gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals); parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);

View file

@ -101,7 +101,7 @@
'spheredesigner' => { libdep => 'gtk' }, 'spheredesigner' => { libdep => 'gtk' },
'spread' => { libdep => 'gtk' }, 'spread' => { libdep => 'gtk' },
'sunras' => { libdep => 'gtk' }, 'sunras' => { libdep => 'gtk' },
'tga' => { libdep => 'gtk' }, 'tga' => { libdep => 'gtk', ui => 1 },
'threshold_alpha' => { libdep => 'gtk' }, 'threshold_alpha' => { libdep => 'gtk' },
'tiff' => { libdep => 'gtk', ui => 1, optional => 1 }, 'tiff' => { libdep => 'gtk', ui => 1, optional => 1 },
'tile' => { libdep => 'gtk' }, 'tile' => { libdep => 'gtk' },
@ -117,7 +117,7 @@
'wind' => { libdep => 'gtk' }, 'wind' => { libdep => 'gtk' },
'wmf' => { libdep => 'gtk' }, 'wmf' => { libdep => 'gtk' },
'xbm' => { libdep => 'gtk' }, 'xbm' => { libdep => 'gtk' },
'xpm' => { libdep => 'gtk', optional => 1 }, 'xpm' => { libdep => 'gtk', ui => 1, optional => 1 },
'xwd' => { libdep => 'glib' }, 'xwd' => { libdep => 'glib' },
'zealouscrop' => { libdep => 'glib' } 'zealouscrop' => { libdep => 'glib' }
); );

View file

@ -185,8 +185,7 @@ run (char *name, /* I - Name of filter program. */
gint32 orig_image_ID; gint32 orig_image_ID;
GRunModeType run_mode; GRunModeType run_mode;
GParam *values; /* Return values */ GParam *values; /* Return values */
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
/* /*
* Initialize parameter data... * Initialize parameter data...
@ -236,6 +235,12 @@ run (char *name, /* I - Name of filter program. */
init_gtk (); init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "PNG", export = gimp_export_image (&image_ID, &drawable_ID, "PNG",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED | CAN_HANDLE_ALPHA)); (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; break;
default: default:
break; break;
@ -298,7 +303,7 @@ run (char *name, /* I - Name of filter program. */
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export) if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID); gimp_image_delete (image_ID);
} }

View file

@ -42,9 +42,9 @@
* Ghostview may hang when displaying the files. * Ghostview may hang when displaying the files.
* V 1.07, PK, 14-Sep-99: Add resolution to image * V 1.07, PK, 14-Sep-99: Add resolution to image
*/ */
#define VERSIO 1.07 #define VERSIO 1.07
static char dversio[] = "v1.07 14-Sep-99"; static char dversio[] = "v1.07 14-Sep-99";
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.07 14-Sep-99"; static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.07 14-Sep-99";
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
@ -409,7 +409,7 @@ run (char *name,
gint32 image_ID = -1; gint32 image_ID = -1;
gint32 drawable_ID = -1; gint32 drawable_ID = -1;
gint32 orig_image_ID = -1; gint32 orig_image_ID = -1;
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
int k; int k;
l_run_mode = run_mode = param[0].data.d_int32; l_run_mode = run_mode = param[0].data.d_int32;
@ -481,6 +481,12 @@ run (char *name,
init_gtk (); init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "PS", export = gimp_export_image (&image_ID, &drawable_ID, "PS",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED)); (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; break;
default: default:
break; break;
@ -543,17 +549,17 @@ run (char *name,
#endif #endif
check_save_vals (); check_save_vals ();
if (save_image (param[3].data.d_string, image_ID, drawable_ID)) if (save_image (param[3].data.d_string, image_ID, drawable_ID))
{ {
/* Store psvals data */ /* Store psvals data */
gimp_set_data ("file_ps_save", &psvals, sizeof (PSSaveVals)); gimp_set_data ("file_ps_save", &psvals, sizeof (PSSaveVals));
} }
else else
{ {
status = STATUS_EXECUTION_ERROR; status = STATUS_EXECUTION_ERROR;
} }
} }
if (export) if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID); gimp_image_delete (image_ID);
values[0].data.d_status = status; values[0].data.d_status = status;

View file

@ -42,9 +42,9 @@
* Ghostview may hang when displaying the files. * Ghostview may hang when displaying the files.
* V 1.07, PK, 14-Sep-99: Add resolution to image * V 1.07, PK, 14-Sep-99: Add resolution to image
*/ */
#define VERSIO 1.07 #define VERSIO 1.07
static char dversio[] = "v1.07 14-Sep-99"; static char dversio[] = "v1.07 14-Sep-99";
static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.07 14-Sep-99"; static char ident[] = "@(#) GIMP PostScript/PDF file-plugin v1.07 14-Sep-99";
#include "config.h" #include "config.h"
#include <stdio.h> #include <stdio.h>
@ -409,7 +409,7 @@ run (char *name,
gint32 image_ID = -1; gint32 image_ID = -1;
gint32 drawable_ID = -1; gint32 drawable_ID = -1;
gint32 orig_image_ID = -1; gint32 orig_image_ID = -1;
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
int k; int k;
l_run_mode = run_mode = param[0].data.d_int32; l_run_mode = run_mode = param[0].data.d_int32;
@ -481,6 +481,12 @@ run (char *name,
init_gtk (); init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "PS", export = gimp_export_image (&image_ID, &drawable_ID, "PS",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED)); (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; break;
default: default:
break; break;
@ -543,17 +549,17 @@ run (char *name,
#endif #endif
check_save_vals (); check_save_vals ();
if (save_image (param[3].data.d_string, image_ID, drawable_ID)) if (save_image (param[3].data.d_string, image_ID, drawable_ID))
{ {
/* Store psvals data */ /* Store psvals data */
gimp_set_data ("file_ps_save", &psvals, sizeof (PSSaveVals)); gimp_set_data ("file_ps_save", &psvals, sizeof (PSSaveVals));
} }
else else
{ {
status = STATUS_EXECUTION_ERROR; status = STATUS_EXECUTION_ERROR;
} }
} }
if (export) if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID); gimp_image_delete (image_ID);
values[0].data.d_status = status; values[0].data.d_status = status;

View file

@ -82,6 +82,7 @@
#endif #endif
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "libgimp/gimp.h" #include "libgimp/gimp.h"
#include "libgimp/gimpui.h"
/* Round up a division to the nearest integer. */ /* Round up a division to the nearest integer. */
#define ROUNDUP_DIVIDE(n,d) (((n) + (d - 1)) / (d)) #define ROUNDUP_DIVIDE(n,d) (((n) + (d - 1)) / (d))
@ -112,12 +113,12 @@ struct tga_header
guint8 colorMapType; guint8 colorMapType;
/* The image type. */ /* The image type. */
#define TGA_TYPE_MAPPED 1 #define TGA_TYPE_MAPPED 1
#define TGA_TYPE_COLOR 2 #define TGA_TYPE_COLOR 2
#define TGA_TYPE_GRAY 3 #define TGA_TYPE_GRAY 3
#define TGA_TYPE_MAPPED_RLE 9 #define TGA_TYPE_MAPPED_RLE 9
#define TGA_TYPE_COLOR_RLE 10 #define TGA_TYPE_COLOR_RLE 10
#define TGA_TYPE_GRAY_RLE 11 #define TGA_TYPE_GRAY_RLE 11
guint8 imageType; guint8 imageType;
/* Color Map Specification. */ /* Color Map Specification. */
@ -142,9 +143,9 @@ struct tga_header
5: top-to-bottom ordering 5: top-to-bottom ordering
7-6: zero 7-6: zero
*/ */
#define TGA_DESC_ABITS 0x0f #define TGA_DESC_ABITS 0x0f
#define TGA_DESC_HORIZONTAL 0x10 #define TGA_DESC_HORIZONTAL 0x10
#define TGA_DESC_VERTICAL 0x20 #define TGA_DESC_VERTICAL 0x20
guint8 descriptor; guint8 descriptor;
}; };
@ -161,19 +162,20 @@ static struct
/* Declare some local functions. /* Declare some local functions.
*/ */
static void query (void); static void query (void);
static void run (char *name, static void run (char *name,
int nparams, int nparams,
GParam *param, GParam *param,
int *nreturn_vals, int *nreturn_vals,
GParam **return_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 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, static void save_close_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void save_ok_callback (GtkWidget *widget, static void save_ok_callback (GtkWidget *widget,
@ -266,6 +268,8 @@ run (char *name,
GStatusType status = STATUS_SUCCESS; GStatusType status = STATUS_SUCCESS;
GRunModeType run_mode; GRunModeType run_mode;
gint32 image_ID; gint32 image_ID;
gint32 drawable_ID;
GimpExportReturnType export = EXPORT_CANCEL;
#ifdef PROFILE #ifdef PROFILE
struct tms tbuf1, tbuf2; struct tms tbuf1, tbuf2;
@ -304,6 +308,30 @@ run (char *name,
} }
else if (strcmp (name, "file_tga_save") == 0) 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) switch (run_mode)
{ {
case RUN_INTERACTIVE: case RUN_INTERACTIVE:
@ -339,7 +367,7 @@ run (char *name,
times (&tbuf1); times (&tbuf1);
#endif #endif
*nreturn_vals = 1; *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 */ /* Store psvals data */
gimp_set_data ("file_tga_save", &tsvals, sizeof (tsvals)); gimp_set_data ("file_tga_save", &tsvals, sizeof (tsvals));
@ -348,6 +376,9 @@ run (char *name,
} }
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
} }
#ifdef PROFILE #ifdef PROFILE
@ -424,7 +455,10 @@ static int totbytes = 0;
#endif #endif
static int static int
std_fread (guchar *buf, int datasize, int nelems, FILE *fp) std_fread (guchar *buf,
int datasize,
int nelems,
FILE *fp)
{ {
#ifdef VERBOSE #ifdef VERBOSE
if (verbose > 1) if (verbose > 1)
@ -439,7 +473,10 @@ std_fread (guchar *buf, int datasize, int nelems, FILE *fp)
} }
static int static int
std_fwrite (guchar *buf, int datasize, int nelems, FILE *fp) std_fwrite (guchar *buf,
int datasize,
int nelems,
FILE *fp)
{ {
#ifdef VERBOSE #ifdef VERBOSE
if (verbose > 1) if (verbose > 1)
@ -457,7 +494,10 @@ std_fwrite (guchar *buf, int datasize, int nelems, FILE *fp)
/* Decode a bufferful of file. */ /* Decode a bufferful of file. */
static int static int
rle_fread (guchar *buf, int datasize, int nelems, FILE *fp) rle_fread (guchar *buf,
int datasize,
int nelems,
FILE *fp)
{ {
static guchar *statebuf = 0; static guchar *statebuf = 0;
static int statelen = 0; static int statelen = 0;
@ -597,7 +637,10 @@ rle_fread (guchar *buf, int datasize, int nelems, FILE *fp)
loading performance than whole-stream images. */ loading performance than whole-stream images. */
/* RunLength Encode a bufferful of file. */ /* RunLength Encode a bufferful of file. */
static int static int
rle_fwrite (guchar *buf, int datasize, int nelems, FILE *fp) rle_fwrite (guchar *buf,
int datasize,
int nelems,
FILE *fp)
{ {
/* Now runlength-encode the whole buffer. */ /* Now runlength-encode the whole buffer. */
int count, j, buflen; int count, j, buflen;
@ -713,7 +756,9 @@ rle_fwrite (guchar *buf, int datasize, int nelems, FILE *fp)
static gint32 static gint32
ReadImage (FILE *fp, struct tga_header *hdr, char *filename) ReadImage (FILE *fp,
struct tga_header *hdr,
char *filename)
{ {
static gint32 image_ID; static gint32 image_ID;
gint32 layer_ID; gint32 layer_ID;
@ -1367,6 +1412,19 @@ save_image (char *filename,
return status; return status;
} }
static void
init_gtk ()
{
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("tga");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
}
static gint static gint
save_dialog () save_dialog ()
@ -1376,15 +1434,6 @@ save_dialog ()
GtkWidget *toggle; GtkWidget *toggle;
GtkWidget *frame; GtkWidget *frame;
GtkWidget *vbox; GtkWidget *vbox;
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("save");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
dlg = gtk_dialog_new (); dlg = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dlg), "Save as Tga"); gtk_window_set_title (GTK_WINDOW (dlg), "Save as Tga");

View file

@ -210,7 +210,7 @@ run (char *name,
gint32 image; gint32 image;
gint32 drawable; gint32 drawable;
gint32 orig_image; gint32 orig_image;
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -250,7 +250,14 @@ run (char *name,
case RUN_WITH_LAST_VALS: case RUN_WITH_LAST_VALS:
init_gtk (); init_gtk ();
export = gimp_export_image (&image, &drawable, "TIFF", export = gimp_export_image (&image, &drawable, "TIFF",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED | CAN_HANDLE_ALPHA)); (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; break;
default: default:
break; break;
@ -332,7 +339,7 @@ run (char *name,
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export) if (export == EXPORT_EXPORT)
gimp_image_delete (image); gimp_image_delete (image);
} }
} }

View file

@ -38,6 +38,7 @@ Previous...Inherited code from Ray Lehtiniemi, who inherited it from S & P.
#include <X11/xpm.h> #include <X11/xpm.h>
#include "gtk/gtk.h" #include "gtk/gtk.h"
#include "libgimp/gimp.h" #include "libgimp/gimp.h"
#include "libgimp/gimpui.h"
#include "libgimp/stdplugins-intl.h" #include "libgimp/stdplugins-intl.h"
static const char linenoise [] = static const char linenoise [] =
@ -60,9 +61,9 @@ typedef struct
typedef struct typedef struct
{ {
guchar r; guchar r;
guchar g; guchar g;
guchar b; guchar b;
} rgbkey; } rgbkey;
/* whether the image is color or not. global so I only have to pass one user value /* whether the image is color or not. global so I only have to pass one user value
@ -73,46 +74,31 @@ to the GHFunc */
int cpp; int cpp;
/* Declare local functions */ /* Declare local functions */
static void query (void); static void query (void);
static void run (char *name, static void run (char *name,
int nparams, int nparams,
GParam *param, GParam *param,
int *nreturn_vals, int *nreturn_vals,
GParam **return_vals); GParam **return_vals);
static gint32 static gint32 load_image (char *filename);
load_image (char *filename); static void parse_colors (XpmImage *xpm_image,
guchar **cmap);
static void static void parse_image (gint32 image_ID,
parse_colors (XpmImage *xpm_image, XpmImage *xpm_image,
guchar **cmap); guchar *cmap);
static gint save_image (char *filename,
static void gint32 image_ID,
parse_image (gint32 image_ID, gint32 drawable_ID);
XpmImage *xpm_image,
guchar *cmap);
static gint
save_image (char *filename,
gint32 image_ID,
gint32 drawable_ID);
static gint
save_dialog ();
static void
save_close_callback (GtkWidget *widget,
gpointer data);
static void
save_ok_callback (GtkWidget *widget,
gpointer data);
static void
save_scale_update (GtkAdjustment *adjustment,
double *scale_val);
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,
gpointer data);
static void save_scale_update (GtkAdjustment *adjustment,
double *scale_val);
@ -143,24 +129,24 @@ query ()
{ {
static GParamDef load_args[] = static GParamDef load_args[] =
{ {
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" }, { PARAM_INT32, "run_mode", "Interactive, non-interactive" },
{ PARAM_STRING, "filename", "The name of the file to load" }, { PARAM_STRING, "filename", "The name of the file to load" },
{ PARAM_STRING, "raw_filename", "The name entered" }, { PARAM_STRING, "raw_filename", "The name entered" },
}; };
static GParamDef load_return_vals[] = static GParamDef load_return_vals[] =
{ {
{ PARAM_IMAGE, "image", "Output image" }, { PARAM_IMAGE, "image", "Output image" },
}; };
static int nload_args = sizeof (load_args) / sizeof (load_args[0]); static int nload_args = sizeof (load_args) / sizeof (load_args[0]);
static int nload_return_vals = sizeof (load_return_vals) / sizeof (load_return_vals[0]); static int nload_return_vals = sizeof (load_return_vals) / sizeof (load_return_vals[0]);
static GParamDef save_args[] = static GParamDef save_args[] =
{ {
{ PARAM_INT32, "run_mode", "Interactive, non-interactive" }, { PARAM_INT32, "run_mode", "Interactive, non-interactive" },
{ PARAM_IMAGE, "image", "Input image" }, { PARAM_IMAGE, "image", "Input image" },
{ PARAM_DRAWABLE, "drawable", "Drawable to save" }, { PARAM_DRAWABLE, "drawable", "Drawable to save" },
{ PARAM_STRING, "filename", "The name of the file to save the image in" }, { PARAM_STRING, "filename", "The name of the file to save the image in" },
{ PARAM_STRING, "raw_filename", "The name of the file to save the image in" }, { PARAM_STRING, "raw_filename", "The name of the file to save the image in" },
}; };
static int nsave_args = sizeof (save_args) / sizeof (save_args[0]); static int nsave_args = sizeof (save_args) / sizeof (save_args[0]);
@ -191,8 +177,8 @@ query ()
save_args, NULL); save_args, NULL);
gimp_register_magic_load_handler ("file_xpm_load", "xpm", "<Load>/Xpm", gimp_register_magic_load_handler ("file_xpm_load", "xpm", "<Load>/Xpm",
"0,string,/* XPM */"); "0, string, /* XPM */");
gimp_register_save_handler ("file_xpm_save", "xpm", "<Save>/Xpm"); gimp_register_save_handler ("file_xpm_save", "xpm", "<Save>/Xpm");
} }
static void static void
@ -205,6 +191,8 @@ run (char *name,
static GParam values[2]; static GParam values[2];
GRunModeType run_mode; GRunModeType run_mode;
gint32 image_ID; gint32 image_ID;
gint32 drawable_ID;
GimpExportReturnType export = EXPORT_CANCEL;
GStatusType status = STATUS_SUCCESS; GStatusType status = STATUS_SUCCESS;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -235,6 +223,30 @@ run (char *name,
} }
else if (strcmp (name, "file_xpm_save") == 0) else if (strcmp (name, "file_xpm_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, "XPM",
(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) switch (run_mode)
{ {
case RUN_INTERACTIVE: case RUN_INTERACTIVE:
@ -242,9 +254,9 @@ run (char *name,
gimp_get_data ("file_xpm_save", &xpmvals); gimp_get_data ("file_xpm_save", &xpmvals);
/* First acquire information with a dialog */ /* First acquire information with a dialog */
if (gimp_drawable_has_alpha(param[2].data.d_int32)) if (gimp_drawable_has_alpha (drawable_ID))
if (! save_dialog ()) if (! save_dialog ())
return; return;
break; break;
case RUN_NONINTERACTIVE: case RUN_NONINTERACTIVE:
@ -269,14 +281,17 @@ run (char *name,
} }
*nreturn_vals = 1; *nreturn_vals = 1;
if (save_image (param[3].data.d_string, if (save_image (param[3].data.d_string,
param[1].data.d_int32, image_ID,
param[2].data.d_int32)) drawable_ID))
{ {
gimp_set_data ("file_xpm_save", &xpmvals, sizeof (XpmSaveVals)); gimp_set_data ("file_xpm_save", &xpmvals, sizeof (XpmSaveVals));
values[0].data.d_status = STATUS_SUCCESS; values[0].data.d_status = STATUS_SUCCESS;
} }
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
} }
else else
g_assert (FALSE); g_assert (FALSE);
@ -330,7 +345,8 @@ load_image (char *filename)
static void static void
parse_colors (XpmImage *xpm_image, guchar **cmap) parse_colors (XpmImage *xpm_image,
guchar **cmap)
{ {
Display *display; Display *display;
Colormap colormap; Colormap colormap;
@ -388,7 +404,9 @@ parse_colors (XpmImage *xpm_image, guchar **cmap)
static void static void
parse_image(gint32 image_ID, XpmImage *xpm_image, guchar *cmap) parse_image (gint32 image_ID,
XpmImage *xpm_image,
guchar *cmap)
{ {
int tile_height; int tile_height;
int scanlines; int scanlines;
@ -464,13 +482,16 @@ guint rgbhash (rgbkey *c)
return ((guint)c->r) ^ ((guint)c->g) ^ ((guint)c->b); return ((guint)c->r) ^ ((guint)c->g) ^ ((guint)c->b);
} }
guint compare (rgbkey *c1, rgbkey *c2) guint compare (rgbkey *c1,
rgbkey *c2)
{ {
return (c1->r == c2->r)&&(c1->g == c2->g)&&(c1->b == c2->b); return (c1->r == c2->r)&&(c1->g == c2->g)&&(c1->b == c2->b);
} }
void set_XpmImage(XpmColor *array, guint index, char *colorstring) void set_XpmImage (XpmColor *array,
guint index,
char *colorstring)
{ {
char *p; char *p;
int i, charnum, indtemp; int i, charnum, indtemp;
@ -503,8 +524,9 @@ void set_XpmImage(XpmColor *array, guint index, char *colorstring)
} }
} }
void create_colormap_from_hash (gpointer gkey, gpointer value, gpointer void create_colormap_from_hash (gpointer gkey,
user_data) gpointer value,
gpointer user_data)
{ {
rgbkey *key = gkey; rgbkey *key = gkey;
char *string = g_new(char, 8); char *string = g_new(char, 8);
@ -543,55 +565,58 @@ save_image (char *filename,
gint rc = FALSE; gint rc = FALSE;
/* get some basic stats about the image */ /* get some basic stats about the image */
switch (gimp_drawable_type (drawable_ID)) { switch (gimp_drawable_type (drawable_ID))
case RGBA_IMAGE: {
case INDEXEDA_IMAGE: case RGBA_IMAGE:
case GRAYA_IMAGE: case INDEXEDA_IMAGE:
alpha = 1; case GRAYA_IMAGE:
break; alpha = 1;
case RGB_IMAGE: break;
case INDEXED_IMAGE: case RGB_IMAGE:
case GRAY_IMAGE: case INDEXED_IMAGE:
alpha = 0; case GRAY_IMAGE:
break; alpha = 0;
default: break;
return FALSE; default:
} return FALSE;
}
switch (gimp_drawable_type (drawable_ID)) { switch (gimp_drawable_type (drawable_ID))
case GRAYA_IMAGE: {
case GRAY_IMAGE: case GRAYA_IMAGE:
color = 0; case GRAY_IMAGE:
break; color = 0;
case RGBA_IMAGE: break;
case RGB_IMAGE: case RGBA_IMAGE:
case INDEXED_IMAGE: case RGB_IMAGE:
case INDEXEDA_IMAGE: case INDEXED_IMAGE:
case INDEXEDA_IMAGE:
color = 1; color = 1;
break; break;
default: default:
return FALSE; return FALSE;
} }
switch (gimp_drawable_type (drawable_ID)) { switch (gimp_drawable_type (drawable_ID))
case GRAYA_IMAGE: {
case GRAY_IMAGE: case GRAYA_IMAGE:
case RGBA_IMAGE: case GRAY_IMAGE:
case RGB_IMAGE: case RGBA_IMAGE:
indexed = 0; case RGB_IMAGE:
break; indexed = 0;
case INDEXED_IMAGE: break;
case INDEXEDA_IMAGE: case INDEXED_IMAGE:
indexed = 1; case INDEXEDA_IMAGE:
break; indexed = 1;
default: break;
return FALSE; default:
} return FALSE;
}
drawable = gimp_drawable_get (drawable_ID); drawable = gimp_drawable_get (drawable_ID);
width = drawable->width; width = drawable->width;
height = drawable->height; height = drawable->height;
/* allocate buffers making the assumption that ibuff and mbuff /* allocate buffers making the assumption that ibuff and mbuff
are 32 bit aligned... */ are 32 bit aligned... */
if ((ibuff = g_new(guint, width*height)) == NULL) if ((ibuff = g_new(guint, width*height)) == NULL)
@ -672,37 +697,38 @@ save_image (char *filename,
gimp_progress_update ((double) (i+j) / (double) height); gimp_progress_update ((double) (i+j) / (double) height);
} }
} }
g_free(buffer); g_free(buffer);
if (indexed) if (indexed)
{ {
guchar *cmap; guchar *cmap;
cmap = gimp_image_get_cmap(image_ID, &ncolors); cmap = gimp_image_get_cmap(image_ID, &ncolors);
ncolors++; /* for transparency */ ncolors++; /* for transparency */
colormap = g_new(XpmColor, ncolors); colormap = g_new(XpmColor, ncolors);
cpp=(double)1.0+(double)log(ncolors)/(double)log(sizeof(linenoise)-1.0); cpp=(double)1.0+(double)log(ncolors)/(double)log(sizeof(linenoise)-1.0);
set_XpmImage(colormap, 0, "None"); set_XpmImage(colormap, 0, "None");
for (i=0; i<ncolors-1; i++) for (i=0; i<ncolors-1; i++)
{ {
char *string; char *string;
guchar r, g, b; guchar r, g, b;
r = *(cmap++); r = *(cmap++);
g = *(cmap++); g = *(cmap++);
b = *(cmap++); b = *(cmap++);
string = g_new(char, 8); string = g_new(char, 8);
sprintf(string, "#%02X%02X%02X", (int)r, (int)g, (int)b); sprintf(string, "#%02X%02X%02X", (int)r, (int)g, (int)b);
set_XpmImage(colormap, i+1, string); set_XpmImage(colormap, i+1, string);
} }
}else }
{ else
colormap = g_new(XpmColor, ncolors); {
colormap = g_new(XpmColor, ncolors);
cpp=(double)1.0+(double)log(ncolors)/(double)log(sizeof(linenoise)-1.0);
set_XpmImage(colormap, 0, "None"); cpp = (double)1.0 + (double)log (ncolors) / (double)log (sizeof (linenoise) - 1.0);
set_XpmImage (colormap, 0, "None");
g_hash_table_foreach (hash, create_colormap_from_hash, colormap);
} g_hash_table_foreach (hash, create_colormap_from_hash, colormap);
}
image = g_new(XpmImage, 1); image = g_new(XpmImage, 1);
@ -713,17 +739,14 @@ save_image (char *filename,
image->colorTable=colormap; image->colorTable=colormap;
image->data = ibuff; image->data = ibuff;
/* do the save */ /* do the save */
XpmWriteFileFromXpmImage(filename, image, NULL); XpmWriteFileFromXpmImage(filename, image, NULL);
rc = TRUE; rc = TRUE;
cleanup: cleanup:
/* clean up resources */ /* clean up resources */
gimp_drawable_detach (drawable); gimp_drawable_detach (drawable);
if (ibuff) g_free(ibuff); if (ibuff) g_free(ibuff);
/*if (mbuff) g_free(mbuff);*/ /*if (mbuff) g_free(mbuff);*/
if (hash) g_hash_table_destroy(hash); if (hash) g_hash_table_destroy(hash);
@ -731,6 +754,19 @@ save_image (char *filename,
return rc; return rc;
} }
static void
init_gtk ()
{
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("xpm");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
}
static gint static gint
save_dialog () save_dialog ()
@ -742,15 +778,6 @@ save_dialog ()
GtkWidget *frame; GtkWidget *frame;
GtkWidget *table; GtkWidget *table;
GtkObject *scale_data; GtkObject *scale_data;
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("save");
gtk_init (&argc, &argv);
gtk_rc_parse(gimp_gtkrc());
dlg = gtk_dialog_new (); dlg = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dlg), _("Save as Xpm")); gtk_window_set_title (GTK_WINDOW (dlg), _("Save as Xpm"));

View file

@ -357,7 +357,7 @@ run (char *name,
Parasite *parasite; Parasite *parasite;
#endif /* GIMP_HAVE_PARASITES */ #endif /* GIMP_HAVE_PARASITES */
int err; int err;
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -399,10 +399,19 @@ run (char *name,
init_gtk (); init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG", export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY)); (CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
if (export) switch (export)
{ {
case EXPORT_EXPORT:
display_ID = gimp_display_new (image_ID); display_ID = gimp_display_new (image_ID);
gimp_displays_flush (); 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; break;
default: default:
@ -475,7 +484,7 @@ run (char *name,
/* First acquire information with a dialog */ /* First acquire information with a dialog */
err = save_dialog (); err = save_dialog ();
if (!export) if (export != EXPORT_EXPORT)
{ {
/* thaw undo saving and end the undo_group. */ /* thaw undo saving and end the undo_group. */
gimp_image_thaw_undo (image_ID); gimp_image_thaw_undo (image_ID);
@ -565,10 +574,10 @@ run (char *name,
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export) if (export == EXPORT_EXPORT)
{ {
/* if the image was exported, delete the new display */ /* If the image was exported, delete the new display. */
/* according to the documentation, this should also delete the image */ /* This also deletes the image. */
if (display_ID > -1) if (display_ID > -1)
gimp_display_delete (display_ID); gimp_display_delete (display_ID);
@ -591,7 +600,7 @@ run (char *name,
image_comment); image_comment);
gimp_image_attach_parasite (orig_image_ID, parasite); gimp_image_attach_parasite (orig_image_ID, parasite);
parasite_free (parasite); parasite_free (parasite);
} }
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options"); gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals); parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);

View file

@ -357,7 +357,7 @@ run (char *name,
Parasite *parasite; Parasite *parasite;
#endif /* GIMP_HAVE_PARASITES */ #endif /* GIMP_HAVE_PARASITES */
int err; int err;
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -399,10 +399,19 @@ run (char *name,
init_gtk (); init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG", export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY)); (CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
if (export) switch (export)
{ {
case EXPORT_EXPORT:
display_ID = gimp_display_new (image_ID); display_ID = gimp_display_new (image_ID);
gimp_displays_flush (); 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; break;
default: default:
@ -475,7 +484,7 @@ run (char *name,
/* First acquire information with a dialog */ /* First acquire information with a dialog */
err = save_dialog (); err = save_dialog ();
if (!export) if (export != EXPORT_EXPORT)
{ {
/* thaw undo saving and end the undo_group. */ /* thaw undo saving and end the undo_group. */
gimp_image_thaw_undo (image_ID); gimp_image_thaw_undo (image_ID);
@ -565,10 +574,10 @@ run (char *name,
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export) if (export == EXPORT_EXPORT)
{ {
/* if the image was exported, delete the new display */ /* If the image was exported, delete the new display. */
/* according to the documentation, this should also delete the image */ /* This also deletes the image. */
if (display_ID > -1) if (display_ID > -1)
gimp_display_delete (display_ID); gimp_display_delete (display_ID);
@ -591,7 +600,7 @@ run (char *name,
image_comment); image_comment);
gimp_image_attach_parasite (orig_image_ID, parasite); gimp_image_attach_parasite (orig_image_ID, parasite);
parasite_free (parasite); parasite_free (parasite);
} }
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options"); gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals); parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);

View file

@ -357,7 +357,7 @@ run (char *name,
Parasite *parasite; Parasite *parasite;
#endif /* GIMP_HAVE_PARASITES */ #endif /* GIMP_HAVE_PARASITES */
int err; int err;
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -399,10 +399,19 @@ run (char *name,
init_gtk (); init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG", export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY)); (CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
if (export) switch (export)
{ {
case EXPORT_EXPORT:
display_ID = gimp_display_new (image_ID); display_ID = gimp_display_new (image_ID);
gimp_displays_flush (); 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; break;
default: default:
@ -475,7 +484,7 @@ run (char *name,
/* First acquire information with a dialog */ /* First acquire information with a dialog */
err = save_dialog (); err = save_dialog ();
if (!export) if (export != EXPORT_EXPORT)
{ {
/* thaw undo saving and end the undo_group. */ /* thaw undo saving and end the undo_group. */
gimp_image_thaw_undo (image_ID); gimp_image_thaw_undo (image_ID);
@ -565,10 +574,10 @@ run (char *name,
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export) if (export == EXPORT_EXPORT)
{ {
/* if the image was exported, delete the new display */ /* If the image was exported, delete the new display. */
/* according to the documentation, this should also delete the image */ /* This also deletes the image. */
if (display_ID > -1) if (display_ID > -1)
gimp_display_delete (display_ID); gimp_display_delete (display_ID);
@ -591,7 +600,7 @@ run (char *name,
image_comment); image_comment);
gimp_image_attach_parasite (orig_image_ID, parasite); gimp_image_attach_parasite (orig_image_ID, parasite);
parasite_free (parasite); parasite_free (parasite);
} }
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options"); gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals); parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);

View file

@ -357,7 +357,7 @@ run (char *name,
Parasite *parasite; Parasite *parasite;
#endif /* GIMP_HAVE_PARASITES */ #endif /* GIMP_HAVE_PARASITES */
int err; int err;
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -399,10 +399,19 @@ run (char *name,
init_gtk (); init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG", export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY)); (CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
if (export) switch (export)
{ {
case EXPORT_EXPORT:
display_ID = gimp_display_new (image_ID); display_ID = gimp_display_new (image_ID);
gimp_displays_flush (); 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; break;
default: default:
@ -475,7 +484,7 @@ run (char *name,
/* First acquire information with a dialog */ /* First acquire information with a dialog */
err = save_dialog (); err = save_dialog ();
if (!export) if (export != EXPORT_EXPORT)
{ {
/* thaw undo saving and end the undo_group. */ /* thaw undo saving and end the undo_group. */
gimp_image_thaw_undo (image_ID); gimp_image_thaw_undo (image_ID);
@ -565,10 +574,10 @@ run (char *name,
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export) if (export == EXPORT_EXPORT)
{ {
/* if the image was exported, delete the new display */ /* If the image was exported, delete the new display. */
/* according to the documentation, this should also delete the image */ /* This also deletes the image. */
if (display_ID > -1) if (display_ID > -1)
gimp_display_delete (display_ID); gimp_display_delete (display_ID);
@ -591,7 +600,7 @@ run (char *name,
image_comment); image_comment);
gimp_image_attach_parasite (orig_image_ID, parasite); gimp_image_attach_parasite (orig_image_ID, parasite);
parasite_free (parasite); parasite_free (parasite);
} }
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options"); gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals); parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);

View file

@ -357,7 +357,7 @@ run (char *name,
Parasite *parasite; Parasite *parasite;
#endif /* GIMP_HAVE_PARASITES */ #endif /* GIMP_HAVE_PARASITES */
int err; int err;
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -399,10 +399,19 @@ run (char *name,
init_gtk (); init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG", export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY)); (CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
if (export) switch (export)
{ {
case EXPORT_EXPORT:
display_ID = gimp_display_new (image_ID); display_ID = gimp_display_new (image_ID);
gimp_displays_flush (); 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; break;
default: default:
@ -475,7 +484,7 @@ run (char *name,
/* First acquire information with a dialog */ /* First acquire information with a dialog */
err = save_dialog (); err = save_dialog ();
if (!export) if (export != EXPORT_EXPORT)
{ {
/* thaw undo saving and end the undo_group. */ /* thaw undo saving and end the undo_group. */
gimp_image_thaw_undo (image_ID); gimp_image_thaw_undo (image_ID);
@ -565,10 +574,10 @@ run (char *name,
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export) if (export == EXPORT_EXPORT)
{ {
/* if the image was exported, delete the new display */ /* If the image was exported, delete the new display. */
/* according to the documentation, this should also delete the image */ /* This also deletes the image. */
if (display_ID > -1) if (display_ID > -1)
gimp_display_delete (display_ID); gimp_display_delete (display_ID);
@ -591,7 +600,7 @@ run (char *name,
image_comment); image_comment);
gimp_image_attach_parasite (orig_image_ID, parasite); gimp_image_attach_parasite (orig_image_ID, parasite);
parasite_free (parasite); parasite_free (parasite);
} }
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options"); gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals); parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);

View file

@ -357,7 +357,7 @@ run (char *name,
Parasite *parasite; Parasite *parasite;
#endif /* GIMP_HAVE_PARASITES */ #endif /* GIMP_HAVE_PARASITES */
int err; int err;
gboolean export = FALSE; GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -399,10 +399,19 @@ run (char *name,
init_gtk (); init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "JPEG", export = gimp_export_image (&image_ID, &drawable_ID, "JPEG",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY)); (CAN_HANDLE_RGB | CAN_HANDLE_GRAY));
if (export) switch (export)
{ {
case EXPORT_EXPORT:
display_ID = gimp_display_new (image_ID); display_ID = gimp_display_new (image_ID);
gimp_displays_flush (); 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; break;
default: default:
@ -475,7 +484,7 @@ run (char *name,
/* First acquire information with a dialog */ /* First acquire information with a dialog */
err = save_dialog (); err = save_dialog ();
if (!export) if (export != EXPORT_EXPORT)
{ {
/* thaw undo saving and end the undo_group. */ /* thaw undo saving and end the undo_group. */
gimp_image_thaw_undo (image_ID); gimp_image_thaw_undo (image_ID);
@ -565,10 +574,10 @@ run (char *name,
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
if (export) if (export == EXPORT_EXPORT)
{ {
/* if the image was exported, delete the new display */ /* If the image was exported, delete the new display. */
/* according to the documentation, this should also delete the image */ /* This also deletes the image. */
if (display_ID > -1) if (display_ID > -1)
gimp_display_delete (display_ID); gimp_display_delete (display_ID);
@ -591,7 +600,7 @@ run (char *name,
image_comment); image_comment);
gimp_image_attach_parasite (orig_image_ID, parasite); gimp_image_attach_parasite (orig_image_ID, parasite);
parasite_free (parasite); parasite_free (parasite);
} }
gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options"); gimp_image_detach_parasite (orig_image_ID, "jpeg-save-options");
parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals); parasite = parasite_new ("jpeg-save-options", 0, sizeof (jsvals), &jsvals);

View file

@ -394,7 +394,7 @@ run(char *name, /* I - Name of print program. */
#endif #endif
gint32 image_ID; /* image ID */ gint32 image_ID; /* image ID */
gint32 drawable_ID; /* drawable ID */ gint32 drawable_ID; /* drawable ID */
gboolean export; /* have we exported the image ? */ GimpExportReturnType export = EXPORT_CANCEL; /* return value of gimp_export_image() */
INIT_I18N_UI(); INIT_I18N_UI();
@ -424,6 +424,12 @@ run(char *name, /* I - Name of print program. */
export = gimp_export_image (&image_ID, &drawable_ID, "Print", export = gimp_export_image (&image_ID, &drawable_ID, "Print",
(CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED | (CAN_HANDLE_RGB | CAN_HANDLE_GRAY | CAN_HANDLE_INDEXED |
CAN_HANDLE_ALPHA)); CAN_HANDLE_ALPHA));
if (export == EXPORT_CANCEL)
{
*nreturn_vals = 1;
values[0].data.d_status = STATUS_EXECUTION_ERROR;
return;
}
break; break;
default: default:
break; break;
@ -643,7 +649,7 @@ run(char *name, /* I - Name of print program. */
gimp_drawable_detach(drawable); gimp_drawable_detach(drawable);
if (export) if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID); gimp_image_delete (image_ID);
} }

View file

@ -29,6 +29,7 @@
#include "siod.h" #include "siod.h"
#include "script-fu-console.h" #include "script-fu-console.h"
#include "script-fu-constants.h"
#include "script-fu-scripts.h" #include "script-fu-scripts.h"
#include "script-fu-server.h" #include "script-fu-server.h"