1998-10-30 18:21:33 +08:00
|
|
|
/* gimpparasite.c: Copyright 1998 Jay Cox <jaycox@earthlink.net>
|
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
1999-04-09 14:00:11 +08:00
|
|
|
#include <stdio.h>
|
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
|
|
|
#ifdef HAVE_UNISTD_H
|
1999-04-09 14:00:11 +08:00
|
|
|
#include <unistd.h>
|
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
|
|
|
#endif
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include "apptypes.h"
|
|
|
|
|
gave parasite undo a MISC_UNDO class for now so it compiles
* app/gimpdrawable.c: gave parasite undo a MISC_UNDO class for now
so it compiles
* app/tools_cmds.c: fix crop invoker to give correct args to
crop_image
* app/color_cmds.c: s/GRAY/GRAY_LUT/g;
* app/brush_select.[ch]: removed PDB procs, export brush_active_dialogs,
brush_select_dialog, s/active_dialogs/brush_active_dialogs/
* app/gimage_cmds.[ch]
* app/channel_ops.[ch]: removed channel ops PDB procs, moved duplicate
function from gimage_cmds to channel_ops, export offset and duplicate
* app/gimpbrushlist.[ch]: removed PDB procs
* app/gradient.[ch]: removed PDB procs,
* app/gradient_header.h: exported G_SAMPLE, GradSelect, num_gradients,
grad_active_dialogs, gradient_select_dialog
* app/gradient_select.c: removed PDB procs,
s/active_dialogs/grad_active_dialogs/
* app/patterns.[ch]: removed PDB procs
* app/pattern_select.[ch]: removed PDB procs,
s/active_dialogs/pattern_active_dialogs/
* app/procedural_db.c: removed PDB procs and supporting functions
* app/procedrual_db.h: fiddled with enums
* app/channel_cmds.[ch]
* app/drawable_cmds.[ch]
* app/parasite_cmds.[ch]: pdbgenned now, removed header files
* app/gimpparasite.c: minor cleanup
* app/internal_procs.c: use pdbgen stuff
* app/tools_cmds.c
* app/text_tool_cmds.c: updated from pdbgen
* app/brushes_cmds.c
* app/brush_select_cmds.c
* app/gradient_cmds.c
* app/gradient_select_cmds.c
* app/patterns_cmds.c
* app/pattern_select_cmds.c
* app/procedural_db_cmds.c: new pdbgen files
* app/Makefile.am: file shuffle (see above)
-Yosh
1999-04-24 04:54:02 +08:00
|
|
|
#include "app_procs.h"
|
1998-10-30 18:21:33 +08:00
|
|
|
#include "parasitelist.h"
|
|
|
|
#include "gimpparasite.h"
|
1999-04-12 06:28:51 +08:00
|
|
|
#include "gimprc.h"
|
2000-03-02 10:23:26 +08:00
|
|
|
|
2000-05-27 09:30:21 +08:00
|
|
|
#include "libgimp/gimpparasite.h"
|
1999-04-09 14:00:11 +08:00
|
|
|
#include "libgimp/gimpenv.h"
|
1998-10-30 18:21:33 +08:00
|
|
|
|
2000-05-27 09:30:21 +08:00
|
|
|
|
1998-10-30 18:21:33 +08:00
|
|
|
static ParasiteList *parasites = NULL;
|
|
|
|
|
|
|
|
void
|
2000-05-27 06:28:40 +08:00
|
|
|
gimp_init_parasites (void)
|
1998-10-30 18:21:33 +08:00
|
|
|
{
|
2000-01-11 07:27:25 +08:00
|
|
|
g_return_if_fail (parasites == NULL);
|
|
|
|
parasites = parasite_list_new ();
|
|
|
|
gimp_parasiterc_load ();
|
1998-10-30 18:21:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-05-27 06:28:40 +08:00
|
|
|
gimp_parasite_attach (GimpParasite *p)
|
1998-10-30 18:21:33 +08:00
|
|
|
{
|
2000-01-11 07:27:25 +08:00
|
|
|
parasite_list_add (parasites, p);
|
1998-10-30 18:21:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-05-27 06:28:40 +08:00
|
|
|
gimp_parasite_detach (const gchar *name)
|
1998-10-30 18:21:33 +08:00
|
|
|
{
|
2000-01-11 07:27:25 +08:00
|
|
|
parasite_list_remove (parasites, name);
|
1998-10-30 18:21:33 +08:00
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
GimpParasite *
|
|
|
|
gimp_parasite_find (const gchar *name)
|
1998-10-30 18:21:33 +08:00
|
|
|
{
|
2000-01-11 07:27:25 +08:00
|
|
|
return parasite_list_find (parasites, name);
|
1998-10-30 18:21:33 +08:00
|
|
|
}
|
|
|
|
|
2000-01-11 07:27:25 +08:00
|
|
|
static void
|
2000-05-27 06:28:40 +08:00
|
|
|
list_func (gchar *key,
|
|
|
|
GimpParasite *p,
|
|
|
|
gchar ***cur)
|
1999-02-14 02:19:44 +08:00
|
|
|
{
|
|
|
|
*(*cur)++ = (char *) g_strdup (key);
|
|
|
|
}
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
gchar **
|
1999-02-14 02:19:44 +08:00
|
|
|
gimp_parasite_list (gint *count)
|
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
gchar **list;
|
|
|
|
gchar **cur;
|
1999-02-14 02:19:44 +08:00
|
|
|
|
|
|
|
*count = parasite_list_length (parasites);
|
2000-05-27 06:28:40 +08:00
|
|
|
cur = list = g_new (gchar *, *count);
|
1999-02-14 02:19:44 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
parasite_list_foreach (parasites, (GHFunc) list_func, &cur);
|
1999-02-14 02:19:44 +08:00
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2000-01-11 07:27:25 +08:00
|
|
|
static void
|
2000-05-27 06:28:40 +08:00
|
|
|
save_func (gchar *key,
|
|
|
|
GimpParasite *p,
|
|
|
|
FILE *fp)
|
1999-04-12 06:28:51 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
if (gimp_parasite_is_persistent (p))
|
1999-04-12 06:28:51 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
gchar *s;
|
|
|
|
guint32 l;
|
1999-04-12 06:28:51 +08:00
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
fprintf (fp, "(parasite \"%s\" %lu \"",
|
|
|
|
gimp_parasite_name (p), gimp_parasite_flags (p));
|
1999-04-12 06:28:51 +08:00
|
|
|
|
1999-07-30 09:21:04 +08:00
|
|
|
/*
|
|
|
|
* the current methodology is: never move the parasiterc from one
|
|
|
|
* system to another. If you want to do this you should probably
|
|
|
|
* write out parasites which contain any non-alphanumeric(+some)
|
|
|
|
* characters as \xHH sequences altogether.
|
|
|
|
*/
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
for (s = (gchar *) gimp_parasite_data (p), l = gimp_parasite_data_size (p);
|
1999-04-12 06:28:51 +08:00
|
|
|
l;
|
|
|
|
l--, s++)
|
|
|
|
{
|
|
|
|
switch (*s)
|
|
|
|
{
|
1999-07-30 09:21:04 +08:00
|
|
|
case '\\': fputs ("\\\\", fp); break;
|
1999-04-12 06:28:51 +08:00
|
|
|
case '\0': fputs ("\\0", fp); break;
|
|
|
|
case '"' : fputs ("\\\"", fp); break;
|
|
|
|
/* disabled, not portable! */
|
|
|
|
/* case '\n': fputs ("\\n", fp); break;*/
|
|
|
|
/* case '\r': fputs ("\\r", fp); break;*/
|
|
|
|
case 26 : fputs ("\\z", fp); break;
|
|
|
|
default : fputc (*s, fp); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs ("\")\n\n", fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-04-09 14:00:11 +08:00
|
|
|
void
|
2000-01-11 07:27:25 +08:00
|
|
|
gimp_parasiterc_save (void)
|
1999-04-09 14:00:11 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
gchar *filename;
|
|
|
|
FILE *fp;
|
1999-04-12 06:28:51 +08:00
|
|
|
|
|
|
|
filename = gimp_personal_rc_file ("#parasiterc.tmp~");
|
|
|
|
|
|
|
|
fp = fopen (filename, "w");
|
|
|
|
g_free (filename);
|
|
|
|
if (!fp)
|
1999-04-09 14:00:11 +08:00
|
|
|
return;
|
1998-10-30 18:21:33 +08:00
|
|
|
|
2000-03-02 10:23:26 +08:00
|
|
|
fprintf (fp,
|
|
|
|
"# GIMP parasiterc\n"
|
|
|
|
"# This file will be entirely rewritten every time you "
|
|
|
|
"quit the gimp.\n\n");
|
2000-05-27 06:28:40 +08:00
|
|
|
|
1999-04-12 06:28:51 +08:00
|
|
|
parasite_list_foreach (parasites, (GHFunc)save_func, fp);
|
1998-10-30 18:21:33 +08:00
|
|
|
|
1999-04-12 06:28:51 +08:00
|
|
|
fclose (fp);
|
|
|
|
|
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
|
|
|
#if defined(G_OS_WIN32) || defined(__EMX__)
|
|
|
|
/* First rename the old parasiterc out of the way */
|
|
|
|
unlink (gimp_personal_rc_file ("parasiterc.bak"));
|
|
|
|
rename (gimp_personal_rc_file ("parasiterc"),
|
|
|
|
gimp_personal_rc_file ("parasiterc.bak"));
|
|
|
|
#endif
|
|
|
|
|
2000-05-27 06:28:40 +08:00
|
|
|
if (rename (gimp_personal_rc_file ("#parasiterc.tmp~"),
|
|
|
|
gimp_personal_rc_file ("parasiterc")) != 0)
|
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
|
|
|
{
|
|
|
|
#if defined(G_OS_WIN32) || defined(__EMX__)
|
|
|
|
/* Rename the old parasiterc back */
|
|
|
|
rename (gimp_personal_rc_file ("parasiterc.bak"),
|
|
|
|
gimp_personal_rc_file ("parasiterc"));
|
|
|
|
#endif
|
2000-05-27 06:28:40 +08:00
|
|
|
unlink (gimp_personal_rc_file ("#parasiterc.tmp~"));
|
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
|
|
|
}
|
1999-04-09 14:00:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-01-11 07:27:25 +08:00
|
|
|
gimp_parasiterc_load (void)
|
1999-04-09 14:00:11 +08:00
|
|
|
{
|
2000-05-27 06:28:40 +08:00
|
|
|
gchar *filename;
|
1999-04-09 14:00:11 +08:00
|
|
|
|
1999-04-12 06:28:51 +08:00
|
|
|
filename = gimp_personal_rc_file ("parasiterc");
|
2000-01-11 07:27:25 +08:00
|
|
|
app_init_update_status (NULL, filename, -1);
|
1999-04-12 06:28:51 +08:00
|
|
|
parse_gimprc_file (filename);
|
|
|
|
g_free (filename);
|
1999-04-09 14:00:11 +08:00
|
|
|
}
|