From 682b1f3c65b2de4ed241ed5bd29136a0fd152248 Mon Sep 17 00:00:00 2001 From: jaycox Date: Fri, 30 Oct 1998 10:21:33 +0000 Subject: [PATCH] Modified Files: ChangeLog app/Makefile.am app/app_procs.c app/channel.c Modified Files: ChangeLog app/Makefile.am app/app_procs.c app/channel.c app/channel.h app/file_new_dialog.c app/gimage_cmds.c app/gimage_cmds.h app/gimpdrawable.c app/gimpdrawable.h app/gimpdrawableP.h app/gimpimage.c app/gimpimage.h app/gimpimageF.h app/gimpimageP.h app/internal_procs.c app/layer.c app/layer.h app/parasite_cmds.c app/parasite_cmds.h app/plug_in.c app/preferences_dialog.c libgimp/Makefile.am libgimp/gimp.h libgimp/gimpdrawable.c libgimp/gimpfeatures.h.in libgimp/gimpimage.c libgimp/gimpmatrix.h libgimp/parasite.c libgimp/parasite.h plug-ins/script-fu/script-fu-console.c plug-ins/script-fu/script-fu.c Added Files: app/gimpparasite.c app/gimpparasite.h app/parasitelist.c app/parasitelist.h app/parasitelistF.h app/parasitelistP.h libgimp/gimpparasite.c lots of parasite related changes. --- ChangeLog | 34 +++++ app/Makefile.am | 6 + app/actions/plug-in-commands.c | 4 +- app/app_procs.c | 2 + app/channel.c | 6 +- app/channel.h | 2 +- app/core/gimp-parasites.c | 50 ++++++ app/core/gimp-parasites.h | 28 ++++ app/core/gimpchannel-combine.c | 6 +- app/core/gimpchannel-combine.h | 2 +- app/core/gimpchannel.c | 6 +- app/core/gimpchannel.h | 2 +- app/core/gimpdrawable.c | 19 +-- app/core/gimpdrawable.h | 4 +- app/core/gimpimage-guides.c | 27 ++-- app/core/gimpimage-guides.h | 35 +++-- app/core/gimpimage-merge.c | 27 ++-- app/core/gimpimage-merge.h | 35 +++-- app/core/gimpimage-projection.c | 27 ++-- app/core/gimpimage-projection.h | 35 +++-- app/core/gimpimage-resize.c | 27 ++-- app/core/gimpimage-resize.h | 35 +++-- app/core/gimpimage-scale.c | 27 ++-- app/core/gimpimage-scale.h | 35 +++-- app/core/gimpimage.c | 27 ++-- app/core/gimpimage.h | 35 +++-- app/core/gimplayer.c | 7 +- app/core/gimplayer.h | 2 +- app/core/gimpparasite.c | 50 ++++++ app/core/gimpparasite.h | 28 ++++ app/core/gimpparasitelist.c | 179 ++++++++++++++++++++++ app/core/gimpparasitelist.h | 45 ++++++ app/core/gimpprojection-construct.c | 27 ++-- app/core/gimpprojection-construct.h | 35 +++-- app/dialogs/image-new-dialog.c | 1 - app/dialogs/preferences-dialog.c | 1 - app/file_new_dialog.c | 1 - app/gimage_cmds.c | 185 +++++++++++++++++++++++ app/gimage_cmds.h | 3 + app/gimpchannel.c | 6 +- app/gimpchannel.h | 2 +- app/gimpdrawable.c | 19 +-- app/gimpdrawable.h | 4 +- app/gimpdrawableP.h | 3 +- app/gimpimage.c | 27 ++-- app/gimpimage.h | 35 +++-- app/gimpimageF.h | 3 +- app/gimpimageP.h | 5 +- app/gimplayer.c | 7 +- app/gimplayer.h | 2 +- app/gimpparasite.c | 50 ++++++ app/gimpparasite.h | 28 ++++ app/gui/file-new-dialog.c | 1 - app/gui/plug-in-commands.c | 4 +- app/gui/plug-in-menus.c | 4 +- app/gui/preferences-dialog.c | 1 - app/internal_procs.c | 8 +- app/layer.c | 7 +- app/layer.h | 2 +- app/menus/plug-in-menus.c | 4 +- app/parasite_cmds.c | 201 ++++++++++++++++++++++++- app/parasite_cmds.h | 3 + app/parasitelist.c | 179 ++++++++++++++++++++++ app/parasitelist.h | 45 ++++++ app/parasitelistF.h | 7 + app/parasitelistP.h | 39 +++++ app/plug-in/gimpplugin-message.c | 4 +- app/plug-in/gimpplugin-progress.c | 4 +- app/plug-in/gimpplugin.c | 4 +- app/plug-in/gimppluginmanager-call.c | 4 +- app/plug-in/gimppluginmanager-run.c | 4 +- app/plug-in/gimppluginmanager.c | 4 +- app/plug-in/gimppluginshm.c | 4 +- app/plug-in/plug-in-def.c | 4 +- app/plug-in/plug-in-message.c | 4 +- app/plug-in/plug-in-params.c | 4 +- app/plug-in/plug-in-progress.c | 4 +- app/plug-in/plug-in-run.c | 4 +- app/plug-in/plug-in-shm.c | 4 +- app/plug-in/plug-in.c | 4 +- app/plug-in/plug-ins.c | 4 +- app/plug_in.c | 4 +- app/preferences_dialog.c | 1 - libgimp/Makefile.am | 1 + libgimp/gimp.h | 26 +++- libgimp/gimpdrawable.c | 19 +++ libgimp/gimpdrawable_pdb.c | 19 +++ libgimp/gimpfeatures.h.in | 1 + libgimp/gimpimage.c | 62 ++++++++ libgimp/gimpimage_pdb.c | 62 ++++++++ libgimp/gimpmatrix.h | 7 + libgimp/gimpparasite.c | 71 +++------ libgimp/gimpparasite.h | 14 +- libgimp/gimpparasite_pdb.c | 70 +++++++++ libgimp/parasite.c | 71 +++------ libgimp/parasite.h | 14 +- libgimpbase/gimpparasite.c | 71 +++------ libgimpbase/gimpparasite.h | 14 +- libgimpbase/gimpversion.h.in | 1 + plug-ins/script-fu/script-fu-console.c | 18 ++- plug-ins/script-fu/script-fu.c | 6 +- 101 files changed, 1903 insertions(+), 512 deletions(-) create mode 100644 app/core/gimp-parasites.c create mode 100644 app/core/gimp-parasites.h create mode 100644 app/core/gimpparasite.c create mode 100644 app/core/gimpparasite.h create mode 100644 app/core/gimpparasitelist.c create mode 100644 app/core/gimpparasitelist.h create mode 100644 app/gimpparasite.c create mode 100644 app/gimpparasite.h create mode 100644 app/parasitelist.c create mode 100644 app/parasitelist.h create mode 100644 app/parasitelistF.h create mode 100644 app/parasitelistP.h create mode 100644 libgimp/gimpparasite_pdb.c diff --git a/ChangeLog b/ChangeLog index 6bb2c1d929..f11510797e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,37 @@ +Fri Oct 30 01:53:56 1998 Jay Cox (jaycox@earthlink.net) + + * app/parasitelist.c + * app/parasitelist.h + * app/parasitelistF.h + * app/parasitelistP.h: new files to implement a list class for + storing parasites in hash tables. + + * app/gimpparasite.c + * app/gimpparasite.h: new files for attaching parasites to the gimp. + + * app/Makefile.am, app/app_procs.c, app/channel.c, app/channel.h, + * app/file_new_dialog.c, app/gimage_cmds.c, app/gimage_cmds.h, + * app/gimpdrawable.c, app/gimpdrawable.h, app/gimpdrawableP.h, + * app/gimpimage.c, app/gimpimage.h, app/gimpimageF.h, app/gimpimageP.h, + * app/internal_procs.c, app/layer.c, app/layer.h, app/parasite_cmds.c, + * app/parasite_cmds.h, app/plug_in.c: various changes to utillize + the above new files + + * app/preferences_dialog.c: remove unecessary #include + + * libgimp/gimpfeatures.h.in: #define GIMP_HAVE_PARASITES + + * plug-ins/script-fu/script-fu-console.c: ugly work around for a bug + I can't track down. Posibly in gtk+, or unique to my system. + + * plug-ins/script-fu/script-fu.c: fix a bug in parasite parsing + + * libgimp/Makefile.am, libgimp/gimp.h, libgimp/gimpdrawable.c, + * libgimp/gimpimage.c, libgimp/gimpparasite.c, libgimp/parasite.c + : removed parasite_slist functions. added new parasite functions. + + * libgimp/gimpmatrix.h, libgimp/parasite.h: added extern "C" + Tue Oct 27 01:21:17 PST 1998 Manish Singh * app/indexed_palette.c: applied gimp-ruth-981025-0, cosmetic fix diff --git a/app/Makefile.am b/app/Makefile.am index b076f2a806..905d7e99e6 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -160,6 +160,8 @@ gimp_SOURCES = \ gimplist.h \ gimplistF.h \ gimplistP.h \ + gimpparasite.c \ + gimpparasite.h \ gimprc.c \ gimprc.h \ global_edit.c \ @@ -229,6 +231,10 @@ gimp_SOURCES = \ paintbrush.h \ parasite_cmds.c \ parasite_cmds.h \ + parasitelist.c \ + parasitelist.h \ + parasitelistF.h \ + parasitelistP.h \ pattern_header.h \ pattern_select.c \ pattern_select.h \ diff --git a/app/actions/plug-in-commands.c b/app/actions/plug-in-commands.c index b93310fb58..dd01e3725d 100644 --- a/app/actions/plug-in-commands.c +++ b/app/actions/plug-in-commands.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/app_procs.c b/app/app_procs.c index 5ceddb7599..58924991c7 100644 --- a/app/app_procs.c +++ b/app/app_procs.c @@ -38,6 +38,7 @@ #include "errorconsole.h" #include "fileops.h" #include "gimprc.h" +#include "gimpparasite.h" #include "gimpset.h" #include "global_edit.h" #include "gradient.h" @@ -500,6 +501,7 @@ app_init (void) file_ops_pre_init (); /* pre-initialize the file types */ RESET_BAR(); xcf_init (); /* initialize the xcf file format routines */ + gimp_init_parasites (); /* initialize the parasite table */ app_init_update_status (_("Looking for data files"), _("Brushes"), 0.00); brushes_init (no_data); /* initialize the list of gimp brushes */ diff --git a/app/channel.c b/app/channel.c index ef70f5adbd..f9c6e4e1c0 100644 --- a/app/channel.c +++ b/app/channel.c @@ -27,7 +27,7 @@ #include "gimage_mask.h" #include "layer.h" #include "paint_funcs.h" -#include "libgimp/parasite.h" +#include "parasitelist.h" #include "temp_buf.h" #include "undo.h" @@ -209,7 +209,7 @@ channel_copy (Channel *channel) /* copy the parasites */ GIMP_DRAWABLE(new_channel)->parasites - = parasite_gslist_copy(GIMP_DRAWABLE(channel)->parasites); + = parasite_list_copy(GIMP_DRAWABLE(channel)->parasites); /* free up the channel_name memory */ g_free (channel_name); @@ -477,7 +477,7 @@ channel_invalidate_previews (GimpImage* gimage) } } -guint32 +Tattoo channel_get_tattoo(const Channel *channel) { return (gimp_drawable_get_tattoo(GIMP_DRAWABLE(channel))); diff --git a/app/channel.h b/app/channel.h index ac9d30cf6e..ba4c84b071 100644 --- a/app/channel.h +++ b/app/channel.h @@ -95,7 +95,7 @@ int channel_toggle_visibility (Channel *); TempBuf * channel_preview (Channel *, int, int); void channel_invalidate_previews (GimpImage*); -guint32 channel_get_tattoo(const Channel *); +Tattoo channel_get_tattoo(const Channel *); /* selection mask functions */ diff --git a/app/core/gimp-parasites.c b/app/core/gimp-parasites.c new file mode 100644 index 0000000000..831b90ffb4 --- /dev/null +++ b/app/core/gimp-parasites.c @@ -0,0 +1,50 @@ +/* gimpparasite.c: Copyright 1998 Jay Cox + * + * 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. + */ + +#include +#include "parasitelist.h" +#include "gimpparasite.h" + +static ParasiteList *parasites = NULL; + +void +gimp_init_parasites() +{ + g_return_if_fail(parasites == NULL); + parasites = parasite_list_new(); +} + +void +gimp_attach_parasite (Parasite *p) +{ + parasite_list_add(parasites, p); +} + +void +gimp_detach_parasite (char *name) +{ + parasite_list_remove(parasites, name); +} + +Parasite * +gimp_find_parasite (char *name) +{ + return parasite_list_find(parasites, name); +} + + + diff --git a/app/core/gimp-parasites.h b/app/core/gimp-parasites.h new file mode 100644 index 0000000000..1b8e368055 --- /dev/null +++ b/app/core/gimp-parasites.h @@ -0,0 +1,28 @@ +/* gimpparasite.h: Copyright 1998 Jay Cox + * + * 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. + */ + +#ifndef __GIMP_PARASITE_H__ +#define __GIMP_PARASITE_H__ + +#include "libgimp/parasiteF.h" + +void gimp_init_parasites (void); +void gimp_attach_parasite (Parasite *p); +void gimp_detach_parasite (char *name); +Parasite * gimp_find_parasite (char *name); + +#endif /* __GIMP_PARASITE_H__ */ diff --git a/app/core/gimpchannel-combine.c b/app/core/gimpchannel-combine.c index ef70f5adbd..f9c6e4e1c0 100644 --- a/app/core/gimpchannel-combine.c +++ b/app/core/gimpchannel-combine.c @@ -27,7 +27,7 @@ #include "gimage_mask.h" #include "layer.h" #include "paint_funcs.h" -#include "libgimp/parasite.h" +#include "parasitelist.h" #include "temp_buf.h" #include "undo.h" @@ -209,7 +209,7 @@ channel_copy (Channel *channel) /* copy the parasites */ GIMP_DRAWABLE(new_channel)->parasites - = parasite_gslist_copy(GIMP_DRAWABLE(channel)->parasites); + = parasite_list_copy(GIMP_DRAWABLE(channel)->parasites); /* free up the channel_name memory */ g_free (channel_name); @@ -477,7 +477,7 @@ channel_invalidate_previews (GimpImage* gimage) } } -guint32 +Tattoo channel_get_tattoo(const Channel *channel) { return (gimp_drawable_get_tattoo(GIMP_DRAWABLE(channel))); diff --git a/app/core/gimpchannel-combine.h b/app/core/gimpchannel-combine.h index ac9d30cf6e..ba4c84b071 100644 --- a/app/core/gimpchannel-combine.h +++ b/app/core/gimpchannel-combine.h @@ -95,7 +95,7 @@ int channel_toggle_visibility (Channel *); TempBuf * channel_preview (Channel *, int, int); void channel_invalidate_previews (GimpImage*); -guint32 channel_get_tattoo(const Channel *); +Tattoo channel_get_tattoo(const Channel *); /* selection mask functions */ diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c index ef70f5adbd..f9c6e4e1c0 100644 --- a/app/core/gimpchannel.c +++ b/app/core/gimpchannel.c @@ -27,7 +27,7 @@ #include "gimage_mask.h" #include "layer.h" #include "paint_funcs.h" -#include "libgimp/parasite.h" +#include "parasitelist.h" #include "temp_buf.h" #include "undo.h" @@ -209,7 +209,7 @@ channel_copy (Channel *channel) /* copy the parasites */ GIMP_DRAWABLE(new_channel)->parasites - = parasite_gslist_copy(GIMP_DRAWABLE(channel)->parasites); + = parasite_list_copy(GIMP_DRAWABLE(channel)->parasites); /* free up the channel_name memory */ g_free (channel_name); @@ -477,7 +477,7 @@ channel_invalidate_previews (GimpImage* gimage) } } -guint32 +Tattoo channel_get_tattoo(const Channel *channel) { return (gimp_drawable_get_tattoo(GIMP_DRAWABLE(channel))); diff --git a/app/core/gimpchannel.h b/app/core/gimpchannel.h index ac9d30cf6e..ba4c84b071 100644 --- a/app/core/gimpchannel.h +++ b/app/core/gimpchannel.h @@ -95,7 +95,7 @@ int channel_toggle_visibility (Channel *); TempBuf * channel_preview (Channel *, int, int); void channel_invalidate_previews (GimpImage*); -guint32 channel_get_tattoo(const Channel *); +Tattoo channel_get_tattoo(const Channel *); /* selection mask functions */ diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c index 28ad900138..a96ac407de 100644 --- a/app/core/gimpdrawable.c +++ b/app/core/gimpdrawable.c @@ -24,7 +24,7 @@ #include "gimpsignal.h" #include "gimage.h" #include "gimage_mask.h" -#include "libgimp/parasite.h" +#include "parasitelist.h" enum { @@ -375,25 +375,22 @@ gimp_drawable_set_name (GimpDrawable *drawable, char *name) Parasite * gimp_drawable_find_parasite (const GimpDrawable *drawable, const char *name) { - return parasite_find_in_gslist(drawable->parasites, name); + return parasite_list_find(drawable->parasites, name); } void -gimp_drawable_attach_parasite (GimpDrawable *drawable, const Parasite *parasite) +gimp_drawable_attach_parasite (GimpDrawable *drawable, Parasite *parasite) { - drawable->parasites = parasite_add_to_gslist(parasite, drawable->parasites); + parasite_list_add(drawable->parasites, parasite); } void gimp_drawable_detach_parasite (GimpDrawable *drawable, const char *parasite) { - Parasite *p; - if ((p = parasite_find_in_gslist(drawable->parasites, parasite))) - drawable->parasites = g_slist_remove (drawable->parasites, p); - parasite_free(p); + parasite_list_remove(drawable->parasites, parasite); } -guint32 +Tattoo gimp_drawable_get_tattoo(const GimpDrawable *drawable) { return drawable->tattoo; @@ -556,7 +553,7 @@ gimp_drawable_init (GimpDrawable *drawable) drawable->has_alpha = FALSE; drawable->preview = NULL; drawable->preview_valid = FALSE; - drawable->parasites = FALSE; + drawable->parasites = parasite_list_new(); drawable->tattoo = 0; gimp_matrix_identity(drawable->transform); @@ -588,7 +585,7 @@ gimp_drawable_destroy (GtkObject *object) temp_buf_free (drawable->preview); if (drawable->parasites) - parasite_gslist_destroy(drawable->parasites); + gtk_object_unref(GTK_OBJECT(drawable->parasites)); if (GTK_OBJECT_CLASS (parent_class)->destroy) (*GTK_OBJECT_CLASS (parent_class)->destroy) (object); diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h index 24e3145d12..6a7108da9b 100644 --- a/app/core/gimpdrawable.h +++ b/app/core/gimpdrawable.h @@ -75,10 +75,10 @@ void gimp_drawable_set_name (GimpDrawable *, char *); Parasite * gimp_drawable_find_parasite (const GimpDrawable *, const char *name); -void gimp_drawable_attach_parasite (GimpDrawable *, const Parasite *); +void gimp_drawable_attach_parasite (GimpDrawable *, Parasite *); void gimp_drawable_detach_parasite (GimpDrawable *, const char *); -guint32 gimp_drawable_get_tattoo (const GimpDrawable *); +Tattoo gimp_drawable_get_tattoo (const GimpDrawable *); GimpDrawable * gimp_drawable_get_ID (int); void gimp_drawable_deallocate (GimpDrawable *); diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c index cff5ba82ee..0bbe75c103 100644 --- a/app/core/gimpimage-guides.c +++ b/app/core/gimpimage-guides.c @@ -26,6 +26,7 @@ #include "paint_funcs.h" #include "palette.h" #include "libgimp/parasite.h" +#include "parasitelist.h" #include "undo.h" #include "gimpsignal.h" @@ -152,7 +153,7 @@ static void gimp_image_init (GimpImage *gimage) gimage->comp_preview_valid[1] = FALSE; gimage->comp_preview_valid[2] = FALSE; gimage->comp_preview = NULL; - gimage->parasites = NULL; + gimage->parasites = parasite_list_new(); gimp_matrix_identity(gimage->transform); gimage->resolution = 72.0; /* maybe should be rc-supplied default? */ gimage->save_proc= NULL; @@ -493,7 +494,7 @@ gimp_image_destroy (GtkObject *object) gimp_image_free_channels (gimage); channel_delete (gimage->selection_mask); if (gimage->parasites) - parasite_gslist_destroy(gimage->parasites); + gtk_object_unref(GTK_OBJECT(gimage->parasites)); } void @@ -875,28 +876,28 @@ gimp_image_delete_guide (GimpImage *gimage, Parasite * gimp_image_find_parasite (const GimpImage *gimage, const char *name) { - return parasite_find_in_gslist(gimage->parasites, name); + return parasite_list_find(gimage->parasites, name); } void -gimp_image_attach_parasite (GimpImage *gimage, const Parasite *parasite) +gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - gimage->parasites = parasite_add_to_gslist(parasite, gimage->parasites); + parasite_list_add(gimage->parasites, parasite); } void gimp_image_detach_parasite (GimpImage *gimage, const char *parasite) { - Parasite *p; - if ((p = parasite_find_in_gslist(gimage->parasites, parasite))) - gimage->parasites = g_slist_remove (gimage->parasites, p); - parasite_free(p); + parasite_list_remove(gimage->parasites, parasite); } -guint32 +Tattoo gimp_image_get_new_tattoo(GimpImage *image) { - return (++image->tattoo_state); + image->tattoo_state++; + if (image->tattoo_state <= 0) + g_warning("Tattoo state has become corrupt (2.1 billion operation limit exceded)"); + return (image->tattoo_state); } @@ -1417,7 +1418,7 @@ gimp_image_get_active_channel (GimpImage *gimage) Layer * -gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_layer_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Layer *layer; GSList *layers = gimage->layers; @@ -1434,7 +1435,7 @@ gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) } Channel * -gimp_image_get_channel_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_channel_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Channel *channel; GSList *channels = gimage->channels; diff --git a/app/core/gimpimage-guides.h b/app/core/gimpimage-guides.h index ab6b1fba90..0ebb8ba10f 100644 --- a/app/core/gimpimage-guides.h +++ b/app/core/gimpimage-guides.h @@ -114,16 +114,23 @@ GimpImage * gimp_image_get_named (char *); GimpImage * gimp_image_get_ID (int); TileManager * gimp_image_shadow (GimpImage *, int, int, int); void gimp_image_free_shadow (GimpImage *); -void gimp_image_apply_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, int, - TileManager *, int, int); -void gimp_image_replace_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, - PixelRegion *, int, int); -void gimp_image_get_foreground (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_background (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_color (GimpImage *, int, unsigned char *, - unsigned char *); -void gimp_image_transform_color (GimpImage *, GimpDrawable *, unsigned char *, - unsigned char *, int); +void gimp_image_apply_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, + int, int, + TileManager *, int, int); +void gimp_image_replace_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, int, + PixelRegion *, int, int); +void gimp_image_get_foreground (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_background (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_color (GimpImage *, int, + unsigned char *, + unsigned char *); +void gimp_image_transform_color (GimpImage *, GimpDrawable *, + unsigned char *, + unsigned char *, int); Guide* gimp_image_add_hguide (GimpImage *); Guide* gimp_image_add_vguide (GimpImage *); void gimp_image_add_guide (GimpImage *, Guide *); @@ -132,10 +139,10 @@ void gimp_image_delete_guide (GimpImage *, Guide *); Parasite * gimp_image_find_parasite (const GimpImage *, const char *name); -void gimp_image_attach_parasite (GimpImage *, const Parasite *); +void gimp_image_attach_parasite (GimpImage *, Parasite *); void gimp_image_detach_parasite (GimpImage *, const char *); -guint32 gimp_image_get_new_tattoo (GimpImage *); +Tattoo gimp_image_get_new_tattoo (GimpImage *); /* layer/channel functions */ @@ -144,8 +151,8 @@ int gimp_image_get_layer_index (GimpImage *, Layer *); int gimp_image_get_channel_index (GimpImage *, Channel *); Layer * gimp_image_get_active_layer (GimpImage *); Channel * gimp_image_get_active_channel (GimpImage *); -Layer * gimp_image_get_layer_by_tattoo (GimpImage *, guint32); -Channel * gimp_image_get_channel_by_tattoo (GimpImage *, guint32); +Layer * gimp_image_get_layer_by_tattoo (GimpImage *, Tattoo); +Channel * gimp_image_get_channel_by_tattoo (GimpImage *, Tattoo); Channel * gimp_image_get_mask (GimpImage *); int gimp_image_get_component_active (GimpImage *, ChannelType); int gimp_image_get_component_visible (GimpImage *, ChannelType); diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c index cff5ba82ee..0bbe75c103 100644 --- a/app/core/gimpimage-merge.c +++ b/app/core/gimpimage-merge.c @@ -26,6 +26,7 @@ #include "paint_funcs.h" #include "palette.h" #include "libgimp/parasite.h" +#include "parasitelist.h" #include "undo.h" #include "gimpsignal.h" @@ -152,7 +153,7 @@ static void gimp_image_init (GimpImage *gimage) gimage->comp_preview_valid[1] = FALSE; gimage->comp_preview_valid[2] = FALSE; gimage->comp_preview = NULL; - gimage->parasites = NULL; + gimage->parasites = parasite_list_new(); gimp_matrix_identity(gimage->transform); gimage->resolution = 72.0; /* maybe should be rc-supplied default? */ gimage->save_proc= NULL; @@ -493,7 +494,7 @@ gimp_image_destroy (GtkObject *object) gimp_image_free_channels (gimage); channel_delete (gimage->selection_mask); if (gimage->parasites) - parasite_gslist_destroy(gimage->parasites); + gtk_object_unref(GTK_OBJECT(gimage->parasites)); } void @@ -875,28 +876,28 @@ gimp_image_delete_guide (GimpImage *gimage, Parasite * gimp_image_find_parasite (const GimpImage *gimage, const char *name) { - return parasite_find_in_gslist(gimage->parasites, name); + return parasite_list_find(gimage->parasites, name); } void -gimp_image_attach_parasite (GimpImage *gimage, const Parasite *parasite) +gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - gimage->parasites = parasite_add_to_gslist(parasite, gimage->parasites); + parasite_list_add(gimage->parasites, parasite); } void gimp_image_detach_parasite (GimpImage *gimage, const char *parasite) { - Parasite *p; - if ((p = parasite_find_in_gslist(gimage->parasites, parasite))) - gimage->parasites = g_slist_remove (gimage->parasites, p); - parasite_free(p); + parasite_list_remove(gimage->parasites, parasite); } -guint32 +Tattoo gimp_image_get_new_tattoo(GimpImage *image) { - return (++image->tattoo_state); + image->tattoo_state++; + if (image->tattoo_state <= 0) + g_warning("Tattoo state has become corrupt (2.1 billion operation limit exceded)"); + return (image->tattoo_state); } @@ -1417,7 +1418,7 @@ gimp_image_get_active_channel (GimpImage *gimage) Layer * -gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_layer_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Layer *layer; GSList *layers = gimage->layers; @@ -1434,7 +1435,7 @@ gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) } Channel * -gimp_image_get_channel_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_channel_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Channel *channel; GSList *channels = gimage->channels; diff --git a/app/core/gimpimage-merge.h b/app/core/gimpimage-merge.h index ab6b1fba90..0ebb8ba10f 100644 --- a/app/core/gimpimage-merge.h +++ b/app/core/gimpimage-merge.h @@ -114,16 +114,23 @@ GimpImage * gimp_image_get_named (char *); GimpImage * gimp_image_get_ID (int); TileManager * gimp_image_shadow (GimpImage *, int, int, int); void gimp_image_free_shadow (GimpImage *); -void gimp_image_apply_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, int, - TileManager *, int, int); -void gimp_image_replace_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, - PixelRegion *, int, int); -void gimp_image_get_foreground (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_background (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_color (GimpImage *, int, unsigned char *, - unsigned char *); -void gimp_image_transform_color (GimpImage *, GimpDrawable *, unsigned char *, - unsigned char *, int); +void gimp_image_apply_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, + int, int, + TileManager *, int, int); +void gimp_image_replace_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, int, + PixelRegion *, int, int); +void gimp_image_get_foreground (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_background (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_color (GimpImage *, int, + unsigned char *, + unsigned char *); +void gimp_image_transform_color (GimpImage *, GimpDrawable *, + unsigned char *, + unsigned char *, int); Guide* gimp_image_add_hguide (GimpImage *); Guide* gimp_image_add_vguide (GimpImage *); void gimp_image_add_guide (GimpImage *, Guide *); @@ -132,10 +139,10 @@ void gimp_image_delete_guide (GimpImage *, Guide *); Parasite * gimp_image_find_parasite (const GimpImage *, const char *name); -void gimp_image_attach_parasite (GimpImage *, const Parasite *); +void gimp_image_attach_parasite (GimpImage *, Parasite *); void gimp_image_detach_parasite (GimpImage *, const char *); -guint32 gimp_image_get_new_tattoo (GimpImage *); +Tattoo gimp_image_get_new_tattoo (GimpImage *); /* layer/channel functions */ @@ -144,8 +151,8 @@ int gimp_image_get_layer_index (GimpImage *, Layer *); int gimp_image_get_channel_index (GimpImage *, Channel *); Layer * gimp_image_get_active_layer (GimpImage *); Channel * gimp_image_get_active_channel (GimpImage *); -Layer * gimp_image_get_layer_by_tattoo (GimpImage *, guint32); -Channel * gimp_image_get_channel_by_tattoo (GimpImage *, guint32); +Layer * gimp_image_get_layer_by_tattoo (GimpImage *, Tattoo); +Channel * gimp_image_get_channel_by_tattoo (GimpImage *, Tattoo); Channel * gimp_image_get_mask (GimpImage *); int gimp_image_get_component_active (GimpImage *, ChannelType); int gimp_image_get_component_visible (GimpImage *, ChannelType); diff --git a/app/core/gimpimage-projection.c b/app/core/gimpimage-projection.c index cff5ba82ee..0bbe75c103 100644 --- a/app/core/gimpimage-projection.c +++ b/app/core/gimpimage-projection.c @@ -26,6 +26,7 @@ #include "paint_funcs.h" #include "palette.h" #include "libgimp/parasite.h" +#include "parasitelist.h" #include "undo.h" #include "gimpsignal.h" @@ -152,7 +153,7 @@ static void gimp_image_init (GimpImage *gimage) gimage->comp_preview_valid[1] = FALSE; gimage->comp_preview_valid[2] = FALSE; gimage->comp_preview = NULL; - gimage->parasites = NULL; + gimage->parasites = parasite_list_new(); gimp_matrix_identity(gimage->transform); gimage->resolution = 72.0; /* maybe should be rc-supplied default? */ gimage->save_proc= NULL; @@ -493,7 +494,7 @@ gimp_image_destroy (GtkObject *object) gimp_image_free_channels (gimage); channel_delete (gimage->selection_mask); if (gimage->parasites) - parasite_gslist_destroy(gimage->parasites); + gtk_object_unref(GTK_OBJECT(gimage->parasites)); } void @@ -875,28 +876,28 @@ gimp_image_delete_guide (GimpImage *gimage, Parasite * gimp_image_find_parasite (const GimpImage *gimage, const char *name) { - return parasite_find_in_gslist(gimage->parasites, name); + return parasite_list_find(gimage->parasites, name); } void -gimp_image_attach_parasite (GimpImage *gimage, const Parasite *parasite) +gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - gimage->parasites = parasite_add_to_gslist(parasite, gimage->parasites); + parasite_list_add(gimage->parasites, parasite); } void gimp_image_detach_parasite (GimpImage *gimage, const char *parasite) { - Parasite *p; - if ((p = parasite_find_in_gslist(gimage->parasites, parasite))) - gimage->parasites = g_slist_remove (gimage->parasites, p); - parasite_free(p); + parasite_list_remove(gimage->parasites, parasite); } -guint32 +Tattoo gimp_image_get_new_tattoo(GimpImage *image) { - return (++image->tattoo_state); + image->tattoo_state++; + if (image->tattoo_state <= 0) + g_warning("Tattoo state has become corrupt (2.1 billion operation limit exceded)"); + return (image->tattoo_state); } @@ -1417,7 +1418,7 @@ gimp_image_get_active_channel (GimpImage *gimage) Layer * -gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_layer_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Layer *layer; GSList *layers = gimage->layers; @@ -1434,7 +1435,7 @@ gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) } Channel * -gimp_image_get_channel_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_channel_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Channel *channel; GSList *channels = gimage->channels; diff --git a/app/core/gimpimage-projection.h b/app/core/gimpimage-projection.h index ab6b1fba90..0ebb8ba10f 100644 --- a/app/core/gimpimage-projection.h +++ b/app/core/gimpimage-projection.h @@ -114,16 +114,23 @@ GimpImage * gimp_image_get_named (char *); GimpImage * gimp_image_get_ID (int); TileManager * gimp_image_shadow (GimpImage *, int, int, int); void gimp_image_free_shadow (GimpImage *); -void gimp_image_apply_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, int, - TileManager *, int, int); -void gimp_image_replace_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, - PixelRegion *, int, int); -void gimp_image_get_foreground (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_background (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_color (GimpImage *, int, unsigned char *, - unsigned char *); -void gimp_image_transform_color (GimpImage *, GimpDrawable *, unsigned char *, - unsigned char *, int); +void gimp_image_apply_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, + int, int, + TileManager *, int, int); +void gimp_image_replace_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, int, + PixelRegion *, int, int); +void gimp_image_get_foreground (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_background (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_color (GimpImage *, int, + unsigned char *, + unsigned char *); +void gimp_image_transform_color (GimpImage *, GimpDrawable *, + unsigned char *, + unsigned char *, int); Guide* gimp_image_add_hguide (GimpImage *); Guide* gimp_image_add_vguide (GimpImage *); void gimp_image_add_guide (GimpImage *, Guide *); @@ -132,10 +139,10 @@ void gimp_image_delete_guide (GimpImage *, Guide *); Parasite * gimp_image_find_parasite (const GimpImage *, const char *name); -void gimp_image_attach_parasite (GimpImage *, const Parasite *); +void gimp_image_attach_parasite (GimpImage *, Parasite *); void gimp_image_detach_parasite (GimpImage *, const char *); -guint32 gimp_image_get_new_tattoo (GimpImage *); +Tattoo gimp_image_get_new_tattoo (GimpImage *); /* layer/channel functions */ @@ -144,8 +151,8 @@ int gimp_image_get_layer_index (GimpImage *, Layer *); int gimp_image_get_channel_index (GimpImage *, Channel *); Layer * gimp_image_get_active_layer (GimpImage *); Channel * gimp_image_get_active_channel (GimpImage *); -Layer * gimp_image_get_layer_by_tattoo (GimpImage *, guint32); -Channel * gimp_image_get_channel_by_tattoo (GimpImage *, guint32); +Layer * gimp_image_get_layer_by_tattoo (GimpImage *, Tattoo); +Channel * gimp_image_get_channel_by_tattoo (GimpImage *, Tattoo); Channel * gimp_image_get_mask (GimpImage *); int gimp_image_get_component_active (GimpImage *, ChannelType); int gimp_image_get_component_visible (GimpImage *, ChannelType); diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c index cff5ba82ee..0bbe75c103 100644 --- a/app/core/gimpimage-resize.c +++ b/app/core/gimpimage-resize.c @@ -26,6 +26,7 @@ #include "paint_funcs.h" #include "palette.h" #include "libgimp/parasite.h" +#include "parasitelist.h" #include "undo.h" #include "gimpsignal.h" @@ -152,7 +153,7 @@ static void gimp_image_init (GimpImage *gimage) gimage->comp_preview_valid[1] = FALSE; gimage->comp_preview_valid[2] = FALSE; gimage->comp_preview = NULL; - gimage->parasites = NULL; + gimage->parasites = parasite_list_new(); gimp_matrix_identity(gimage->transform); gimage->resolution = 72.0; /* maybe should be rc-supplied default? */ gimage->save_proc= NULL; @@ -493,7 +494,7 @@ gimp_image_destroy (GtkObject *object) gimp_image_free_channels (gimage); channel_delete (gimage->selection_mask); if (gimage->parasites) - parasite_gslist_destroy(gimage->parasites); + gtk_object_unref(GTK_OBJECT(gimage->parasites)); } void @@ -875,28 +876,28 @@ gimp_image_delete_guide (GimpImage *gimage, Parasite * gimp_image_find_parasite (const GimpImage *gimage, const char *name) { - return parasite_find_in_gslist(gimage->parasites, name); + return parasite_list_find(gimage->parasites, name); } void -gimp_image_attach_parasite (GimpImage *gimage, const Parasite *parasite) +gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - gimage->parasites = parasite_add_to_gslist(parasite, gimage->parasites); + parasite_list_add(gimage->parasites, parasite); } void gimp_image_detach_parasite (GimpImage *gimage, const char *parasite) { - Parasite *p; - if ((p = parasite_find_in_gslist(gimage->parasites, parasite))) - gimage->parasites = g_slist_remove (gimage->parasites, p); - parasite_free(p); + parasite_list_remove(gimage->parasites, parasite); } -guint32 +Tattoo gimp_image_get_new_tattoo(GimpImage *image) { - return (++image->tattoo_state); + image->tattoo_state++; + if (image->tattoo_state <= 0) + g_warning("Tattoo state has become corrupt (2.1 billion operation limit exceded)"); + return (image->tattoo_state); } @@ -1417,7 +1418,7 @@ gimp_image_get_active_channel (GimpImage *gimage) Layer * -gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_layer_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Layer *layer; GSList *layers = gimage->layers; @@ -1434,7 +1435,7 @@ gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) } Channel * -gimp_image_get_channel_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_channel_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Channel *channel; GSList *channels = gimage->channels; diff --git a/app/core/gimpimage-resize.h b/app/core/gimpimage-resize.h index ab6b1fba90..0ebb8ba10f 100644 --- a/app/core/gimpimage-resize.h +++ b/app/core/gimpimage-resize.h @@ -114,16 +114,23 @@ GimpImage * gimp_image_get_named (char *); GimpImage * gimp_image_get_ID (int); TileManager * gimp_image_shadow (GimpImage *, int, int, int); void gimp_image_free_shadow (GimpImage *); -void gimp_image_apply_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, int, - TileManager *, int, int); -void gimp_image_replace_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, - PixelRegion *, int, int); -void gimp_image_get_foreground (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_background (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_color (GimpImage *, int, unsigned char *, - unsigned char *); -void gimp_image_transform_color (GimpImage *, GimpDrawable *, unsigned char *, - unsigned char *, int); +void gimp_image_apply_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, + int, int, + TileManager *, int, int); +void gimp_image_replace_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, int, + PixelRegion *, int, int); +void gimp_image_get_foreground (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_background (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_color (GimpImage *, int, + unsigned char *, + unsigned char *); +void gimp_image_transform_color (GimpImage *, GimpDrawable *, + unsigned char *, + unsigned char *, int); Guide* gimp_image_add_hguide (GimpImage *); Guide* gimp_image_add_vguide (GimpImage *); void gimp_image_add_guide (GimpImage *, Guide *); @@ -132,10 +139,10 @@ void gimp_image_delete_guide (GimpImage *, Guide *); Parasite * gimp_image_find_parasite (const GimpImage *, const char *name); -void gimp_image_attach_parasite (GimpImage *, const Parasite *); +void gimp_image_attach_parasite (GimpImage *, Parasite *); void gimp_image_detach_parasite (GimpImage *, const char *); -guint32 gimp_image_get_new_tattoo (GimpImage *); +Tattoo gimp_image_get_new_tattoo (GimpImage *); /* layer/channel functions */ @@ -144,8 +151,8 @@ int gimp_image_get_layer_index (GimpImage *, Layer *); int gimp_image_get_channel_index (GimpImage *, Channel *); Layer * gimp_image_get_active_layer (GimpImage *); Channel * gimp_image_get_active_channel (GimpImage *); -Layer * gimp_image_get_layer_by_tattoo (GimpImage *, guint32); -Channel * gimp_image_get_channel_by_tattoo (GimpImage *, guint32); +Layer * gimp_image_get_layer_by_tattoo (GimpImage *, Tattoo); +Channel * gimp_image_get_channel_by_tattoo (GimpImage *, Tattoo); Channel * gimp_image_get_mask (GimpImage *); int gimp_image_get_component_active (GimpImage *, ChannelType); int gimp_image_get_component_visible (GimpImage *, ChannelType); diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c index cff5ba82ee..0bbe75c103 100644 --- a/app/core/gimpimage-scale.c +++ b/app/core/gimpimage-scale.c @@ -26,6 +26,7 @@ #include "paint_funcs.h" #include "palette.h" #include "libgimp/parasite.h" +#include "parasitelist.h" #include "undo.h" #include "gimpsignal.h" @@ -152,7 +153,7 @@ static void gimp_image_init (GimpImage *gimage) gimage->comp_preview_valid[1] = FALSE; gimage->comp_preview_valid[2] = FALSE; gimage->comp_preview = NULL; - gimage->parasites = NULL; + gimage->parasites = parasite_list_new(); gimp_matrix_identity(gimage->transform); gimage->resolution = 72.0; /* maybe should be rc-supplied default? */ gimage->save_proc= NULL; @@ -493,7 +494,7 @@ gimp_image_destroy (GtkObject *object) gimp_image_free_channels (gimage); channel_delete (gimage->selection_mask); if (gimage->parasites) - parasite_gslist_destroy(gimage->parasites); + gtk_object_unref(GTK_OBJECT(gimage->parasites)); } void @@ -875,28 +876,28 @@ gimp_image_delete_guide (GimpImage *gimage, Parasite * gimp_image_find_parasite (const GimpImage *gimage, const char *name) { - return parasite_find_in_gslist(gimage->parasites, name); + return parasite_list_find(gimage->parasites, name); } void -gimp_image_attach_parasite (GimpImage *gimage, const Parasite *parasite) +gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - gimage->parasites = parasite_add_to_gslist(parasite, gimage->parasites); + parasite_list_add(gimage->parasites, parasite); } void gimp_image_detach_parasite (GimpImage *gimage, const char *parasite) { - Parasite *p; - if ((p = parasite_find_in_gslist(gimage->parasites, parasite))) - gimage->parasites = g_slist_remove (gimage->parasites, p); - parasite_free(p); + parasite_list_remove(gimage->parasites, parasite); } -guint32 +Tattoo gimp_image_get_new_tattoo(GimpImage *image) { - return (++image->tattoo_state); + image->tattoo_state++; + if (image->tattoo_state <= 0) + g_warning("Tattoo state has become corrupt (2.1 billion operation limit exceded)"); + return (image->tattoo_state); } @@ -1417,7 +1418,7 @@ gimp_image_get_active_channel (GimpImage *gimage) Layer * -gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_layer_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Layer *layer; GSList *layers = gimage->layers; @@ -1434,7 +1435,7 @@ gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) } Channel * -gimp_image_get_channel_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_channel_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Channel *channel; GSList *channels = gimage->channels; diff --git a/app/core/gimpimage-scale.h b/app/core/gimpimage-scale.h index ab6b1fba90..0ebb8ba10f 100644 --- a/app/core/gimpimage-scale.h +++ b/app/core/gimpimage-scale.h @@ -114,16 +114,23 @@ GimpImage * gimp_image_get_named (char *); GimpImage * gimp_image_get_ID (int); TileManager * gimp_image_shadow (GimpImage *, int, int, int); void gimp_image_free_shadow (GimpImage *); -void gimp_image_apply_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, int, - TileManager *, int, int); -void gimp_image_replace_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, - PixelRegion *, int, int); -void gimp_image_get_foreground (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_background (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_color (GimpImage *, int, unsigned char *, - unsigned char *); -void gimp_image_transform_color (GimpImage *, GimpDrawable *, unsigned char *, - unsigned char *, int); +void gimp_image_apply_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, + int, int, + TileManager *, int, int); +void gimp_image_replace_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, int, + PixelRegion *, int, int); +void gimp_image_get_foreground (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_background (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_color (GimpImage *, int, + unsigned char *, + unsigned char *); +void gimp_image_transform_color (GimpImage *, GimpDrawable *, + unsigned char *, + unsigned char *, int); Guide* gimp_image_add_hguide (GimpImage *); Guide* gimp_image_add_vguide (GimpImage *); void gimp_image_add_guide (GimpImage *, Guide *); @@ -132,10 +139,10 @@ void gimp_image_delete_guide (GimpImage *, Guide *); Parasite * gimp_image_find_parasite (const GimpImage *, const char *name); -void gimp_image_attach_parasite (GimpImage *, const Parasite *); +void gimp_image_attach_parasite (GimpImage *, Parasite *); void gimp_image_detach_parasite (GimpImage *, const char *); -guint32 gimp_image_get_new_tattoo (GimpImage *); +Tattoo gimp_image_get_new_tattoo (GimpImage *); /* layer/channel functions */ @@ -144,8 +151,8 @@ int gimp_image_get_layer_index (GimpImage *, Layer *); int gimp_image_get_channel_index (GimpImage *, Channel *); Layer * gimp_image_get_active_layer (GimpImage *); Channel * gimp_image_get_active_channel (GimpImage *); -Layer * gimp_image_get_layer_by_tattoo (GimpImage *, guint32); -Channel * gimp_image_get_channel_by_tattoo (GimpImage *, guint32); +Layer * gimp_image_get_layer_by_tattoo (GimpImage *, Tattoo); +Channel * gimp_image_get_channel_by_tattoo (GimpImage *, Tattoo); Channel * gimp_image_get_mask (GimpImage *); int gimp_image_get_component_active (GimpImage *, ChannelType); int gimp_image_get_component_visible (GimpImage *, ChannelType); diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index cff5ba82ee..0bbe75c103 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -26,6 +26,7 @@ #include "paint_funcs.h" #include "palette.h" #include "libgimp/parasite.h" +#include "parasitelist.h" #include "undo.h" #include "gimpsignal.h" @@ -152,7 +153,7 @@ static void gimp_image_init (GimpImage *gimage) gimage->comp_preview_valid[1] = FALSE; gimage->comp_preview_valid[2] = FALSE; gimage->comp_preview = NULL; - gimage->parasites = NULL; + gimage->parasites = parasite_list_new(); gimp_matrix_identity(gimage->transform); gimage->resolution = 72.0; /* maybe should be rc-supplied default? */ gimage->save_proc= NULL; @@ -493,7 +494,7 @@ gimp_image_destroy (GtkObject *object) gimp_image_free_channels (gimage); channel_delete (gimage->selection_mask); if (gimage->parasites) - parasite_gslist_destroy(gimage->parasites); + gtk_object_unref(GTK_OBJECT(gimage->parasites)); } void @@ -875,28 +876,28 @@ gimp_image_delete_guide (GimpImage *gimage, Parasite * gimp_image_find_parasite (const GimpImage *gimage, const char *name) { - return parasite_find_in_gslist(gimage->parasites, name); + return parasite_list_find(gimage->parasites, name); } void -gimp_image_attach_parasite (GimpImage *gimage, const Parasite *parasite) +gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - gimage->parasites = parasite_add_to_gslist(parasite, gimage->parasites); + parasite_list_add(gimage->parasites, parasite); } void gimp_image_detach_parasite (GimpImage *gimage, const char *parasite) { - Parasite *p; - if ((p = parasite_find_in_gslist(gimage->parasites, parasite))) - gimage->parasites = g_slist_remove (gimage->parasites, p); - parasite_free(p); + parasite_list_remove(gimage->parasites, parasite); } -guint32 +Tattoo gimp_image_get_new_tattoo(GimpImage *image) { - return (++image->tattoo_state); + image->tattoo_state++; + if (image->tattoo_state <= 0) + g_warning("Tattoo state has become corrupt (2.1 billion operation limit exceded)"); + return (image->tattoo_state); } @@ -1417,7 +1418,7 @@ gimp_image_get_active_channel (GimpImage *gimage) Layer * -gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_layer_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Layer *layer; GSList *layers = gimage->layers; @@ -1434,7 +1435,7 @@ gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) } Channel * -gimp_image_get_channel_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_channel_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Channel *channel; GSList *channels = gimage->channels; diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h index ab6b1fba90..0ebb8ba10f 100644 --- a/app/core/gimpimage.h +++ b/app/core/gimpimage.h @@ -114,16 +114,23 @@ GimpImage * gimp_image_get_named (char *); GimpImage * gimp_image_get_ID (int); TileManager * gimp_image_shadow (GimpImage *, int, int, int); void gimp_image_free_shadow (GimpImage *); -void gimp_image_apply_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, int, - TileManager *, int, int); -void gimp_image_replace_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, - PixelRegion *, int, int); -void gimp_image_get_foreground (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_background (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_color (GimpImage *, int, unsigned char *, - unsigned char *); -void gimp_image_transform_color (GimpImage *, GimpDrawable *, unsigned char *, - unsigned char *, int); +void gimp_image_apply_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, + int, int, + TileManager *, int, int); +void gimp_image_replace_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, int, + PixelRegion *, int, int); +void gimp_image_get_foreground (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_background (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_color (GimpImage *, int, + unsigned char *, + unsigned char *); +void gimp_image_transform_color (GimpImage *, GimpDrawable *, + unsigned char *, + unsigned char *, int); Guide* gimp_image_add_hguide (GimpImage *); Guide* gimp_image_add_vguide (GimpImage *); void gimp_image_add_guide (GimpImage *, Guide *); @@ -132,10 +139,10 @@ void gimp_image_delete_guide (GimpImage *, Guide *); Parasite * gimp_image_find_parasite (const GimpImage *, const char *name); -void gimp_image_attach_parasite (GimpImage *, const Parasite *); +void gimp_image_attach_parasite (GimpImage *, Parasite *); void gimp_image_detach_parasite (GimpImage *, const char *); -guint32 gimp_image_get_new_tattoo (GimpImage *); +Tattoo gimp_image_get_new_tattoo (GimpImage *); /* layer/channel functions */ @@ -144,8 +151,8 @@ int gimp_image_get_layer_index (GimpImage *, Layer *); int gimp_image_get_channel_index (GimpImage *, Channel *); Layer * gimp_image_get_active_layer (GimpImage *); Channel * gimp_image_get_active_channel (GimpImage *); -Layer * gimp_image_get_layer_by_tattoo (GimpImage *, guint32); -Channel * gimp_image_get_channel_by_tattoo (GimpImage *, guint32); +Layer * gimp_image_get_layer_by_tattoo (GimpImage *, Tattoo); +Channel * gimp_image_get_channel_by_tattoo (GimpImage *, Tattoo); Channel * gimp_image_get_mask (GimpImage *); int gimp_image_get_component_active (GimpImage *, ChannelType); int gimp_image_get_component_visible (GimpImage *, ChannelType); diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c index 7c13ea4eab..f57c527221 100644 --- a/app/core/gimplayer.c +++ b/app/core/gimplayer.c @@ -30,10 +30,9 @@ #include "layer.h" #include "paint_funcs.h" #include "temp_buf.h" +#include "parasitelist.h" #include "undo.h" -#include "libgimp/parasite.h" - #include "layer_pvt.h" #include "tile_manager_pvt.h" #include "tile.h" /* ick. */ @@ -375,7 +374,7 @@ layer_copy (layer, add_alpha) /* copy the parasites */ GIMP_DRAWABLE(new_layer)->parasites - = parasite_gslist_copy(GIMP_DRAWABLE(layer)->parasites); + = parasite_list_copy(GIMP_DRAWABLE(layer)->parasites); cleanup: /* free up the layer_name memory */ @@ -1172,7 +1171,7 @@ layer_mask_preview (layer, w, h) } } -guint32 +Tattoo layer_get_tattoo(const Layer *layer) { return (gimp_drawable_get_tattoo(GIMP_DRAWABLE(layer))); diff --git a/app/core/gimplayer.h b/app/core/gimplayer.h index da5507bb28..ab8b19cc01 100644 --- a/app/core/gimplayer.h +++ b/app/core/gimplayer.h @@ -119,7 +119,7 @@ TempBuf * layer_preview (Layer *, int, int); TempBuf * layer_mask_preview (Layer *, int, int); void layer_invalidate_previews (GimpImage*); -guint32 layer_get_tattoo(const Layer *); +Tattoo layer_get_tattoo(const Layer *); #define drawable_layer GIMP_IS_LAYER diff --git a/app/core/gimpparasite.c b/app/core/gimpparasite.c new file mode 100644 index 0000000000..831b90ffb4 --- /dev/null +++ b/app/core/gimpparasite.c @@ -0,0 +1,50 @@ +/* gimpparasite.c: Copyright 1998 Jay Cox + * + * 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. + */ + +#include +#include "parasitelist.h" +#include "gimpparasite.h" + +static ParasiteList *parasites = NULL; + +void +gimp_init_parasites() +{ + g_return_if_fail(parasites == NULL); + parasites = parasite_list_new(); +} + +void +gimp_attach_parasite (Parasite *p) +{ + parasite_list_add(parasites, p); +} + +void +gimp_detach_parasite (char *name) +{ + parasite_list_remove(parasites, name); +} + +Parasite * +gimp_find_parasite (char *name) +{ + return parasite_list_find(parasites, name); +} + + + diff --git a/app/core/gimpparasite.h b/app/core/gimpparasite.h new file mode 100644 index 0000000000..1b8e368055 --- /dev/null +++ b/app/core/gimpparasite.h @@ -0,0 +1,28 @@ +/* gimpparasite.h: Copyright 1998 Jay Cox + * + * 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. + */ + +#ifndef __GIMP_PARASITE_H__ +#define __GIMP_PARASITE_H__ + +#include "libgimp/parasiteF.h" + +void gimp_init_parasites (void); +void gimp_attach_parasite (Parasite *p); +void gimp_detach_parasite (char *name); +Parasite * gimp_find_parasite (char *name); + +#endif /* __GIMP_PARASITE_H__ */ diff --git a/app/core/gimpparasitelist.c b/app/core/gimpparasitelist.c new file mode 100644 index 0000000000..48e955af3e --- /dev/null +++ b/app/core/gimpparasitelist.c @@ -0,0 +1,179 @@ +/* parasitelist.c: Copyright 1998 Jay Cox + * + * 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. + */ + +#include "gimpobjectP.h" +#include "gimpobject.h" +#include "gimpsignal.h" +#include "parasitelistP.h" +#include "libgimp/parasite.h" +#include "libgimp/parasiteP.h" + +enum +{ + ADD, + REMOVE, + LAST_SIGNAL +}; + +static guint parasite_list_signals[LAST_SIGNAL]; + +static void parasite_list_destroy (GtkObject* list); +static void parasite_list_init (ParasiteList* list); +static void parasite_list_class_init (ParasiteListClass *klass); +static int parasite_compare_func (gconstpointer n1, gconstpointer n2); +static int free_a_parasite (void *key, void *parasite, void *unused); + +static void +parasite_list_init (ParasiteList* list) +{ + list->table=NULL; +} + +static void +parasite_list_class_init(ParasiteListClass *klass) +{ + GtkObjectClass *class = GTK_OBJECT_CLASS(klass); + GtkType type = class->type; + + class->destroy = parasite_list_destroy; + + parasite_list_signals[ADD] = + gimp_signal_new("add", GTK_RUN_FIRST, type, 0, gimp_sigtype_pointer); + parasite_list_signals[REMOVE] = + gimp_signal_new("remove", GTK_RUN_FIRST, type, 0, gimp_sigtype_pointer); + gtk_object_class_add_signals (class, parasite_list_signals, LAST_SIGNAL); +} + +GtkType +parasite_list_get_type() +{ + static GtkType type = 0; + if (!type) + { + GtkTypeInfo info = + { + "ParasiteList", + sizeof (ParasiteList), + sizeof (ParasiteListClass), + (GtkClassInitFunc) parasite_list_class_init, + (GtkObjectInitFunc) parasite_list_init, + NULL, + NULL, + (GtkClassInitFunc) NULL + }; + type = gtk_type_unique(GIMP_TYPE_OBJECT, &info); + } + return type; +} + +ParasiteList* +parasite_list_new() +{ + ParasiteList *list = gtk_type_new(GIMP_TYPE_PARASITE_LIST); + list->table = NULL; + return list; +} + +static int +parasite_compare_func(gconstpointer n1, gconstpointer n2) +{ + return (!strcmp((char*)n1, (char*)n2)); +} + +static int +free_a_parasite(void *key, void *parasite, void *unused) +{ + parasite_free((Parasite *)parasite); + return TRUE; +} + +static void +parasite_list_destroy(GtkObject *obj) +{ + ParasiteList *list; + + g_return_if_fail(obj != NULL); + g_return_if_fail(GIMP_IS_PARASITE_LIST(obj)); + + list = (ParasiteList *)obj; + + if (list->table) + { + g_hash_table_foreach_remove(list->table, free_a_parasite, NULL); + g_hash_table_destroy(list->table); + } +} + +static void +parasite_copy_one(void *key, void *p, void *data) +{ + ParasiteList *list = (ParasiteList*)data; + Parasite *parasite = (Parasite*)p; + parasite_list_add(list, parasite); +} + +ParasiteList* +parasite_list_copy(const ParasiteList *list) +{ + ParasiteList *newlist; + newlist = parasite_list_new(); + if (list->table) + g_hash_table_foreach(list->table, parasite_copy_one, newlist); + return newlist; +} + +void +parasite_list_add(ParasiteList *list, Parasite *p) +{ + g_return_if_fail(list != NULL); + if (list->table == NULL) + list->table = g_hash_table_new(g_str_hash, parasite_compare_func); + g_return_if_fail(p != NULL); + g_return_if_fail(p->name != NULL); + p = parasite_copy(p); + g_hash_table_insert(list->table, p->name, p); + gtk_signal_emit (GTK_OBJECT(list), parasite_list_signals[ADD], p); +} + +void +parasite_list_remove(ParasiteList *list, const char *name) +{ + Parasite *p; + g_return_if_fail(list != NULL); + if (list->table) + { + p = parasite_list_find(list, name); + if (p) + { + g_hash_table_remove(list->table, name); + gtk_signal_emit (GTK_OBJECT(list), parasite_list_signals[REMOVE], p); + parasite_free(p); + } + } +} + +Parasite * +parasite_list_find(ParasiteList *list, const char *name) +{ + g_return_val_if_fail(list != NULL, NULL); + if (list->table) + return (Parasite *)g_hash_table_lookup(list->table, name); + else + return NULL; +} + + diff --git a/app/core/gimpparasitelist.h b/app/core/gimpparasitelist.h new file mode 100644 index 0000000000..256c4da9c9 --- /dev/null +++ b/app/core/gimpparasitelist.h @@ -0,0 +1,45 @@ +/* parasitelist.h: Copyright 1998 Jay Cox + * + * 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. + */ + +#ifndef __PARASITE_LIST_H__ +#define __PARASITE_LIST_H__ + +#include +#include "libgimp/parasiteF.h" +#include "parasitelistF.h" +#include "gimpobject.h" + +#define GIMP_TYPE_PARASITE_LIST (parasite_list_get_type ()) +#define GIMP_PARASITE_LIST(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_PARASITE_LIST, GimpParasiteList)) +#define GIMP_IS_PARASITE_LIST(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_PARASITE_LIST)) + +/* Signals: + add + remove +*/ + +GtkType parasite_list_get_type (void); + +/* function declarations */ + +ParasiteList *parasite_list_new (void); +ParasiteList *parasite_list_copy (const ParasiteList *list); +void parasite_list_add (ParasiteList *list, Parasite *p); +void parasite_list_remove (ParasiteList *list, const char *name); +Parasite *parasite_list_find (ParasiteList *list, const char *name); + +#endif /* __GIMP_PARASITE_H__ */ diff --git a/app/core/gimpprojection-construct.c b/app/core/gimpprojection-construct.c index cff5ba82ee..0bbe75c103 100644 --- a/app/core/gimpprojection-construct.c +++ b/app/core/gimpprojection-construct.c @@ -26,6 +26,7 @@ #include "paint_funcs.h" #include "palette.h" #include "libgimp/parasite.h" +#include "parasitelist.h" #include "undo.h" #include "gimpsignal.h" @@ -152,7 +153,7 @@ static void gimp_image_init (GimpImage *gimage) gimage->comp_preview_valid[1] = FALSE; gimage->comp_preview_valid[2] = FALSE; gimage->comp_preview = NULL; - gimage->parasites = NULL; + gimage->parasites = parasite_list_new(); gimp_matrix_identity(gimage->transform); gimage->resolution = 72.0; /* maybe should be rc-supplied default? */ gimage->save_proc= NULL; @@ -493,7 +494,7 @@ gimp_image_destroy (GtkObject *object) gimp_image_free_channels (gimage); channel_delete (gimage->selection_mask); if (gimage->parasites) - parasite_gslist_destroy(gimage->parasites); + gtk_object_unref(GTK_OBJECT(gimage->parasites)); } void @@ -875,28 +876,28 @@ gimp_image_delete_guide (GimpImage *gimage, Parasite * gimp_image_find_parasite (const GimpImage *gimage, const char *name) { - return parasite_find_in_gslist(gimage->parasites, name); + return parasite_list_find(gimage->parasites, name); } void -gimp_image_attach_parasite (GimpImage *gimage, const Parasite *parasite) +gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - gimage->parasites = parasite_add_to_gslist(parasite, gimage->parasites); + parasite_list_add(gimage->parasites, parasite); } void gimp_image_detach_parasite (GimpImage *gimage, const char *parasite) { - Parasite *p; - if ((p = parasite_find_in_gslist(gimage->parasites, parasite))) - gimage->parasites = g_slist_remove (gimage->parasites, p); - parasite_free(p); + parasite_list_remove(gimage->parasites, parasite); } -guint32 +Tattoo gimp_image_get_new_tattoo(GimpImage *image) { - return (++image->tattoo_state); + image->tattoo_state++; + if (image->tattoo_state <= 0) + g_warning("Tattoo state has become corrupt (2.1 billion operation limit exceded)"); + return (image->tattoo_state); } @@ -1417,7 +1418,7 @@ gimp_image_get_active_channel (GimpImage *gimage) Layer * -gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_layer_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Layer *layer; GSList *layers = gimage->layers; @@ -1434,7 +1435,7 @@ gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) } Channel * -gimp_image_get_channel_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_channel_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Channel *channel; GSList *channels = gimage->channels; diff --git a/app/core/gimpprojection-construct.h b/app/core/gimpprojection-construct.h index ab6b1fba90..0ebb8ba10f 100644 --- a/app/core/gimpprojection-construct.h +++ b/app/core/gimpprojection-construct.h @@ -114,16 +114,23 @@ GimpImage * gimp_image_get_named (char *); GimpImage * gimp_image_get_ID (int); TileManager * gimp_image_shadow (GimpImage *, int, int, int); void gimp_image_free_shadow (GimpImage *); -void gimp_image_apply_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, int, - TileManager *, int, int); -void gimp_image_replace_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, - PixelRegion *, int, int); -void gimp_image_get_foreground (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_background (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_color (GimpImage *, int, unsigned char *, - unsigned char *); -void gimp_image_transform_color (GimpImage *, GimpDrawable *, unsigned char *, - unsigned char *, int); +void gimp_image_apply_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, + int, int, + TileManager *, int, int); +void gimp_image_replace_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, int, + PixelRegion *, int, int); +void gimp_image_get_foreground (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_background (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_color (GimpImage *, int, + unsigned char *, + unsigned char *); +void gimp_image_transform_color (GimpImage *, GimpDrawable *, + unsigned char *, + unsigned char *, int); Guide* gimp_image_add_hguide (GimpImage *); Guide* gimp_image_add_vguide (GimpImage *); void gimp_image_add_guide (GimpImage *, Guide *); @@ -132,10 +139,10 @@ void gimp_image_delete_guide (GimpImage *, Guide *); Parasite * gimp_image_find_parasite (const GimpImage *, const char *name); -void gimp_image_attach_parasite (GimpImage *, const Parasite *); +void gimp_image_attach_parasite (GimpImage *, Parasite *); void gimp_image_detach_parasite (GimpImage *, const char *); -guint32 gimp_image_get_new_tattoo (GimpImage *); +Tattoo gimp_image_get_new_tattoo (GimpImage *); /* layer/channel functions */ @@ -144,8 +151,8 @@ int gimp_image_get_layer_index (GimpImage *, Layer *); int gimp_image_get_channel_index (GimpImage *, Channel *); Layer * gimp_image_get_active_layer (GimpImage *); Channel * gimp_image_get_active_channel (GimpImage *); -Layer * gimp_image_get_layer_by_tattoo (GimpImage *, guint32); -Channel * gimp_image_get_channel_by_tattoo (GimpImage *, guint32); +Layer * gimp_image_get_layer_by_tattoo (GimpImage *, Tattoo); +Channel * gimp_image_get_channel_by_tattoo (GimpImage *, Tattoo); Channel * gimp_image_get_mask (GimpImage *); int gimp_image_get_component_active (GimpImage *, ChannelType); int gimp_image_get_component_visible (GimpImage *, ChannelType); diff --git a/app/dialogs/image-new-dialog.c b/app/dialogs/image-new-dialog.c index 73ea4d1f98..6135f80eef 100644 --- a/app/dialogs/image-new-dialog.c +++ b/app/dialogs/image-new-dialog.c @@ -6,7 +6,6 @@ #include "commands.h" #include "general.h" #include "gimage.h" -#include "gimage_cmds.h" #include "gimprc.h" #include "global_edit.h" #include "interface.h" diff --git a/app/dialogs/preferences-dialog.c b/app/dialogs/preferences-dialog.c index ceec12c061..ea7fc426ad 100644 --- a/app/dialogs/preferences-dialog.c +++ b/app/dialogs/preferences-dialog.c @@ -21,7 +21,6 @@ #include "floating_sel.h" #include "gdisplay_ops.h" #include "general.h" -#include "gimage_cmds.h" #include "gimage_mask.h" #include "gimprc.h" #include "global_edit.h" diff --git a/app/file_new_dialog.c b/app/file_new_dialog.c index 73ea4d1f98..6135f80eef 100644 --- a/app/file_new_dialog.c +++ b/app/file_new_dialog.c @@ -6,7 +6,6 @@ #include "commands.h" #include "general.h" #include "gimage.h" -#include "gimage_cmds.h" #include "gimprc.h" #include "global_edit.h" #include "interface.h" diff --git a/app/gimage_cmds.c b/app/gimage_cmds.c index c0abb19cb7..1addeaa7bf 100644 --- a/app/gimage_cmds.c +++ b/app/gimage_cmds.c @@ -50,6 +50,9 @@ static Argument *gimp_image_find_parasite_invoker (Argument *); static Argument *gimp_image_attach_parasite_invoker (Argument *); static Argument *gimp_image_detach_parasite_invoker (Argument *); +/* The Tattoo procs prototypes */ +static Argument *gimp_image_get_layer_by_tattoo_invoker (Argument *); +static Argument *gimp_image_get_channel_by_tattoo_invoker (Argument *); static GImage * duplicate (GImage *gimage); @@ -4546,3 +4549,185 @@ gimp_image_detach_parasite_invoker (Argument *args) return return_args; } + +/******************************/ +/***** Tattoo functions *****/ + +/*** gimp_image_get_layer_by_tattoo ***/ + +ProcArg gimp_image_get_layer_by_tattoo_args[] = +{ + { PDB_IMAGE, + "image", + "the input image" + }, + { PDB_INT32, + "tattoo", + "The tattoo of the layer to find" + } +}; + +ProcArg gimp_image_get_layer_by_tattoo_out_args[] = +{ + { PDB_LAYER, + "layer", + "the layer with the specified tattoo" + }, +}; + +ProcRecord gimp_image_get_layer_by_tattoo_proc = +{ + "gimp_image_get_layer_by_tattoo", + "Find a layer with a given tattoo in an image", + "This procedure returns the layer with the given tattoo in the specified image.", + "Jay Cox", + "Jay Cox", + "1998", + PDB_INTERNAL, + + /* Input arguments */ + 2, + gimp_image_get_layer_by_tattoo_args, + + /* Output arguments */ + 1, + gimp_image_get_layer_by_tattoo_out_args, + + /* Exec method */ + { { gimp_image_get_layer_by_tattoo_invoker } }, +}; + + +static Argument * +gimp_image_get_layer_by_tattoo_invoker (Argument *args) +{ + int success = TRUE; + int int_value; + GImage *gimage; + Tattoo tattoo; + Argument *return_args; + Layer *layer; + + /* the gimage */ + if (success) + { + int_value = args[0].value.pdb_int; + if (! (gimage = gimage_get_ID (int_value))) + success = FALSE; + } + + if (success) + { + tattoo = args[1].value.pdb_int; + if (tattoo == 0) + success = FALSE; + } + + if (success) + { + layer = gimp_image_get_layer_by_tattoo (gimage, tattoo); + if (layer == NULL) + success = FALSE; + } + + return_args = + procedural_db_return_args (&gimp_image_get_layer_by_tattoo_proc, + success); + if (success) + { + return_args[1].value.pdb_int = drawable_ID(GIMP_DRAWABLE(layer)); + } + + return return_args; +} + + +/*** gimp_image_get_channel_by_tattoo ***/ + +ProcArg gimp_image_get_channel_by_tattoo_args[] = +{ + { PDB_IMAGE, + "image", + "the input image" + }, + { PDB_INT32, + "tattoo", + "The tattoo of the channel to find" + } +}; + +ProcArg gimp_image_get_channel_by_tattoo_out_args[] = +{ + { PDB_CHANNEL, + "channel", + "the channel with the specified tattoo" + }, +}; + +ProcRecord gimp_image_get_channel_by_tattoo_proc = +{ + "gimp_image_get_channel_by_tattoo", + "Find a channel with a given tattoo in an image", + "This procedure returns the channel with the given tattoo in the specified image.", + "Jay Cox", + "Jay Cox", + "1998", + PDB_INTERNAL, + + /* Input arguments */ + 2, + gimp_image_get_channel_by_tattoo_args, + + /* Output arguments */ + 1, + gimp_image_get_channel_by_tattoo_out_args, + + /* Exec method */ + { { gimp_image_get_channel_by_tattoo_invoker } }, +}; + + +static Argument * +gimp_image_get_channel_by_tattoo_invoker (Argument *args) +{ + int success = TRUE; + int int_value; + GImage *gimage; + Tattoo tattoo; + Argument *return_args; + Channel *channel; + + /* the gimage */ + if (success) + { + int_value = args[0].value.pdb_int; + if (! (gimage = gimage_get_ID (int_value))) + success = FALSE; + } + + if (success) + { + tattoo = args[1].value.pdb_int; + if (tattoo == 0) + success = FALSE; + } + + if (success) + { + channel = gimp_image_get_channel_by_tattoo (gimage, tattoo); + if (channel == NULL) + success = FALSE; + } + + return_args = + procedural_db_return_args (&gimp_image_get_channel_by_tattoo_proc, + success); + if (success) + { + return_args[1].value.pdb_int = drawable_ID(GIMP_DRAWABLE(channel)); + } + + return return_args; +} + + diff --git a/app/gimage_cmds.h b/app/gimage_cmds.h index ae563e6510..70dd015933 100644 --- a/app/gimage_cmds.h +++ b/app/gimage_cmds.h @@ -81,4 +81,7 @@ extern ProcRecord gimp_image_find_parasite_proc; extern ProcRecord gimp_image_attach_parasite_proc; extern ProcRecord gimp_image_detach_parasite_proc; +extern ProcRecord gimp_image_get_layer_by_tattoo_proc; +extern ProcRecord gimp_image_get_channel_by_tattoo_proc; + #endif /* __GIMAGE_CMDS_H__ */ diff --git a/app/gimpchannel.c b/app/gimpchannel.c index ef70f5adbd..f9c6e4e1c0 100644 --- a/app/gimpchannel.c +++ b/app/gimpchannel.c @@ -27,7 +27,7 @@ #include "gimage_mask.h" #include "layer.h" #include "paint_funcs.h" -#include "libgimp/parasite.h" +#include "parasitelist.h" #include "temp_buf.h" #include "undo.h" @@ -209,7 +209,7 @@ channel_copy (Channel *channel) /* copy the parasites */ GIMP_DRAWABLE(new_channel)->parasites - = parasite_gslist_copy(GIMP_DRAWABLE(channel)->parasites); + = parasite_list_copy(GIMP_DRAWABLE(channel)->parasites); /* free up the channel_name memory */ g_free (channel_name); @@ -477,7 +477,7 @@ channel_invalidate_previews (GimpImage* gimage) } } -guint32 +Tattoo channel_get_tattoo(const Channel *channel) { return (gimp_drawable_get_tattoo(GIMP_DRAWABLE(channel))); diff --git a/app/gimpchannel.h b/app/gimpchannel.h index ac9d30cf6e..ba4c84b071 100644 --- a/app/gimpchannel.h +++ b/app/gimpchannel.h @@ -95,7 +95,7 @@ int channel_toggle_visibility (Channel *); TempBuf * channel_preview (Channel *, int, int); void channel_invalidate_previews (GimpImage*); -guint32 channel_get_tattoo(const Channel *); +Tattoo channel_get_tattoo(const Channel *); /* selection mask functions */ diff --git a/app/gimpdrawable.c b/app/gimpdrawable.c index 28ad900138..a96ac407de 100644 --- a/app/gimpdrawable.c +++ b/app/gimpdrawable.c @@ -24,7 +24,7 @@ #include "gimpsignal.h" #include "gimage.h" #include "gimage_mask.h" -#include "libgimp/parasite.h" +#include "parasitelist.h" enum { @@ -375,25 +375,22 @@ gimp_drawable_set_name (GimpDrawable *drawable, char *name) Parasite * gimp_drawable_find_parasite (const GimpDrawable *drawable, const char *name) { - return parasite_find_in_gslist(drawable->parasites, name); + return parasite_list_find(drawable->parasites, name); } void -gimp_drawable_attach_parasite (GimpDrawable *drawable, const Parasite *parasite) +gimp_drawable_attach_parasite (GimpDrawable *drawable, Parasite *parasite) { - drawable->parasites = parasite_add_to_gslist(parasite, drawable->parasites); + parasite_list_add(drawable->parasites, parasite); } void gimp_drawable_detach_parasite (GimpDrawable *drawable, const char *parasite) { - Parasite *p; - if ((p = parasite_find_in_gslist(drawable->parasites, parasite))) - drawable->parasites = g_slist_remove (drawable->parasites, p); - parasite_free(p); + parasite_list_remove(drawable->parasites, parasite); } -guint32 +Tattoo gimp_drawable_get_tattoo(const GimpDrawable *drawable) { return drawable->tattoo; @@ -556,7 +553,7 @@ gimp_drawable_init (GimpDrawable *drawable) drawable->has_alpha = FALSE; drawable->preview = NULL; drawable->preview_valid = FALSE; - drawable->parasites = FALSE; + drawable->parasites = parasite_list_new(); drawable->tattoo = 0; gimp_matrix_identity(drawable->transform); @@ -588,7 +585,7 @@ gimp_drawable_destroy (GtkObject *object) temp_buf_free (drawable->preview); if (drawable->parasites) - parasite_gslist_destroy(drawable->parasites); + gtk_object_unref(GTK_OBJECT(drawable->parasites)); if (GTK_OBJECT_CLASS (parent_class)->destroy) (*GTK_OBJECT_CLASS (parent_class)->destroy) (object); diff --git a/app/gimpdrawable.h b/app/gimpdrawable.h index 24e3145d12..6a7108da9b 100644 --- a/app/gimpdrawable.h +++ b/app/gimpdrawable.h @@ -75,10 +75,10 @@ void gimp_drawable_set_name (GimpDrawable *, char *); Parasite * gimp_drawable_find_parasite (const GimpDrawable *, const char *name); -void gimp_drawable_attach_parasite (GimpDrawable *, const Parasite *); +void gimp_drawable_attach_parasite (GimpDrawable *, Parasite *); void gimp_drawable_detach_parasite (GimpDrawable *, const char *); -guint32 gimp_drawable_get_tattoo (const GimpDrawable *); +Tattoo gimp_drawable_get_tattoo (const GimpDrawable *); GimpDrawable * gimp_drawable_get_ID (int); void gimp_drawable_deallocate (GimpDrawable *); diff --git a/app/gimpdrawableP.h b/app/gimpdrawableP.h index 22c48ec118..b120810dfb 100644 --- a/app/gimpdrawableP.h +++ b/app/gimpdrawableP.h @@ -20,6 +20,7 @@ #include "gimpobjectP.h" #include "gimpdrawable.h" +#include "parasitelistF.h" #include "libgimp/gimpmatrix.h" struct _GimpDrawable @@ -40,7 +41,7 @@ struct _GimpDrawable int type; /* type of drawable */ int has_alpha; /* drawable has alpha */ - GSList *parasites; /* Plug-in parasite data */ + ParasiteList *parasites; /* Plug-in parasite data */ GimpMatrix transform; /* a matrix describing all of the transformations this drawable diff --git a/app/gimpimage.c b/app/gimpimage.c index cff5ba82ee..0bbe75c103 100644 --- a/app/gimpimage.c +++ b/app/gimpimage.c @@ -26,6 +26,7 @@ #include "paint_funcs.h" #include "palette.h" #include "libgimp/parasite.h" +#include "parasitelist.h" #include "undo.h" #include "gimpsignal.h" @@ -152,7 +153,7 @@ static void gimp_image_init (GimpImage *gimage) gimage->comp_preview_valid[1] = FALSE; gimage->comp_preview_valid[2] = FALSE; gimage->comp_preview = NULL; - gimage->parasites = NULL; + gimage->parasites = parasite_list_new(); gimp_matrix_identity(gimage->transform); gimage->resolution = 72.0; /* maybe should be rc-supplied default? */ gimage->save_proc= NULL; @@ -493,7 +494,7 @@ gimp_image_destroy (GtkObject *object) gimp_image_free_channels (gimage); channel_delete (gimage->selection_mask); if (gimage->parasites) - parasite_gslist_destroy(gimage->parasites); + gtk_object_unref(GTK_OBJECT(gimage->parasites)); } void @@ -875,28 +876,28 @@ gimp_image_delete_guide (GimpImage *gimage, Parasite * gimp_image_find_parasite (const GimpImage *gimage, const char *name) { - return parasite_find_in_gslist(gimage->parasites, name); + return parasite_list_find(gimage->parasites, name); } void -gimp_image_attach_parasite (GimpImage *gimage, const Parasite *parasite) +gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - gimage->parasites = parasite_add_to_gslist(parasite, gimage->parasites); + parasite_list_add(gimage->parasites, parasite); } void gimp_image_detach_parasite (GimpImage *gimage, const char *parasite) { - Parasite *p; - if ((p = parasite_find_in_gslist(gimage->parasites, parasite))) - gimage->parasites = g_slist_remove (gimage->parasites, p); - parasite_free(p); + parasite_list_remove(gimage->parasites, parasite); } -guint32 +Tattoo gimp_image_get_new_tattoo(GimpImage *image) { - return (++image->tattoo_state); + image->tattoo_state++; + if (image->tattoo_state <= 0) + g_warning("Tattoo state has become corrupt (2.1 billion operation limit exceded)"); + return (image->tattoo_state); } @@ -1417,7 +1418,7 @@ gimp_image_get_active_channel (GimpImage *gimage) Layer * -gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_layer_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Layer *layer; GSList *layers = gimage->layers; @@ -1434,7 +1435,7 @@ gimp_image_get_layer_by_tattoo (GimpImage *gimage, guint32 tattoo) } Channel * -gimp_image_get_channel_by_tattoo (GimpImage *gimage, guint32 tattoo) +gimp_image_get_channel_by_tattoo (GimpImage *gimage, Tattoo tattoo) { Channel *channel; GSList *channels = gimage->channels; diff --git a/app/gimpimage.h b/app/gimpimage.h index ab6b1fba90..0ebb8ba10f 100644 --- a/app/gimpimage.h +++ b/app/gimpimage.h @@ -114,16 +114,23 @@ GimpImage * gimp_image_get_named (char *); GimpImage * gimp_image_get_ID (int); TileManager * gimp_image_shadow (GimpImage *, int, int, int); void gimp_image_free_shadow (GimpImage *); -void gimp_image_apply_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, int, - TileManager *, int, int); -void gimp_image_replace_image (GimpImage *, GimpDrawable *, PixelRegion *, int, int, - PixelRegion *, int, int); -void gimp_image_get_foreground (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_background (GimpImage *, GimpDrawable *, unsigned char *); -void gimp_image_get_color (GimpImage *, int, unsigned char *, - unsigned char *); -void gimp_image_transform_color (GimpImage *, GimpDrawable *, unsigned char *, - unsigned char *, int); +void gimp_image_apply_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, + int, int, + TileManager *, int, int); +void gimp_image_replace_image (GimpImage *, GimpDrawable *, + PixelRegion *, int, int, + PixelRegion *, int, int); +void gimp_image_get_foreground (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_background (GimpImage *, GimpDrawable *, + unsigned char *); +void gimp_image_get_color (GimpImage *, int, + unsigned char *, + unsigned char *); +void gimp_image_transform_color (GimpImage *, GimpDrawable *, + unsigned char *, + unsigned char *, int); Guide* gimp_image_add_hguide (GimpImage *); Guide* gimp_image_add_vguide (GimpImage *); void gimp_image_add_guide (GimpImage *, Guide *); @@ -132,10 +139,10 @@ void gimp_image_delete_guide (GimpImage *, Guide *); Parasite * gimp_image_find_parasite (const GimpImage *, const char *name); -void gimp_image_attach_parasite (GimpImage *, const Parasite *); +void gimp_image_attach_parasite (GimpImage *, Parasite *); void gimp_image_detach_parasite (GimpImage *, const char *); -guint32 gimp_image_get_new_tattoo (GimpImage *); +Tattoo gimp_image_get_new_tattoo (GimpImage *); /* layer/channel functions */ @@ -144,8 +151,8 @@ int gimp_image_get_layer_index (GimpImage *, Layer *); int gimp_image_get_channel_index (GimpImage *, Channel *); Layer * gimp_image_get_active_layer (GimpImage *); Channel * gimp_image_get_active_channel (GimpImage *); -Layer * gimp_image_get_layer_by_tattoo (GimpImage *, guint32); -Channel * gimp_image_get_channel_by_tattoo (GimpImage *, guint32); +Layer * gimp_image_get_layer_by_tattoo (GimpImage *, Tattoo); +Channel * gimp_image_get_channel_by_tattoo (GimpImage *, Tattoo); Channel * gimp_image_get_mask (GimpImage *); int gimp_image_get_component_active (GimpImage *, ChannelType); int gimp_image_get_component_visible (GimpImage *, ChannelType); diff --git a/app/gimpimageF.h b/app/gimpimageF.h index 59e075207c..59c331ccb3 100644 --- a/app/gimpimageF.h +++ b/app/gimpimageF.h @@ -3,7 +3,8 @@ typedef struct _GimpImage GimpImage; -/* Move this someplace else */ +/* Move these someplace else */ typedef struct _Guide Guide; +typedef guint32 Tattoo; #endif diff --git a/app/gimpimageP.h b/app/gimpimageP.h index af86f6f03c..0257457734 100644 --- a/app/gimpimageP.h +++ b/app/gimpimageP.h @@ -8,6 +8,7 @@ #include "temp_buf.h" #include "channel.h" #include "layer.h" +#include "parasitelistF.h" #include "libgimp/gimpmatrix.h" @@ -33,7 +34,7 @@ struct _GimpImage int instance_count; /* number of instances */ int ref_count; /* number of references */ - guint32 tattoo_state; /* the next unique tattoo to use*/ + Tattoo tattoo_state; /* the next unique tattoo to use*/ TileManager *shadow; /* shadow buffer tiles */ @@ -57,7 +58,7 @@ struct _GimpImage Layer * floating_sel; /* ID of fs layer */ Channel * selection_mask; /* selection mask channel */ - GSList *parasites; /* Plug-in parasite data */ + ParasiteList *parasites; /* Plug-in parasite data */ GimpMatrix transform; /* a matrix describing all of the transformations this image diff --git a/app/gimplayer.c b/app/gimplayer.c index 7c13ea4eab..f57c527221 100644 --- a/app/gimplayer.c +++ b/app/gimplayer.c @@ -30,10 +30,9 @@ #include "layer.h" #include "paint_funcs.h" #include "temp_buf.h" +#include "parasitelist.h" #include "undo.h" -#include "libgimp/parasite.h" - #include "layer_pvt.h" #include "tile_manager_pvt.h" #include "tile.h" /* ick. */ @@ -375,7 +374,7 @@ layer_copy (layer, add_alpha) /* copy the parasites */ GIMP_DRAWABLE(new_layer)->parasites - = parasite_gslist_copy(GIMP_DRAWABLE(layer)->parasites); + = parasite_list_copy(GIMP_DRAWABLE(layer)->parasites); cleanup: /* free up the layer_name memory */ @@ -1172,7 +1171,7 @@ layer_mask_preview (layer, w, h) } } -guint32 +Tattoo layer_get_tattoo(const Layer *layer) { return (gimp_drawable_get_tattoo(GIMP_DRAWABLE(layer))); diff --git a/app/gimplayer.h b/app/gimplayer.h index da5507bb28..ab8b19cc01 100644 --- a/app/gimplayer.h +++ b/app/gimplayer.h @@ -119,7 +119,7 @@ TempBuf * layer_preview (Layer *, int, int); TempBuf * layer_mask_preview (Layer *, int, int); void layer_invalidate_previews (GimpImage*); -guint32 layer_get_tattoo(const Layer *); +Tattoo layer_get_tattoo(const Layer *); #define drawable_layer GIMP_IS_LAYER diff --git a/app/gimpparasite.c b/app/gimpparasite.c new file mode 100644 index 0000000000..831b90ffb4 --- /dev/null +++ b/app/gimpparasite.c @@ -0,0 +1,50 @@ +/* gimpparasite.c: Copyright 1998 Jay Cox + * + * 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. + */ + +#include +#include "parasitelist.h" +#include "gimpparasite.h" + +static ParasiteList *parasites = NULL; + +void +gimp_init_parasites() +{ + g_return_if_fail(parasites == NULL); + parasites = parasite_list_new(); +} + +void +gimp_attach_parasite (Parasite *p) +{ + parasite_list_add(parasites, p); +} + +void +gimp_detach_parasite (char *name) +{ + parasite_list_remove(parasites, name); +} + +Parasite * +gimp_find_parasite (char *name) +{ + return parasite_list_find(parasites, name); +} + + + diff --git a/app/gimpparasite.h b/app/gimpparasite.h new file mode 100644 index 0000000000..1b8e368055 --- /dev/null +++ b/app/gimpparasite.h @@ -0,0 +1,28 @@ +/* gimpparasite.h: Copyright 1998 Jay Cox + * + * 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. + */ + +#ifndef __GIMP_PARASITE_H__ +#define __GIMP_PARASITE_H__ + +#include "libgimp/parasiteF.h" + +void gimp_init_parasites (void); +void gimp_attach_parasite (Parasite *p); +void gimp_detach_parasite (char *name); +Parasite * gimp_find_parasite (char *name); + +#endif /* __GIMP_PARASITE_H__ */ diff --git a/app/gui/file-new-dialog.c b/app/gui/file-new-dialog.c index 73ea4d1f98..6135f80eef 100644 --- a/app/gui/file-new-dialog.c +++ b/app/gui/file-new-dialog.c @@ -6,7 +6,6 @@ #include "commands.h" #include "general.h" #include "gimage.h" -#include "gimage_cmds.h" #include "gimprc.h" #include "global_edit.h" #include "interface.h" diff --git a/app/gui/plug-in-commands.c b/app/gui/plug-in-commands.c index b93310fb58..dd01e3725d 100644 --- a/app/gui/plug-in-commands.c +++ b/app/gui/plug-in-commands.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/gui/plug-in-menus.c b/app/gui/plug-in-menus.c index b93310fb58..dd01e3725d 100644 --- a/app/gui/plug-in-menus.c +++ b/app/gui/plug-in-menus.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/gui/preferences-dialog.c b/app/gui/preferences-dialog.c index ceec12c061..ea7fc426ad 100644 --- a/app/gui/preferences-dialog.c +++ b/app/gui/preferences-dialog.c @@ -21,7 +21,6 @@ #include "floating_sel.h" #include "gdisplay_ops.h" #include "general.h" -#include "gimage_cmds.h" #include "gimage_mask.h" #include "gimprc.h" #include "global_edit.h" diff --git a/app/internal_procs.c b/app/internal_procs.c index 630a86216b..d5131977fa 100644 --- a/app/internal_procs.c +++ b/app/internal_procs.c @@ -80,7 +80,7 @@ internal_procs_init () { gfloat pcount = 0; /* grep -c procedural_db_register internal_procs.c */ - gfloat total_pcount = 240; + gfloat total_pcount = 245; app_init_update_status("Internal Procedures", "Tool procedures", pcount/total_pcount); @@ -193,6 +193,8 @@ internal_procs_init () procedural_db_register (&gimp_image_find_parasite_proc); pcount++; procedural_db_register (&gimp_image_attach_parasite_proc); pcount++; procedural_db_register (&gimp_image_detach_parasite_proc); pcount++; + procedural_db_register (&gimp_image_get_layer_by_tattoo_proc); pcount++; + procedural_db_register (&gimp_image_get_channel_by_tattoo_proc); pcount++; app_init_update_status(NULL, "GImage mask procedures", pcount/total_pcount); @@ -392,9 +394,11 @@ internal_procs_init () app_init_update_status(NULL, "parasites", pcount/total_pcount); - /* parasite procedures */ procedural_db_register (¶site_new_proc); pcount++; + procedural_db_register (&gimp_find_parasite_proc); pcount++; + procedural_db_register (&gimp_attach_parasite_proc); pcount++; + procedural_db_register (&gimp_detach_parasite_proc); pcount++; app_init_update_status(NULL, "Procedural database", pcount/total_pcount); diff --git a/app/layer.c b/app/layer.c index 7c13ea4eab..f57c527221 100644 --- a/app/layer.c +++ b/app/layer.c @@ -30,10 +30,9 @@ #include "layer.h" #include "paint_funcs.h" #include "temp_buf.h" +#include "parasitelist.h" #include "undo.h" -#include "libgimp/parasite.h" - #include "layer_pvt.h" #include "tile_manager_pvt.h" #include "tile.h" /* ick. */ @@ -375,7 +374,7 @@ layer_copy (layer, add_alpha) /* copy the parasites */ GIMP_DRAWABLE(new_layer)->parasites - = parasite_gslist_copy(GIMP_DRAWABLE(layer)->parasites); + = parasite_list_copy(GIMP_DRAWABLE(layer)->parasites); cleanup: /* free up the layer_name memory */ @@ -1172,7 +1171,7 @@ layer_mask_preview (layer, w, h) } } -guint32 +Tattoo layer_get_tattoo(const Layer *layer) { return (gimp_drawable_get_tattoo(GIMP_DRAWABLE(layer))); diff --git a/app/layer.h b/app/layer.h index da5507bb28..ab8b19cc01 100644 --- a/app/layer.h +++ b/app/layer.h @@ -119,7 +119,7 @@ TempBuf * layer_preview (Layer *, int, int); TempBuf * layer_mask_preview (Layer *, int, int); void layer_invalidate_previews (GimpImage*); -guint32 layer_get_tattoo(const Layer *); +Tattoo layer_get_tattoo(const Layer *); #define drawable_layer GIMP_IS_LAYER diff --git a/app/menus/plug-in-menus.c b/app/menus/plug-in-menus.c index b93310fb58..dd01e3725d 100644 --- a/app/menus/plug-in-menus.c +++ b/app/menus/plug-in-menus.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/parasite_cmds.c b/app/parasite_cmds.c index c34480b05b..c2e5218ced 100644 --- a/app/parasite_cmds.c +++ b/app/parasite_cmds.c @@ -18,12 +18,22 @@ */ #include "libgimp/parasite.h" +#include "parasitelist.h" +#include "gimpparasite.h" #include "procedural_db.h" #include "appenv.h" #include +/* The Parasite procs prototypes */ +static Argument *parasite_new_invoker (Argument *); +static Argument *gimp_find_parasite_invoker (Argument *); +static Argument *gimp_attach_parasite_invoker (Argument *); +static Argument *gimp_detach_parasite_invoker (Argument *); + static Argument *parasite_new_invoker (Argument *args); + +/***** parasite_new ****/ ProcArg parasite_new_args[] = { { PDB_STRING, @@ -83,7 +93,7 @@ parasite_new_invoker (Argument *args) guint32 flags, size; void *data; - /* creator */ + /* name */ if (success) { name = (char *) args[0].value.pdb_pointer; } /* flags */ @@ -101,13 +111,200 @@ parasite_new_invoker (Argument *args) } return_args = procedural_db_return_args (¶site_new_proc, + success); + /* The real work */ + if (success) + { + return_args[1].value.pdb_pointer = + parasite_new (name, flags, size, data); + } + + return return_args; +} + + +/***** gimp_find_parasite *****/ +ProcArg gimp_find_parasite_args[] = +{ + { PDB_STRING, + "name", + "The name of the parasite to find" + }, +}; + +ProcArg gimp_find_parasite_out_args[] = +{ + { PDB_PARASITE, + "parasite", + "the found parasite" + }, +}; + +ProcRecord gimp_find_parasite_proc = +{ + "gimp_find_parasite", + "Finds the named parasite.", + "Finds and returns the named parasite that was previously attached to the gimp.", + "Jay Cox", + "Jay Cox", + "1998", + PDB_INTERNAL, + + /* Input arguments */ + 1, + gimp_find_parasite_args, + + /* Output arguments */ + 1, + gimp_find_parasite_out_args, + + /* Exec method */ + { { gimp_find_parasite_invoker } }, +}; + + +static Argument * +gimp_find_parasite_invoker (Argument *args) +{ + int success = TRUE; + Argument *return_args; + char *name = NULL; + + /* name */ + if (success) + { + name = (char *) args[0].value.pdb_pointer; + } + + return_args = procedural_db_return_args (&gimp_find_parasite_proc, success); /* The real work */ if (success) { return_args[1].value.pdb_pointer = - parasite_new (name, flags, size, data); + gimp_find_parasite (name); + if (return_args[1].value.pdb_pointer == NULL) + return_args[1].value.pdb_pointer = parasite_error(); } return return_args; } + +/*** gimp_attach_parasite ***/ + +ProcArg gimp_attach_parasite_args[] = +{ + { PDB_PARASITE, + "parasite", + "The parasite to attach to the gimp" + } +}; + +ProcRecord gimp_attach_parasite_proc = +{ + "gimp_attach_parasite", + "Add a parasite to the gimp", + "This procedure attaches a parasite to the gimp. It has no return values.", + "Jay Cox", + "Jay Cox", + "1998", + PDB_INTERNAL, + + /* Input arguments */ + 1, + gimp_attach_parasite_args, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { gimp_attach_parasite_invoker } }, +}; + + +static Argument * +gimp_attach_parasite_invoker (Argument *args) +{ + int success = TRUE; + Parasite *parasite = NULL; + Argument *return_args; + + + + if (success) + { + parasite = (Parasite *)args[0].value.pdb_pointer; + if (parasite == NULL) + success = FALSE; + } + + if (success) + { + gimp_attach_parasite (parasite); + } + + return_args = procedural_db_return_args (&gimp_attach_parasite_proc, + success); + + return return_args; +} + + +/*** gimp_detach_parasite ***/ + +ProcArg gimp_detach_parasite_args[] = +{ + { PDB_STRING, + "name", + "The name of the parasite to detach from the gimp" + } +}; + +ProcRecord gimp_detach_parasite_proc = +{ + "gimp_detach_parasite", + "Removes a parasite from the gimp.", + "This procedure detaches a parasite from the gimp. It has no return values.", + "Jay Cox", + "Jay Cox", + "1998", + PDB_INTERNAL, + + /* Input arguments */ + 1, + gimp_detach_parasite_args, + + /* Output arguments */ + 0, + NULL, + + /* Exec method */ + { { gimp_detach_parasite_invoker } }, +}; + + +static Argument * +gimp_detach_parasite_invoker (Argument *args) +{ + int success = TRUE; + char *parasite = NULL; + Argument *return_args; + + if (success) + { + parasite = (char *)args[0].value.pdb_pointer; + if (parasite == NULL) + success = FALSE; + } + + if (success) + { + gimp_detach_parasite (parasite); + } + + return_args = procedural_db_return_args (&gimp_detach_parasite_proc, + success); + + return return_args; +} diff --git a/app/parasite_cmds.h b/app/parasite_cmds.h index 0d62fb4b34..d22b0d1dc4 100644 --- a/app/parasite_cmds.h +++ b/app/parasite_cmds.h @@ -21,5 +21,8 @@ #define __PARASITE_CMDS_H__ extern ProcRecord parasite_new_proc; +extern ProcRecord gimp_find_parasite_proc; +extern ProcRecord gimp_attach_parasite_proc; +extern ProcRecord gimp_detach_parasite_proc; #endif __PARASITE_CMDS_H__ diff --git a/app/parasitelist.c b/app/parasitelist.c new file mode 100644 index 0000000000..48e955af3e --- /dev/null +++ b/app/parasitelist.c @@ -0,0 +1,179 @@ +/* parasitelist.c: Copyright 1998 Jay Cox + * + * 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. + */ + +#include "gimpobjectP.h" +#include "gimpobject.h" +#include "gimpsignal.h" +#include "parasitelistP.h" +#include "libgimp/parasite.h" +#include "libgimp/parasiteP.h" + +enum +{ + ADD, + REMOVE, + LAST_SIGNAL +}; + +static guint parasite_list_signals[LAST_SIGNAL]; + +static void parasite_list_destroy (GtkObject* list); +static void parasite_list_init (ParasiteList* list); +static void parasite_list_class_init (ParasiteListClass *klass); +static int parasite_compare_func (gconstpointer n1, gconstpointer n2); +static int free_a_parasite (void *key, void *parasite, void *unused); + +static void +parasite_list_init (ParasiteList* list) +{ + list->table=NULL; +} + +static void +parasite_list_class_init(ParasiteListClass *klass) +{ + GtkObjectClass *class = GTK_OBJECT_CLASS(klass); + GtkType type = class->type; + + class->destroy = parasite_list_destroy; + + parasite_list_signals[ADD] = + gimp_signal_new("add", GTK_RUN_FIRST, type, 0, gimp_sigtype_pointer); + parasite_list_signals[REMOVE] = + gimp_signal_new("remove", GTK_RUN_FIRST, type, 0, gimp_sigtype_pointer); + gtk_object_class_add_signals (class, parasite_list_signals, LAST_SIGNAL); +} + +GtkType +parasite_list_get_type() +{ + static GtkType type = 0; + if (!type) + { + GtkTypeInfo info = + { + "ParasiteList", + sizeof (ParasiteList), + sizeof (ParasiteListClass), + (GtkClassInitFunc) parasite_list_class_init, + (GtkObjectInitFunc) parasite_list_init, + NULL, + NULL, + (GtkClassInitFunc) NULL + }; + type = gtk_type_unique(GIMP_TYPE_OBJECT, &info); + } + return type; +} + +ParasiteList* +parasite_list_new() +{ + ParasiteList *list = gtk_type_new(GIMP_TYPE_PARASITE_LIST); + list->table = NULL; + return list; +} + +static int +parasite_compare_func(gconstpointer n1, gconstpointer n2) +{ + return (!strcmp((char*)n1, (char*)n2)); +} + +static int +free_a_parasite(void *key, void *parasite, void *unused) +{ + parasite_free((Parasite *)parasite); + return TRUE; +} + +static void +parasite_list_destroy(GtkObject *obj) +{ + ParasiteList *list; + + g_return_if_fail(obj != NULL); + g_return_if_fail(GIMP_IS_PARASITE_LIST(obj)); + + list = (ParasiteList *)obj; + + if (list->table) + { + g_hash_table_foreach_remove(list->table, free_a_parasite, NULL); + g_hash_table_destroy(list->table); + } +} + +static void +parasite_copy_one(void *key, void *p, void *data) +{ + ParasiteList *list = (ParasiteList*)data; + Parasite *parasite = (Parasite*)p; + parasite_list_add(list, parasite); +} + +ParasiteList* +parasite_list_copy(const ParasiteList *list) +{ + ParasiteList *newlist; + newlist = parasite_list_new(); + if (list->table) + g_hash_table_foreach(list->table, parasite_copy_one, newlist); + return newlist; +} + +void +parasite_list_add(ParasiteList *list, Parasite *p) +{ + g_return_if_fail(list != NULL); + if (list->table == NULL) + list->table = g_hash_table_new(g_str_hash, parasite_compare_func); + g_return_if_fail(p != NULL); + g_return_if_fail(p->name != NULL); + p = parasite_copy(p); + g_hash_table_insert(list->table, p->name, p); + gtk_signal_emit (GTK_OBJECT(list), parasite_list_signals[ADD], p); +} + +void +parasite_list_remove(ParasiteList *list, const char *name) +{ + Parasite *p; + g_return_if_fail(list != NULL); + if (list->table) + { + p = parasite_list_find(list, name); + if (p) + { + g_hash_table_remove(list->table, name); + gtk_signal_emit (GTK_OBJECT(list), parasite_list_signals[REMOVE], p); + parasite_free(p); + } + } +} + +Parasite * +parasite_list_find(ParasiteList *list, const char *name) +{ + g_return_val_if_fail(list != NULL, NULL); + if (list->table) + return (Parasite *)g_hash_table_lookup(list->table, name); + else + return NULL; +} + + diff --git a/app/parasitelist.h b/app/parasitelist.h new file mode 100644 index 0000000000..256c4da9c9 --- /dev/null +++ b/app/parasitelist.h @@ -0,0 +1,45 @@ +/* parasitelist.h: Copyright 1998 Jay Cox + * + * 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. + */ + +#ifndef __PARASITE_LIST_H__ +#define __PARASITE_LIST_H__ + +#include +#include "libgimp/parasiteF.h" +#include "parasitelistF.h" +#include "gimpobject.h" + +#define GIMP_TYPE_PARASITE_LIST (parasite_list_get_type ()) +#define GIMP_PARASITE_LIST(obj) (GIMP_CHECK_CAST ((obj), GIMP_TYPE_PARASITE_LIST, GimpParasiteList)) +#define GIMP_IS_PARASITE_LIST(obj) (GIMP_CHECK_TYPE ((obj), GIMP_TYPE_PARASITE_LIST)) + +/* Signals: + add + remove +*/ + +GtkType parasite_list_get_type (void); + +/* function declarations */ + +ParasiteList *parasite_list_new (void); +ParasiteList *parasite_list_copy (const ParasiteList *list); +void parasite_list_add (ParasiteList *list, Parasite *p); +void parasite_list_remove (ParasiteList *list, const char *name); +Parasite *parasite_list_find (ParasiteList *list, const char *name); + +#endif /* __GIMP_PARASITE_H__ */ diff --git a/app/parasitelistF.h b/app/parasitelistF.h new file mode 100644 index 0000000000..cb0d4eee04 --- /dev/null +++ b/app/parasitelistF.h @@ -0,0 +1,7 @@ +#ifndef __PARASITE_LIST_F_H__ +#define __PARASITE_LIST_F_H__ + +typedef struct _ParasiteList ParasiteList; + +#endif /* __PARASITE_LIST_F_H__ */ + diff --git a/app/parasitelistP.h b/app/parasitelistP.h new file mode 100644 index 0000000000..3d6a1336be --- /dev/null +++ b/app/parasitelistP.h @@ -0,0 +1,39 @@ +/* parasitelistP.h: Copyright 1998 Jay Cox + * + * 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. + */ + +#ifndef __PARASITE_LIST_P_H__ +#define __PARASITE_LIST_P_H__ + +#include "gimpobjectP.h" +#include "parasitelist.h" + +struct _ParasiteList +{ + GimpObject object; + GHashTable *table; +}; + +typedef struct _ParasiteListClass +{ + GimpObjectClass parent_class; + void (* add) (ParasiteList *list, Parasite *parasite); + void (* remove) (ParasiteList *list, Parasite *parasite); +} ParasiteListClass; + +#define PARASITE_LIST_CLASS(class) GIMP_CHECK_CLASS_CAST (class, parasite_list_get_type(), ParasiteListClass) + +#endif /* __GIMP_PARASITE_P_H__ */ diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/gimpplugin-message.c +++ b/app/plug-in/gimpplugin-message.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/gimpplugin-progress.c b/app/plug-in/gimpplugin-progress.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/gimpplugin-progress.c +++ b/app/plug-in/gimpplugin-progress.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/gimpplugin.c +++ b/app/plug-in/gimpplugin.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/gimppluginmanager-call.c +++ b/app/plug-in/gimppluginmanager-call.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/gimppluginmanager-run.c b/app/plug-in/gimppluginmanager-run.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/gimppluginmanager-run.c +++ b/app/plug-in/gimppluginmanager-run.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/gimppluginmanager.c +++ b/app/plug-in/gimppluginmanager.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/gimppluginshm.c b/app/plug-in/gimppluginshm.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/gimppluginshm.c +++ b/app/plug-in/gimppluginshm.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/plug-in-def.c b/app/plug-in/plug-in-def.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/plug-in-def.c +++ b/app/plug-in/plug-in-def.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/plug-in-message.c b/app/plug-in/plug-in-message.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/plug-in-message.c +++ b/app/plug-in/plug-in-message.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/plug-in-params.c b/app/plug-in/plug-in-params.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/plug-in-params.c +++ b/app/plug-in/plug-in-params.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/plug-in-progress.c b/app/plug-in/plug-in-progress.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/plug-in-progress.c +++ b/app/plug-in/plug-in-progress.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/plug-in-run.c b/app/plug-in/plug-in-run.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/plug-in-run.c +++ b/app/plug-in/plug-in-run.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/plug-in-shm.c b/app/plug-in/plug-in-shm.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/plug-in-shm.c +++ b/app/plug-in/plug-in-shm.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/plug-in.c b/app/plug-in/plug-in.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/plug-in.c +++ b/app/plug-in/plug-in.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug-in/plug-ins.c b/app/plug-in/plug-ins.c index b93310fb58..dd01e3725d 100644 --- a/app/plug-in/plug-ins.c +++ b/app/plug-in/plug-ins.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/plug_in.c b/app/plug_in.c index b93310fb58..dd01e3725d 100644 --- a/app/plug_in.c +++ b/app/plug_in.c @@ -2991,8 +2991,8 @@ plug_in_args_destroy (Argument *args, case PDB_PARASITE: if (full_destroy) { -/* parasite_free ((Parasite *)(args[i].value.pdb_pointer)); - args[i].value.pdb_pointer = NULL;*/ + parasite_free ((Parasite *)(args[i].value.pdb_pointer)); + args[i].value.pdb_pointer = NULL; } break; case PDB_STATUS: diff --git a/app/preferences_dialog.c b/app/preferences_dialog.c index ceec12c061..ea7fc426ad 100644 --- a/app/preferences_dialog.c +++ b/app/preferences_dialog.c @@ -21,7 +21,6 @@ #include "floating_sel.h" #include "gdisplay_ops.h" #include "general.h" -#include "gimage_cmds.h" #include "gimage_mask.h" #include "gimprc.h" #include "global_edit.h" diff --git a/libgimp/Makefile.am b/libgimp/Makefile.am index aa2b368f57..136c9bc427 100644 --- a/libgimp/Makefile.am +++ b/libgimp/Makefile.am @@ -37,6 +37,7 @@ libgimp_la_SOURCES = \ gimpmatrix.c \ gimpmatrix.h \ gimppalette.c \ + gimpparasite.c \ gimppixelrgn.c \ gimpprotocol.c \ gimpprotocol.h \ diff --git a/libgimp/gimp.h b/libgimp/gimp.h index 1b23c51fe8..4680b4ebc1 100644 --- a/libgimp/gimp.h +++ b/libgimp/gimp.h @@ -432,12 +432,18 @@ Parasite *gimp_image_find_parasite (gint32 image_ID, const char *name); void gimp_image_attach_parasite (gint32 image_ID, const Parasite *p); +void gimp_image_attach_new_parasite (gint32 image_ID, + const char *name, int flags, + int size, const void *data); void gimp_image_detach_parasite (gint32 image_ID, const char *name); void gimp_image_set_resolution (gint32 image_ID, float resolution); float gimp_image_get_resolution (gint32 image_ID); - +gint32 gimp_image_get_layer_by_tattoo (gint32 image_ID, + gint32 tattoo); +gint32 gimp_image_get_channel_by_tattoo (gint32 image_ID, + gint32 tattoo); /**************************************** @@ -529,12 +535,6 @@ void gimp_layer_set_show_mask (gint32 layer_ID, gint show_mask); void gimp_layer_set_visible (gint32 layer_ID, gint visible); -Parasite *gimp_layer_find_parasite (gint32 image_ID, - const char *name); -void gimp_layer_attach_parasite (gint32 layer_ID, - const Parasite *p); -void gimp_layer_detach_parasite (gint32 layer_ID, - const char *name); /**************************************** @@ -630,6 +630,9 @@ Parasite *gimp_drawable_find_parasite (gint32 drawable, const char *name); void gimp_drawable_attach_parasite (gint32 drawable, const Parasite *p); +void gimp_layer_attach_new_parasite(gint32 drawable, + const char *name, int flags, + int size, const void *data); void gimp_drawable_detach_parasite (gint32 drawable, const char *name); @@ -738,6 +741,15 @@ gdouble* gimp_gradients_sample_uniform (gint num_samples); gdouble* gimp_gradients_sample_custom (gint num_samples, gdouble *positions); +/**************************************** + * Parasites * + ****************************************/ + +Parasite *gimp_find_parasite (const char *name); +void gimp_attach_parasite (const Parasite *p); +void gimp_attach_new_parasite (const char *name, int flags, + int size, const void *data); +void gimp_detach_parasite (const char *name); #ifdef __cplusplus } diff --git a/libgimp/gimpdrawable.c b/libgimp/gimpdrawable.c index 896d3b718e..c52e3697ef 100644 --- a/libgimp/gimpdrawable.c +++ b/libgimp/gimpdrawable.c @@ -619,6 +619,25 @@ gimp_drawable_attach_parasite (gint32 drawable_ID, gimp_destroy_params (return_vals, nreturn_vals); } + +void +gimp_drawable_attach_new_parasite (gint32 drawable, const char *name, int flags, + int size, const void *data) +{ + GParam *return_vals; + int nreturn_vals; + Parasite *p = parasite_new(name, flags, size, data); + + return_vals = gimp_run_procedure ("gimp_drawable_attach_parasite", + &nreturn_vals, + PARAM_DRAWABLE, drawable, + PARAM_PARASITE, p, + PARAM_END); + + parasite_free(p); + gimp_destroy_params (return_vals, nreturn_vals); +} + void gimp_drawable_detach_parasite (gint32 drawable_ID, const char *name) diff --git a/libgimp/gimpdrawable_pdb.c b/libgimp/gimpdrawable_pdb.c index 896d3b718e..c52e3697ef 100644 --- a/libgimp/gimpdrawable_pdb.c +++ b/libgimp/gimpdrawable_pdb.c @@ -619,6 +619,25 @@ gimp_drawable_attach_parasite (gint32 drawable_ID, gimp_destroy_params (return_vals, nreturn_vals); } + +void +gimp_drawable_attach_new_parasite (gint32 drawable, const char *name, int flags, + int size, const void *data) +{ + GParam *return_vals; + int nreturn_vals; + Parasite *p = parasite_new(name, flags, size, data); + + return_vals = gimp_run_procedure ("gimp_drawable_attach_parasite", + &nreturn_vals, + PARAM_DRAWABLE, drawable, + PARAM_PARASITE, p, + PARAM_END); + + parasite_free(p); + gimp_destroy_params (return_vals, nreturn_vals); +} + void gimp_drawable_detach_parasite (gint32 drawable_ID, const char *name) diff --git a/libgimp/gimpfeatures.h.in b/libgimp/gimpfeatures.h.in index 88352633ab..0520cf2872 100644 --- a/libgimp/gimpfeatures.h.in +++ b/libgimp/gimpfeatures.h.in @@ -31,6 +31,7 @@ extern "C" { #define GIMP_VERSION "@GIMP_VERSION@" #define GIMP_HAVE_GET_DATA_SIZE 1-1-0 +#define GIMP_HAVE_PARASITES 1-1-0 #ifdef __cplusplus } diff --git a/libgimp/gimpimage.c b/libgimp/gimpimage.c index 48ef786079..fcbab4d613 100644 --- a/libgimp/gimpimage.c +++ b/libgimp/gimpimage.c @@ -949,6 +949,24 @@ gimp_image_attach_parasite (gint32 image_ID, const Parasite *p) gimp_destroy_params (return_vals, nreturn_vals); } +void +gimp_image_attach_new_parasite (gint32 image_ID, const char *name, int flags, + int size, const void *data) +{ + GParam *return_vals; + int nreturn_vals; + Parasite *p = parasite_new(name, flags, size, data); + + return_vals = gimp_run_procedure ("gimp_image_attach_parasite", + &nreturn_vals, + PARAM_IMAGE, image_ID, + PARAM_PARASITE, p, + PARAM_END); + + parasite_free(p); + gimp_destroy_params (return_vals, nreturn_vals); +} + void gimp_image_detach_parasite (gint32 image_ID, const char *name) { @@ -1001,3 +1019,47 @@ gimp_image_set_resolution (gint32 image_ID, gimp_destroy_params (return_vals, nreturn_vals); } +gint32 +gimp_image_get_layer_by_tattoo (gint32 image_ID, gint32 tattoo) +{ + GParam *return_vals; + int nreturn_vals; + gint32 layer = 0; + + return_vals = gimp_run_procedure ("gimp_image_get_layer_by_tattoo", + &nreturn_vals, + PARAM_IMAGE, image_ID, + PARAM_INT32, tattoo, + PARAM_END); + + layer = 0; + if (return_vals[0].data.d_status == STATUS_SUCCESS) + layer = return_vals[1].data.d_layer; + + gimp_destroy_params (return_vals, nreturn_vals); + + return layer; +} + +gint32 +gimp_image_get_channel_by_tattoo (gint32 image_ID, gint32 tattoo) +{ + GParam *return_vals; + int nreturn_vals; + gint32 channel = 0; + + return_vals = gimp_run_procedure ("gimp_image_get_channel_by_tattoo", + &nreturn_vals, + PARAM_IMAGE, image_ID, + PARAM_INT32, tattoo, + PARAM_END); + + channel = 0; + if (return_vals[0].data.d_status == STATUS_SUCCESS) + channel = return_vals[1].data.d_channel; + + gimp_destroy_params (return_vals, nreturn_vals); + + return channel; +} + diff --git a/libgimp/gimpimage_pdb.c b/libgimp/gimpimage_pdb.c index 48ef786079..fcbab4d613 100644 --- a/libgimp/gimpimage_pdb.c +++ b/libgimp/gimpimage_pdb.c @@ -949,6 +949,24 @@ gimp_image_attach_parasite (gint32 image_ID, const Parasite *p) gimp_destroy_params (return_vals, nreturn_vals); } +void +gimp_image_attach_new_parasite (gint32 image_ID, const char *name, int flags, + int size, const void *data) +{ + GParam *return_vals; + int nreturn_vals; + Parasite *p = parasite_new(name, flags, size, data); + + return_vals = gimp_run_procedure ("gimp_image_attach_parasite", + &nreturn_vals, + PARAM_IMAGE, image_ID, + PARAM_PARASITE, p, + PARAM_END); + + parasite_free(p); + gimp_destroy_params (return_vals, nreturn_vals); +} + void gimp_image_detach_parasite (gint32 image_ID, const char *name) { @@ -1001,3 +1019,47 @@ gimp_image_set_resolution (gint32 image_ID, gimp_destroy_params (return_vals, nreturn_vals); } +gint32 +gimp_image_get_layer_by_tattoo (gint32 image_ID, gint32 tattoo) +{ + GParam *return_vals; + int nreturn_vals; + gint32 layer = 0; + + return_vals = gimp_run_procedure ("gimp_image_get_layer_by_tattoo", + &nreturn_vals, + PARAM_IMAGE, image_ID, + PARAM_INT32, tattoo, + PARAM_END); + + layer = 0; + if (return_vals[0].data.d_status == STATUS_SUCCESS) + layer = return_vals[1].data.d_layer; + + gimp_destroy_params (return_vals, nreturn_vals); + + return layer; +} + +gint32 +gimp_image_get_channel_by_tattoo (gint32 image_ID, gint32 tattoo) +{ + GParam *return_vals; + int nreturn_vals; + gint32 channel = 0; + + return_vals = gimp_run_procedure ("gimp_image_get_channel_by_tattoo", + &nreturn_vals, + PARAM_IMAGE, image_ID, + PARAM_INT32, tattoo, + PARAM_END); + + channel = 0; + if (return_vals[0].data.d_status == STATUS_SUCCESS) + channel = return_vals[1].data.d_channel; + + gimp_destroy_params (return_vals, nreturn_vals); + + return channel; +} + diff --git a/libgimp/gimpmatrix.h b/libgimp/gimpmatrix.h index 4e3337e3cb..a1b6a72862 100644 --- a/libgimp/gimpmatrix.h +++ b/libgimp/gimpmatrix.h @@ -20,6 +20,10 @@ #ifndef __GIMPMATRIX_H__ #define __GIMPMATRIX_H__ +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + typedef double GimpMatrix[3][3]; void gimp_matrix_transform_point (GimpMatrix, double, double, @@ -34,5 +38,8 @@ void gimp_matrix_yshear (GimpMatrix, double); double gimp_matrix_determinant (GimpMatrix); void gimp_matrix_invert (GimpMatrix m, GimpMatrix m_inv); +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif /* __GIMPMATRIX_H__ */ diff --git a/libgimp/gimpparasite.c b/libgimp/gimpparasite.c index e9f7a44a86..9678547d78 100644 --- a/libgimp/gimpparasite.c +++ b/libgimp/gimpparasite.c @@ -22,6 +22,24 @@ #include #include +static void parasite_print(Parasite *p) +{ + if (p == NULL) + { + printf("(pid %d)attempt to print a null parasite\n", getpid()); + return; + } + printf("(pid %d), parasite: %X\n", getpid(), p); + if (p->name) + printf("\tname: %s\n", p->name); + else + printf("\tname: NULL\n"); + printf("\tflags: %d\n", p->flags); + printf("\tsize: %d\n", p->size); + if (p->size > 0) + printf("\tdata: %X\n", p->data); +} + Parasite * parasite_new (const char *name, guint32 flags, guint32 size, const void *data) @@ -41,6 +59,7 @@ parasite_new (const char *name, guint32 flags, return p; } + void parasite_free (Parasite *parasite) { @@ -55,7 +74,7 @@ parasite_free (Parasite *parasite) int parasite_is_type (const Parasite *parasite, const char *name) { - if (!parasite) + if (!parasite || !parasite->name) return FALSE; return (strcmp(parasite->name, name) == 0); } @@ -93,53 +112,3 @@ parasite_is_persistant(const Parasite *p) return FALSE; return (p->flags & PARASITE_PERSISTANT); } - -/* parasite list functions */ - -Parasite * -parasite_find_in_gslist (const GSList *list, const char *name) -{ - while (list) - { - if (parasite_is_type((Parasite *)(list->data), name)) - return (Parasite *)(list->data); - list = list->next; - } - return NULL; -} - -GSList* -parasite_add_to_gslist (const Parasite *parasite, GSList *list) -{ - Parasite *p; - if (parasite_is_error(parasite)) - return list; - if ((p = parasite_find_in_gslist(list, parasite->name))) - { - list = g_slist_remove(list, p); - parasite_free(p); - } - return g_slist_prepend (list, parasite_copy(parasite)); -} - -GSList* -parasite_gslist_copy (const GSList *list) -{ - GSList *copy = NULL; - while (list) - { - copy = g_slist_append (copy, parasite_copy((Parasite *)list->data)); - list = list->next; - } - return copy; -} - -void -parasite_gslist_destroy (GSList *list) -{ - while (list) - { - parasite_free((Parasite *)list->data); - list = g_slist_remove (list, list->data); - } -} diff --git a/libgimp/gimpparasite.h b/libgimp/gimpparasite.h index 89ef0fbb3f..92e7dea1c2 100644 --- a/libgimp/gimpparasite.h +++ b/libgimp/gimpparasite.h @@ -23,6 +23,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + #define PARASITE_PERSISTANT 1 Parasite *parasite_new (const char *name, guint32 flags, @@ -38,12 +42,8 @@ int parasite_is_error (const Parasite *p); int parasite_is_persistant (const Parasite *p); -/* parasite list functions */ - -GSList *parasite_add_to_gslist (const Parasite *parasite, GSList *list); -Parasite *parasite_find_in_gslist (const GSList *list, const char *name); - -GSList *parasite_gslist_copy (const GSList *list); -void parasite_gslist_destroy (GSList *list); +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif _PARASITE_H_ diff --git a/libgimp/gimpparasite_pdb.c b/libgimp/gimpparasite_pdb.c new file mode 100644 index 0000000000..a2fdd4a677 --- /dev/null +++ b/libgimp/gimpparasite_pdb.c @@ -0,0 +1,70 @@ +#include "gimp.h" + +Parasite * +gimp_find_parasite (const char *name) +{ + GParam *return_vals; + int nreturn_vals; + Parasite *parasite; + return_vals = gimp_run_procedure ("gimp_find_parasite", + &nreturn_vals, + PARAM_STRING, name, + PARAM_END); + + if (return_vals[0].data.d_status == STATUS_SUCCESS) + { + parasite = parasite_copy(&return_vals[1].data.d_parasite); + } + else + parasite = NULL; + + gimp_destroy_params (return_vals, nreturn_vals); + + return parasite; +} + + +void +gimp_attach_parasite (const Parasite *p) +{ + GParam *return_vals; + int nreturn_vals; + + return_vals = gimp_run_procedure ("gimp_attach_parasite", + &nreturn_vals, + PARAM_PARASITE, p, + PARAM_END); + + gimp_destroy_params (return_vals, nreturn_vals); +} + +void +gimp_attach_new_parasite (const char *name, int flags, + int size, const void *data) +{ + GParam *return_vals; + int nreturn_vals; + Parasite *p = parasite_new(name, flags, size, data); + + return_vals = gimp_run_procedure ("gimp_attach_parasite", + &nreturn_vals, + PARAM_PARASITE, p, + PARAM_END); + + parasite_free(p); + gimp_destroy_params (return_vals, nreturn_vals); +} + +void +gimp_detach_parasite (const char *name) +{ + GParam *return_vals; + int nreturn_vals; + + return_vals = gimp_run_procedure ("gimp_image_detach_parasite", + &nreturn_vals, + PARAM_STRING, name, + PARAM_END); + + gimp_destroy_params (return_vals, nreturn_vals); +} diff --git a/libgimp/parasite.c b/libgimp/parasite.c index e9f7a44a86..9678547d78 100644 --- a/libgimp/parasite.c +++ b/libgimp/parasite.c @@ -22,6 +22,24 @@ #include #include +static void parasite_print(Parasite *p) +{ + if (p == NULL) + { + printf("(pid %d)attempt to print a null parasite\n", getpid()); + return; + } + printf("(pid %d), parasite: %X\n", getpid(), p); + if (p->name) + printf("\tname: %s\n", p->name); + else + printf("\tname: NULL\n"); + printf("\tflags: %d\n", p->flags); + printf("\tsize: %d\n", p->size); + if (p->size > 0) + printf("\tdata: %X\n", p->data); +} + Parasite * parasite_new (const char *name, guint32 flags, guint32 size, const void *data) @@ -41,6 +59,7 @@ parasite_new (const char *name, guint32 flags, return p; } + void parasite_free (Parasite *parasite) { @@ -55,7 +74,7 @@ parasite_free (Parasite *parasite) int parasite_is_type (const Parasite *parasite, const char *name) { - if (!parasite) + if (!parasite || !parasite->name) return FALSE; return (strcmp(parasite->name, name) == 0); } @@ -93,53 +112,3 @@ parasite_is_persistant(const Parasite *p) return FALSE; return (p->flags & PARASITE_PERSISTANT); } - -/* parasite list functions */ - -Parasite * -parasite_find_in_gslist (const GSList *list, const char *name) -{ - while (list) - { - if (parasite_is_type((Parasite *)(list->data), name)) - return (Parasite *)(list->data); - list = list->next; - } - return NULL; -} - -GSList* -parasite_add_to_gslist (const Parasite *parasite, GSList *list) -{ - Parasite *p; - if (parasite_is_error(parasite)) - return list; - if ((p = parasite_find_in_gslist(list, parasite->name))) - { - list = g_slist_remove(list, p); - parasite_free(p); - } - return g_slist_prepend (list, parasite_copy(parasite)); -} - -GSList* -parasite_gslist_copy (const GSList *list) -{ - GSList *copy = NULL; - while (list) - { - copy = g_slist_append (copy, parasite_copy((Parasite *)list->data)); - list = list->next; - } - return copy; -} - -void -parasite_gslist_destroy (GSList *list) -{ - while (list) - { - parasite_free((Parasite *)list->data); - list = g_slist_remove (list, list->data); - } -} diff --git a/libgimp/parasite.h b/libgimp/parasite.h index 89ef0fbb3f..92e7dea1c2 100644 --- a/libgimp/parasite.h +++ b/libgimp/parasite.h @@ -23,6 +23,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + #define PARASITE_PERSISTANT 1 Parasite *parasite_new (const char *name, guint32 flags, @@ -38,12 +42,8 @@ int parasite_is_error (const Parasite *p); int parasite_is_persistant (const Parasite *p); -/* parasite list functions */ - -GSList *parasite_add_to_gslist (const Parasite *parasite, GSList *list); -Parasite *parasite_find_in_gslist (const GSList *list, const char *name); - -GSList *parasite_gslist_copy (const GSList *list); -void parasite_gslist_destroy (GSList *list); +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif _PARASITE_H_ diff --git a/libgimpbase/gimpparasite.c b/libgimpbase/gimpparasite.c index e9f7a44a86..9678547d78 100644 --- a/libgimpbase/gimpparasite.c +++ b/libgimpbase/gimpparasite.c @@ -22,6 +22,24 @@ #include #include +static void parasite_print(Parasite *p) +{ + if (p == NULL) + { + printf("(pid %d)attempt to print a null parasite\n", getpid()); + return; + } + printf("(pid %d), parasite: %X\n", getpid(), p); + if (p->name) + printf("\tname: %s\n", p->name); + else + printf("\tname: NULL\n"); + printf("\tflags: %d\n", p->flags); + printf("\tsize: %d\n", p->size); + if (p->size > 0) + printf("\tdata: %X\n", p->data); +} + Parasite * parasite_new (const char *name, guint32 flags, guint32 size, const void *data) @@ -41,6 +59,7 @@ parasite_new (const char *name, guint32 flags, return p; } + void parasite_free (Parasite *parasite) { @@ -55,7 +74,7 @@ parasite_free (Parasite *parasite) int parasite_is_type (const Parasite *parasite, const char *name) { - if (!parasite) + if (!parasite || !parasite->name) return FALSE; return (strcmp(parasite->name, name) == 0); } @@ -93,53 +112,3 @@ parasite_is_persistant(const Parasite *p) return FALSE; return (p->flags & PARASITE_PERSISTANT); } - -/* parasite list functions */ - -Parasite * -parasite_find_in_gslist (const GSList *list, const char *name) -{ - while (list) - { - if (parasite_is_type((Parasite *)(list->data), name)) - return (Parasite *)(list->data); - list = list->next; - } - return NULL; -} - -GSList* -parasite_add_to_gslist (const Parasite *parasite, GSList *list) -{ - Parasite *p; - if (parasite_is_error(parasite)) - return list; - if ((p = parasite_find_in_gslist(list, parasite->name))) - { - list = g_slist_remove(list, p); - parasite_free(p); - } - return g_slist_prepend (list, parasite_copy(parasite)); -} - -GSList* -parasite_gslist_copy (const GSList *list) -{ - GSList *copy = NULL; - while (list) - { - copy = g_slist_append (copy, parasite_copy((Parasite *)list->data)); - list = list->next; - } - return copy; -} - -void -parasite_gslist_destroy (GSList *list) -{ - while (list) - { - parasite_free((Parasite *)list->data); - list = g_slist_remove (list, list->data); - } -} diff --git a/libgimpbase/gimpparasite.h b/libgimpbase/gimpparasite.h index 89ef0fbb3f..92e7dea1c2 100644 --- a/libgimpbase/gimpparasite.h +++ b/libgimpbase/gimpparasite.h @@ -23,6 +23,10 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + #define PARASITE_PERSISTANT 1 Parasite *parasite_new (const char *name, guint32 flags, @@ -38,12 +42,8 @@ int parasite_is_error (const Parasite *p); int parasite_is_persistant (const Parasite *p); -/* parasite list functions */ - -GSList *parasite_add_to_gslist (const Parasite *parasite, GSList *list); -Parasite *parasite_find_in_gslist (const GSList *list, const char *name); - -GSList *parasite_gslist_copy (const GSList *list); -void parasite_gslist_destroy (GSList *list); +#ifdef __cplusplus +} +#endif /* __cplusplus */ #endif _PARASITE_H_ diff --git a/libgimpbase/gimpversion.h.in b/libgimpbase/gimpversion.h.in index 88352633ab..0520cf2872 100644 --- a/libgimpbase/gimpversion.h.in +++ b/libgimpbase/gimpversion.h.in @@ -31,6 +31,7 @@ extern "C" { #define GIMP_VERSION "@GIMP_VERSION@" #define GIMP_HAVE_GET_DATA_SIZE 1-1-0 +#define GIMP_HAVE_PARASITES 1-1-0 #ifdef __cplusplus } diff --git a/plug-ins/script-fu/script-fu-console.c b/plug-ins/script-fu/script-fu-console.c index aa373d8278..c7ba284efe 100644 --- a/plug-ins/script-fu/script-fu-console.c +++ b/plug-ins/script-fu/script-fu-console.c @@ -100,6 +100,8 @@ extern char siod_err_msg[]; extern FILE *siod_output; +#define message(string) printf("(%s): %d ::: %s\n", __PRETTY_FUNCTION__, __LINE__, string) + /* * Function definitions */ @@ -380,12 +382,26 @@ script_fu_siod_read (gpointer data, GdkInputCondition cond) { int count; + static int hack = 0; if ((count = read (id, read_buffer, BUFSIZE - 1)) != 0) { + if (!hack) /* this is a stupid hack, but as of 10/27/98 + * the script-fu-console will hang on my system without it. + * the real cause of this needs to be tracked down. + * posibly a problem with the text widget, or the + * signal handlers not getting fully initialized or... + * no reports of hangs on other platforms, could just be a + * problem with my system. + */ + { + hack = 1; + return; + } read_buffer[count] = '\0'; gtk_text_freeze (GTK_TEXT (cint.console)); - gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL, read_buffer, -1); + gtk_text_insert (GTK_TEXT (cint.console), cint.font_weak, NULL, NULL, + read_buffer, -1); gtk_text_thaw (GTK_TEXT (cint.console)); script_fu_console_scroll_end (NULL); diff --git a/plug-ins/script-fu/script-fu.c b/plug-ins/script-fu/script-fu.c index d718418a25..f7c48c1263 100644 --- a/plug-ins/script-fu/script-fu.c +++ b/plug-ins/script-fu/script-fu.c @@ -775,15 +775,14 @@ marshall_proc_db_call (LISP a) if (success) { args[i].type = PARAM_PARASITE; - /* parasite->name */ intermediate_val = car (a); args[i].data.d_parasite.name = get_c_string (car (intermediate_val)); - + /* parasite->flags */ intermediate_val = cdr (intermediate_val); - args[i].data.d_parasite.flags = get_c_long ( (intermediate_val)); + args[i].data.d_parasite.flags = get_c_long (car(intermediate_val)); /* parasite->size */ intermediate_val = cdr (intermediate_val); @@ -791,6 +790,7 @@ marshall_proc_db_call (LISP a) /* parasite->data */ args[i].data.d_parasite.data = (void*) (car (intermediate_val))->storage_as.string.data; + printf("e\n"); } break;