renamed gimp_initialize() to gimp_restore() because it loads all kinds of

2001-07-05  Michael Natterer  <mitch@gimp.org>

	* app/core/gimp.[ch]: renamed gimp_initialize() to gimp_restore()
	because it loads all kinds of data. Added gimp_shutdown() to save
	the data. Added the global parasite list.

	* app/apptypes.h: removed ParasiteList.

	* app/core/core-types.h: added GimpParasiteList.

	* app/gimpparasite.[ch]: removed the global parasite list.

	* app/parasitelist.[ch]: s/ParasiteList/GimpParasiteList/
	s/parasite_list_*/gimp_patasite_list_*/

	* app/widgets/gimpdatafactoryview.c: don't save the data in
	gimp_data-factory_data_free().

	* app/app_procs.c
	* app/gimprc.c
	* app/undo.c
	* app/core/gimpchannel.c
	* app/core/gimpdatafactory.c
	* app/core/gimpdrawable.[ch]
	* app/core/gimpimage-duplicate.c
	* app/core/gimpimage.[ch]
	* app/core/gimplayer.c
	* app/pdb/brushes_cmds.c
	* app/pdb/parasite_cmds.c
	* app/xcf/xcf-save.c
	* tools/pdbgen/pdb/brushes.pdb
	* tools/pdbgen/pdb/parasite.pdb: changed accordingly.
This commit is contained in:
Michael Natterer 2001-07-04 22:59:25 +00:00 committed by Michael Natterer
parent 0164596064
commit f7c69b072b
46 changed files with 641 additions and 499 deletions

View File

@ -1,3 +1,36 @@
2001-07-05 Michael Natterer <mitch@gimp.org>
* app/core/gimp.[ch]: renamed gimp_initialize() to gimp_restore()
because it loads all kinds of data. Added gimp_shutdown() to save
the data. Added the global parasite list.
* app/apptypes.h: removed ParasiteList.
* app/core/core-types.h: added GimpParasiteList.
* app/gimpparasite.[ch]: removed the global parasite list.
* app/parasitelist.[ch]: s/ParasiteList/GimpParasiteList/
s/parasite_list_*/gimp_patasite_list_*/
* app/widgets/gimpdatafactoryview.c: don't save the data in
gimp_data-factory_data_free().
* app/app_procs.c
* app/gimprc.c
* app/undo.c
* app/core/gimpchannel.c
* app/core/gimpdatafactory.c
* app/core/gimpdrawable.[ch]
* app/core/gimpimage-duplicate.c
* app/core/gimpimage.[ch]
* app/core/gimplayer.c
* app/pdb/brushes_cmds.c
* app/pdb/parasite_cmds.c
* app/xcf/xcf-save.c
* tools/pdbgen/pdb/brushes.pdb
* tools/pdbgen/pdb/parasite.pdb: changed accordingly.
2001-07-04 Michael Natterer <mitch@gimp.org>
* app/core/Makefile.am

View File

@ -55,7 +55,6 @@
#include "gdisplay.h"
#include "gdisplay_ops.h"
#include "gimprc.h"
#include "gimpparasite.h"
#include "plug_in.h"
#include "module_db.h"
@ -68,8 +67,6 @@
#include "gdisplay_color.h"
#endif /* DISPLAY_FILTERS */
#include "gimpparasite.h"
#include "libgimp/gimpintl.h"
@ -173,8 +170,8 @@ app_init (gint gimp_argc,
RESET_BAR();
xcf_init (the_gimp); /* initialize the xcf file format routines */
/* initialize the global gimp object */
gimp_initialize (the_gimp);
/* load all data files */
gimp_restore (the_gimp);
plug_in_init (); /* initialize the plug in structures */
module_db_init (); /* load any modules we need */
@ -244,7 +241,6 @@ app_exit_finish (void)
context_manager_free ();
plug_in_kill ();
save_unitrc ();
gimp_parasiterc_save ();
tools_exit ();
@ -255,6 +251,8 @@ app_exit_finish (void)
xcf_exit ();
gimp_shutdown (the_gimp);
gtk_object_unref (GTK_OBJECT (the_gimp));
the_gimp = NULL;

View File

@ -57,8 +57,6 @@ typedef struct _PlugIn PlugIn;
typedef struct _PlugInDef PlugInDef;
typedef struct _PlugInProcDef PlugInProcDef;
typedef struct _ParasiteList ParasiteList;
typedef struct _ProcArg ProcArg;
typedef struct _ProcRecord ProcRecord;

View File

@ -78,6 +78,8 @@ typedef struct _GimpObject GimpObject;
typedef struct _Gimp Gimp;
typedef struct _GimpParasiteList GimpParasiteList;
typedef struct _GimpContainer GimpContainer;
typedef struct _GimpList GimpList;
typedef struct _GimpDataList GimpDataList;

View File

@ -28,38 +28,54 @@
#include "core/core-types.h"
#include "core/gimp.h"
#include "app_procs.h"
#include "parasitelist.h"
#include "gimpparasite.h"
#include "gimprc.h"
static ParasiteList *parasites = NULL;
void
gimp_parasites_init (Gimp *gimp)
{
g_return_if_fail (gimp->parasites == NULL);
gimp->parasites = gimp_parasite_list_new ();
gtk_object_ref (GTK_OBJECT (gimp->parasites));
gtk_object_sink (GTK_OBJECT (gimp->parasites));
}
void
gimp_init_parasites (void)
gimp_parasites_exit (Gimp *gimp)
{
g_return_if_fail (parasites == NULL);
parasites = parasite_list_new ();
gimp_parasiterc_load ();
if (gimp->parasites)
{
gtk_object_unref (GTK_OBJECT (gimp->parasites));
gimp->parasites = NULL;
}
}
void
gimp_parasite_attach (GimpParasite *p)
gimp_parasite_attach (Gimp *gimp,
GimpParasite *parasite)
{
parasite_list_add (parasites, p);
gimp_parasite_list_add (gimp->parasites, parasite);
}
void
gimp_parasite_detach (const gchar *name)
gimp_parasite_detach (Gimp *gimp,
const gchar *name)
{
parasite_list_remove (parasites, name);
gimp_parasite_list_remove (gimp->parasites, name);
}
GimpParasite *
gimp_parasite_find (const gchar *name)
gimp_parasite_find (Gimp *gimp,
const gchar *name)
{
return parasite_list_find (parasites, name);
return gimp_parasite_list_find (gimp->parasites, name);
}
static void
@ -71,31 +87,33 @@ list_func (gchar *key,
}
gchar **
gimp_parasite_list (gint *count)
gimp_parasite_list (Gimp *gimp,
gint *count)
{
gchar **list;
gchar **cur;
*count = parasite_list_length (parasites);
*count = gimp_parasite_list_length (gimp->parasites);
cur = list = g_new (gchar *, *count);
parasite_list_foreach (parasites, (GHFunc) list_func, &cur);
gimp_parasite_list_foreach (gimp->parasites, (GHFunc) list_func, &cur);
return list;
}
static void
save_func (gchar *key,
GimpParasite *p,
GimpParasite *parasite,
FILE *fp)
{
if (gimp_parasite_is_persistent (p))
if (gimp_parasite_is_persistent (parasite))
{
gchar *s;
guint32 l;
fprintf (fp, "(parasite \"%s\" %lu \"",
gimp_parasite_name (p), gimp_parasite_flags (p));
gimp_parasite_name (parasite),
gimp_parasite_flags (parasite));
/*
* the current methodology is: never move the parasiterc from one
@ -104,7 +122,8 @@ save_func (gchar *key,
* characters as \xHH sequences altogether.
*/
for (s = (gchar *) gimp_parasite_data (p), l = gimp_parasite_data_size (p);
for (s = (gchar *) gimp_parasite_data (parasite),
l = gimp_parasite_data_size (parasite);
l;
l--, s++)
{
@ -120,17 +139,27 @@ save_func (gchar *key,
default : fputc (*s, fp); break;
}
}
fputs ("\")\n\n", fp);
}
}
void
gimp_parasiterc_save (void)
gimp_parasiterc_load (Gimp *gimp)
{
gchar *filename;
filename = gimp_personal_rc_file ("parasiterc");
parse_gimprc_file (filename);
g_free (filename);
}
void
gimp_parasiterc_save (Gimp *gimp)
{
gchar *tmp_filename = NULL;
gchar *bak_filename = NULL;
gchar *rc_filename = NULL;
gchar *rc_filename = NULL;
FILE *fp;
tmp_filename = gimp_personal_rc_file ("#parasiterc.tmp~");
@ -147,7 +176,7 @@ gimp_parasiterc_save (void)
"# This file will be entirely rewritten every time you "
"quit the gimp.\n\n");
parasite_list_foreach (parasites, (GHFunc)save_func, fp);
gimp_parasite_list_foreach (gimp->parasites, (GHFunc) save_func, fp);
fclose (fp);
@ -171,14 +200,3 @@ gimp_parasiterc_save (void)
g_free (bak_filename);
g_free (rc_filename);
}
void
gimp_parasiterc_load (void)
{
gchar *filename;
filename = gimp_personal_rc_file ("parasiterc");
app_init_update_status (NULL, filename, -1);
parse_gimprc_file (filename);
g_free (filename);
}

View File

@ -19,16 +19,21 @@
#define __APP_GIMP_PARASITE_H__
void gimp_init_parasites (void);
void gimp_parasites_init (Gimp *gimp);
void gimp_parasites_exit (Gimp *gimp);
void gimp_parasite_attach (GimpParasite *parasite);
void gimp_parasite_detach (const gchar *name);
void gimp_parasite_attach (Gimp *gimp,
GimpParasite *parasite);
void gimp_parasite_detach (Gimp *gimp,
const gchar *name);
GimpParasite * gimp_parasite_find (const gchar *name);
gchar ** gimp_parasite_list (gint *count);
GimpParasite * gimp_parasite_find (Gimp *gimp,
const gchar *name);
gchar ** gimp_parasite_list (Gimp *gimp,
gint *count);
void gimp_parasiterc_save (void);
void gimp_parasiterc_load (void);
void gimp_parasiterc_load (Gimp *gimp);
void gimp_parasiterc_save (Gimp *gimp);
#endif /* __APP_GIMP_PARASITE_H__ */

View File

