Commit fe3fa4e2 authored by jaycox's avatar jaycox
Browse files

libgimp/gserialize.c Changed the enum values to allow for simpler future


	* libgimp/gserialize.c
	* libgimp/gserialize.h: Changed the enum values to allow for
 	simpler future expansion.

	* libgimp/parasite.c
	* libgimp/parasite.h: s/persistant/persistent/.
 	new accessor functions for parasites.  #defines for new flags.

	* app/paintbrush.c: added timeing code for brush strokes.
  	It is #ifed out, and is only valid for shift clicks.

	* app/parasite_cmds.h: fixed a warning

	* app/parasitelist.h
	* app/parasitelist.c: added _for_each and _length functions

	* app/gimpdrawable.c:  set the dirty flag when adding or removing a
 	persistent parasite

	* app/gimpimage.c: set the dirty flag when adding or removing a
 	persistent parasite.  Fixed bug and removed debug statements in
 	merge_down.

	* app/xcf.c: save and load resolution, parasites, and tattoos.

	* app/main.c: updated the deserialize test.

	* plug-ins/tiff/tiff.c
	* plug-ins/gif/gif.c: use PARASITE_PERSISTENT define instead of 1

	* plug-ins/bmp/bmp.c
	* plug-ins/bmp/bmp.h: declare some struct variable as extern.

	* app/paint_funcs.c: Lots of optimizations aimed at speeding up
 	painting.  Should see a 2-4X speed up on most painting
 	(depending on paint modes, brush size etc.)

	* app/drawable.c: check for NULL drawable in drawable_ID.
  	this stops us from being crashed by ill-behaved plug-ins
