export-o-mania

--Sven
This commit is contained in:
Sven Neumann 1999-10-14 02:11:52 +00:00
parent fce4ad6327
commit 90d2f89a1e
7 changed files with 2399 additions and 2222 deletions

View File

@ -1,3 +1,13 @@
Thu Oct 14 04:08:31 *EST 1999 Sven Neumann <sven@gimp.org>
* plug-ins/common/Makefile.am
* plug-ins/common/plugin-defs.pl
* plug-ins/common/pnm.c
* plug-ins/common/sunras.c
* plug-ins/common/xbm.c
* plug-ins/common/xwd.c: a step further down on the road to make
all save plug-ins export-aware
Thu Oct 14 01:00:03 MEST 1999 Sven Neumann <sven@gimp.org> Thu Oct 14 01:00:03 MEST 1999 Sven Neumann <sven@gimp.org>
* app/gdisplay.c * app/gdisplay.c

View File

@ -820,6 +820,7 @@ pnm_SOURCES = \
pnm.c pnm.c
pnm_LDADD = \ pnm_LDADD = \
$(top_builddir)/libgimp/libgimpui.la \
$(top_builddir)/libgimp/libgimp.la \ $(top_builddir)/libgimp/libgimp.la \
$(GTK_LIBS) \ $(GTK_LIBS) \
$(INTLLIBS) $(INTLLIBS)
@ -1000,6 +1001,7 @@ sunras_SOURCES = \
sunras.c sunras.c
sunras_LDADD = \ sunras_LDADD = \
$(top_builddir)/libgimp/libgimpui.la \
$(top_builddir)/libgimp/libgimp.la \ $(top_builddir)/libgimp/libgimp.la \
$(GTK_LIBS) \ $(GTK_LIBS) \
$(INTLLIBS) $(INTLLIBS)
@ -1133,6 +1135,7 @@ xbm_SOURCES = \
xbm.c xbm.c
xbm_LDADD = \ xbm_LDADD = \
$(top_builddir)/libgimp/libgimpui.la \
$(top_builddir)/libgimp/libgimp.la \ $(top_builddir)/libgimp/libgimp.la \
$(GTK_LIBS) \ $(GTK_LIBS) \
$(INTLLIBS) $(INTLLIBS)
@ -1151,8 +1154,9 @@ xwd_SOURCES = \
xwd.c xwd.c
xwd_LDADD = \ xwd_LDADD = \
$(top_builddir)/libgimp/libgimpui.la \
$(top_builddir)/libgimp/libgimp.la \ $(top_builddir)/libgimp/libgimp.la \
$(GLIB_LIBS) \ $(GTK_LIBS) \
$(INTLLIBS) $(INTLLIBS)
zealouscrop_SOURCES = \ zealouscrop_SOURCES = \

View File

@ -78,7 +78,7 @@
'plasma' => { libdep => 'gtk' }, 'plasma' => { libdep => 'gtk' },
'plugindetails' => { libdep => 'gtk' }, 'plugindetails' => { libdep => 'gtk' },
'png' => { libdep => 'gtk', ui => 1, optional => 1 }, 'png' => { libdep => 'gtk', ui => 1, optional => 1 },
'pnm' => { libdep => 'gtk' }, 'pnm' => { libdep => 'gtk', ui => 1 },
'polar' => { libdep => 'gtk' }, 'polar' => { libdep => 'gtk' },
'ps' => { libdep => 'gtk', ui => 1 }, 'ps' => { libdep => 'gtk', ui => 1 },
'psd' => { libdep => 'glib' }, 'psd' => { libdep => 'glib' },
@ -100,7 +100,7 @@
'sparkle' => { libdep => 'gtk' }, 'sparkle' => { libdep => 'gtk' },
'spheredesigner' => { libdep => 'gtk' }, 'spheredesigner' => { libdep => 'gtk' },
'spread' => { libdep => 'gtk' }, 'spread' => { libdep => 'gtk' },
'sunras' => { libdep => 'gtk' }, 'sunras' => { libdep => 'gtk', ui => 1 },
'tga' => { libdep => 'gtk', ui => 1 }, '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 },
@ -116,9 +116,9 @@
'whirlpinch' => { libdep => 'gtk' }, 'whirlpinch' => { libdep => 'gtk' },
'wind' => { libdep => 'gtk' }, 'wind' => { libdep => 'gtk' },
'wmf' => { libdep => 'gtk' }, 'wmf' => { libdep => 'gtk' },
'xbm' => { libdep => 'gtk' }, 'xbm' => { libdep => 'gtk', ui => 1 },
'xpm' => { libdep => 'gtk', ui => 1, optional => 1 }, 'xpm' => { libdep => 'gtk', ui => 1, optional => 1 },
'xwd' => { libdep => 'glib' }, 'xwd' => { libdep => 'gtk', ui => 1 },
'zealouscrop' => { libdep => 'glib' } 'zealouscrop' => { libdep => 'glib' }
); );