@ -142,6 +142,8 @@ gimp_init (Gimp *gimp)
gtk_object_ref (GTK_OBJECT (gimp->named_buffers));
gtk_object_sink (GTK_OBJECT (gimp->named_buffers));
gimp_parasites_init (gimp);
gimp->brush_factory =
gimp_data_factory_new (GIMP_TYPE_BRUSH,
(const gchar **) &gimprc.brush_path,
@ -238,6 +240,8 @@ gimp_destroy (GtkObject *object)
gimp->palette_factory = NULL;
}
gimp_parasites_exit (gimp);
if (gimp->named_buffers)
{
gtk_object_unref (GTK_OBJECT (gimp->named_buffers));
@ -271,14 +275,14 @@ gimp_new (void)
}
void
gimp_initialize (Gimp *gimp)
gimp_restore (Gimp *gimp)
{
g_return_if_fail (gimp != NULL);
g_return_if_fail (GIMP_IS_GIMP (gimp));
/* initialize the global parasite table */
app_init_update_status (_("Looking for data files"), _("Parasites"), 0.00);
gimp_init_parasites ();
gimp_parasiterc_load (gimp);
/* initialize the list of gimp brushes */
app_init_update_status (NULL, _("Brushes"), 0.20);
@ -298,3 +302,13 @@ gimp_initialize (Gimp *gimp)
app_init_update_status (NULL, NULL, 1.00);
}
void
gimp_shutdown (Gimp *gimp)
{
gimp_data_factory_data_save (gimp->brush_factory);
gimp_data_factory_data_save (gimp->pattern_factory);
gimp_data_factory_data_save (gimp->gradient_factory);
gimp_data_factory_data_save (gimp->palette_factory);
gimp_parasiterc_save (gimp);
}

View File

@ -34,21 +34,23 @@ typedef struct _GimpClass GimpClass;
struct _Gimp
{
GimpObject parent_instance;
GimpObject parent_instance;
GimpContainer *images;
GimpContainer *images;
TileManager *global_buffer;
GimpContainer *named_buffers;
TileManager *global_buffer;
GimpContainer *named_buffers;
GimpDataFactory *brush_factory;
GimpDataFactory *pattern_factory;
GimpDataFactory *gradient_factory;
GimpDataFactory *palette_factory;
GimpParasiteList *parasites;
GHashTable *procedural_ht;
GimpDataFactory *brush_factory;
GimpDataFactory *pattern_factory;
GimpDataFactory *gradient_factory;
GimpDataFactory *palette_factory;
GimpContainer *tool_info_list;
GHashTable *procedural_ht;
GimpContainer *tool_info_list;
};
struct _GimpClass
@ -60,7 +62,8 @@ struct _GimpClass
GtkType gimp_get_type (void);
Gimp * gimp_new (void);
void gimp_initialize (Gimp *gimp);
void gimp_restore (Gimp *gimp);
void gimp_shutdown (Gimp *gimp);
#endif /* __GIMP_H__ */

View File