parent d2ea549d
1998-12-16 Jay Cox <jaycox@earthlink.net>
* libgimp/gserialize.c
* libgimp/gserialize.h: Changed the enum values to allow for
simpler future expansion.
* libgimp/parasite.c
* libgimp/parasite.h: s/persistant/persistent/.
new accessor functions for parasites. #defines for new flags.
* app/paintbrush.c: added timeing code for brush strokes.
It is #ifed out, and is only valid for shift clicks.
* app/parasite_cmds.h: fixed a warning
* app/parasitelist.h
* app/parasitelist.c: added _for_each and _length functions
* app/gimpdrawable.c: set the dirty flag when adding or removing a
persistent parasite
* app/gimpimage.c: set the dirty flag when adding or removing a
persistent parasite. Fixed bug and removed debug statements in
merge_down.
* app/xcf.c: save and load resolution, parasites, and tattoos.
* app/main.c: updated the deserialize test.
* plug-ins/tiff/tiff.c
* plug-ins/gif/gif.c: use PARASITE_PERSISTENT define instead of 1
* plug-ins/bmp/bmp.c
* plug-ins/bmp/bmp.h: declare some struct variable as extern.
* app/paint_funcs.c: Lots of optimizations aimed at speeding up
painting. Should see a 2-4X speed up on most painting
(depending on paint modes, brush size etc.)
* app/drawable.c: check for NULL drawable in drawable_ID.
this stops us from being crashed by ill-behaved plug-ins
Tue Dec 15 16:18:40 PST 1998 Manish Singh <yosh@gimp.org>
* app/*: stuff from patches/i18n by Daniel Egger
......
......@@ -26,6 +26,7 @@
#include "gimage_mask.h"
#include "parasitelist.h"
#include "libgimp/parasite.h"
#include "libgimp/gimpintl.h"
enum {
......@@ -260,11 +261,11 @@ void
gimp_drawable_set_gimage (GimpDrawable *drawable, GimpImage *gimage)
{
g_assert(GIMP_IS_DRAWABLE(drawable));
drawable->gimage = gimage;
if (gimage == NULL)
drawable->tattoo = 0;
else
else if (drawable->tattoo == 0 || drawable->gimage != gimage )
drawable->tattoo = gimp_image_get_new_tattoo(gimage);
drawable->gimage = gimage;
}
......@@ -383,11 +384,29 @@ void
gimp_drawable_attach_parasite (GimpDrawable *drawable, Parasite *parasite)
{
parasite_list_add(drawable->parasites, parasite);
if (parasite_is_persistent(parasite)) /* make sure we can be saved */
gimp_image_dirty(drawable->gimage);
if (parasite_has_flag(parasite, PARASITE_ATTACH_PARENT))
{
parasite_shift_parent(parasite);
gimp_image_attach_parasite(drawable->gimage, parasite);
}
else if (parasite_has_flag(parasite, PARASITE_ATTACH_GRANDPARENT))
{
parasite_shift_parent(parasite);
parasite_shift_parent(parasite);
gimp_attach_parasite(parasite);
}
}
void
gimp_drawable_detach_parasite (GimpDrawable *drawable, const char *parasite)
{
Parasite *p;
if (!(p = parasite_list_find(drawable->parasites, parasite)))
return;
if (parasite_is_persistent(p))
gimp_image_dirty(drawable->gimage);
parasite_list_remove(drawable->parasites, parasite);
}
......
......@@ -893,11 +893,23 @@ void
gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite)
{
parasite_list_add(gimage->parasites, parasite);
if (parasite_is_persistent(parasite)) /* make sure we can be saved */
gimp_image_dirty(gimage);
if (parasite_has_flag(parasite, PARASITE_ATTACH_PARENT))
{
parasite_shift_parent(parasite);
gimp_attach_parasite(parasite);
}
}
void
gimp_image_detach_parasite (GimpImage *gimage, const char *parasite)
{
Parasite *p;
if (!(p = parasite_list_find(gimage->parasites, parasite)))
return;
if (parasite_is_persistent(p))
gimp_image_dirty(gimage);
parasite_list_remove(gimage->parasites, parasite);
}
......@@ -2025,8 +2037,6 @@ gimp_image_merge_down (GimpImage *gimage,
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
......@@ -2034,7 +2044,6 @@ gimp_image_merge_down (GimpImage *gimage,
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
......@@ -2042,6 +2051,8 @@ gimp_image_merge_down (GimpImage *gimage,
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
else
layer_list = g_slist_next (layer_list);
}
if (merge_list && merge_list->next)
......
......@@ -893,11 +893,23 @@ void
gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite)
{
parasite_list_add(gimage->parasites, parasite);
if (parasite_is_persistent(parasite)) /* make sure we can be saved */
gimp_image_dirty(gimage);
if (parasite_has_flag(parasite, PARASITE_ATTACH_PARENT))
{
parasite_shift_parent(parasite);
gimp_attach_parasite(parasite);
}
}
void
gimp_image_detach_parasite (GimpImage *gimage, const char *parasite)
{
Parasite *p;
if (!(p = parasite_list_find(gimage->parasites, parasite)))
return;
if (parasite_is_persistent(p))
gimp_image_dirty(gimage);
parasite_list_remove(gimage->parasites, parasite);
}
......@@ -2025,8 +2037,6 @@ gimp_image_merge_down (GimpImage *gimage,
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
......@@ -2034,7 +2044,6 @@ gimp_image_merge_down (GimpImage *gimage,
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
......@@ -2042,6 +2051,8 @@ gimp_image_merge_down (GimpImage *gimage,
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
else
layer_list = g_slist_next (layer_list);
}
if (merge_list && merge_list->next)
......
......@@ -893,11 +893,23 @@ void
gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite)
{
parasite_list_add(gimage->parasites, parasite);
if (parasite_is_persistent(parasite)) /* make sure we can be saved */
gimp_image_dirty(gimage);
if (parasite_has_flag(parasite, PARASITE_ATTACH_PARENT))
{
parasite_shift_parent(parasite);
gimp_attach_parasite(parasite);
}
}
void
gimp_image_detach_parasite (GimpImage *gimage, const char *parasite)
{
Parasite *p;
if (!(p = parasite_list_find(gimage->parasites, parasite)))
return;
if (parasite_is_persistent(p))
gimp_image_dirty(gimage);
parasite_list_remove(gimage->parasites, parasite);
}
......@@ -2025,8 +2037,6 @@ gimp_image_merge_down (GimpImage *gimage,
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
......@@ -2034,7 +2044,6 @@ gimp_image_merge_down (GimpImage *gimage,
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
......@@ -2042,6 +2051,8 @@ gimp_image_merge_down (GimpImage *gimage,
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
else
layer_list = g_slist_next (layer_list);
}
if (merge_list && merge_list->next)
......
......@@ -893,11 +893,23 @@ void
gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite)
{
parasite_list_add(gimage->parasites, parasite);
if (parasite_is_persistent(parasite)) /* make sure we can be saved */
gimp_image_dirty(gimage);
if (parasite_has_flag(parasite, PARASITE_ATTACH_PARENT))
{
parasite_shift_parent(parasite);
gimp_attach_parasite(parasite);
}
}
void
gimp_image_detach_parasite (GimpImage *gimage, const char *parasite)
{
Parasite *p;
if (!(p = parasite_list_find(gimage->parasites, parasite)))
return;
if (parasite_is_persistent(p))
gimp_image_dirty(gimage);
parasite_list_remove(gimage->parasites, parasite);
}
......@@ -2025,8 +2037,6 @@ gimp_image_merge_down (GimpImage *gimage,
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
......@@ -2034,7 +2044,6 @@ gimp_image_merge_down (GimpImage *gimage,
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
......@@ -2042,6 +2051,8 @@ gimp_image_merge_down (GimpImage *gimage,
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
else
layer_list = g_slist_next (layer_list);
}
if (merge_list && merge_list->next)
......
......@@ -893,11 +893,23 @@ void
gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite)
{
parasite_list_add(gimage->parasites, parasite);
if (parasite_is_persistent(parasite)) /* make sure we can be saved */
gimp_image_dirty(gimage);
if (parasite_has_flag(parasite, PARASITE_ATTACH_PARENT))
{
parasite_shift_parent(parasite);
gimp_attach_parasite(parasite);
}
}
void
gimp_image_detach_parasite (GimpImage *gimage, const char *parasite)
{
Parasite *p;
if (!(p = parasite_list_find(gimage->parasites, parasite)))
return;
if (parasite_is_persistent(p))
gimp_image_dirty(gimage);
parasite_list_remove(gimage->parasites, parasite);
}
......@@ -2025,8 +2037,6 @@ gimp_image_merge_down (GimpImage *gimage,
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
......@@ -2034,7 +2044,6 @@ gimp_image_merge_down (GimpImage *gimage,
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
......@@ -2042,6 +2051,8 @@ gimp_image_merge_down (GimpImage *gimage,
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
else
layer_list = g_slist_next (layer_list);
}
if (merge_list && merge_list->next)
......
......@@ -893,11 +893,23 @@ void
gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite)
{
parasite_list_add(gimage->parasites, parasite);
if (parasite_is_persistent(parasite)) /* make sure we can be saved */
gimp_image_dirty(gimage);
if (parasite_has_flag(parasite, PARASITE_ATTACH_PARENT))
{
parasite_shift_parent(parasite);
gimp_attach_parasite(parasite);
}
}
void
gimp_image_detach_parasite (GimpImage *gimage, const char *parasite)
{
Parasite *p;
if (!(p = parasite_list_find(gimage->parasites, parasite)))
return;
if (parasite_is_persistent(p))
gimp_image_dirty(gimage);
parasite_list_remove(gimage->parasites, parasite);
}
......@@ -2025,8 +2037,6 @@ gimp_image_merge_down (GimpImage *gimage,
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
......@@ -2034,7 +2044,6 @@ gimp_image_merge_down (GimpImage *gimage,
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
......@@ -2042,6 +2051,8 @@ gimp_image_merge_down (GimpImage *gimage,
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
else
layer_list = g_slist_next (layer_list);
}
if (merge_list && merge_list->next)
......
......@@ -144,6 +144,7 @@ parasite_list_add(ParasiteList *list, Parasite *p)
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);
parasite_list_remove(list, p->name);
p = parasite_copy(p);
g_hash_table_insert(list->table, p->name, p);
gtk_signal_emit (GTK_OBJECT(list), parasite_list_signals[ADD], p);
......@@ -166,6 +167,41 @@ parasite_list_remove(ParasiteList *list, const char *name)
}
}
gint
parasite_list_length(ParasiteList *list)
{
g_return_val_if_fail(list != NULL, 0);
if (!list->table)
return 0;
return g_hash_table_size(list->table);
}
static void ppcount_func(char *key, Parasite *p, int *count)
{
if (parasite_is_persistent(p))
*count = *count + 1;
}
gint
parasite_list_persistent_length(ParasiteList *list)
{
int ppcount = 0;
g_return_val_if_fail(list != NULL, 0);
if (!list->table)
return 0;
parasite_list_foreach(list, (GHFunc)ppcount_func, &ppcount);
return ppcount;
}
void
parasite_list_foreach(ParasiteList *list, GHFunc function, gpointer user_data)
{
g_return_if_fail(list != NULL);
if (!list->table)
return;
g_hash_table_foreach(list->table, function, user_data);
}
Parasite *
parasite_list_find(ParasiteList *list, const char *name)
{
......@@ -177,3 +213,10 @@ parasite_list_find(ParasiteList *list, const char *name)
}
void
parasite_shift_parent(Parasite *p)
{
if (p == NULL)
return;
p->flags = (p->flags >> 8);
}
......@@ -40,6 +40,12 @@ 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);
gint parasite_list_length (ParasiteList *list);
gint parasite_list_persistent_length (ParasiteList *list);
void parasite_list_foreach (ParasiteList *list, GHFunc function,
gpointer user_data);
Parasite *parasite_list_find (ParasiteList *list, const char *name);
void parasite_shift_parent (Parasite *p);
#endif /* __GIMP_PARASITE_H__ */
......@@ -893,11 +893,23 @@ void
gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite)
{
parasite_list_add(gimage->parasites, parasite);
if (parasite_is_persistent(parasite)) /* make sure we can be saved */
gimp_image_dirty(gimage);
if (parasite_has_flag(parasite, PARASITE_ATTACH_PARENT))
{
parasite_shift_parent(parasite);
gimp_attach_parasite(parasite);
}
}
void
gimp_image_detach_parasite (GimpImage *gimage, const char *parasite)
{
Parasite *p;
if (!(p = parasite_list_find(gimage->parasites, parasite)))
return;
if (parasite_is_persistent(p))
gimp_image_dirty(gimage);
parasite_list_remove(gimage->parasites, parasite);
}
......@@ -2025,8 +2037,6 @@ gimp_image_merge_down (GimpImage *gimage,
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
......@@ -2034,7 +2044,6 @@ gimp_image_merge_down (GimpImage *gimage,
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
......@@ -2042,6 +2051,8 @@ gimp_image_merge_down (GimpImage *gimage,
}
merge_list = g_slist_prepend (merge_list, current_layer);
}
else
layer_list = g_slist_next (layer_list);
}
if (merge_list && merge_list->next)
......
......@@ -29,7 +29,11 @@
int
drawable_ID (GimpDrawable *drawable)
{
return drawable->ID;
if (drawable)
return drawable->ID;
else
g_warning("drawable_ID called on a NULL pointer");
return 0;
}
void
......
......@@ -26,6 +26,7 @@
#include "gimage_mask.h"
#include "parasitelist.h"
#include "libgimp/parasite.h"
#include "libgimp/gimpintl.h"
enum {
......@@ -260,11 +261,11 @@ void
gimp_drawable_set_gimage (GimpDrawable *drawable, GimpImage *gimage)
{
g_assert(GIMP_IS_DRAWABLE(drawable));
drawable->gimage = gimage;
if (gimage == NULL)
drawable->tattoo = 0;
else
else if (drawable->tattoo == 0 || drawable->gimage != gimage )
drawable->tattoo = gimp_image_get_new_tattoo(gimage);
drawable->gimage = gimage;
}
......@@ -383,11 +384,29 @@ void
gimp_drawable_attach_parasite (GimpDrawable *drawable, Parasite *parasite)
{
parasite_list_add(drawable->parasites, parasite);
if (parasite_is_persistent(parasite)) /* make sure we can be saved */
gimp_image_dirty(drawable->gimage);
if (parasite_has_flag(parasite, PARASITE_ATTACH_PARENT))
{
parasite_shift_parent(parasite);
gimp_image_attach_parasite(drawable->gimage, parasite);
}
else if (parasite_has_flag(parasite, PARASITE_ATTACH_GRANDPARENT))
{
parasite_shift_parent(parasite);
parasite_shift_parent(parasite);
gimp_attach_parasite(parasite);
}
}
void
gimp_drawable_detach_parasite (GimpDrawable *drawable, const char *parasite)
{
Parasite *p;
if (!(p = parasite_list_find(drawable->parasites, parasite)))
return;
if (parasite_is_persistent(p))
gimp_image_dirty(drawable->gimage);
parasite_list_remove(drawable->parasites, parasite);
}
......
......@@ -893,11 +893,23 @@ void
gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite)
{
parasite_list_add(gimage->parasites, parasite);
if (parasite_is_persistent(parasite)) /* make sure we can be saved */
gimp_image_dirty(gimage);
if (parasite_has_flag(parasite, PARASITE_ATTACH_PARENT))
{
parasite_shift_parent(parasite);
gimp_attach_parasite(parasite);
}
}
void
gimp_image_detach_parasite (GimpImage *gimage, const char *parasite)
{
Parasite *p;
if (!(p = parasite_list_find(gimage->parasites, parasite)))
return;
if (parasite_is_persistent(p))
gimp_image_dirty(gimage);
parasite_list_remove(gimage->parasites, parasite);
}
......@@ -2025,8 +2037,6 @@ gimp_image_merge_down (GimpImage *gimage,
layer = (Layer *) layer_list->data;
if (layer == current_layer)
{
printf ("found it\n");
layer_list = g_slist_next (layer_list);
while (layer_list)
{
......@@ -2034,7 +2044,6 @@ gimp_image_merge_down (GimpImage *gimage,
if (drawable_visible (GIMP_DRAWABLE(layer)))
{
merge_list = g_slist_append (merge_list, layer);
printf ("found the next\n");
layer_list = NULL;
}
else
......@@ -2042,6 +2051,8 @@ gimp_image_merge_down (GimpImage *gimage,
}