View File

@ -42,6 +42,7 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include <libgimp/gimp.h> #include <libgimp/gimp.h>
#include <libgimp/gimpui.h>
#ifdef G_OS_WIN32 #ifdef G_OS_WIN32
#include <io.h> #include <io.h>
@ -118,7 +119,8 @@ static gint save_image (char *filename,
gint32 image_ID, gint32 image_ID,
gint32 drawable_ID); gint32 drawable_ID);
static gint save_dialog (); static void init_gtk (void);
static gint save_dialog (void);
static void pnm_load_ascii (PNMScanner * scan, static void pnm_load_ascii (PNMScanner * scan,
PNMInfo * info, PNMInfo * info,
@ -221,12 +223,12 @@ query ()
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" },
{ PARAM_INT32, "raw", "Specify non-zero for raw output, zero for ascii output" } { PARAM_INT32, "raw", "Specify non-zero for raw output, zero for ascii output" }
}; };
static int nsave_args = sizeof (save_args) / sizeof (save_args[0]); static int nsave_args = sizeof (save_args) / sizeof (save_args[0]);
@ -249,7 +251,7 @@ query ()
"Erik Nygren", "Erik Nygren",
"1996", "1996",
"<Save>/PNM", "<Save>/PNM",
"RGB*, GRAY*, INDEXED*", "RGB, GRAY, INDEXED",
PROC_PLUG_IN, PROC_PLUG_IN,
nsave_args, 0, nsave_args, 0,
save_args, NULL); save_args, NULL);
@ -270,6 +272,8 @@ run (char *name,
GRunModeType run_mode; GRunModeType run_mode;
GStatusType status = STATUS_SUCCESS; GStatusType status = STATUS_SUCCESS;
gint32 image_ID; gint32 image_ID;
gint32 drawable_ID;
GimpExportReturnType export = EXPORT_CANCEL;
run_mode = param[0].data.d_int32; run_mode = param[0].data.d_int32;
@ -296,6 +300,29 @@ run (char *name,
} }
else if (strcmp (name, "file_pnm_save") == 0) else if (strcmp (name, "file_pnm_save") == 0)
{ {
*nreturn_vals = 1;
image_ID = param[1].data.d_int32;
drawable_ID = param[2].data.d_int32;
/* eventually export the image */
switch (run_mode)
{
case RUN_INTERACTIVE:
case RUN_WITH_LAST_VALS:
init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "PNM",
(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;
}
switch (run_mode) switch (run_mode)
{ {
case RUN_INTERACTIVE: case RUN_INTERACTIVE:
@ -325,7 +352,7 @@ run (char *name,
break; break;
} }
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_pnm_save", &psvals, sizeof (PNMSaveVals)); gimp_set_data ("file_pnm_save", &psvals, sizeof (PNMSaveVals));
@ -334,7 +361,9 @@ run (char *name,
} }
else else
values[0].data.d_status = STATUS_EXECUTION_ERROR; values[0].data.d_status = STATUS_EXECUTION_ERROR;
*nreturn_vals = 1;
if (export == EXPORT_EXPORT)
gimp_image_delete (image_ID);
} }
} }
@ -570,8 +599,8 @@ pnm_load_raw (PNMScanner *scan,
g_free (data); g_free (data);
} }
void static void
static pnm_load_rawpbm (PNMScanner *scan, pnm_load_rawpbm (PNMScanner *scan,
PNMInfo *info, PNMInfo *info,
GPixelRgn *pixel_rgn) GPixelRgn *pixel_rgn)
{ {
@ -714,7 +743,7 @@ save_image (char *filename,
/* Make sure we're not saving an image with an alpha channel */ /* Make sure we're not saving an image with an alpha channel */
if (gimp_drawable_has_alpha (drawable_ID)) if (gimp_drawable_has_alpha (drawable_ID))
{ {
/* gimp_message ("PNM save cannot handle images with alpha channels."); */ gimp_message ("PNM save cannot handle images with alpha channels.");
return FALSE; return FALSE;
} }
@ -849,6 +878,21 @@ save_image (char *filename,
return TRUE; return TRUE;
} }
static void
init_gtk ()
{
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("pnm");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
}
static gint static gint
save_dialog () save_dialog ()
{ {
@ -858,18 +902,9 @@ save_dialog ()
GtkWidget *frame; GtkWidget *frame;
GtkWidget *toggle_vbox; GtkWidget *toggle_vbox;
GSList *group; GSList *group;
gchar **argv;
gint argc;
gint use_raw = (psvals.raw == TRUE); gint use_raw = (psvals.raw == TRUE);
gint use_ascii = (psvals.raw == FALSE); gint use_ascii = (psvals.raw == FALSE);
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 PNM"); gtk_window_set_title (GTK_WINDOW (dlg), "Save as PNM");
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE); gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);

File diff suppressed because it is too large Load Diff

View File

@ -44,6 +44,7 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "libgimp/gimp.h" #include "libgimp/gimp.h"
#include "libgimp/gimpui.h"
#include "libgimp/stdplugins-intl.h" #include "libgimp/stdplugins-intl.h"
/* Wear your GIMP with pride! */ /* Wear your GIMP with pride! */
@ -89,27 +90,28 @@ static XBMSaveInterface xsint =
/* 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 void init_gtk (void);
static gint save_image (char *filename, static gint32 load_image (char *filename);
gint32 image_ID, static gint save_image (char *filename,
gint32 drawable_ID); gint32 image_ID,
static gint save_dialog (gint32 drawable_ID); gint32 drawable_ID);
static void close_callback (GtkWidget *widget, static gint save_dialog (gint32 drawable_ID);
gpointer data); static void close_callback (GtkWidget *widget,
static void save_ok_callback (GtkWidget *widget, gpointer data);
gpointer data); static void save_ok_callback (GtkWidget *widget,
static void save_toggle_update (GtkWidget *widget, gpointer data);
gpointer data); static void save_toggle_update (GtkWidget *widget,
gpointer data);
static void comment_entry_callback (GtkWidget *widget, static void comment_entry_callback (GtkWidget *widget,
gpointer data); gpointer data);
static void prefix_entry_callback(GtkWidget *widget, static void prefix_entry_callback (GtkWidget *widget,
gpointer data); gpointer data);
GPlugInInfo PLUG_IN_INFO = GPlugInInfo PLUG_IN_INFO =
@ -132,13 +134,13 @@ 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]);
@ -146,16 +148,16 @@ query ()
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" }, { PARAM_STRING, "filename", "The name of the file to save" },
{ PARAM_STRING, "raw_filename", "The name entered" }, { PARAM_STRING, "raw_filename", "The name entered" },
{ PARAM_STRING, "comment", "Image description (maximum 72 bytes)" }, { PARAM_STRING, "comment", "Image description (maximum 72 bytes)" },
{ PARAM_INT32, "x10", "Save in X10 format" }, { PARAM_INT32, "x10", "Save in X10 format" },
{ PARAM_INT32, "x_hot", "X coordinate of hotspot" }, { PARAM_INT32, "x_hot", "X coordinate of hotspot" },
{ PARAM_INT32, "y_hot", "Y coordinate of hotspot" }, { PARAM_INT32, "y_hot", "Y coordinate of hotspot" },
{ PARAM_STRING, "prefix", "Identifier prefix [determined from filename]"}, { PARAM_STRING, "prefix", "Identifier prefix [determined from filename]"},
} ; } ;
static int nsave_args = sizeof (save_args) / sizeof (save_args[0]); static int nsave_args = sizeof (save_args) / sizeof (save_args[0]);
@ -225,6 +227,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;
INIT_I18N_UI(); INIT_I18N_UI();
strncpy(xsvals.comment, _("Made with Gimp"), MAX_COMMENT); strncpy(xsvals.comment, _("Made with Gimp"), MAX_COMMENT);
@ -259,12 +263,26 @@ run (char *name,
} }
else if (strcmp (name, "file_xbm_save") == 0) else if (strcmp (name, "file_xbm_save") == 0)
{ {
int argc; image_ID = param[1].data.d_int32;
char **argv; drawable_ID = param[2].data.d_int32;
argc = 1; /* eventually export the image */
argv = g_new (gchar *, 1); switch (run_mode)
argv[0] = g_strdup ("xbm"); {
case RUN_INTERACTIVE:
case RUN_WITH_LAST_VALS:
init_gtk ();
export = gimp_export_image (&image_ID, &drawable_ID, "XBM", CAN_HANDLE_INDEXED);
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)
{ {
@ -276,7 +294,7 @@ run (char *name,
init_prefix (param[3].data.d_string); init_prefix (param[3].data.d_string);
/* First acquire information with a dialog */ /* First acquire information with a dialog */
if (! save_dialog (param[2].data.d_int32)) if (! save_dialog (drawable_ID))
return; return;
break; break;
@ -335,8 +353,7 @@ run (char *name,
} }
*nreturn_vals = 1; *nreturn_vals = 1;
if (save_image (param[3].data.d_string, param[1].data.d_int32, if (save_image (param[3].data.d_string, image_ID, drawable_ID))
param[2].data.d_int32))
{ {
/* Store xsvals data */ /* Store xsvals data */
gimp_set_data ("file_xbm_save", &xsvals, sizeof (xsvals)); gimp_set_data ("file_xbm_save", &xsvals, sizeof (xsvals));
@ -344,6 +361,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);
} }
} }
@ -351,7 +371,8 @@ run (char *name,
/* Return the value of a digit. */ /* Return the value of a digit. */
static gint static gint
getval (int c, int base) getval (int c,
int base)
{ {
static guchar *digits = "0123456789abcdefABCDEF"; static guchar *digits = "0123456789abcdefABCDEF";
int val; int val;
@ -417,7 +438,8 @@ cpp_fgetc (FILE *fp)
/* Match a string with a file. */ /* Match a string with a file. */
static gint static gint
match (FILE *fp, char *s) match (FILE *fp,
char *s)
{ {
int c; int c;
@ -926,25 +948,27 @@ save_image (char *filename,
} }
static void
init_gtk ()
{
gchar **argv;
gint argc;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("xbm");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
}
static gint static gint
save_dialog (gint32 drawable_ID) save_dialog (gint32 drawable_ID)
{ {
GtkWidget *dlg, *button, *toggle, *label, *entry, *frame, *hbox, *vbox; GtkWidget *dlg, *button, *toggle, *label, *entry, *frame, *hbox, *vbox;
gchar **argv;
gint argc;
xsint.run = FALSE; xsint.run = FALSE;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("save");
gtk_init (&argc, &argv);
gtk_initialized = TRUE;
gtk_rc_parse (gimp_gtkrc ());
gdk_set_use_xshm(gimp_use_xshm());
dlg = gtk_dialog_new (); dlg = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dlg), _("Save as XBM")); gtk_window_set_title (GTK_WINDOW (dlg), _("Save as XBM"));
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE); gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
@ -1048,8 +1072,8 @@ save_dialog (gint32 drawable_ID)
/* Update the comment string. */ /* Update the comment string. */
static void static void
comment_entry_callback (GtkWidget *widget, comment_entry_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
memset (xsvals.comment, 0, sizeof (xsvals.comment)); memset (xsvals.comment, 0, sizeof (xsvals.comment));
strncpy (xsvals.comment, strncpy (xsvals.comment,
@ -1058,8 +1082,8 @@ comment_entry_callback (GtkWidget *widget,
static void static void
prefix_entry_callback(GtkWidget *widget, prefix_entry_callback (GtkWidget *widget,
gpointer data) gpointer data)
{ {
memset (xsvals.prefix, 0, sizeof (xsvals.prefix)); memset (xsvals.prefix, 0, sizeof (xsvals.prefix));
strncpy (xsvals.prefix, gtk_entry_get_text (GTK_ENTRY (widget)), MAX_PREFIX); strncpy (xsvals.prefix, gtk_entry_get_text (GTK_ENTRY (widget)), MAX_PREFIX);
@ -1094,3 +1118,15 @@ Local Variables:
compile-command:"gcc -Wall -Wmissing-prototypes -g -O -o xbm xbm.c -lgimp -lgtk -lgdk -lglib -lm" compile-command:"gcc -Wall -Wmissing-prototypes -g -O -o xbm xbm.c -lgimp -lgtk -lgdk -lglib -lm"
End: End:
*/ */

File diff suppressed because it is too large Load Diff