@ -228,7 +228,7 @@ gimp_channel_copy (const GimpChannel *channel,
/* copy the parasites */
GIMP_DRAWABLE (new_channel)->parasites =
parasite_list_copy (GIMP_DRAWABLE (channel)->parasites);
gimp_parasite_list_copy (GIMP_DRAWABLE (channel)->parasites);
/* free up the channel_name memory */
g_free (channel_name);

View File

@ -228,7 +228,7 @@ gimp_channel_copy (const GimpChannel *channel,
/* copy the parasites */
GIMP_DRAWABLE (new_channel)->parasites =
parasite_list_copy (GIMP_DRAWABLE (channel)->parasites);
gimp_parasite_list_copy (GIMP_DRAWABLE (channel)->parasites);
/* free up the channel_name memory */
g_free (channel_name);

View File

@ -25,13 +25,14 @@
#include "core-types.h"
#include "datafiles.h"
#include "gimpdata.h"
#include "gimpdatalist.h"
#include "gimpdatafactory.h"
#include "gimpcontext.h"
#include "gimpmarshal.h"
#include "datafiles.h"
#include "libgimp/gimpintl.h"
@ -146,7 +147,7 @@ gimp_data_factory_new (GtkType data_type,
void
gimp_data_factory_data_init (GimpDataFactory *factory,
gboolean no_data)
gboolean no_data /* FIXME */)
{
g_return_if_fail (factory != NULL);
g_return_if_fail (GIMP_IS_DATA_FACTORY (factory));
@ -218,8 +219,6 @@ gimp_data_factory_data_free (GimpDataFactory *factory)
gimp_container_freeze (factory->container);
gimp_data_factory_data_save (factory);
while (list->list)
{
gimp_container_remove (factory->container,

View File

@ -163,7 +163,7 @@ gimp_drawable_init (GimpDrawable *drawable)
drawable->has_alpha = FALSE;
drawable->preview_cache = NULL;
drawable->preview_valid = FALSE;
drawable->parasites = parasite_list_new ();
drawable->parasites = gimp_parasite_list_new ();
drawable->preview_cache = NULL;
drawable->preview_valid = FALSE;
@ -683,7 +683,7 @@ gimp_drawable_parasite_find (const GimpDrawable *drawable,
{
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
return parasite_list_find (drawable->parasites, name);
return gimp_parasite_list_find (drawable->parasites, name);
}
static void
@ -705,12 +705,12 @@ gimp_drawable_parasite_list (const GimpDrawable *drawable,
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
g_return_val_if_fail (count != NULL, NULL);
*count = parasite_list_length (drawable->parasites);
*count = gimp_parasite_list_length (drawable->parasites);
cur = list = g_new (gchar *, *count);
parasite_list_foreach (drawable->parasites,
(GHFunc) gimp_drawable_parasite_list_foreach_func,
&cur);
gimp_parasite_list_foreach (drawable->parasites,
(GHFunc) gimp_drawable_parasite_list_foreach_func,
&cur);
return list;
}
@ -738,18 +738,18 @@ gimp_drawable_parasite_attach (GimpDrawable *drawable,
undo_push_cantundo (drawable->gimage, _("parasite attach to drawable"));
}
parasite_list_add (drawable->parasites, parasite);
gimp_parasite_list_add (drawable->parasites, parasite);
if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_PARENT))
{
parasite_shift_parent (parasite);
gimp_parasite_shift_parent (parasite);
gimp_image_parasite_attach (drawable->gimage, parasite);
}
else if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_GRANDPARENT))
{
parasite_shift_parent (parasite);
parasite_shift_parent (parasite);
gimp_parasite_attach (parasite);
gimp_parasite_shift_parent (parasite);
gimp_parasite_shift_parent (parasite);
gimp_parasite_attach (drawable->gimage->gimp, parasite);
}
if (gimp_parasite_is_undoable (parasite))
@ -766,7 +766,7 @@ gimp_drawable_parasite_detach (GimpDrawable *drawable,
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
if (! (p = parasite_list_find (drawable->parasites, parasite)))
if (! (p = gimp_parasite_list_find (drawable->parasites, parasite)))
return;
if (gimp_parasite_is_undoable (p))
@ -775,7 +775,7 @@ gimp_drawable_parasite_detach (GimpDrawable *drawable,
else if (gimp_parasite_is_persistent (p))
undo_push_cantundo (drawable->gimage, _("detach parasite from drawable"));
parasite_list_remove (drawable->parasites, parasite);
gimp_parasite_list_remove (drawable->parasites, parasite);
}
Tattoo

View File

@ -34,25 +34,25 @@ typedef struct _GimpDrawableClass GimpDrawableClass;
struct _GimpDrawable
{
GimpViewable parent_instance;
GimpViewable parent_instance;
TileManager *tiles; /* tiles for drawable data */
gboolean visible; /* controls visibility */
gint width, height; /* size of drawable */
gint offset_x, offset_y; /* offset of layer in image */
TileManager *tiles; /* tiles for drawable data */
gboolean visible; /* controls visibility */
gint width, height; /* size of drawable */
gint offset_x, offset_y; /* offset of layer in image */
gint bytes; /* bytes per pixel */
gint ID; /* provides a unique ID */
guint32 tattoo; /* provides a perminant ID */
GimpImage *gimage; /* gimage owner */
GimpImageType type; /* type of drawable */
gboolean has_alpha; /* drawable has alpha */
gint bytes; /* bytes per pixel */
gint ID; /* provides a unique ID */
guint32 tattoo; /* provides a perminant ID */
GimpImage *gimage; /* gimage owner */
GimpImageType type; /* type of drawable */
gboolean has_alpha; /* drawable has alpha */
ParasiteList *parasites; /* Plug-in parasite data */
GimpParasiteList *parasites; /* Plug-in parasite data */
/* Preview variables */
GSList *preview_cache; /* preview caches of the channel */
gboolean preview_valid; /* is the preview valid? */
GSList *preview_cache; /* preview caches of the channel */
gboolean preview_valid; /* is the preview valid? */
};
struct _GimpDrawableClass

View File

@ -54,20 +54,20 @@
GimpImage *
gimp_image_duplicate (GimpImage *gimage)
{
PixelRegion srcPR, destPR;
GimpImage *new_gimage;
GimpLayer *layer, *new_layer;
GimpLayer *floating_layer;
GimpChannel *channel, *new_channel;
GList *list;
GimpGuide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
GimpDrawable *new_floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
ParasiteList *parasites;
PathList *paths;
gint count;
PixelRegion srcPR, destPR;
GimpImage *new_gimage;
GimpLayer *layer, *new_layer;
GimpLayer *floating_layer;
GimpChannel *channel, *new_channel;
GList *list;
GimpGuide *guide = NULL;
GimpLayer *active_layer = NULL;
GimpChannel *active_channel = NULL;
GimpDrawable *new_floating_sel_drawable = NULL;
GimpDrawable *floating_sel_drawable = NULL;
GimpParasiteList *parasites;
PathList *paths;
gint count;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
@ -218,7 +218,7 @@ gimp_image_duplicate (GimpImage *gimage)
/* Copy parasites */
parasites = gimage->parasites;
if (parasites)
new_gimage->parasites = parasite_list_copy (parasites);
new_gimage->parasites = gimp_parasite_list_copy (parasites);
/* Copy paths */
paths = gimp_image_get_paths (gimage);

View File

@ -429,7 +429,7 @@ gimp_image_init (GimpImage *gimage)
gimage->floating_sel = NULL;
gimage->selection_mask = NULL;
gimage->parasites = parasite_list_new ();
gimage->parasites = gimp_parasite_list_new ();
gimage->paths = NULL;
@ -1513,7 +1513,7 @@ gimp_image_parasite_find (const GimpImage *gimage,
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return parasite_list_find (gimage->parasites, name);
return gimp_parasite_list_find (gimage->parasites, name);
}
static void
@ -1533,10 +1533,10 @@ gimp_image_parasite_list (const GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
*count = parasite_list_length (gimage->parasites);
*count = gimp_parasite_list_length (gimage->parasites);
cur = list = g_new (gchar*, *count);
parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
gimp_parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
return list;
}
@ -1559,12 +1559,12 @@ gimp_image_parasite_attach (GimpImage *gimage,
undoable but does not block the undo system. --Sven
*/
parasite_list_add (gimage->parasites, parasite);
gimp_parasite_list_add (gimage->parasites, parasite);
if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_PARENT))
{
parasite_shift_parent (parasite);
gimp_parasite_attach (parasite);
gimp_parasite_shift_parent (parasite);
gimp_parasite_attach (gimage->gimp, parasite);
}
}
@ -1576,13 +1576,13 @@ gimp_image_parasite_detach (GimpImage *gimage,
g_return_if_fail (GIMP_IS_IMAGE (gimage) && parasite != NULL);
if (!(p = parasite_list_find (gimage->parasites, parasite)))
if (!(p = gimp_parasite_list_find (gimage->parasites, parasite)))
return;
if (gimp_parasite_is_undoable (p))
undo_push_image_parasite_remove (gimage, gimp_parasite_name (p));
parasite_list_remove (gimage->parasites, parasite);
gimp_parasite_list_remove (gimage->parasites, parasite);
}
Tattoo
@ -3324,7 +3324,7 @@ gimp_image_merge_layers (GimpImage *gimage,
gimp_drawable_set_tattoo (GIMP_DRAWABLE (merge_layer),
gimp_drawable_get_tattoo (GIMP_DRAWABLE (layer)));
GIMP_DRAWABLE (merge_layer)->parasites =
parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
gimp_parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
while (reverse_list)
{

View File

@ -105,7 +105,7 @@ struct _GimpImage
GimpLayer *floating_sel; /* the FS layer */
GimpChannel *selection_mask; /* the selection mask channel */
ParasiteList *parasites; /* Plug-in parasite data */
GimpParasiteList *parasites; /* Plug-in parasite data */
PathList *paths; /* Paths data for this image */

View File

@ -429,7 +429,7 @@ gimp_image_init (GimpImage *gimage)
gimage->floating_sel = NULL;
gimage->selection_mask = NULL;
gimage->parasites = parasite_list_new ();
gimage->parasites = gimp_parasite_list_new ();
gimage->paths = NULL;
@ -1513,7 +1513,7 @@ gimp_image_parasite_find (const GimpImage *gimage,
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return parasite_list_find (gimage->parasites, name);
return gimp_parasite_list_find (gimage->parasites, name);
}
static void
@ -1533,10 +1533,10 @@ gimp_image_parasite_list (const GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
*count = parasite_list_length (gimage->parasites);
*count = gimp_parasite_list_length (gimage->parasites);
cur = list = g_new (gchar*, *count);
parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
gimp_parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
return list;
}
@ -1559,12 +1559,12 @@ gimp_image_parasite_attach (GimpImage *gimage,
undoable but does not block the undo system. --Sven
*/
parasite_list_add (gimage->parasites, parasite);
gimp_parasite_list_add (gimage->parasites, parasite);
if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_PARENT))
{
parasite_shift_parent (parasite);
gimp_parasite_attach (parasite);
gimp_parasite_shift_parent (parasite);
gimp_parasite_attach (gimage->gimp, parasite);
}
}
@ -1576,13 +1576,13 @@ gimp_image_parasite_detach (GimpImage *gimage,
g_return_if_fail (GIMP_IS_IMAGE (gimage) && parasite != NULL);
if (!(p = parasite_list_find (gimage->parasites, parasite)))
if (!(p = gimp_parasite_list_find (gimage->parasites, parasite)))
return;
if (gimp_parasite_is_undoable (p))
undo_push_image_parasite_remove (gimage, gimp_parasite_name (p));
parasite_list_remove (gimage->parasites, parasite);
gimp_parasite_list_remove (gimage->parasites, parasite);
}
Tattoo
@ -3324,7 +3324,7 @@ gimp_image_merge_layers (GimpImage *gimage,
gimp_drawable_set_tattoo (GIMP_DRAWABLE (merge_layer),
gimp_drawable_get_tattoo (GIMP_DRAWABLE (layer)));
GIMP_DRAWABLE (merge_layer)->parasites =
parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
gimp_parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
while (reverse_list)
{

View File

@ -105,7 +105,7 @@ struct _GimpImage
GimpLayer *floating_sel; /* the FS layer */
GimpChannel *selection_mask; /* the selection mask channel */
ParasiteList *parasites; /* Plug-in parasite data */
GimpParasiteList *parasites; /* Plug-in parasite data */
PathList *paths; /* Paths data for this image */

View File

@ -429,7 +429,7 @@ gimp_image_init (GimpImage *gimage)
gimage->floating_sel = NULL;
gimage->selection_mask = NULL;
gimage->parasites = parasite_list_new ();
gimage->parasites = gimp_parasite_list_new ();
gimage->paths = NULL;
@ -1513,7 +1513,7 @@ gimp_image_parasite_find (const GimpImage *gimage,
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return parasite_list_find (gimage->parasites, name);
return gimp_parasite_list_find (gimage->parasites, name);
}
static void
@ -1533,10 +1533,10 @@ gimp_image_parasite_list (const GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
*count = parasite_list_length (gimage->parasites);
*count = gimp_parasite_list_length (gimage->parasites);
cur = list = g_new (gchar*, *count);
parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
gimp_parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
return list;
}
@ -1559,12 +1559,12 @@ gimp_image_parasite_attach (GimpImage *gimage,
undoable but does not block the undo system. --Sven
*/
parasite_list_add (gimage->parasites, parasite);
gimp_parasite_list_add (gimage->parasites, parasite);
if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_PARENT))
{
parasite_shift_parent (parasite);
gimp_parasite_attach (parasite);
gimp_parasite_shift_parent (parasite);
gimp_parasite_attach (gimage->gimp, parasite);
}
}
@ -1576,13 +1576,13 @@ gimp_image_parasite_detach (GimpImage *gimage,
g_return_if_fail (GIMP_IS_IMAGE (gimage) && parasite != NULL);
if (!(p = parasite_list_find (gimage->parasites, parasite)))
if (!(p = gimp_parasite_list_find (gimage->parasites, parasite)))
return;
if (gimp_parasite_is_undoable (p))
undo_push_image_parasite_remove (gimage, gimp_parasite_name (p));
parasite_list_remove (gimage->parasites, parasite);
gimp_parasite_list_remove (gimage->parasites, parasite);
}
Tattoo
@ -3324,7 +3324,7 @@ gimp_image_merge_layers (GimpImage *gimage,
gimp_drawable_set_tattoo (GIMP_DRAWABLE (merge_layer),
gimp_drawable_get_tattoo (GIMP_DRAWABLE (layer)));
GIMP_DRAWABLE (merge_layer)->parasites =
parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
gimp_parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
while (reverse_list)
{

View File

@ -105,7 +105,7 @@ struct _GimpImage
GimpLayer *floating_sel; /* the FS layer */
GimpChannel *selection_mask; /* the selection mask channel */
ParasiteList *parasites; /* Plug-in parasite data */
GimpParasiteList *parasites; /* Plug-in parasite data */
PathList *paths; /* Paths data for this image */

View File

@ -429,7 +429,7 @@ gimp_image_init (GimpImage *gimage)
gimage->floating_sel = NULL;
gimage->selection_mask = NULL;
gimage->parasites = parasite_list_new ();
gimage->parasites = gimp_parasite_list_new ();
gimage->paths = NULL;
@ -1513,7 +1513,7 @@ gimp_image_parasite_find (const GimpImage *gimage,
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return parasite_list_find (gimage->parasites, name);
return gimp_parasite_list_find (gimage->parasites, name);
}
static void
@ -1533,10 +1533,10 @@ gimp_image_parasite_list (const GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
*count = parasite_list_length (gimage->parasites);
*count = gimp_parasite_list_length (gimage->parasites);
cur = list = g_new (gchar*, *count);
parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
gimp_parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
return list;
}
@ -1559,12 +1559,12 @@ gimp_image_parasite_attach (GimpImage *gimage,
undoable but does not block the undo system. --Sven
*/
parasite_list_add (gimage->parasites, parasite);
gimp_parasite_list_add (gimage->parasites, parasite);
if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_PARENT))
{
parasite_shift_parent (parasite);
gimp_parasite_attach (parasite);
gimp_parasite_shift_parent (parasite);
gimp_parasite_attach (gimage->gimp, parasite);
}
}
@ -1576,13 +1576,13 @@ gimp_image_parasite_detach (GimpImage *gimage,
g_return_if_fail (GIMP_IS_IMAGE (gimage) && parasite != NULL);
if (!(p = parasite_list_find (gimage->parasites, parasite)))
if (!(p = gimp_parasite_list_find (gimage->parasites, parasite)))
return;
if (gimp_parasite_is_undoable (p))
undo_push_image_parasite_remove (gimage, gimp_parasite_name (p));
parasite_list_remove (gimage->parasites, parasite);
gimp_parasite_list_remove (gimage->parasites, parasite);
}
Tattoo
@ -3324,7 +3324,7 @@ gimp_image_merge_layers (GimpImage *gimage,
gimp_drawable_set_tattoo (GIMP_DRAWABLE (merge_layer),
gimp_drawable_get_tattoo (GIMP_DRAWABLE (layer)));
GIMP_DRAWABLE (merge_layer)->parasites =
parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
gimp_parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
while (reverse_list)
{

View File

@ -105,7 +105,7 @@ struct _GimpImage
GimpLayer *floating_sel; /* the FS layer */
GimpChannel *selection_mask; /* the selection mask channel */
ParasiteList *parasites; /* Plug-in parasite data */
GimpParasiteList *parasites; /* Plug-in parasite data */
PathList *paths; /* Paths data for this image */

View File

@ -429,7 +429,7 @@ gimp_image_init (GimpImage *gimage)
gimage->floating_sel = NULL;
gimage->selection_mask = NULL;
gimage->parasites = parasite_list_new ();
gimage->parasites = gimp_parasite_list_new ();
gimage->paths = NULL;
@ -1513,7 +1513,7 @@ gimp_image_parasite_find (const GimpImage *gimage,
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return parasite_list_find (gimage->parasites, name);
return gimp_parasite_list_find (gimage->parasites, name);
}
static void
@ -1533,10 +1533,10 @@ gimp_image_parasite_list (const GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
*count = parasite_list_length (gimage->parasites);
*count = gimp_parasite_list_length (gimage->parasites);
cur = list = g_new (gchar*, *count);
parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
gimp_parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
return list;
}
@ -1559,12 +1559,12 @@ gimp_image_parasite_attach (GimpImage *gimage,
undoable but does not block the undo system. --Sven
*/
parasite_list_add (gimage->parasites, parasite);
gimp_parasite_list_add (gimage->parasites, parasite);
if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_PARENT))
{
parasite_shift_parent (parasite);
gimp_parasite_attach (parasite);
gimp_parasite_shift_parent (parasite);
gimp_parasite_attach (gimage->gimp, parasite);
}
}
@ -1576,13 +1576,13 @@ gimp_image_parasite_detach (GimpImage *gimage,
g_return_if_fail (GIMP_IS_IMAGE (gimage) && parasite != NULL);
if (!(p = parasite_list_find (gimage->parasites, parasite)))
if (!(p = gimp_parasite_list_find (gimage->parasites, parasite)))
return;
if (gimp_parasite_is_undoable (p))
undo_push_image_parasite_remove (gimage, gimp_parasite_name (p));
parasite_list_remove (gimage->parasites, parasite);
gimp_parasite_list_remove (gimage->parasites, parasite);
}
Tattoo
@ -3324,7 +3324,7 @@ gimp_image_merge_layers (GimpImage *gimage,
gimp_drawable_set_tattoo (GIMP_DRAWABLE (merge_layer),
gimp_drawable_get_tattoo (GIMP_DRAWABLE (layer)));
GIMP_DRAWABLE (merge_layer)->parasites =
parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
gimp_parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
while (reverse_list)
{

View File

@ -105,7 +105,7 @@ struct _GimpImage
GimpLayer *floating_sel; /* the FS layer */
GimpChannel *selection_mask; /* the selection mask channel */
ParasiteList *parasites; /* Plug-in parasite data */
GimpParasiteList *parasites; /* Plug-in parasite data */
PathList *paths; /* Paths data for this image */

View File

@ -48,6 +48,7 @@
#include "tools/gimptransformtool.h"
#include "tools/tool_manager.h"
#include "app_procs.h"
#include "drawable.h"
#include "floating_sel.h"
#include "gdisplay.h"
@ -2652,9 +2653,9 @@ undo_pop_parasite (GimpImage *gimage,
gimp_parasite_copy (gimp_image_parasite_find (gimage, data->name));
if (tmp)
parasite_list_add (data->gimage->parasites, tmp);
gimp_parasite_list_add (data->gimage->parasites, tmp);
else
parasite_list_remove (data->gimage->parasites, data->name);
gimp_parasite_list_remove (data->gimage->parasites, data->name);
}
else if (data->drawable)
{
@ -2662,17 +2663,18 @@ undo_pop_parasite (GimpImage *gimage,
gimp_parasite_copy (gimp_drawable_parasite_find (data->drawable,
data->name));
if (tmp)
parasite_list_add (data->drawable->parasites, tmp);
gimp_parasite_list_add (data->drawable->parasites, tmp);
else
parasite_list_remove (data->drawable->parasites, data->name);
gimp_parasite_list_remove (data->drawable->parasites, data->name);
}
else
{
data->parasite = gimp_parasite_copy (gimp_parasite_find (data->name));
data->parasite = gimp_parasite_copy (gimp_parasite_find (gimage->gimp,
data->name));
if (tmp)
gimp_parasite_attach (tmp);
gimp_parasite_attach (gimage->gimp, tmp);
else
gimp_parasite_detach (data->name);
gimp_parasite_detach (gimage->gimp, data->name);
}
if (tmp)

View File

@ -429,7 +429,7 @@ gimp_image_init (GimpImage *gimage)
gimage->floating_sel = NULL;
gimage->selection_mask = NULL;
gimage->parasites = parasite_list_new ();
gimage->parasites = gimp_parasite_list_new ();
gimage->paths = NULL;
@ -1513,7 +1513,7 @@ gimp_image_parasite_find (const GimpImage *gimage,
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return parasite_list_find (gimage->parasites, name);
return gimp_parasite_list_find (gimage->parasites, name);
}
static void
@ -1533,10 +1533,10 @@ gimp_image_parasite_list (const GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
*count = parasite_list_length (gimage->parasites);
*count = gimp_parasite_list_length (gimage->parasites);
cur = list = g_new (gchar*, *count);
parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
gimp_parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
return list;
}
@ -1559,12 +1559,12 @@ gimp_image_parasite_attach (GimpImage *gimage,
undoable but does not block the undo system. --Sven
*/
parasite_list_add (gimage->parasites, parasite);
gimp_parasite_list_add (gimage->parasites, parasite);
if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_PARENT))
{
parasite_shift_parent (parasite);
gimp_parasite_attach (parasite);
gimp_parasite_shift_parent (parasite);
gimp_parasite_attach (gimage->gimp, parasite);
}
}
@ -1576,13 +1576,13 @@ gimp_image_parasite_detach (GimpImage *gimage,
g_return_if_fail (GIMP_IS_IMAGE (gimage) && parasite != NULL);
if (!(p = parasite_list_find (gimage->parasites, parasite)))
if (!(p = gimp_parasite_list_find (gimage->parasites, parasite)))
return;
if (gimp_parasite_is_undoable (p))
undo_push_image_parasite_remove (gimage, gimp_parasite_name (p));
parasite_list_remove (gimage->parasites, parasite);
gimp_parasite_list_remove (gimage->parasites, parasite);
}
Tattoo
@ -3324,7 +3324,7 @@ gimp_image_merge_layers (GimpImage *gimage,
gimp_drawable_set_tattoo (GIMP_DRAWABLE (merge_layer),
gimp_drawable_get_tattoo (GIMP_DRAWABLE (layer)));
GIMP_DRAWABLE (merge_layer)->parasites =
parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
gimp_parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
while (reverse_list)
{

View File

@ -105,7 +105,7 @@ struct _GimpImage
GimpLayer *floating_sel; /* the FS layer */
GimpChannel *selection_mask; /* the selection mask channel */
ParasiteList *parasites; /* Plug-in parasite data */
GimpParasiteList *parasites; /* Plug-in parasite data */
PathList *paths; /* Paths data for this image */

View File

@ -391,8 +391,8 @@ gimp_layer_copy (GimpLayer *layer,
/* copy the parasites */
gtk_object_unref (GTK_OBJECT (GIMP_DRAWABLE (new_layer)->parasites));
GIMP_DRAWABLE (new_layer)->parasites
= parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
GIMP_DRAWABLE (new_layer)->parasites =
gimp_parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
cleanup:
/* free up the layer_name memory */

View File

@ -28,38 +28,54 @@
#include "core/core-types.h"
#include "core/gimp.h"
#include "app_procs.h"
#include "parasitelist.h"
#include "gimpparasite.h"
#include "gimprc.h"
static ParasiteList *parasites = NULL;
void
gimp_parasites_init (Gimp *gimp)
{
g_return_if_fail (gimp->parasites == NULL);
gimp->parasites = gimp_parasite_list_new ();
gtk_object_ref (GTK_OBJECT (gimp->parasites));
gtk_object_sink (GTK_OBJECT (gimp->parasites));
}
void
gimp_init_parasites (void)
gimp_parasites_exit (Gimp *gimp)
{
g_return_if_fail (parasites == NULL);
parasites = parasite_list_new ();
gimp_parasiterc_load ();
if (gimp->parasites)
{
gtk_object_unref (GTK_OBJECT (gimp->parasites));
gimp->parasites = NULL;
}
}
void
gimp_parasite_attach (GimpParasite *p)
gimp_parasite_attach (Gimp *gimp,
GimpParasite *parasite)
{
parasite_list_add (parasites, p);
gimp_parasite_list_add (gimp->parasites, parasite);
}
void
gimp_parasite_detach (const gchar *name)
gimp_parasite_detach (Gimp *gimp,
const gchar *name)
{
parasite_list_remove (parasites, name);
gimp_parasite_list_remove (gimp->parasites, name);
}
GimpParasite *
gimp_parasite_find (const gchar *name)
gimp_parasite_find (Gimp *gimp,
const gchar *name)
{
return parasite_list_find (parasites, name);
return gimp_parasite_list_find (gimp->parasites, name);
}
static void
@ -71,31 +87,33 @@ list_func (gchar *key,
}
gchar **
gimp_parasite_list (gint *count)
gimp_parasite_list (Gimp *gimp,
gint *count)
{
gchar **list;
gchar **cur;
*count = parasite_list_length (parasites);
*count = gimp_parasite_list_length (gimp->parasites);
cur = list = g_new (gchar *, *count);
parasite_list_foreach (parasites, (GHFunc) list_func, &cur);
gimp_parasite_list_foreach (gimp->parasites, (GHFunc) list_func, &cur);
return list;
}
static void
save_func (gchar *key,
GimpParasite *p,
GimpParasite *parasite,
FILE *fp)
{
if (gimp_parasite_is_persistent (p))
if (gimp_parasite_is_persistent (parasite))
{
gchar *s;
guint32 l;
fprintf (fp, "(parasite \"%s\" %lu \"",
gimp_parasite_name (p), gimp_parasite_flags (p));
gimp_parasite_name (parasite),
gimp_parasite_flags (parasite));
/*
* the current methodology is: never move the parasiterc from one
@ -104,7 +122,8 @@ save_func (gchar *key,
* characters as \xHH sequences altogether.
*/
for (s = (gchar *) gimp_parasite_data (p), l = gimp_parasite_data_size (p);
for (s = (gchar *) gimp_parasite_data (parasite),
l = gimp_parasite_data_size (parasite);
l;
l--, s++)
{
@ -120,17 +139,27 @@ save_func (gchar *key,
default : fputc (*s, fp); break;
}
}
fputs ("\")\n\n", fp);
}
}
void
gimp_parasiterc_save (void)
gimp_parasiterc_load (Gimp *gimp)
{
gchar *filename;
filename = gimp_personal_rc_file ("parasiterc");
parse_gimprc_file (filename);
g_free (filename);
}
void
gimp_parasiterc_save (Gimp *gimp)
{
gchar *tmp_filename = NULL;
gchar *bak_filename = NULL;
gchar *rc_filename = NULL;
gchar *rc_filename = NULL;
FILE *fp;
tmp_filename = gimp_personal_rc_file ("#parasiterc.tmp~");
@ -147,7 +176,7 @@ gimp_parasiterc_save (void)
"# This file will be entirely rewritten every time you "
"quit the gimp.\n\n");
parasite_list_foreach (parasites, (GHFunc)save_func, fp);
gimp_parasite_list_foreach (gimp->parasites, (GHFunc) save_func, fp);
fclose (fp);
@ -171,14 +200,3 @@ gimp_parasiterc_save (void)
g_free (bak_filename);
g_free (rc_filename);
}
void
gimp_parasiterc_load (void)
{
gchar *filename;
filename = gimp_personal_rc_file ("parasiterc");
app_init_update_status (NULL, filename, -1);
parse_gimprc_file (filename);
g_free (filename);
}

View File

@ -19,16 +19,21 @@
#define __APP_GIMP_PARASITE_H__
void gimp_init_parasites (void);
void gimp_parasites_init (Gimp *gimp);
void gimp_parasites_exit (Gimp *gimp);
void gimp_parasite_attach (GimpParasite *parasite);
void gimp_parasite_detach (const gchar *name);
void gimp_parasite_attach (Gimp *gimp,
GimpParasite *parasite);
void gimp_parasite_detach (Gimp *gimp,
const gchar *name);
GimpParasite * gimp_parasite_find (const gchar *name);
gchar ** gimp_parasite_list (gint *count);
GimpParasite * gimp_parasite_find (Gimp *gimp,
const gchar *name);
gchar ** gimp_parasite_list (Gimp *gimp,
gint *count);
void gimp_parasiterc_save (void);
void gimp_parasiterc_load (void);
void gimp_parasiterc_load (Gimp *gimp);
void gimp_parasiterc_save (Gimp *gimp);
#endif /* __APP_GIMP_PARASITE_H__ */

View File

@ -36,25 +36,20 @@ enum
};
static void parasite_list_destroy (GtkObject *list);
static void parasite_list_init (ParasiteList *list);
static void parasite_list_class_init (ParasiteListClass *klass);
static int free_a_parasite (gpointer key,
gpointer parasite,
gpointer unused);
static void gimp_parasite_list_class_init (GimpParasiteListClass *klass);
static void gimp_parasite_list_init (GimpParasiteList *list);
static void gimp_parasite_list_destroy (GtkObject *list);
static gint free_a_parasite (gpointer key,
gpointer parasite,
gpointer unused);
static guint parasite_list_signals[LAST_SIGNAL] = { 0 };
static void
parasite_list_init (ParasiteList *list)
{
list->table = NULL;
}
static void
parasite_list_class_init (ParasiteListClass *klass)
gimp_parasite_list_class_init (GimpParasiteListClass *klass)
{
GtkObjectClass *object_class;
@ -64,7 +59,7 @@ parasite_list_class_init (ParasiteListClass *klass)
gtk_signal_new ("add",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (ParasiteListClass,
GTK_SIGNAL_OFFSET (GimpParasiteListClass,
add),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@ -74,7 +69,7 @@ parasite_list_class_init (ParasiteListClass *klass)
gtk_signal_new ("remove",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (ParasiteListClass,
GTK_SIGNAL_OFFSET (GimpParasiteListClass,
remove),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@ -83,14 +78,20 @@ parasite_list_class_init (ParasiteListClass *klass)
gtk_object_class_add_signals (object_class, parasite_list_signals,
LAST_SIGNAL);
object_class->destroy = parasite_list_destroy;
object_class->destroy = gimp_parasite_list_destroy;
klass->add = NULL;
klass->remove = NULL;
}
static void
gimp_parasite_list_init (GimpParasiteList *list)
{
list->table = NULL;
}
GtkType
parasite_list_get_type (void)
gimp_parasite_list_get_type (void)
{
static GtkType type = 0;
@ -98,11 +99,11 @@ parasite_list_get_type (void)
{
GtkTypeInfo info =
{
"ParasiteList",
sizeof (ParasiteList),
sizeof (ParasiteListClass),
(GtkClassInitFunc) parasite_list_class_init,
(GtkObjectInitFunc) parasite_list_init,
"GimpParasiteList",
sizeof (GimpParasiteList),
sizeof (GimpParasiteListClass),
(GtkClassInitFunc) gimp_parasite_list_class_init,
(GtkObjectInitFunc) gimp_parasite_list_init,
NULL,
NULL,
(GtkClassInitFunc) NULL
@ -114,11 +115,13 @@ parasite_list_get_type (void)
return type;
}
ParasiteList *
parasite_list_new (void)
GimpParasiteList *
gimp_parasite_list_new (void)
{
ParasiteList *list = gtk_type_new (GIMP_TYPE_PARASITE_LIST);
list->table = NULL;
GimpParasiteList *list = gtk_type_new (GIMP_TYPE_PARASITE_LIST);
list = gtk_type_new (GIMP_TYPE_PARASITE_LIST);
return list;
}
@ -128,18 +131,19 @@ free_a_parasite (void *key,
void *unused)
{
gimp_parasite_free ((GimpParasite *) parasite);
return TRUE;
}
static void
parasite_list_destroy (GtkObject *obj)
gimp_parasite_list_destroy (GtkObject *object)
{
ParasiteList *list;
GimpParasiteList *list;
g_return_if_fail (obj != NULL);
g_return_if_fail (GIMP_IS_PARASITE_LIST(obj));
g_return_if_fail (object != NULL);
g_return_if_fail (GIMP_IS_PARASITE_LIST (object));
list = (ParasiteList *) obj;
list = GIMP_PARASITE_LIST (object);
if (list->table)
{
@ -153,18 +157,18 @@ parasite_copy_one (void *key,
void *p,
void *data)
{
ParasiteList *list = (ParasiteList *) data;
GimpParasite *parasite = (GimpParasite *) p;
GimpParasiteList *list = (GimpParasiteList *) data;
GimpParasite *parasite = (GimpParasite *) p;
parasite_list_add (list, parasite);
gimp_parasite_list_add (list, parasite);
}
ParasiteList *
parasite_list_copy (const ParasiteList *list)
GimpParasiteList *
gimp_parasite_list_copy (const GimpParasiteList *list)
{
ParasiteList *newlist;
GimpParasiteList *newlist;
newlist = parasite_list_new ();
newlist = gimp_parasite_list_new ();
if (list->table)
g_hash_table_foreach (list->table, parasite_copy_one, newlist);
@ -172,50 +176,56 @@ parasite_list_copy (const ParasiteList *list)
}
void
parasite_list_add (ParasiteList *list,
GimpParasite *p)
gimp_parasite_list_add (GimpParasiteList *list,
GimpParasite *parasite)
{
g_return_if_fail (list != NULL);
if (list->table == NULL)
list->table = g_hash_table_new (g_str_hash, g_str_equal);
g_return_if_fail (p != NULL);
g_return_if_fail (p->name != NULL);
g_return_if_fail (parasite != NULL);
g_return_if_fail (parasite->name != NULL);
parasite_list_remove (list, p->name);
p = gimp_parasite_copy (p);
g_hash_table_insert (list->table, p->name, p);
gtk_signal_emit (GTK_OBJECT(list), parasite_list_signals[ADD], p);
gimp_parasite_list_remove (list, parasite->name);
parasite = gimp_parasite_copy (parasite);
g_hash_table_insert (list->table, parasite->name, parasite);
gtk_signal_emit (GTK_OBJECT (list), parasite_list_signals[ADD], parasite);
}
void
parasite_list_remove (ParasiteList *list,
const gchar *name)
gimp_parasite_list_remove (GimpParasiteList *list,
const gchar *name)
{
GimpParasite *p;
GimpParasite *parasite;
g_return_if_fail (list != NULL);
if (list->table)
{
p = parasite_list_find (list, name);
if (p)
parasite = gimp_parasite_list_find (list, name);
if (parasite)
{
g_hash_table_remove (list->table, name);
gtk_signal_emit (GTK_OBJECT (list), parasite_list_signals[REMOVE], p);
gimp_parasite_free (p);
gtk_signal_emit (GTK_OBJECT (list), parasite_list_signals[REMOVE],
parasite);
gimp_parasite_free (parasite);
}
}
}
gint
parasite_list_length (ParasiteList *list)
gimp_parasite_list_length (GimpParasiteList *list)
{
g_return_val_if_fail (list != NULL, 0);
if (!list->table)
return 0;
return g_hash_table_size (list->table);
}
@ -229,7 +239,7 @@ ppcount_func (gchar *key,
}
gint
parasite_list_persistent_length (ParasiteList *list)
gimp_parasite_list_persistent_length (GimpParasiteList *list)
{
gint ppcount = 0;
@ -238,15 +248,15 @@ parasite_list_persistent_length (ParasiteList *list)
if (!list->table)
return 0;
parasite_list_foreach (list, (GHFunc) ppcount_func, &ppcount);
gimp_parasite_list_foreach (list, (GHFunc) ppcount_func, &ppcount);
return ppcount;
}
void
parasite_list_foreach (ParasiteList *list,
GHFunc function,
gpointer user_data)
gimp_parasite_list_foreach (GimpParasiteList *list,
GHFunc function,
gpointer user_data)
{
g_return_if_fail (list != NULL);
@ -257,8 +267,8 @@ parasite_list_foreach (ParasiteList *list,
}
GimpParasite *
parasite_list_find (ParasiteList *list,
const gchar *name)
gimp_parasite_list_find (GimpParasiteList *list,
const gchar *name)
{
g_return_val_if_fail (list != NULL, NULL);
@ -269,10 +279,10 @@ parasite_list_find (ParasiteList *list,
}
void
parasite_shift_parent (GimpParasite *p)
gimp_parasite_shift_parent (GimpParasite *parasite)
{
if (p == NULL)
if (parasite == NULL)
return;
p->flags = (p->flags >> 8);
parasite->flags = (parasite->flags >> 8);
}

View File

@ -15,58 +15,56 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PARASITE_LIST_H__
#define __PARASITE_LIST_H__
#ifndef __GIMP_PARASITE_LIST_H__
#define __GIMP_PARASITE_LIST_H__
#include "core/gimpobject.h"
#define GIMP_TYPE_PARASITE_LIST (parasite_list_get_type ())
#define GIMP_TYPE_PARASITE_LIST (gimp_parasite_list_get_type ())
#define GIMP_PARASITE_LIST(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PARASITE_LIST, GimpParasiteList))
#define GIMP_IS_PARASITE_LIST(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_PARASITE_LIST))
#define PARASITE_LIST_CLASS(class) GIMP_CHECK_CLASS_CAST (class, parasite_list_get_type(), ParasiteListClass)
#define PARASITE_LIST_CLASS(class) GIMP_CHECK_CLASS_CAST (class, GIMP_TYPE_PARASITE_LIST, GimpParasiteListClass)
typedef struct _ParasiteListClass ParasiteListClass;
typedef struct _GimpParasiteListClass GimpParasiteListClass;
struct _ParasiteList
struct _GimpParasiteList
{
GimpObject object;
GHashTable *table;
};
struct _ParasiteListClass
struct _GimpParasiteListClass
{
GimpObjectClass parent_class;
void (* add) (ParasiteList *list,
GimpParasite *parasite);
void (* remove) (ParasiteList *list,
GimpParasite *parasite);
void (* add) (GimpParasiteList *list,
GimpParasite *parasite);
void (* remove) (GimpParasiteList *list,
GimpParasite *parasite);
};
/* function declarations */
GtkType gimp_parasite_list_get_type (void);
GtkType parasite_list_get_type (void);
GimpParasiteList * gimp_parasite_list_new (void);
GimpParasiteList * gimp_parasite_list_copy (const GimpParasiteList *list);
void gimp_parasite_list_add (GimpParasiteList *list,
GimpParasite *parasite);
void gimp_parasite_list_remove (GimpParasiteList *list,
const gchar *name);
gint gimp_parasite_list_length (GimpParasiteList *list);
gint gimp_parasite_list_persistent_length (GimpParasiteList *list);
void gimp_parasite_list_foreach (GimpParasiteList *list,
GHFunc function,
gpointer user_data);
GimpParasite * gimp_parasite_list_find (GimpParasiteList *list,
const gchar *name);
ParasiteList * parasite_list_new (void);
ParasiteList * parasite_list_copy (const ParasiteList *list);
void parasite_list_add (ParasiteList *list,
GimpParasite *parasite);
void parasite_list_remove (ParasiteList *list,
const gchar *name);
gint parasite_list_length (ParasiteList *list);
gint parasite_list_persistent_length (ParasiteList *list);
void parasite_list_foreach (ParasiteList *list,
GHFunc function,
gpointer user_data);
GimpParasite * parasite_list_find (ParasiteList *list,
const gchar *name);
void parasite_shift_parent (GimpParasite *parasite);
void gimp_parasite_shift_parent (GimpParasite *parasite);
#endif /* __PARASITE_LIST_H__ */
#endif /* __GIMP_PARASITE_LIST_H__ */

View File

@ -429,7 +429,7 @@ gimp_image_init (GimpImage *gimage)
gimage->floating_sel = NULL;
gimage->selection_mask = NULL;
gimage->parasites = parasite_list_new ();
gimage->parasites = gimp_parasite_list_new ();
gimage->paths = NULL;
@ -1513,7 +1513,7 @@ gimp_image_parasite_find (const GimpImage *gimage,
{
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
return parasite_list_find (gimage->parasites, name);
return gimp_parasite_list_find (gimage->parasites, name);
}
static void
@ -1533,10 +1533,10 @@ gimp_image_parasite_list (const GimpImage *gimage,
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
*count = parasite_list_length (gimage->parasites);
*count = gimp_parasite_list_length (gimage->parasites);
cur = list = g_new (gchar*, *count);
parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
gimp_parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur);
return list;
}
@ -1559,12 +1559,12 @@ gimp_image_parasite_attach (GimpImage *gimage,
undoable but does not block the undo system. --Sven
*/
parasite_list_add (gimage->parasites, parasite);
gimp_parasite_list_add (gimage->parasites, parasite);
if (gimp_parasite_has_flag (parasite, GIMP_PARASITE_ATTACH_PARENT))
{
parasite_shift_parent (parasite);
gimp_parasite_attach (parasite);
gimp_parasite_shift_parent (parasite);
gimp_parasite_attach (gimage->gimp, parasite);
}
}
@ -1576,13 +1576,13 @@ gimp_image_parasite_detach (GimpImage *gimage,
g_return_if_fail (GIMP_IS_IMAGE (gimage) && parasite != NULL);
if (!(p = parasite_list_find (gimage->parasites, parasite)))
if (!(p = gimp_parasite_list_find (gimage->parasites, parasite)))
return;
if (gimp_parasite_is_undoable (p))
undo_push_image_parasite_remove (gimage, gimp_parasite_name (p));
parasite_list_remove (gimage->parasites, parasite);
gimp_parasite_list_remove (gimage->parasites, parasite);
}
Tattoo
@ -3324,7 +3324,7 @@ gimp_image_merge_layers (GimpImage *gimage,
gimp_drawable_set_tattoo (GIMP_DRAWABLE (merge_layer),
gimp_drawable_get_tattoo (GIMP_DRAWABLE (layer)));
GIMP_DRAWABLE (merge_layer)->parasites =
parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
gimp_parasite_list_copy (GIMP_DRAWABLE (layer)->parasites);
while (reverse_list)
{

View File

@ -105,7 +105,7 @@ struct _GimpImage
GimpLayer *floating_sel; /* the FS layer */
GimpChannel *selection_mask; /* the selection mask channel */
ParasiteList *parasites; /* Plug-in parasite data */
GimpParasiteList *parasites; /* Plug-in parasite data */
PathList *paths; /* Paths data for this image */

View File

@ -28,38 +28,54 @@
#include "core/core-types.h"
#include "core/gimp.h"
#include "app_procs.h"
#include "parasitelist.h"
#include "gimpparasite.h"
#include "gimprc.h"
static ParasiteList *parasites = NULL;
void
gimp_parasites_init (Gimp *gimp)
{
g_return_if_fail (gimp->parasites == NULL);
gimp->parasites = gimp_parasite_list_new ();
gtk_object_ref (GTK_OBJECT (gimp->parasites));
gtk_object_sink (GTK_OBJECT (gimp->parasites));
}
void
gimp_init_parasites (void)
gimp_parasites_exit (Gimp *gimp)
{
g_return_if_fail (parasites == NULL);
parasites = parasite_list_new ();
gimp_parasiterc_load ();
if (gimp->parasites)
{
gtk_object_unref (GTK_OBJECT (gimp->parasites));
gimp->parasites = NULL;
}
}
void
gimp_parasite_attach (GimpParasite *p)
gimp_parasite_attach (Gimp *gimp,
GimpParasite *parasite)
{
parasite_list_add (parasites, p);
gimp_parasite_list_add (gimp->parasites, parasite);
}
void
gimp_parasite_detach (const gchar *name)
gimp_parasite_detach (Gimp *gimp,
const gchar *name)
{
parasite_list_remove (parasites, name);
gimp_parasite_list_remove (gimp->parasites, name);
}
GimpParasite *
gimp_parasite_find (const gchar *name)
gimp_parasite_find (Gimp *gimp,
const gchar *name)
{
return parasite_list_find (parasites, name);
return gimp_parasite_list_find (gimp->parasites, name);
}
static void
@ -71,31 +87,33 @@ list_func (gchar *key,
}
gchar **
gimp_parasite_list (gint *count)
gimp_parasite_list (Gimp *gimp,
gint *count)
{
gchar **list;
gchar **cur;
*count = parasite_list_length (parasites);
*count = gimp_parasite_list_length (gimp->parasites);
cur = list = g_new (gchar *, *count);
parasite_list_foreach (parasites, (GHFunc) list_func, &cur);
gimp_parasite_list_foreach (gimp->parasites, (GHFunc) list_func, &cur);
return list;
}
static void
save_func (gchar *key,
GimpParasite *p,
GimpParasite *parasite,
FILE *fp)
{
if (gimp_parasite_is_persistent (p))
if (gimp_parasite_is_persistent (parasite))
{
gchar *s;
guint32 l;
fprintf (fp, "(parasite \"%s\" %lu \"",
gimp_parasite_name (p), gimp_parasite_flags (p));
gimp_parasite_name (parasite),
gimp_parasite_flags (parasite));
/*
* the current methodology is: never move the parasiterc from one
@ -104,7 +122,8 @@ save_func (gchar *key,
* characters as \xHH sequences altogether.
*/
for (s = (gchar *) gimp_parasite_data (p), l = gimp_parasite_data_size (p);
for (s = (gchar *) gimp_parasite_data (parasite),
l = gimp_parasite_data_size (parasite);
l;
l--, s++)
{
@ -120,17 +139,27 @@ save_func (gchar *key,
default : fputc (*s, fp); break;
}
}
fputs ("\")\n\n", fp);
}
}
void
gimp_parasiterc_save (void)
gimp_parasiterc_load (Gimp *gimp)
{
gchar *filename;
filename = gimp_personal_rc_file ("parasiterc");
parse_gimprc_file (filename);
g_free (filename);
}
void
gimp_parasiterc_save (Gimp *gimp)
{
gchar *tmp_filename = NULL;
gchar *bak_filename = NULL;
gchar *rc_filename = NULL;
gchar *rc_filename = NULL;
FILE *fp;
tmp_filename = gimp_personal_rc_file ("#parasiterc.tmp~");
@ -147,7 +176,7 @@ gimp_parasiterc_save (void)
"# This file will be entirely rewritten every time you "
"quit the gimp.\n\n");
parasite_list_foreach (parasites, (GHFunc)save_func, fp);
gimp_parasite_list_foreach (gimp->parasites, (GHFunc) save_func, fp);
fclose (fp);
@ -171,14 +200,3 @@ gimp_parasiterc_save (void)
g_free (bak_filename);
g_free (rc_filename);
}
void
gimp_parasiterc_load (void)
{
gchar *filename;
filename = gimp_personal_rc_file ("parasiterc");
app_init_update_status (NULL, filename, -1);
parse_gimprc_file (filename);
g_free (filename);
}

View File

@ -19,16 +19,21 @@
#define __APP_GIMP_PARASITE_H__
void gimp_init_parasites (void);
void gimp_parasites_init (Gimp *gimp);
void gimp_parasites_exit (Gimp *gimp);
void gimp_parasite_attach (GimpParasite *parasite);
void gimp_parasite_detach (const gchar *name);
void gimp_parasite_attach (Gimp *gimp,
GimpParasite *parasite);
void gimp_parasite_detach (Gimp *gimp,
const gchar *name);
GimpParasite * gimp_parasite_find (const gchar *name);
gchar ** gimp_parasite_list (gint *count);
GimpParasite * gimp_parasite_find (Gimp *gimp,
const gchar *name);
gchar ** gimp_parasite_list (Gimp *gimp,
gint *count);
void gimp_parasiterc_save (void);
void gimp_parasiterc_load (void);
void gimp_parasiterc_load (Gimp *gimp);
void gimp_parasiterc_save (Gimp *gimp);
#endif /* __APP_GIMP_PARASITE_H__ */

View File

@ -195,7 +195,8 @@ static gchar * open_backup_file (gchar *filename,
/* global gimprc variables */
GimpRc gimprc = {
GimpRc gimprc =
{
.plug_in_path = NULL,
.brush_path = NULL,
.default_brush = NULL,
@ -2752,7 +2753,7 @@ parse_parasite (gpointer val1p,
goto error;
parasite = gimp_parasite_new (identifier, flags, token_int, token_str);
gimp_parasite_attach (parasite); /* attaches a copy */
gimp_parasite_attach (the_gimp, parasite); /* attaches a copy */
gimp_parasite_free (parasite);
token = get_next_token ();

View File

@ -36,25 +36,20 @@ enum
};
static void parasite_list_destroy (GtkObject *list);
static void parasite_list_init (ParasiteList *list);
static void parasite_list_class_init (ParasiteListClass *klass);
static int free_a_parasite (gpointer key,
gpointer parasite,
gpointer unused);
static void gimp_parasite_list_class_init (GimpParasiteListClass *klass);
static void gimp_parasite_list_init (GimpParasiteList *list);
static void gimp_parasite_list_destroy (GtkObject *list);
static gint free_a_parasite (gpointer key,
gpointer parasite,
gpointer unused);
static guint parasite_list_signals[LAST_SIGNAL] = { 0 };
static void
parasite_list_init (ParasiteList *list)
{
list->table = NULL;
}
static void
parasite_list_class_init (ParasiteListClass *klass)
gimp_parasite_list_class_init (GimpParasiteListClass *klass)
{
GtkObjectClass *object_class;
@ -64,7 +59,7 @@ parasite_list_class_init (ParasiteListClass *klass)
gtk_signal_new ("add",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (ParasiteListClass,
GTK_SIGNAL_OFFSET (GimpParasiteListClass,
add),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@ -74,7 +69,7 @@ parasite_list_class_init (ParasiteListClass *klass)
gtk_signal_new ("remove",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (ParasiteListClass,
GTK_SIGNAL_OFFSET (GimpParasiteListClass,
remove),
gtk_marshal_NONE__POINTER,
GTK_TYPE_NONE, 1,
@ -83,14 +78,20 @@ parasite_list_class_init (ParasiteListClass *klass)
gtk_object_class_add_signals (object_class, parasite_list_signals,
LAST_SIGNAL);
object_class->destroy = parasite_list_destroy;
object_class->destroy = gimp_parasite_list_destroy;
klass->add = NULL;
klass->remove = NULL;
}
static void
gimp_parasite_list_init (GimpParasiteList *list)
{
list->table = NULL;
}
GtkType
parasite_list_get_type (void)
gimp_parasite_list_get_type (void)
{
static GtkType type = 0;
@ -98,11 +99,11 @@ parasite_list_get_type (void)
{
GtkTypeInfo info =
{
"ParasiteList",
sizeof (ParasiteList),
sizeof (ParasiteListClass),
(GtkClassInitFunc) parasite_list_class_init,
(GtkObjectInitFunc) parasite_list_init,
"GimpParasiteList",
sizeof (GimpParasiteList),
sizeof (GimpParasiteListClass),
(GtkClassInitFunc) gimp_parasite_list_class_init,
(GtkObjectInitFunc) gimp_parasite_list_init,
NULL,
NULL,
(GtkClassInitFunc) NULL
@ -114,11 +115,13 @@ parasite_list_get_type (void)
return type;
}
ParasiteList *
parasite_list_new (void)
GimpParasiteList *
gimp_parasite_list_new (void)
{
ParasiteList *list = gtk_type_new (GIMP_TYPE_PARASITE_LIST);
list->table = NULL;
GimpParasiteList *list = gtk_type_new (GIMP_TYPE_PARASITE_LIST);
list = gtk_type_new (GIMP_TYPE_PARASITE_LIST);
return list;
}
@ -128,18 +131,19 @@ free_a_parasite (void *key,
void *unused)
{
gimp_parasite_free ((GimpParasite *) parasite);
return TRUE;
}
static void
parasite_list_destroy (GtkObject *obj)
gimp_parasite_list_destroy (GtkObject *object)
{
ParasiteList *list;
GimpParasiteList *list;
g_return_if_fail (obj != NULL);
g_return_if_fail (GIMP_IS_PARASITE_LIST(obj));
g_return_if_fail (object != NULL);
g_return_if_fail (GIMP_IS_PARASITE_LIST (object));
list = (ParasiteList *) obj;
list = GIMP_PARASITE_LIST (object);
if (list->table)
{
@ -153,18 +157,18 @@ parasite_copy_one (void *key,
void *p,
void *data)
{
ParasiteList *list = (ParasiteList *) data;
GimpParasite *parasite = (GimpParasite *) p;
GimpParasiteList *list = (GimpParasiteList *) data;
GimpParasite *parasite = (GimpParasite *) p;
parasite_list_add (list, parasite);
gimp_parasite_list_add (list, parasite);
}
ParasiteList *
parasite_list_copy (const ParasiteList *list)
GimpParasiteList *
gimp_parasite_list_copy (const GimpParasiteList *list)
{
ParasiteList *newlist;
GimpParasiteList *newlist;
newlist = parasite_list_new ();
newlist = gimp_parasite_list_new ();
if (list->table)
g_hash_table_foreach (list->table, parasite_copy_one, newlist);
@ -172,50 +176,56 @@ parasite_list_copy (const ParasiteList *list)
}
void
parasite_list_add (ParasiteList *list,
GimpParasite *p)
gimp_parasite_list_add (GimpParasiteList *list,
GimpParasite *parasite)
{
g_return_if_fail (list != NULL);
if (list->table == NULL)
list->table = g_hash_table_new (g_str_hash, g_str_equal);
g_return_if_fail (p != NULL);
g_return_if_fail (p->name != NULL);
g_return_if_fail (parasite != NULL);
g_return_if_fail (parasite->name != NULL);
parasite_list_remove (list, p->name);
p = gimp_parasite_copy (p);
g_hash_table_insert (list->table, p->name, p);
gtk_signal_emit (GTK_OBJECT(list), parasite_list_signals[ADD], p);
gimp_parasite_list_remove (list, parasite->name);
parasite = gimp_parasite_copy (parasite);
g_hash_table_insert (list->table, parasite->name, parasite);
gtk_signal_emit (GTK_OBJECT (list), parasite_list_signals[ADD], parasite);
}
void
parasite_list_remove (ParasiteList *list,
const gchar *name)
gimp_parasite_list_remove (GimpParasiteList *list,
const gchar *name)
{
GimpParasite *p;
GimpParasite *parasite;
g_return_if_fail (list != NULL);
if (list->table)
{
p = parasite_list_find (list, name);
if (p)
parasite = gimp_parasite_list_find (list, name);
if (parasite)
{
g_hash_table_remove (list->table, name);
gtk_signal_emit (GTK_OBJECT (list), parasite_list_signals[REMOVE], p);
gimp_parasite_free (p);
gtk_signal_emit (GTK_OBJECT (list), parasite_list_signals[REMOVE],
parasite);
gimp_parasite_free (parasite);
}
}
}
gint
parasite_list_length (ParasiteList *list)
gimp_parasite_list_length (GimpParasiteList *list)
{
g_return_val_if_fail (list != NULL, 0);
if (!list->table)
return 0;
return g_hash_table_size (list->table);
}
@ -229,7 +239,7 @@ ppcount_func (gchar *key,
}
gint
parasite_list_persistent_length (ParasiteList *list)
gimp_parasite_list_persistent_length (GimpParasiteList *list)
{
gint ppcount = 0;
@ -238,15 +248,15 @@ parasite_list_persistent_length (ParasiteList *list)
if (!list->table)
return 0;
parasite_list_foreach (list, (GHFunc) ppcount_func, &ppcount);
gimp_parasite_list_foreach (list, (GHFunc) ppcount_func, &ppcount);
return ppcount;
}
void
parasite_list_foreach (ParasiteList *list,
GHFunc function,
gpointer user_data)
gimp_parasite_list_foreach (GimpParasiteList *list,
GHFunc function,
gpointer user_data)
{
g_return_if_fail (list != NULL);
@ -257,8 +267,8 @@ parasite_list_foreach (ParasiteList *list,
}
GimpParasite *
parasite_list_find (ParasiteList *list,
const gchar *name)
gimp_parasite_list_find (GimpParasiteList *list,
const gchar *name)
{
g_return_val_if_fail (list != NULL, NULL);
@ -269,10 +279,10 @@ parasite_list_find (ParasiteList *list,
}
void
parasite_shift_parent (GimpParasite *p)
gimp_parasite_shift_parent (GimpParasite *parasite)
{
if (p == NULL)
if (parasite == NULL)
return;
p->flags = (p->flags >> 8);
parasite->flags = (parasite->flags >> 8);
}

View File

@ -15,58 +15,56 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __PARASITE_LIST_H__
#define __PARASITE_LIST_H__
#ifndef __GIMP_PARASITE_LIST_H__
#define __GIMP_PARASITE_LIST_H__
#include "core/gimpobject.h"
#define GIMP_TYPE_PARASITE_LIST (parasite_list_get_type ())
#define GIMP_TYPE_PARASITE_LIST (gimp_parasite_list_get_type ())
#define GIMP_PARASITE_LIST(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_PARASITE_LIST, GimpParasiteList))
#define GIMP_IS_PARASITE_LIST(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_PARASITE_LIST))
#define PARASITE_LIST_CLASS(class) GIMP_CHECK_CLASS_CAST (class, parasite_list_get_type(), ParasiteListClass)
#define PARASITE_LIST_CLASS(class) GIMP_CHECK_CLASS_CAST (class, GIMP_TYPE_PARASITE_LIST, GimpParasiteListClass)
typedef struct _ParasiteListClass ParasiteListClass;
typedef struct _GimpParasiteListClass GimpParasiteListClass;
struct _ParasiteList
struct _GimpParasiteList
{
GimpObject object;
GHashTable *table;
};
struct _ParasiteListClass
struct _GimpParasiteListClass
{
GimpObjectClass parent_class;
void (* add) (ParasiteList *list,
GimpParasite *parasite);
void (* remove) (ParasiteList *list,
GimpParasite *parasite);
void (* add) (GimpParasiteList *list,
GimpParasite *parasite);
void (* remove) (GimpParasiteList *list,
GimpParasite *parasite);
};
/* function declarations */
GtkType gimp_parasite_list_get_type (void);
GtkType parasite_list_get_type (void);
GimpParasiteList * gimp_parasite_list_new (void);
GimpParasiteList * gimp_parasite_list_copy (const GimpParasiteList *list);
void gimp_parasite_list_add (GimpParasiteList *list,
GimpParasite *parasite);
void gimp_parasite_list_remove (GimpParasiteList *list,
const gchar *name);
gint gimp_parasite_list_length (GimpParasiteList *list);
gint gimp_parasite_list_persistent_length (GimpParasiteList *list);
void gimp_parasite_list_foreach (GimpParasiteList *list,
GHFunc function,
gpointer user_data);
GimpParasite * gimp_parasite_list_find (GimpParasiteList *list,
const gchar *name);
ParasiteList * parasite_list_new (void);
ParasiteList * parasite_list_copy (const ParasiteList *list);
void parasite_list_add (ParasiteList *list,
GimpParasite *parasite);
void parasite_list_remove (ParasiteList *list,
const gchar *name);
gint parasite_list_length (ParasiteList *list);
gint parasite_list_persistent_length (ParasiteList *list);
void parasite_list_foreach (ParasiteList *list,
GHFunc function,
gpointer user_data);
GimpParasite * parasite_list_find (ParasiteList *list,
const gchar *name);
void parasite_shift_parent (GimpParasite *parasite);
void gimp_parasite_shift_parent (GimpParasite *parasite);
#endif /* __PARASITE_LIST_H__ */
#endif /* __GIMP_PARASITE_LIST_H__ */

View File

@ -77,6 +77,7 @@ brushes_refresh_invoker (Gimp *gimp,
* <sjburges@gimp.org>
*/
gimp_data_factory_data_save (gimp->brush_factory);
gimp_data_factory_data_init (gimp->brush_factory, FALSE);
return procedural_db_return_args (&brushes_refresh_proc, TRUE);

View File

@ -80,7 +80,7 @@ parasite_find_invoker (Gimp *gimp,
if (success)
{
parasite = gimp_parasite_copy (gimp_parasite_find (name));
parasite = gimp_parasite_copy (gimp_parasite_find (gimp, name));
success = parasite != NULL;
}
@ -138,7 +138,7 @@ parasite_attach_invoker (Gimp *gimp,
success = FALSE;
if (success)
gimp_parasite_attach (parasite);
gimp_parasite_attach (gimp, parasite);
return procedural_db_return_args (&parasite_attach_proc, success);
}
@ -180,7 +180,7 @@ parasite_detach_invoker (Gimp *gimp,
success = FALSE;
if (success)
gimp_parasite_detach (name);
gimp_parasite_detach (gimp, name);
return procedural_db_return_args (&parasite_detach_proc, success);
}
@ -218,7 +218,7 @@ parasite_list_invoker (Gimp *gimp,
gint32 num_parasites;
gchar **parasites;
parasites = gimp_parasite_list (&num_parasites);
parasites = gimp_parasite_list (gimp, &num_parasites);
return_args = procedural_db_return_args (&parasite_list_proc, TRUE);
@ -278,7 +278,7 @@ drawable_parasite_find_invoker (Gimp *gimp,
if (success)
{
parasite = gimp_parasite_copy (gimp_drawable_parasite_find (drawable, name));
parasite = gimp_parasite_copy (gimp_parasite_find (gimp, name));
success = parasite != NULL;
}
@ -346,7 +346,7 @@ drawable_parasite_attach_invoker (Gimp *gimp,
success = FALSE;
if (success)
gimp_drawable_parasite_attach (drawable, parasite);
gimp_parasite_attach (gimp, parasite);
return procedural_db_return_args (&drawable_parasite_attach_proc, success);
}
@ -398,7 +398,7 @@ drawable_parasite_detach_invoker (Gimp *gimp,
success = FALSE;
if (success)
gimp_drawable_parasite_detach (drawable, name);
gimp_parasite_detach (gimp, name);
return procedural_db_return_args (&drawable_parasite_detach_proc, success);
}
@ -448,7 +448,7 @@ drawable_parasite_list_invoker (Gimp *gimp,
success = FALSE;
if (success)
parasites = gimp_drawable_parasite_list (drawable, &num_parasites);
parasites = gimp_parasite_list (gimp, &num_parasites);
return_args = procedural_db_return_args (&drawable_parasite_list_proc, success);
@ -520,7 +520,7 @@ image_parasite_find_invoker (Gimp *gimp,
if (success)
{
parasite = gimp_parasite_copy (gimp_image_parasite_find (gimage, name));
parasite = gimp_parasite_copy (gimp_parasite_find (gimp, name));
success = parasite != NULL;
}
@ -588,7 +588,7 @@ image_parasite_attach_invoker (Gimp *gimp,
success = FALSE;
if (success)
gimp_image_parasite_attach (gimage, parasite);
gimp_parasite_attach (gimp, parasite);
return procedural_db_return_args (&image_parasite_attach_proc, success);
}
@ -640,7 +640,7 @@ image_parasite_detach_invoker (Gimp *gimp,
success = FALSE;
if (success)
gimp_image_parasite_detach (gimage, name);
gimp_parasite_detach (gimp, name);
return procedural_db_return_args (&image_parasite_detach_proc, success);
}
@ -690,7 +690,7 @@ image_parasite_list_invoker (Gimp *gimp,
success = FALSE;
if (success)
parasites = gimp_image_parasite_list (gimage, &num_parasites);
parasites = gimp_parasite_list (gimp, &num_parasites);
return_args = procedural_db_return_args (&image_parasite_list_proc, success);

View File

@ -48,6 +48,7 @@
#include "tools/gimptransformtool.h"
#include "tools/tool_manager.h"
#include "app_procs.h"
#include "drawable.h"
#include "floating_sel.h"
#include "gdisplay.h"
@ -2652,9 +2653,9 @@ undo_pop_parasite (GimpImage *gimage,
gimp_parasite_copy (gimp_image_parasite_find (gimage, data->name));
if (tmp)
parasite_list_add (data->gimage->parasites, tmp);
gimp_parasite_list_add (data->gimage->parasites, tmp);
else
parasite_list_remove (data->gimage->parasites, data->name);
gimp_parasite_list_remove (data->gimage->parasites, data->name);
}
else if (data->drawable)
{
@ -2662,17 +2663,18 @@ undo_pop_parasite (GimpImage *gimage,
gimp_parasite_copy (gimp_drawable_parasite_find (data->drawable,
data->name));
if (tmp)
parasite_list_add (data->drawable->parasites, tmp);
gimp_parasite_list_add (data->drawable->parasites, tmp);
else
parasite_list_remove (data->drawable->parasites, data->name);
gimp_parasite_list_remove (data->drawable->parasites, data->name);
}
else
{
data->parasite = gimp_parasite_copy (gimp_parasite_find (data->name));
data->parasite = gimp_parasite_copy (gimp_parasite_find (gimage->gimp,
data->name));
if (tmp)
gimp_parasite_attach (tmp);
gimp_parasite_attach (gimage->gimp, tmp);
else
gimp_parasite_detach (data->name);
gimp_parasite_detach (gimage->gimp, data->name);
}
if (tmp)

View File

@ -426,6 +426,7 @@ static void
gimp_data_factory_view_refresh_clicked (GtkWidget *widget,
GimpDataFactoryView *view)
{
gimp_data_factory_data_save (view->factory);
gimp_data_factory_data_init (view->factory, FALSE);
}

View File

@ -265,7 +265,7 @@ xcf_save_image_props (XcfInfo *info,
xcf_save_prop (info, PROP_TATTOO, gimage->tattoo_state);
if (parasite_list_length(gimage->parasites) > 0)
if (gimp_parasite_list_length (gimage->parasites) > 0)
xcf_save_prop (info, PROP_PARASITES, gimage->parasites);
if (gimage->unit < gimp_unit_get_number_of_built_in_units ())
@ -318,7 +318,7 @@ xcf_save_layer_props (XcfInfo *info,
xcf_save_prop (info, PROP_MODE, layer->mode);
xcf_save_prop (info, PROP_TATTOO, GIMP_DRAWABLE (layer)->tattoo);
if (parasite_list_length (GIMP_DRAWABLE (layer)->parasites) > 0)
if (gimp_parasite_list_length (GIMP_DRAWABLE (layer)->parasites) > 0)
xcf_save_prop (info, PROP_PARASITES, GIMP_DRAWABLE (layer)->parasites);
xcf_save_prop (info, PROP_END);
@ -347,7 +347,7 @@ xcf_save_channel_props (XcfInfo *info,
xcf_save_prop (info, PROP_TATTOO, GIMP_DRAWABLE (channel)->tattoo);
if (parasite_list_length (GIMP_DRAWABLE (channel)->parasites) > 0)
if (gimp_parasite_list_length (GIMP_DRAWABLE (channel)->parasites) > 0)
xcf_save_prop (info, PROP_PARASITES, GIMP_DRAWABLE (channel)->parasites);
xcf_save_prop (info, PROP_END);
@ -671,7 +671,7 @@ xcf_save_prop (XcfInfo *info,
break;
case PROP_RESOLUTION:
{
float xresolution, yresolution;
gfloat xresolution, yresolution;
/* we pass in floats, but they are promoted to double by the compiler */
xresolution = va_arg (args, double);
@ -700,20 +700,22 @@ xcf_save_prop (XcfInfo *info,
break;
case PROP_PARASITES:
{
ParasiteList *list;
guint32 base, length;
long pos;
list = va_arg (args, ParasiteList*);
if (parasite_list_persistent_length (list) > 0)
GimpParasiteList *list;
guint32 base, length;
long pos;
list = va_arg (args, GimpParasiteList *);
if (gimp_parasite_list_persistent_length (list) > 0)
{
info->cp += xcf_write_int32 (info->fp, (guint32*) &prop_type, 1);
info->cp += xcf_write_int32 (info->fp, (guint32 *) &prop_type, 1);
/* because we don't know how much room the parasite list will take
* we save the file position and write the length later
*/
pos = ftell (info->fp);
info->cp += xcf_write_int32 (info->fp, &length, 1);
base = info->cp;
parasite_list_foreach (list, (GHFunc) write_a_parasite, info);
gimp_parasite_list_foreach (list, (GHFunc) write_a_parasite, info);
length = info->cp - base;
/* go back to the saved position and write the length */
fseek (info->fp, pos, SEEK_SET);

View File

@ -84,6 +84,7 @@ HELP
* <sjburges@gimp.org>
*/
gimp_data_factory_data_save (gimp->brush_factory);
gimp_data_factory_data_init (gimp->brush_factory, FALSE);
}
CODE

View File

@ -55,8 +55,8 @@ sub convert_proc {
$invoke{code} =~ s/gimp_parasite_copy/GIMP_parasite_copy/e;
$invoke{code} =~ s/gimp/"gimp_$type"/e;
$invoke{code} =~ s/\(((?!gimp).*?(?:parasite|name))/"($var, $1"/e;
$invoke{code} =~ s/gimp_/"gimp_$type_"/e;
$invoke{code} =~ s/"gimp, "/"$var, "/e;
$invoke{code} =~ s/GIMP_parasite_copy/gimp_parasite_copy/e;
}
@ -79,7 +79,7 @@ HELP
%invoke = (
code => <<'CODE'
{
parasite = gimp_parasite_copy (gimp_parasite_find (name));
parasite = gimp_parasite_copy (gimp_parasite_find (gimp, name));
success = parasite != NULL;
}
CODE
@ -100,7 +100,7 @@ HELP
desc => 'The parasite to attach to the gimp' }
);
%invoke = ( code => 'gimp_parasite_attach (parasite);' );
%invoke = ( code => 'gimp_parasite_attach (gimp, parasite);' );
}
sub parasite_detach {
@ -117,7 +117,7 @@ HELP
desc => 'The name of the parasite to detach from the gimp.' }
);
%invoke = ( code => 'gimp_parasite_detach (name);' );
%invoke = ( code => 'gimp_parasite_detach (gimp, name);' );
}
sub parasite_list {
@ -134,7 +134,7 @@ sub parasite_list {
array => { desc => 'The number of attached parasites' } }
);
%invoke = ( code => 'parasites = gimp_parasite_list (&num_parasites);' );
%invoke = ( code => 'parasites = gimp_parasite_list (gimp, &num_parasites);' );
}
@headers = qw("gimpparasite.h" "core/gimpdrawable.h");