2000-02-25 00:11:26 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2000-12-17 05:37:03 +08:00
|
|
|
|
1999-02-21 07:20:54 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2001-08-17 22:27:31 +08:00
|
|
|
#include <glib-object.h>
|
2005-02-07 09:38:18 +08:00
|
|
|
#include <glib/gstdio.h>
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2004-01-19 09:54:11 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
|
2001-05-10 06:34:59 +08:00
|
|
|
#include "core/core-types.h"
|
2000-12-29 23:22:01 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
#include "core/gimp.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2006-03-30 07:56:07 +08:00
|
|
|
#include "core/gimpparamspecs.h"
|
2001-07-04 02:38:56 +08:00
|
|
|
|
2006-04-05 01:47:22 +08:00
|
|
|
#include "pdb/gimp-pdb.h"
|
2006-03-31 17:15:08 +08:00
|
|
|
#include "pdb/gimpprocedure.h"
|
2001-12-01 08:14:14 +08:00
|
|
|
|
2002-03-21 01:46:13 +08:00
|
|
|
#include "plug-in/plug-ins.h"
|
2004-09-22 23:12:24 +08:00
|
|
|
#include "plug-in/plug-in-proc-def.h"
|
2001-12-01 08:14:14 +08:00
|
|
|
|
2001-07-04 02:38:56 +08:00
|
|
|
#include "xcf.h"
|
|
|
|
#include "xcf-private.h"
|
|
|
|
#include "xcf-load.h"
|
|
|
|
#include "xcf-read.h"
|
|
|
|
#include "xcf-save.h"
|
2001-05-09 10:32:03 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
2000-04-28 01:27:28 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-05 03:31:35 +08:00
|
|
|
typedef GimpImage * GimpXcfLoaderFunc (Gimp *gimp,
|
2006-04-01 01:42:13 +08:00
|
|
|
XcfInfo *info);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
2006-04-04 18:30:58 +08:00
|
|
|
static GValueArray * xcf_load_invoker (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
const GValueArray *args);
|
|
|
|
static GValueArray * xcf_save_invoker (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
const GValueArray *args);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
|
|
|
|
static PlugInProcDef xcf_plug_in_load_proc =
|
|
|
|
{
|
2005-08-03 06:52:23 +08:00
|
|
|
"gimp-xcf-load",
|
2004-05-14 08:01:11 +08:00
|
|
|
N_("GIMP XCF image"),
|
2004-05-06 21:51:56 +08:00
|
|
|
NULL,
|
2004-05-19 05:19:43 +08:00
|
|
|
GIMP_ICON_TYPE_STOCK_ID,
|
|
|
|
-1,
|
2006-03-31 22:34:02 +08:00
|
|
|
(guint8 *) "gimp-wilber",
|
1997-11-25 06:05:25 +08:00
|
|
|
NULL, /* ignored for load */
|
|
|
|
0, /* ignored for load */
|
2004-05-19 05:19:43 +08:00
|
|
|
0,
|
|
|
|
FALSE,
|
2006-04-01 00:17:07 +08:00
|
|
|
NULL,
|
2005-04-25 20:42:26 +08:00
|
|
|
TRUE,
|
2004-05-19 05:19:43 +08:00
|
|
|
"xcf",
|
|
|
|
"",
|
|
|
|
"0,string,gimp\\040xcf\\040",
|
|
|
|
"image/x-xcf",
|
1997-11-25 06:05:25 +08:00
|
|
|
NULL, /* fill me in at runtime */
|
2001-12-28 01:58:30 +08:00
|
|
|
NULL, /* fill me in at runtime */
|
2004-05-19 05:19:43 +08:00
|
|
|
NULL /* fill me in at runtime */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
static PlugInProcDef xcf_plug_in_save_proc =
|
|
|
|
{
|
2005-08-03 06:52:23 +08:00
|
|
|
"gimp-xcf-save",
|
2004-05-14 08:01:11 +08:00
|
|
|
N_("GIMP XCF image"),
|
2004-05-06 21:51:56 +08:00
|
|
|
NULL,
|
2004-05-19 05:19:43 +08:00
|
|
|
GIMP_ICON_TYPE_STOCK_ID,
|
|
|
|
-1,
|
2006-03-31 22:34:02 +08:00
|
|
|
(guint8 *) "gimp-wilber",
|
1997-11-25 06:05:25 +08:00
|
|
|
"RGB*, GRAY*, INDEXED*",
|
|
|
|
0, /* fill me in at runtime */
|
2004-05-19 05:19:43 +08:00
|
|
|
0,
|
|
|
|
FALSE,
|
2006-04-01 00:17:07 +08:00
|
|
|
NULL,
|
2005-04-25 20:42:26 +08:00
|
|
|
TRUE,
|
2004-05-19 05:19:43 +08:00
|
|
|
"xcf",
|
|
|
|
"",
|
|
|
|
NULL,
|
|
|
|
"image/x-xcf",
|
1997-11-25 06:05:25 +08:00
|
|
|
NULL, /* fill me in at runtime */
|
2001-12-28 01:58:30 +08:00
|
|
|
NULL, /* fill me in at runtime */
|
2004-05-19 05:19:43 +08:00
|
|
|
NULL /* fill me in at runtime */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
2001-07-04 02:38:56 +08:00
|
|
|
|
|
|
|
static GimpXcfLoaderFunc *xcf_loaders[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2002-12-20 20:56:11 +08:00
|
|
|
xcf_load_image, /* version 0 */
|
2002-11-06 18:07:31 +08:00
|
|
|
xcf_load_image, /* version 1 */
|
|
|
|
xcf_load_image /* version 2 */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
void
|
2001-07-05 03:31:35 +08:00
|
|
|
xcf_init (Gimp *gimp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-01 01:42:13 +08:00
|
|
|
GimpProcedure *procedure;
|
2006-03-31 17:15:08 +08:00
|
|
|
|
2001-10-19 01:27:36 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
|
2004-07-17 06:54:53 +08:00
|
|
|
/* So this is sort of a hack, but its better than it was before. To
|
|
|
|
* do this right there would be a file load-save handler type and
|
|
|
|
* the whole interface would change but there isn't, and currently
|
|
|
|
* the plug-in structure contains all the load-save info, so it
|
|
|
|
* makes sense to use that for the XCF load/save handlers, even
|
|
|
|
* though they are internal. The only thing it requires is using a
|
|
|
|
* PlugInProcDef struct. -josh
|
2001-07-04 02:38:56 +08:00
|
|
|
*/
|
2006-04-01 00:17:07 +08:00
|
|
|
|
|
|
|
/* gimp-xcf-save */
|
|
|
|
procedure = xcf_plug_in_save_proc.procedure = gimp_procedure_new ();
|
2006-04-05 05:11:45 +08:00
|
|
|
gimp_procedure_initialize (procedure, GIMP_INTERNAL, 5, 0, xcf_save_invoker);
|
2006-04-01 00:17:07 +08:00
|
|
|
gimp_procedure_set_static_strings (procedure,
|
|
|
|
"gimp-xcf-save",
|
|
|
|
"gimp-xcf-save",
|
|
|
|
"saves file in the .xcf file format",
|
|
|
|
"The xcf file format has been designed "
|
|
|
|
"specifically for loading and saving "
|
|
|
|
"tiled and layered images in the GIMP. "
|
|
|
|
"This procedure will save the specified "
|
|
|
|
"image in the xcf file format.",
|
|
|
|
"Spencer Kimball & Peter Mattis",
|
|
|
|
"Spencer Kimball & Peter Mattis",
|
|
|
|
"1995-1996",
|
|
|
|
NULL);
|
|
|
|
|
2006-04-04 23:54:51 +08:00
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
gimp_param_spec_int32 ("dummy-param",
|
|
|
|
"Dummy Param",
|
|
|
|
"Dummy parameter",
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
gimp_param_spec_image_id ("image",
|
|
|
|
"Image",
|
|
|
|
"Input image",
|
|
|
|
gimp,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
gimp_param_spec_drawable_id ("drawable",
|
|
|
|
"Drawable",
|
|
|
|
"Active drawable of input image",
|
|
|
|
gimp,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
gimp_param_spec_string ("filename",
|
|
|
|
"Filename",
|
|
|
|
"The name of the file "
|
|
|
|
"to save the image in, "
|
|
|
|
"in the on-disk "
|
|
|
|
"character set and "
|
|
|
|
"encoding",
|
|
|
|
TRUE, FALSE, NULL,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
gimp_param_spec_string ("raw-filename",
|
|
|
|
"Raw filename",
|
|
|
|
"The basename of the "
|
|
|
|
"file, in UTF-8",
|
|
|
|
FALSE, FALSE, NULL,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-05 01:47:22 +08:00
|
|
|
gimp_pdb_register (gimp, procedure);
|
2006-04-01 00:17:07 +08:00
|
|
|
|
2001-07-04 02:38:56 +08:00
|
|
|
xcf_plug_in_save_proc.image_types_val =
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_ins_image_types_parse (xcf_plug_in_save_proc.image_types);
|
2004-07-17 06:54:53 +08:00
|
|
|
plug_ins_add_internal (gimp, &xcf_plug_in_save_proc);
|
|
|
|
|
2006-04-01 00:17:07 +08:00
|
|
|
/* gimp-xcf-load */
|
|
|
|
procedure = xcf_plug_in_load_proc.procedure = gimp_procedure_new ();
|
2006-04-05 05:11:45 +08:00
|
|
|
gimp_procedure_initialize (procedure, GIMP_INTERNAL, 3, 1, xcf_load_invoker);
|
2006-04-01 00:17:07 +08:00
|
|
|
gimp_procedure_set_static_strings (procedure,
|
|
|
|
"gimp-xcf-load",
|
|
|
|
"gimp-xcf-load",
|
|
|
|
"loads file saved in the .xcf file format",
|
|
|
|
"The xcf file format has been designed "
|
|
|
|
"specifically for loading and saving "
|
|
|
|
"tiled and layered images in the GIMP. "
|
|
|
|
"This procedure will load the specified "
|
|
|
|
"file.",
|
|
|
|
"Spencer Kimball & Peter Mattis",
|
|
|
|
"Spencer Kimball & Peter Mattis",
|
|
|
|
"1995-1996",
|
|
|
|
NULL);
|
|
|
|
|
2006-04-04 23:54:51 +08:00
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
gimp_param_spec_int32 ("dummy-param",
|
|
|
|
"Dummy Param",
|
|
|
|
"Dummy parameter",
|
|
|
|
G_MININT32, G_MAXINT32, 0,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
gimp_param_spec_string ("filename",
|
|
|
|
"Filename",
|
|
|
|
"The name of the file "
|
|
|
|
"to load, in the "
|
|
|
|
"on-disk character "
|
|
|
|
"set and encoding",
|
|
|
|
TRUE, FALSE, NULL,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
gimp_procedure_add_argument (procedure,
|
|
|
|
gimp_param_spec_string ("raw-filename",
|
|
|
|
"Raw filename",
|
|
|
|
"The basename of the "
|
|
|
|
"file, in UTF-8",
|
|
|
|
FALSE, FALSE, NULL,
|
|
|
|
GIMP_PARAM_READWRITE));
|
|
|
|
|
|
|
|
gimp_procedure_add_return_value (procedure,
|
|
|
|
gimp_param_spec_image_id ("image",
|
|
|
|
"Image",
|
|
|
|
"Output image",
|
|
|
|
gimp,
|
|
|
|
GIMP_PARAM_READWRITE));
|
2006-04-05 01:47:22 +08:00
|
|
|
gimp_pdb_register (gimp, procedure);
|
2001-07-04 02:38:56 +08:00
|
|
|
xcf_plug_in_load_proc.image_types_val =
|
2002-03-21 01:46:13 +08:00
|
|
|
plug_ins_image_types_parse (xcf_plug_in_load_proc.image_types);
|
2003-02-11 20:07:31 +08:00
|
|
|
plug_ins_add_internal (gimp, &xcf_plug_in_load_proc);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2001-07-04 02:38:56 +08:00
|
|
|
void
|
2001-10-19 01:27:36 +08:00
|
|
|
xcf_exit (Gimp *gimp)
|
2001-07-04 02:38:56 +08:00
|
|
|
{
|
2001-10-19 01:27:36 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2001-07-04 02:38:56 +08:00
|
|
|
}
|
|
|
|
|
2006-04-04 18:30:58 +08:00
|
|
|
static GValueArray *
|
|
|
|
xcf_load_invoker (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
const GValueArray *args)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-04 18:30:58 +08:00
|
|
|
XcfInfo info;
|
|
|
|
GValueArray *return_vals;
|
|
|
|
GimpImage *image = NULL;
|
|
|
|
const gchar *filename;
|
|
|
|
gboolean success = FALSE;
|
|
|
|
gchar id[14];
|
1997-11-25 06:05:25 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
gimp_set_busy (gimp);
|
1999-01-11 07:36:29 +08:00
|
|
|
|
2006-04-04 18:30:58 +08:00
|
|
|
filename = g_value_get_string (&args->values[1]);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-02-07 09:38:18 +08:00
|
|
|
info.fp = g_fopen (filename, "rb");
|
2001-07-04 02:38:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (info.fp)
|
|
|
|
{
|
2001-07-04 02:38:56 +08:00
|
|
|
info.cp = 0;
|
|
|
|
info.filename = filename;
|
2003-12-06 23:53:26 +08:00
|
|
|
info.tattoo_state = 0;
|
2001-07-04 02:38:56 +08:00
|
|
|
info.active_layer = NULL;
|
|
|
|
info.active_channel = NULL;
|
1998-01-22 15:02:57 +08:00
|
|
|
info.floating_sel_drawable = NULL;
|
2001-07-04 02:38:56 +08:00
|
|
|
info.floating_sel = NULL;
|
|
|
|
info.floating_sel_offset = 0;
|
|
|
|
info.swap_num = 0;
|
|
|
|
info.ref_count = NULL;
|
|
|
|
info.compression = COMPRESS_NONE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
success = TRUE;
|
2001-07-04 02:38:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
info.cp += xcf_read_int8 (info.fp, (guint8*) id, 14);
|
2001-07-04 02:38:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (strncmp (id, "gimp xcf ", 9) != 0)
|
2001-07-04 02:38:56 +08:00
|
|
|
{
|
|
|
|
success = FALSE;
|
|
|
|
}
|
2003-09-10 18:40:57 +08:00
|
|
|
else if (strcmp (id+9, "file") == 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
info.file_version = 0;
|
2003-09-10 18:40:57 +08:00
|
|
|
}
|
|
|
|
else if (id[9] == 'v')
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-08-11 02:47:21 +08:00
|
|
|
info.file_version = atoi (id + 10);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2001-07-04 02:38:56 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
success = FALSE;
|
|
|
|
}
|
2003-09-10 18:40:57 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (success)
|
|
|
|
{
|
2002-12-20 20:56:11 +08:00
|
|
|
if (info.file_version < G_N_ELEMENTS (xcf_loaders))
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
image = (*(xcf_loaders[info.file_version])) (gimp, &info);
|
2001-07-04 02:38:56 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
if (! image)
|
1998-04-13 17:17:27 +08:00
|
|
|
success = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2003-09-10 18:40:57 +08:00
|
|
|
else
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2001-07-04 02:38:56 +08:00
|
|
|
g_message (_("XCF error: unsupported XCF file version %d "
|
|
|
|
"encountered"), info.file_version);
|
1997-11-25 06:05:25 +08:00
|
|
|
success = FALSE;
|
|
|
|
}
|
|
|
|
}
|
2001-07-04 02:38:56 +08:00
|
|
|
|
1997-12-17 01:26:00 +08:00
|
|
|
fclose (info.fp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2003-11-14 23:33:40 +08:00
|
|
|
else
|
2004-01-14 10:03:37 +08:00
|
|
|
g_message (_("Could not open '%s' for reading: %s"),
|
2004-01-19 09:08:43 +08:00
|
|
|
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
2003-09-10 18:40:57 +08:00
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (success)
|
2006-04-04 18:30:58 +08:00
|
|
|
gimp_value_set_image (&return_vals->values[1], image);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
gimp_unset_busy (gimp);
|
1999-01-11 07:36:29 +08:00
|
|
|
|
2006-03-28 05:09:32 +08:00
|
|
|
return return_vals;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2006-04-04 18:30:58 +08:00
|
|
|
static GValueArray *
|
|
|
|
xcf_save_invoker (GimpProcedure *procedure,
|
|
|
|
Gimp *gimp,
|
|
|
|
GimpContext *context,
|
|
|
|
GimpProgress *progress,
|
|
|
|
const GValueArray *args)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-04-04 18:30:58 +08:00
|
|
|
XcfInfo info;
|
|
|
|
GValueArray *return_vals;
|
|
|
|
GimpImage *image;
|
|
|
|
const gchar *filename;
|
|
|
|
gboolean success = FALSE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
gimp_set_busy (gimp);
|
1999-01-11 07:36:29 +08:00
|
|
|
|
2006-04-04 18:30:58 +08:00
|
|
|
image = gimp_value_get_image (&args->values[1], gimp);
|
|
|
|
filename = g_value_get_string (&args->values[3]);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-02-07 09:38:18 +08:00
|
|
|
info.fp = g_fopen (filename, "wb");
|
2001-07-04 02:38:56 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (info.fp)
|
|
|
|
{
|
2001-07-04 02:38:56 +08:00
|
|
|
info.cp = 0;
|
|
|
|
info.filename = filename;
|
|
|
|
info.active_layer = NULL;
|
|
|
|
info.active_channel = NULL;
|
1998-01-22 15:02:57 +08:00
|
|
|
info.floating_sel_drawable = NULL;
|
2001-07-04 02:38:56 +08:00
|
|
|
info.floating_sel = NULL;
|
|
|
|
info.floating_sel_offset = 0;
|
|
|
|
info.swap_num = 0;
|
|
|
|
info.ref_count = NULL;
|
|
|
|
info.compression = COMPRESS_RLE;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
xcf_save_choose_format (&info, image);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
success = xcf_save_image (&info, image);
|
2002-12-20 14:26:34 +08:00
|
|
|
if (fclose (info.fp) == EOF)
|
|
|
|
{
|
|
|
|
g_message (_("Error saving XCF file: %s"), g_strerror (errno));
|
|
|
|
|
|
|
|
success = FALSE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
2004-01-14 10:03:37 +08:00
|
|
|
g_message (_("Could not open '%s' for writing: %s"),
|
2004-01-19 09:08:43 +08:00
|
|
|
gimp_filename_to_utf8 (filename), g_strerror (errno));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-03-31 17:15:08 +08:00
|
|
|
return_vals = gimp_procedure_get_return_values (procedure, success);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
removed the gimp_busy boolean, check whether user_installation is needed
2001-07-10 Michael Natterer <mitch@gimp.org>
* app/app_procs.[ch]: removed the gimp_busy boolean, check whether
user_installation is needed here, not in user_install.c, parse
gtkrc an friends only if(!no_interface), create the Gimp object
before parsing gimp's rc files an pas it to the parse functions,
many other cleanups.
* app/appenums.h: added MessageHandlerType and StackTraceMode.
* app/appenv.h: removed MessageHandlerType, declare all global
variables from main.c (no more hidden global stuff please).
* app/errors.[ch]: added the fatal message func here (from main.c),
removed the StackTraceMode enum.
* app/gimprc.[ch]: renamed functions to gimprc_*(), pass a Gimp
pointer to some functions.
* app/gimpunit.c
* app/unitrc.h: ok, this is ugly: renamed all functions to
_gimp_unit_*() and made them public. The unit list is part
of the Gimp object now, so pass a Gimp* to all functions.
* app/libgimp_glue.[ch]: added EEKy wrappers for all gimp_unit_*()
functions which are used by widgets.
* app/main.c: cleaned up the global variables, removed the fatal
message handler, call app_init() directly, not via the
user_install stuff, misc. cleanups.
* app/user_install.[ch]: removed the check if user_installation is
needed (done by app_procs.c now).
* app/core/gimp.[ch]: added the user_unit list and the "busy"
boolean. Moved gimp_[set|unset]_busy() here. Added
gimp_initialize() which is called after unitrc and gimprc are
parsed.
* app/batch.c
* app/colormaps.c
* app/devices.c
* app/disp_callbacks.c
* app/gdisplay_ops.c
* app/gimphelp.c
* app/module_db.c
* app/nav_window.c
* app/plug_in.c
* app/core/gimpcontext.c
* app/core/gimpdatafiles.c
* app/core/gimpimage-convert.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.c
* app/core/gimpparasite.c
* app/core/gimpparasitelist.h
* app/gui/file-open-dialog.c
* app/gui/gui.[ch]
* app/gui/info-dialog.c
* app/gui/info-window.c
* app/gui/preferences-dialog.c
* app/gui/session.c
* app/gui/tips-dialog.c
* app/gui/toolbox.c
* app/tools/gimpblendtool.c
* app/tools/gimpbucketfilltool.c
* app/tools/gimpcolorpickertool.c
* app/tools/gimpfuzzyselecttool.c
* app/tools/gimptransformtool.c
* app/tools/tool_manager.c
* app/widgets/gimpcolorpanel.c
* app/widgets/gimpcursor.c
* app/xcf/xcf-load.c
* app/xcf/xcf-save.c
* app/xcf/xcf.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/app.pl
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/image.pdb
* tools/pdbgen/pdb/message.pdb
* tools/pdbgen/pdb/unit.pdb
* app/pdb/image_cmds.c
* app/pdb/message_cmds.c
* app/pdb/unit_cmds.c: changed accordingly, minor cleanups.
2001-07-11 03:16:16 +08:00
|
|
|
gimp_unset_busy (gimp);
|
1999-01-11 07:36:29 +08:00
|
|
|
|
2006-03-28 05:09:32 +08:00
|
|
|
return return_vals;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|