Commit f7c69b07 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

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.
parent 01645960
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
......
......@@ -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;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
}
......@@ -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__ */
......@@ -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);
}
......@@ -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__ */
......@@ -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);
......
......@@ -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);
......
......@@ -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,
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
......@@ -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);