2006-01-12 08:50:44 +08:00
|
|
|
/* gimpparasite.c: Copyright 1998 Jay Cox <jaycox@gimp.org>
|
1998-10-30 18:21:33 +08:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
Win32 portability changes:
* config.h.win32, README.win32: Small changes.
* tools/pdbgen/pdb/*.pdb: Include <string.h>.
* app/*_cmds.c: Autogenerated files reflect above changes.
* libgimp/makefile.msc app/makefile.msc: Various updates,
including new object files. Gtk+ directory now should be called
gtk+ (not gtk-plus). Use win32-specific gdk subdir. Glib directory
now should be called just glib.
* libgimp/gimp.def: Updates.
* libgimp/gimpfeatures.h.win32: Made current with
gimpfeatures.h.in.
* libgimp/gimpfileselection.c: Define S_ISDIR and S_ISREG if
necessary.
* tools/pdbgen/pdb/fileops.pdb: Must have a
statement (even an empty one) after a label.
* app/fileops_cmds.c: Autogenerated file reflects above changes.
* app/crop.c: Include <string.h>.
* app/{app_procs,batch,fileops,datafiles,errorconsole,general,
plug_in,temp_buf,tile_swap}.c: Test NATIVE_WIN32, not
_MSC_VER. (NATIVE_WIN32 means we are using the Microsoft C
runtime, even if we might be compiling with gcc.)
* app/fileops.c: Don't include <process.h> here.
* app/fileops.h: Do include <process.h> here.
* app/gimpparasite.c: Include config.h, guard inclusion of
<unistd.h>. (Is the inclusion of unistd.h in source files all over
the place really necessary?)
* app/ink.c: MSC doesn't handle conversion from unsigned __int64
to double, so cast to signed.
* app/lut_funcs.c: Include config.h, and define rint() if necessary.
* app/pixel_processor.c: Include config.h without "..", like in
all the other places. Include <string.h>
* app/text_tool.c: Guard the "POINTS" identifier that clashes with
<windows.h>, sigh.
1999-05-05 05:32:17 +08:00
|
|
|
#include "config.h"
|
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
#include <glib-object.h>
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-05-21 21:58:46 +08:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2005-01-26 03:11:26 +08:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2001-05-21 21:58:46 +08:00
|
|
|
|
2001-07-10 03:48:30 +08:00
|
|
|
#include "core-types.h"
|
2000-12-17 05:37:03 +08:00
|
|
|
|
2001-07-10 03:48:30 +08:00
|
|
|
#include "gimp.h"
|
2002-05-15 19:05:32 +08:00
|
|
|
#include "gimp-parasites.h"
|
2001-07-10 03:48:30 +08:00
|
|
|
#include "gimpparasitelist.h"
|
|
|
|
|
1998-10-30 18:21:33 +08:00
|
|
|
|
|
|
|
void
|
2006-04-02 23:37:25 +08:00
|
|
|
gimp_parasite_attach (Gimp *gimp,
|
2006-04-12 20:49:29 +08:00
|
|
|
const GimpParasite *parasite)
|
1998-10-30 18:21:33 +08:00
|
|
|
{
|
2006-04-02 23:37:25 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
g_return_if_fail (parasite != NULL);
|
|
|
|
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_list_add (gimp->parasites, parasite);
|
1998-10-30 18:21:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_detach (Gimp *gimp,
|
2006-04-12 20:49:29 +08:00
|
|
|
const gchar *name)
|
1998-10-30 18:21:33 +08:00
|
|
|
{
|
2006-04-02 23:37:25 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
|
|
|
g_return_if_fail (name != NULL);
|
|
|
|
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_list_remove (gimp->parasites, name);
|
1998-10-30 18:21:33 +08:00
|
|
|
}
|
|
|
|
|
2006-04-02 23:37:25 +08:00
|
|
|
const GimpParasite *
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_find (Gimp *gimp,
|
2006-04-12 20:49:29 +08:00
|
|
|
const gchar *name)
|
1998-10-30 18:21:33 +08:00
|
|
|
{
|
2006-04-02 23:37:25 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
|
2001-07-05 06:59:25 +08:00
|
|
|
return gimp_parasite_list_find (gimp->parasites, name);
|
1998-10-30 18:21:33 +08:00
|
|
|
}
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
static void
|
2002-05-15 06:48:24 +08:00
|
|
|
list_func (const gchar *key,
|
2006-04-12 20:49:29 +08:00
|
|
|
GimpParasite *parasite,
|
|
|
|
gchar ***current)
|
1999-02-14 02:19:44 +08:00
|
|
|
{
|
2002-05-15 06:48:24 +08:00
|
|
|
*(*current)++ = g_strdup (key);
|
1999-02-14 02:19:44 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gchar **
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasite_list (Gimp *gimp,
|
2006-04-12 20:49:29 +08:00
|
|
|
gint *count)
|
1999-02-14 02:19:44 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
gchar **list;
|
2002-05-15 06:48:24 +08:00
|
|
|
gchar **current;
|
1999-02-14 02:19:44 +08:00
|
|
|
|
2006-04-02 23:37:25 +08:00
|
|
|
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
|
|
|
|
g_return_val_if_fail (count != NULL, NULL);
|
|
|
|
|
2001-07-05 06:59:25 +08:00
|
|
|
*count = gimp_parasite_list_length (gimp->parasites);
|
1999-02-14 02:19:44 +08:00
|
|
|
|
2002-05-15 06:48:24 +08:00
|
|
|
list = current = g_new (gchar *, *count);
|
|
|
|
|
|
|
|
gimp_parasite_list_foreach (gimp->parasites, (GHFunc) list_func, ¤t);
|
|
|
|
|
1999-02-14 02:19:44 +08:00
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2002-05-14 04:24:19 +08:00
|
|
|
|
2002-05-15 19:05:32 +08:00
|
|
|
/* FIXME: this doesn't belong here */
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_parasite_shift_parent (GimpParasite *parasite)
|
|
|
|
{
|
2006-04-02 23:37:25 +08:00
|
|
|
g_return_if_fail (parasite != NULL);
|
2002-05-15 19:05:32 +08:00
|
|
|
|
|
|
|
parasite->flags = (parasite->flags >> 8);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* parasiterc functions */
|
2002-05-14 04:24:19 +08:00
|
|
|
|
1999-04-09 14:00:11 +08:00
|
|
|
void
|
2001-07-05 06:59:25 +08:00
|
|
|
gimp_parasiterc_load (Gimp *gimp)
|
|
|
|
{
|
2002-05-15 06:48:24 +08:00
|
|
|
gchar *filename;
|
|
|
|
GError *error = NULL;
|
2002-05-14 04:24:19 +08:00
|
|
|
|
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2001-07-05 06:59:25 +08:00
|
|
|
|
|
|
|
filename = gimp_personal_rc_file ("parasiterc");
|
2002-05-14 04:24:19 +08:00
|
|
|
|
2005-11-07 06:01:25 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename));
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
if (! gimp_config_deserialize_file (GIMP_CONFIG (gimp->parasites),
|
2006-04-12 20:49:29 +08:00
|
|
|
filename, NULL, &error))
|
2002-05-14 04:24:19 +08:00
|
|
|
{
|
2002-05-15 19:59:51 +08:00
|
|
|
if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT)
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
|
|
|
|
|
2002-05-15 06:48:24 +08:00
|
|
|
g_error_free (error);
|
2002-05-14 04:24:19 +08:00
|
|
|
}
|
|
|
|
|
2002-05-15 06:48:24 +08:00
|
|
|
g_free (filename);
|
2001-07-05 06:59:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_parasiterc_save (Gimp *gimp)
|
1999-04-09 14:00:11 +08:00
|
|
|
{
|
2002-05-15 19:05:32 +08:00
|
|
|
const gchar *header =
|
2003-03-06 04:21:50 +08:00
|
|
|
"GIMP parasiterc\n"
|
|
|
|
"\n"
|
2006-12-22 18:09:09 +08:00
|
|
|
"This file will be entirely rewritten each time you exit.";
|
2002-05-15 19:05:32 +08:00
|
|
|
const gchar *footer =
|
2003-03-06 04:21:50 +08:00
|
|
|
"end of parasiterc";
|
2002-05-15 19:05:32 +08:00
|
|
|
|
2002-05-15 06:48:24 +08:00
|
|
|
gchar *filename;
|
|
|
|
GError *error = NULL;
|
2001-04-25 07:06:51 +08:00
|
|
|
|
2002-05-15 06:48:24 +08:00
|
|
|
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
2002-05-15 19:05:32 +08:00
|
|
|
g_return_if_fail (GIMP_IS_PARASITE_LIST (gimp->parasites));
|
1999-04-12 06:28:51 +08:00
|
|
|
|
2002-05-15 06:48:24 +08:00
|
|
|
filename = gimp_personal_rc_file ("parasiterc");
|
libgimp/gimp.def libgimp/gimpui.def libgimp/makefile.{cygwin,msc}
2000-02-15 Tor Lillqvist <tml@iki.fi>
* libgimp/gimp.def
* libgimp/gimpui.def
* libgimp/makefile.{cygwin,msc}
* app/makefile.{cygwin,msc}
* plug-ins/makefile.{cygwin,msc}: Updates.
* app/datafiles.c (is_script): New Win32-only function, which
tests if a file's extension matches one of the extensions in the
PATHEXT environment variable (which the cmd.exe command
interpreter also uses). This is to avoid starting applications
associated with any random data file the user might have dropped
in the plug-ins folder, while still supporting plug-ins written in
scripting languages.
* app/gimpparasite.c (gimp_parasiterc_save): (Win32:) Cannot
rename to an existing file.
* plug-ins/Lighting/lighting_image.c
* plug-ins/Lighting/lighting_share.c
* plug-ins/MapObject/mapobject_preview.c
* plug-ins/MapObject/mapobject_shade.c: Use G_PI.
* plug-ins/common/gz.c: #ifdef G_OS_WIN32 was used before its
potential definition via glib.h.
* plug-ins/common/jpeg.c: Also recognize Exif files, which are
typically produced by digital cameras. The usually have a .jpg
file name extension, and would thus already match this plug-in,
but add the magic string just in case. They are loaded just fine
by libjpeg even if they don't have the JFIF signature.
* plug-ins/common/tiff.c: Set TIFF warning and error handler, so
we get to pass libtiff's messages through the normal channels.
2000-02-15 06:44:06 +08:00
|
|
|
|
2005-11-07 06:01:25 +08:00
|
|
|
if (gimp->be_verbose)
|
|
|
|
g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename));
|
|
|
|
|
2003-10-11 22:30:18 +08:00
|
|
|
if (! gimp_config_serialize_to_file (GIMP_CONFIG (gimp->parasites),
|
2006-04-12 20:49:29 +08:00
|
|
|
filename,
|
|
|
|
header, footer, NULL,
|
|
|
|
&error))
|
libgimp/gimp.def libgimp/gimpui.def libgimp/makefile.{cygwin,msc}
2000-02-15 Tor Lillqvist <tml@iki.fi>
* libgimp/gimp.def
* libgimp/gimpui.def
* libgimp/makefile.{cygwin,msc}
* app/makefile.{cygwin,msc}
* plug-ins/makefile.{cygwin,msc}: Updates.
* app/datafiles.c (is_script): New Win32-only function, which
tests if a file's extension matches one of the extensions in the
PATHEXT environment variable (which the cmd.exe command
interpreter also uses). This is to avoid starting applications
associated with any random data file the user might have dropped
in the plug-ins folder, while still supporting plug-ins written in
scripting languages.
* app/gimpparasite.c (gimp_parasiterc_save): (Win32:) Cannot
rename to an existing file.
* plug-ins/Lighting/lighting_image.c
* plug-ins/Lighting/lighting_share.c
* plug-ins/MapObject/mapobject_preview.c
* plug-ins/MapObject/mapobject_shade.c: Use G_PI.
* plug-ins/common/gz.c: #ifdef G_OS_WIN32 was used before its
potential definition via glib.h.
* plug-ins/common/jpeg.c: Also recognize Exif files, which are
typically produced by digital cameras. The usually have a .jpg
file name extension, and would thus already match this plug-in,
but add the magic string just in case. They are loaded just fine
by libjpeg even if they don't have the JFIF signature.
* plug-ins/common/tiff.c: Set TIFF warning and error handler, so
we get to pass libtiff's messages through the normal channels.
2000-02-15 06:44:06 +08:00
|
|
|
{
|
2006-10-10 02:49:15 +08:00
|
|
|
gimp_message (gimp, NULL, GIMP_MESSAGE_ERROR, "%s", error->message);
|
2002-05-15 06:48:24 +08:00
|
|
|
g_error_free (error);
|
libgimp/gimp.def libgimp/gimpui.def libgimp/makefile.{cygwin,msc}
2000-02-15 Tor Lillqvist <tml@iki.fi>
* libgimp/gimp.def
* libgimp/gimpui.def
* libgimp/makefile.{cygwin,msc}
* app/makefile.{cygwin,msc}
* plug-ins/makefile.{cygwin,msc}: Updates.
* app/datafiles.c (is_script): New Win32-only function, which
tests if a file's extension matches one of the extensions in the
PATHEXT environment variable (which the cmd.exe command
interpreter also uses). This is to avoid starting applications
associated with any random data file the user might have dropped
in the plug-ins folder, while still supporting plug-ins written in
scripting languages.
* app/gimpparasite.c (gimp_parasiterc_save): (Win32:) Cannot
rename to an existing file.
* plug-ins/Lighting/lighting_image.c
* plug-ins/Lighting/lighting_share.c
* plug-ins/MapObject/mapobject_preview.c
* plug-ins/MapObject/mapobject_shade.c: Use G_PI.
* plug-ins/common/gz.c: #ifdef G_OS_WIN32 was used before its
potential definition via glib.h.
* plug-ins/common/jpeg.c: Also recognize Exif files, which are
typically produced by digital cameras. The usually have a .jpg
file name extension, and would thus already match this plug-in,
but add the magic string just in case. They are loaded just fine
by libjpeg even if they don't have the JFIF signature.
* plug-ins/common/tiff.c: Set TIFF warning and error handler, so
we get to pass libtiff's messages through the normal channels.
2000-02-15 06:44:06 +08:00
|
|
|
}
|
2001-04-25 07:06:51 +08:00
|
|
|
|
2002-05-15 06:48:24 +08:00
|
|
|
g_free (filename);
|
1999-04-09 14:00:11 +08:00
|
|
|
}
|