diff --git a/ChangeLog b/ChangeLog index 377adff9a8..81729a3a7e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +1999-04-22 Jay Cox + + * app/edit_selection.c: removed some nonfunctional code. + + * app/paint_core.c: remove the alt toggles perfectmouse behaviour. + + * app/paintbrush.c: when ctl (or alt) is held set the fg (or bg) color. + + * app/gimpparasite.[ch]: made char *name parameters const. + + * app/parasitelist.c: removed unused static variable. + + * app/gimpdrawable.c, app/gimpimage.c, app/undo.[ch]: added + support for undoing parasite changes. + + * libgimp/gimp.h, libgimp/gimpimage.c: added + gimp_undo_push_group_start and gimp_undo_push_group_end + + * libgimp/parasite.[ch]: added undoable flag. + + * plug-ins/gdyntext/font_selection.c: fixed c++ style comment. + + * plug-ins/gdyntext/gdyntext.c: use the new undoable parasites. + + * plug-ins/rcm/rcm_misc.c: arctg can't be inline because it is + used in other .c files + + * plug-ins/waterselect/waterselect.c, + * plug-ins/rotators/rotators.c, app/tips_dialog.c, app/plug_in.c: + fixed some warnings + Fri Apr 23 01:31:29 MEST 1999 Sven Neumann * app/crop.c: autocrop used to miss the bottom line diff --git a/app/actions/plug-in-commands.c b/app/actions/plug-in-commands.c index 73ce25151d..0f8a702408 100644 --- a/app/actions/plug-in-commands.c +++ b/app/actions/plug-in-commands.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/core/gimp-parasites.c b/app/core/gimp-parasites.c index 99b660cd3f..bc869f014f 100644 --- a/app/core/gimp-parasites.c +++ b/app/core/gimp-parasites.c @@ -42,13 +42,13 @@ gimp_attach_parasite (Parasite *p) } void -gimp_detach_parasite (char *name) +gimp_detach_parasite (const char *name) { parasite_list_remove(parasites, name); } Parasite * -gimp_find_parasite (char *name) +gimp_find_parasite (const char *name) { return parasite_list_find(parasites, name); } diff --git a/app/core/gimp-parasites.h b/app/core/gimp-parasites.h index eaaceb197e..5493b158a7 100644 --- a/app/core/gimp-parasites.h +++ b/app/core/gimp-parasites.h @@ -22,8 +22,8 @@ void gimp_init_parasites (void); void gimp_attach_parasite (Parasite *p); -void gimp_detach_parasite (char *name); -Parasite * gimp_find_parasite (char *name); +void gimp_detach_parasite (const char *name); +Parasite * gimp_find_parasite (const char *name); char ** gimp_parasite_list (gint *count); void gimp_parasiterc_save (void); void gimp_parasiterc_load (void); diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c index 31b3da4dfe..7a544ef49d 100644 --- a/app/core/gimpdrawable.c +++ b/app/core/gimpdrawable.c @@ -444,10 +444,16 @@ gimp_drawable_parasite_list (GimpDrawable *drawable, gint *count) void gimp_drawable_attach_parasite (GimpDrawable *drawable, Parasite *parasite) { - /* only set the dirty bit if we can be saved and the new parasite differs - from the current one */ - if (parasite_is_persistent(parasite) && - !parasite_compare(parasite, gimp_drawable_find_parasite(drawable, + /* only set the dirty bit manually if we can be saved and the new + parasite differs from the current one and we arn't undoable */ + if (parasite_is_undoable(parasite)) + { + undo_push_group_start(drawable->gimage); /* do a group in case we have + attach_parrent set */ + undo_push_drawable_parasite (drawable->gimage, drawable, parasite); + } + else if (parasite_is_persistent(parasite) && + !parasite_compare(parasite, gimp_drawable_find_parasite(drawable, parasite_name(parasite)))) gimp_image_dirty(drawable->gimage); parasite_list_add(drawable->parasites, parasite); @@ -462,6 +468,10 @@ gimp_drawable_attach_parasite (GimpDrawable *drawable, Parasite *parasite) parasite_shift_parent(parasite); gimp_attach_parasite(parasite); } + if (parasite_is_undoable(parasite)) + { + undo_push_group_end(drawable->gimage); + } } void @@ -470,7 +480,10 @@ 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)) + if (parasite_is_undoable(p)) + undo_push_drawable_parasite_remove (drawable->gimage, drawable, + parasite_name(p)); + else if (parasite_is_persistent(p)) gimp_image_dirty(drawable->gimage); parasite_list_remove(drawable->parasites, parasite); } diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c index 7c4f8a73e0..cad389609a 100644 --- a/app/core/gimpimage-guides.c +++ b/app/core/gimpimage-guides.c @@ -994,8 +994,10 @@ gimp_image_parasite_list (GimpImage *image, gint *count) void gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - /* only set the dirty bit if we can be saved and the new parasite differs - from the current one */ + /* only set the dirty bit manually if we can be saved and the new + parasite differs from the current one and we arn't undoable */ + if (parasite_is_undoable(parasite)) + undo_push_image_parasite (gimage, parasite); if (parasite_is_persistent(parasite) && !parasite_compare(parasite, gimp_image_find_parasite(gimage, parasite_name(parasite)))) @@ -1014,7 +1016,9 @@ 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)) + if (parasite_is_undoable(p)) + undo_push_image_parasite_remove (gimage, parasite_name(p)); + else if (parasite_is_persistent(p)) gimp_image_dirty(gimage); parasite_list_remove(gimage->parasites, parasite); } diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c index 7c4f8a73e0..cad389609a 100644 --- a/app/core/gimpimage-merge.c +++ b/app/core/gimpimage-merge.c @@ -994,8 +994,10 @@ gimp_image_parasite_list (GimpImage *image, gint *count) void gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - /* only set the dirty bit if we can be saved and the new parasite differs - from the current one */ + /* only set the dirty bit manually if we can be saved and the new + parasite differs from the current one and we arn't undoable */ + if (parasite_is_undoable(parasite)) + undo_push_image_parasite (gimage, parasite); if (parasite_is_persistent(parasite) && !parasite_compare(parasite, gimp_image_find_parasite(gimage, parasite_name(parasite)))) @@ -1014,7 +1016,9 @@ 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)) + if (parasite_is_undoable(p)) + undo_push_image_parasite_remove (gimage, parasite_name(p)); + else if (parasite_is_persistent(p)) gimp_image_dirty(gimage); parasite_list_remove(gimage->parasites, parasite); } diff --git a/app/core/gimpimage-projection.c b/app/core/gimpimage-projection.c index 7c4f8a73e0..cad389609a 100644 --- a/app/core/gimpimage-projection.c +++ b/app/core/gimpimage-projection.c @@ -994,8 +994,10 @@ gimp_image_parasite_list (GimpImage *image, gint *count) void gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - /* only set the dirty bit if we can be saved and the new parasite differs - from the current one */ + /* only set the dirty bit manually if we can be saved and the new + parasite differs from the current one and we arn't undoable */ + if (parasite_is_undoable(parasite)) + undo_push_image_parasite (gimage, parasite); if (parasite_is_persistent(parasite) && !parasite_compare(parasite, gimp_image_find_parasite(gimage, parasite_name(parasite)))) @@ -1014,7 +1016,9 @@ 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)) + if (parasite_is_undoable(p)) + undo_push_image_parasite_remove (gimage, parasite_name(p)); + else if (parasite_is_persistent(p)) gimp_image_dirty(gimage); parasite_list_remove(gimage->parasites, parasite); } diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c index 7c4f8a73e0..cad389609a 100644 --- a/app/core/gimpimage-resize.c +++ b/app/core/gimpimage-resize.c @@ -994,8 +994,10 @@ gimp_image_parasite_list (GimpImage *image, gint *count) void gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - /* only set the dirty bit if we can be saved and the new parasite differs - from the current one */ + /* only set the dirty bit manually if we can be saved and the new + parasite differs from the current one and we arn't undoable */ + if (parasite_is_undoable(parasite)) + undo_push_image_parasite (gimage, parasite); if (parasite_is_persistent(parasite) && !parasite_compare(parasite, gimp_image_find_parasite(gimage, parasite_name(parasite)))) @@ -1014,7 +1016,9 @@ 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)) + if (parasite_is_undoable(p)) + undo_push_image_parasite_remove (gimage, parasite_name(p)); + else if (parasite_is_persistent(p)) gimp_image_dirty(gimage); parasite_list_remove(gimage->parasites, parasite); } diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c index 7c4f8a73e0..cad389609a 100644 --- a/app/core/gimpimage-scale.c +++ b/app/core/gimpimage-scale.c @@ -994,8 +994,10 @@ gimp_image_parasite_list (GimpImage *image, gint *count) void gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - /* only set the dirty bit if we can be saved and the new parasite differs - from the current one */ + /* only set the dirty bit manually if we can be saved and the new + parasite differs from the current one and we arn't undoable */ + if (parasite_is_undoable(parasite)) + undo_push_image_parasite (gimage, parasite); if (parasite_is_persistent(parasite) && !parasite_compare(parasite, gimp_image_find_parasite(gimage, parasite_name(parasite)))) @@ -1014,7 +1016,9 @@ 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)) + if (parasite_is_undoable(p)) + undo_push_image_parasite_remove (gimage, parasite_name(p)); + else if (parasite_is_persistent(p)) gimp_image_dirty(gimage); parasite_list_remove(gimage->parasites, parasite); } diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index dcdbceb2cc..3d80b12f38 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -41,6 +41,9 @@ #include "tile_manager_pvt.h" #include "tile.h" /* ick. */ +#include "libgimp/parasite.h" +#include "gimpparasite.h" + typedef int (* UndoPopFunc) (GImage *, int, int, void *); @@ -75,6 +78,7 @@ int undo_pop_fs_rigor (GImage *, int, int, void *); int undo_pop_fs_relax (GImage *, int, int, void *); int undo_pop_gimage_mod (GImage *, int, int, void *); int undo_pop_guide (GImage *, int, int, void *); +int undo_pop_parasite (GImage *, int, int, void *); /* Free functions */ @@ -93,6 +97,8 @@ void undo_free_fs_rigor (int, void *); void undo_free_fs_relax (int, void *); void undo_free_gimage_mod (int, void *); void undo_free_guide (int, void *); +void undo_free_parasite (int, void *); + /* Sizing functions */ @@ -2099,3 +2105,219 @@ undo_free_guide (int state, g_free (data_ptr); } + + +/************/ +/* Parasite */ + +typedef struct _ParasiteUndo ParasiteUndo; + +struct _ParasiteUndo +{ + GImage *gimage; + GimpDrawable *drawable; + Parasite *parasite; + char *name; +}; + +int +undo_push_image_parasite (GImage *gimage, + void *parasite) +{ + Undo *new; + ParasiteUndo *data; + long size; + + /* increment the dirty flag for this gimage */ + gimage_dirty (gimage); + + size = sizeof (ParasiteUndo); + + if ((new = undo_push (gimage, size, GIMAGE_MOD))) + { + data = g_new (ParasiteUndo, 1); + new->data = data; + new->pop_func = undo_pop_parasite; + new->free_func = undo_free_parasite; + + data->gimage = gimage; + data->drawable = NULL; + data->name = g_strdup(parasite_name(parasite)); + data->parasite = parasite_copy(gimp_image_find_parasite(gimage, data->name)); + + return TRUE; + } + + return FALSE; +} + +int +undo_push_image_parasite_remove (GImage *gimage, + const char *name) +{ + Undo *new; + ParasiteUndo *data; + long size; + + /* increment the dirty flag for this gimage */ + gimage_dirty (gimage); + + size = sizeof (ParasiteUndo); + + if ((new = undo_push (gimage, size, GIMAGE_MOD))) + { + data = g_new (ParasiteUndo, 1); + new->data = data; + new->pop_func = undo_pop_parasite; + new->free_func = undo_free_parasite; + + data->gimage = gimage; + data->drawable = NULL; + data->name = g_strdup(name); + data->parasite = parasite_copy(gimp_image_find_parasite(gimage, data->name)); + + return TRUE; + } + + return FALSE; +} + +int +undo_push_drawable_parasite (GImage *gimage, + GimpDrawable *drawable, + void *parasite) +{ + Undo *new; + ParasiteUndo *data; + long size; + + /* increment the dirty flag for this gimage */ + gimage_dirty (gimage); + + size = sizeof (ParasiteUndo); + + if ((new = undo_push (gimage, size, GIMAGE_MOD))) + { + data = g_new (ParasiteUndo, 1); + new->data = data; + new->pop_func = undo_pop_parasite; + new->free_func = undo_free_parasite; + + data->gimage = NULL; + data->drawable = drawable; + data->name = g_strdup(parasite_name(parasite)); + data->parasite = parasite_copy(gimp_drawable_find_parasite(drawable, data->name)); + return TRUE; + } + + return FALSE; +} + +int +undo_push_drawable_parasite_remove (GImage *gimage, + GimpDrawable *drawable, + const char *name) +{ + Undo *new; + ParasiteUndo *data; + long size; + + /* increment the dirty flag for this gimage */ + gimage_dirty (gimage); + + size = sizeof (ParasiteUndo); + + if ((new = undo_push (gimage, size, GIMAGE_MOD))) + { + data = g_new (ParasiteUndo, 1); + new->data = data; + new->pop_func = undo_pop_parasite; + new->free_func = undo_free_parasite; + + data->gimage = NULL; + data->drawable = drawable; + data->name = g_strdup(name); + data->parasite = parasite_copy(gimp_drawable_find_parasite(drawable, data->name)); + return TRUE; + } + + return FALSE; +} + + +int +undo_pop_parasite (GImage *gimage, + int state, + int type, + void *data_ptr) +{ + ParasiteUndo *data; + Parasite *tmp; + int tmp_ref; + + data = data_ptr; + + tmp = data->parasite; + + if (data->gimage) + { + data->parasite = parasite_copy(gimp_image_find_parasite(gimage, + data->name)); + if (tmp) + parasite_list_add(data->gimage->parasites, tmp); + else + parasite_list_remove(data->gimage->parasites, data->name); + } + else if (data->drawable) + { + data->parasite = parasite_copy(gimp_drawable_find_parasite(data->drawable, + data->name)); + if (tmp) + parasite_list_add(data->drawable->parasites, tmp); + else + parasite_list_remove(data->drawable->parasites, data->name); + } + else + { + data->parasite = parasite_copy(gimp_find_parasite(data->name)); + if (tmp) + gimp_attach_parasite(tmp); + else + gimp_detach_parasite(data->name); + } + + if (tmp) + parasite_free(tmp); + +/* if ((tmp && parasite_is_persistant(tmp)) || */ +/* (data->parasite && parasite_is_persistant(data->parasite))) */ + switch (state) + { + case UNDO: + gimage_clean (gimage); + break; + case REDO: + gimage_dirty (gimage); + break; + } + + return TRUE; +} + + +void +undo_free_parasite (int state, + void *data_ptr) +{ + ParasiteUndo *data; + + data = data_ptr; + + if (data->parasite) + parasite_free (data->parasite); + if (data->name) + g_free (data->name); + + g_free (data_ptr); +} + diff --git a/app/core/gimpimage-undo-push.h b/app/core/gimpimage-undo-push.h index b679fc31a5..57b53c3062 100644 --- a/app/core/gimpimage-undo-push.h +++ b/app/core/gimpimage-undo-push.h @@ -79,6 +79,11 @@ int undo_push_fs_rigor (GImage *, int); int undo_push_fs_relax (GImage *, int); int undo_push_gimage_mod (GImage *); int undo_push_guide (GImage *, void *); +int undo_push_image_parasite (GImage *, void *); +int undo_push_drawable_parasite (GImage *, GimpDrawable *, void *); +int undo_push_image_parasite_remove (GImage *, const char *); +int undo_push_drawable_parasite_remove (GImage *, GimpDrawable *, + const char *); int undo_pop (GImage *); int undo_redo (GImage *); diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 7c4f8a73e0..cad389609a 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -994,8 +994,10 @@ gimp_image_parasite_list (GimpImage *image, gint *count) void gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - /* only set the dirty bit if we can be saved and the new parasite differs - from the current one */ + /* only set the dirty bit manually if we can be saved and the new + parasite differs from the current one and we arn't undoable */ + if (parasite_is_undoable(parasite)) + undo_push_image_parasite (gimage, parasite); if (parasite_is_persistent(parasite) && !parasite_compare(parasite, gimp_image_find_parasite(gimage, parasite_name(parasite)))) @@ -1014,7 +1016,9 @@ 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)) + if (parasite_is_undoable(p)) + undo_push_image_parasite_remove (gimage, parasite_name(p)); + else if (parasite_is_persistent(p)) gimp_image_dirty(gimage); parasite_list_remove(gimage->parasites, parasite); } diff --git a/app/core/gimpparasite.c b/app/core/gimpparasite.c index 99b660cd3f..bc869f014f 100644 --- a/app/core/gimpparasite.c +++ b/app/core/gimpparasite.c @@ -42,13 +42,13 @@ gimp_attach_parasite (Parasite *p) } void -gimp_detach_parasite (char *name) +gimp_detach_parasite (const char *name) { parasite_list_remove(parasites, name); } Parasite * -gimp_find_parasite (char *name) +gimp_find_parasite (const char *name) { return parasite_list_find(parasites, name); } diff --git a/app/core/gimpparasite.h b/app/core/gimpparasite.h index eaaceb197e..5493b158a7 100644 --- a/app/core/gimpparasite.h +++ b/app/core/gimpparasite.h @@ -22,8 +22,8 @@ void gimp_init_parasites (void); void gimp_attach_parasite (Parasite *p); -void gimp_detach_parasite (char *name); -Parasite * gimp_find_parasite (char *name); +void gimp_detach_parasite (const char *name); +Parasite * gimp_find_parasite (const char *name); char ** gimp_parasite_list (gint *count); void gimp_parasiterc_save (void); void gimp_parasiterc_load (void); diff --git a/app/core/gimpparasitelist.c b/app/core/gimpparasitelist.c index 848d7b6513..391402b728 100644 --- a/app/core/gimpparasitelist.c +++ b/app/core/gimpparasitelist.c @@ -214,8 +214,6 @@ parasite_list_find(ParasiteList *list, const char *name) return NULL; } -static int saved_bytes; - void parasite_shift_parent(Parasite *p) { diff --git a/app/core/gimpprojection-construct.c b/app/core/gimpprojection-construct.c index 7c4f8a73e0..cad389609a 100644 --- a/app/core/gimpprojection-construct.c +++ b/app/core/gimpprojection-construct.c @@ -994,8 +994,10 @@ gimp_image_parasite_list (GimpImage *image, gint *count) void gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - /* only set the dirty bit if we can be saved and the new parasite differs - from the current one */ + /* only set the dirty bit manually if we can be saved and the new + parasite differs from the current one and we arn't undoable */ + if (parasite_is_undoable(parasite)) + undo_push_image_parasite (gimage, parasite); if (parasite_is_persistent(parasite) && !parasite_compare(parasite, gimp_image_find_parasite(gimage, parasite_name(parasite)))) @@ -1014,7 +1016,9 @@ 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)) + if (parasite_is_undoable(p)) + undo_push_image_parasite_remove (gimage, parasite_name(p)); + else if (parasite_is_persistent(p)) gimp_image_dirty(gimage); parasite_list_remove(gimage->parasites, parasite); } diff --git a/app/dialogs/tips-dialog.c b/app/dialogs/tips-dialog.c index 0874ab63cc..e79383e092 100644 --- a/app/dialogs/tips-dialog.c +++ b/app/dialogs/tips-dialog.c @@ -43,6 +43,7 @@ tips_dialog_create () GtkWidget *vbox_check; GtkWidget *button_check; gchar * temp; + guchar * utemp; guchar * src; guchar * dest; int x; @@ -98,20 +99,20 @@ tips_dialog_create () preview = gtk_preview_new (GTK_PREVIEW_COLOR); gtk_preview_size (GTK_PREVIEW (preview), wilber_width, wilber_height); - temp = g_malloc (wilber_width * 3); + utemp = g_new (guchar, wilber_width * 3); src = (guchar *)wilber_data; for (y = 0; y < wilber_height; y++) { - dest = temp; + dest = utemp; for (x = 0; x < wilber_width; x++) { HEADER_PIXEL(src, dest); dest += 3; } - gtk_preview_draw_row (GTK_PREVIEW (preview), temp, + gtk_preview_draw_row (GTK_PREVIEW (preview), utemp, 0, y, wilber_width); } - g_free(temp); + g_free(utemp); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_end (GTK_BOX (hbox1), frame, FALSE, TRUE, 3); diff --git a/app/edit_selection.c b/app/edit_selection.c index 33c2a5a442..f0dc7c9113 100644 --- a/app/edit_selection.c +++ b/app/edit_selection.c @@ -513,11 +513,6 @@ edit_selection_draw (Tool *tool) break; case MaskToLayerTranslate: - if (diff_x < 0) - { - x1 = x1 + 1; - x1 --; - } gdisplay_transform_coords (gdisp, edit_select.x1, edit_select.y1, &x1, &y1, TRUE); gdisplay_transform_coords (gdisp, edit_select.x2, edit_select.y2, &x2, &y2, TRUE); gdk_draw_rectangle (edit_select.core->win, diff --git a/app/gimpdrawable.c b/app/gimpdrawable.c index 31b3da4dfe..7a544ef49d 100644 --- a/app/gimpdrawable.c +++ b/app/gimpdrawable.c @@ -444,10 +444,16 @@ gimp_drawable_parasite_list (GimpDrawable *drawable, gint *count) void gimp_drawable_attach_parasite (GimpDrawable *drawable, Parasite *parasite) { - /* only set the dirty bit if we can be saved and the new parasite differs - from the current one */ - if (parasite_is_persistent(parasite) && - !parasite_compare(parasite, gimp_drawable_find_parasite(drawable, + /* only set the dirty bit manually if we can be saved and the new + parasite differs from the current one and we arn't undoable */ + if (parasite_is_undoable(parasite)) + { + undo_push_group_start(drawable->gimage); /* do a group in case we have + attach_parrent set */ + undo_push_drawable_parasite (drawable->gimage, drawable, parasite); + } + else if (parasite_is_persistent(parasite) && + !parasite_compare(parasite, gimp_drawable_find_parasite(drawable, parasite_name(parasite)))) gimp_image_dirty(drawable->gimage); parasite_list_add(drawable->parasites, parasite); @@ -462,6 +468,10 @@ gimp_drawable_attach_parasite (GimpDrawable *drawable, Parasite *parasite) parasite_shift_parent(parasite); gimp_attach_parasite(parasite); } + if (parasite_is_undoable(parasite)) + { + undo_push_group_end(drawable->gimage); + } } void @@ -470,7 +480,10 @@ 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)) + if (parasite_is_undoable(p)) + undo_push_drawable_parasite_remove (drawable->gimage, drawable, + parasite_name(p)); + else if (parasite_is_persistent(p)) gimp_image_dirty(drawable->gimage); parasite_list_remove(drawable->parasites, parasite); } diff --git a/app/gimpimage.c b/app/gimpimage.c index 7c4f8a73e0..cad389609a 100644 --- a/app/gimpimage.c +++ b/app/gimpimage.c @@ -994,8 +994,10 @@ gimp_image_parasite_list (GimpImage *image, gint *count) void gimp_image_attach_parasite (GimpImage *gimage, Parasite *parasite) { - /* only set the dirty bit if we can be saved and the new parasite differs - from the current one */ + /* only set the dirty bit manually if we can be saved and the new + parasite differs from the current one and we arn't undoable */ + if (parasite_is_undoable(parasite)) + undo_push_image_parasite (gimage, parasite); if (parasite_is_persistent(parasite) && !parasite_compare(parasite, gimp_image_find_parasite(gimage, parasite_name(parasite)))) @@ -1014,7 +1016,9 @@ 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)) + if (parasite_is_undoable(p)) + undo_push_image_parasite_remove (gimage, parasite_name(p)); + else if (parasite_is_persistent(p)) gimp_image_dirty(gimage); parasite_list_remove(gimage->parasites, parasite); } diff --git a/app/gimpparasite.c b/app/gimpparasite.c index 99b660cd3f..bc869f014f 100644 --- a/app/gimpparasite.c +++ b/app/gimpparasite.c @@ -42,13 +42,13 @@ gimp_attach_parasite (Parasite *p) } void -gimp_detach_parasite (char *name) +gimp_detach_parasite (const char *name) { parasite_list_remove(parasites, name); } Parasite * -gimp_find_parasite (char *name) +gimp_find_parasite (const char *name) { return parasite_list_find(parasites, name); } diff --git a/app/gimpparasite.h b/app/gimpparasite.h index eaaceb197e..5493b158a7 100644 --- a/app/gimpparasite.h +++ b/app/gimpparasite.h @@ -22,8 +22,8 @@ void gimp_init_parasites (void); void gimp_attach_parasite (Parasite *p); -void gimp_detach_parasite (char *name); -Parasite * gimp_find_parasite (char *name); +void gimp_detach_parasite (const char *name); +Parasite * gimp_find_parasite (const char *name); char ** gimp_parasite_list (gint *count); void gimp_parasiterc_save (void); void gimp_parasiterc_load (void); diff --git a/app/gui/plug-in-commands.c b/app/gui/plug-in-commands.c index 73ce25151d..0f8a702408 100644 --- a/app/gui/plug-in-commands.c +++ b/app/gui/plug-in-commands.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/gui/plug-in-menus.c b/app/gui/plug-in-menus.c index 73ce25151d..0f8a702408 100644 --- a/app/gui/plug-in-menus.c +++ b/app/gui/plug-in-menus.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/gui/tips-dialog.c b/app/gui/tips-dialog.c index 0874ab63cc..e79383e092 100644 --- a/app/gui/tips-dialog.c +++ b/app/gui/tips-dialog.c @@ -43,6 +43,7 @@ tips_dialog_create () GtkWidget *vbox_check; GtkWidget *button_check; gchar * temp; + guchar * utemp; guchar * src; guchar * dest; int x; @@ -98,20 +99,20 @@ tips_dialog_create () preview = gtk_preview_new (GTK_PREVIEW_COLOR); gtk_preview_size (GTK_PREVIEW (preview), wilber_width, wilber_height); - temp = g_malloc (wilber_width * 3); + utemp = g_new (guchar, wilber_width * 3); src = (guchar *)wilber_data; for (y = 0; y < wilber_height; y++) { - dest = temp; + dest = utemp; for (x = 0; x < wilber_width; x++) { HEADER_PIXEL(src, dest); dest += 3; } - gtk_preview_draw_row (GTK_PREVIEW (preview), temp, + gtk_preview_draw_row (GTK_PREVIEW (preview), utemp, 0, y, wilber_width); } - g_free(temp); + g_free(utemp); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_end (GTK_BOX (hbox1), frame, FALSE, TRUE, 3); diff --git a/app/menus/plug-in-menus.c b/app/menus/plug-in-menus.c index 73ce25151d..0f8a702408 100644 --- a/app/menus/plug-in-menus.c +++ b/app/menus/plug-in-menus.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/paint_core.c b/app/paint_core.c index 497e215b11..22ead286e4 100644 --- a/app/paint_core.c +++ b/app/paint_core.c @@ -187,7 +187,7 @@ paint_core_button_press (tool, bevent, gdisp_ptr) gdisplays_selection_visibility (gdisp->gimage, SelectionPause); /* add motion memory if you press mod1 first ^ perfectmouse */ - if (((bevent->state & GDK_MOD1_MASK) != 0) != (perfectmouse != 0)) + if (perfectmouse == 0) gdk_pointer_grab (gdisp->canvas->window, FALSE, GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); diff --git a/app/paintbrush.c b/app/paintbrush.c index 701da9911e..876bfe9471 100644 --- a/app/paintbrush.c +++ b/app/paintbrush.c @@ -279,21 +279,15 @@ paintbrush_options_new (void) return options; } - -#define USE_SPEEDSHOP_CALIPERS 0 #define TIMED_BRUSH 0 -#if USE_SPEEDSHOP_CALIPERS -#include -#endif - void * paintbrush_paint_func (PaintCore *paint_core, GimpDrawable *drawable, int state) { #if TIMED_BRUSH - static GTimer *timer; + static GTimer *timer = NULL; #endif switch (state) { @@ -301,29 +295,58 @@ paintbrush_paint_func (PaintCore *paint_core, #if TIMED_BRUSH timer = g_timer_new(); g_timer_start(timer); -#if USE_SPEEDSHOP_CALIPERS - ssrt_caliper_point(0, "Painting"); -#endif /* USE_SPEEDSHOP_CALIPERS */ #endif /* TIMED_BRUSH */ + if ((paint_core->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) + { + unsigned char *color; + if ((color = gimp_drawable_get_color_at(drawable, paint_core->curx, + paint_core->cury))) + { + if ((paint_core->state & GDK_CONTROL_MASK)) + palette_set_foreground (color[RED_PIX], color[GREEN_PIX], + color [BLUE_PIX]); + else + palette_set_background (color[RED_PIX], color[GREEN_PIX], + color [BLUE_PIX]); + g_free(color); + } + } break; case MOTION_PAINT : - paintbrush_motion (paint_core, drawable, - paintbrush_options->fade_out, - paintbrush_options->use_gradient ? - exp(paintbrush_options->gradient_length/10) : 0, - paintbrush_options->incremental, - paintbrush_options->gradient_type); + if ((paint_core->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) + { + unsigned char *color; + if ((color = gimp_drawable_get_color_at(drawable, paint_core->curx, + paint_core->cury))) + { + if ((paint_core->state & GDK_CONTROL_MASK)) + palette_set_foreground (color[RED_PIX], color[GREEN_PIX], + color [BLUE_PIX]); + else + palette_set_background (color[RED_PIX], color[GREEN_PIX], + color [BLUE_PIX]); + g_free(color); + } + } + else + paintbrush_motion (paint_core, drawable, + paintbrush_options->fade_out, + paintbrush_options->use_gradient ? + exp(paintbrush_options->gradient_length/10) : 0, + paintbrush_options->incremental, + paintbrush_options->gradient_type); break; case FINISH_PAINT : #if TIMED_BRUSH -#if USE_SPEEDSHOP_CALIPERS - ssrt_caliper_point(0, "Not Painting Anymore"); -#endif /* USE_SPEEDSHOP_CALIPERS */ - g_timer_stop(timer); - printf("painting took %f:\n", g_timer_elapsed(timer, NULL)); - g_timer_destroy(timer); + if (timer) + { + g_timer_stop(timer); + printf("painting took %f:\n", g_timer_elapsed(timer, NULL)); + g_timer_destroy(timer); + timer = NULL; + } #endif /* TIMED_BRUSH */ break; @@ -459,16 +482,16 @@ paintbrush_non_gui_paint_func (PaintCore *paint_core, gboolean paintbrush_non_gui (GimpDrawable *drawable, - int num_strokes, - double *stroke_array, - double fade_out, - int method, - double gradient_length) + int num_strokes, + double *stroke_array, + double fade_out, + int method, + double gradient_length) { int i; if (paint_core_init (&non_gui_paint_core, drawable, - stroke_array[0], stroke_array[1])) + stroke_array[0], stroke_array[1])) { non_gui_fade_out = fade_out; non_gui_gradient_length = gradient_length; @@ -482,18 +505,18 @@ paintbrush_non_gui (GimpDrawable *drawable, non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1]; if (num_strokes == 1) - paintbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0); + paintbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0); for (i = 1; i < num_strokes; i++) - { - non_gui_paint_core.curx = stroke_array[i * 2 + 0]; - non_gui_paint_core.cury = stroke_array[i * 2 + 1]; + { + non_gui_paint_core.curx = stroke_array[i * 2 + 0]; + non_gui_paint_core.cury = stroke_array[i * 2 + 1]; - paint_core_interpolate (&non_gui_paint_core, drawable); + paint_core_interpolate (&non_gui_paint_core, drawable); - non_gui_paint_core.lastx = non_gui_paint_core.curx; - non_gui_paint_core.lasty = non_gui_paint_core.cury; - } + non_gui_paint_core.lastx = non_gui_paint_core.curx; + non_gui_paint_core.lasty = non_gui_paint_core.cury; + } /* Finish the painting */ paint_core_finish (&non_gui_paint_core, drawable, -1); diff --git a/app/parasitelist.c b/app/parasitelist.c index 848d7b6513..391402b728 100644 --- a/app/parasitelist.c +++ b/app/parasitelist.c @@ -214,8 +214,6 @@ parasite_list_find(ParasiteList *list, const char *name) return NULL; } -static int saved_bytes; - void parasite_shift_parent(Parasite *p) { diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/gimpplugin-message.c +++ b/app/plug-in/gimpplugin-message.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/gimpplugin-progress.c b/app/plug-in/gimpplugin-progress.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/gimpplugin-progress.c +++ b/app/plug-in/gimpplugin-progress.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/gimpplugin.c +++ b/app/plug-in/gimpplugin.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/gimppluginmanager-call.c +++ b/app/plug-in/gimppluginmanager-call.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/gimppluginmanager-run.c b/app/plug-in/gimppluginmanager-run.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/gimppluginmanager-run.c +++ b/app/plug-in/gimppluginmanager-run.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/gimppluginmanager.c +++ b/app/plug-in/gimppluginmanager.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/gimppluginshm.c b/app/plug-in/gimppluginshm.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/gimppluginshm.c +++ b/app/plug-in/gimppluginshm.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/plug-in-def.c b/app/plug-in/plug-in-def.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/plug-in-def.c +++ b/app/plug-in/plug-in-def.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/plug-in-message.c b/app/plug-in/plug-in-message.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/plug-in-message.c +++ b/app/plug-in/plug-in-message.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/plug-in-params.c b/app/plug-in/plug-in-params.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/plug-in-params.c +++ b/app/plug-in/plug-in-params.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/plug-in-progress.c b/app/plug-in/plug-in-progress.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/plug-in-progress.c +++ b/app/plug-in/plug-in-progress.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/plug-in-run.c b/app/plug-in/plug-in-run.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/plug-in-run.c +++ b/app/plug-in/plug-in-run.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/plug-in-shm.c b/app/plug-in/plug-in-shm.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/plug-in-shm.c +++ b/app/plug-in/plug-in-shm.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/plug-in.c b/app/plug-in/plug-in.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/plug-in.c +++ b/app/plug-in/plug-in.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug-in/plug-ins.c b/app/plug-in/plug-ins.c index 73ce25151d..0f8a702408 100644 --- a/app/plug-in/plug-ins.c +++ b/app/plug-in/plug-ins.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/plug_in.c b/app/plug_in.c index 73ce25151d..0f8a702408 100644 --- a/app/plug_in.c +++ b/app/plug_in.c @@ -2130,7 +2130,7 @@ plug_in_flush (GIOChannel *channel) { GIOError error; int count; - int bytes; + guint bytes; if (current_write_buffer_index > 0) { diff --git a/app/tips_dialog.c b/app/tips_dialog.c index 0874ab63cc..e79383e092 100644 --- a/app/tips_dialog.c +++ b/app/tips_dialog.c @@ -43,6 +43,7 @@ tips_dialog_create () GtkWidget *vbox_check; GtkWidget *button_check; gchar * temp; + guchar * utemp; guchar * src; guchar * dest; int x; @@ -98,20 +99,20 @@ tips_dialog_create () preview = gtk_preview_new (GTK_PREVIEW_COLOR); gtk_preview_size (GTK_PREVIEW (preview), wilber_width, wilber_height); - temp = g_malloc (wilber_width * 3); + utemp = g_new (guchar, wilber_width * 3); src = (guchar *)wilber_data; for (y = 0; y < wilber_height; y++) { - dest = temp; + dest = utemp; for (x = 0; x < wilber_width; x++) { HEADER_PIXEL(src, dest); dest += 3; } - gtk_preview_draw_row (GTK_PREVIEW (preview), temp, + gtk_preview_draw_row (GTK_PREVIEW (preview), utemp, 0, y, wilber_width); } - g_free(temp); + g_free(utemp); frame = gtk_frame_new (NULL); gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN); gtk_box_pack_end (GTK_BOX (hbox1), frame, FALSE, TRUE, 3); diff --git a/app/tools/edit_selection.c b/app/tools/edit_selection.c index 33c2a5a442..f0dc7c9113 100644 --- a/app/tools/edit_selection.c +++ b/app/tools/edit_selection.c @@ -513,11 +513,6 @@ edit_selection_draw (Tool *tool) break; case MaskToLayerTranslate: - if (diff_x < 0) - { - x1 = x1 + 1; - x1 --; - } gdisplay_transform_coords (gdisp, edit_select.x1, edit_select.y1, &x1, &y1, TRUE); gdisplay_transform_coords (gdisp, edit_select.x2, edit_select.y2, &x2, &y2, TRUE); gdk_draw_rectangle (edit_select.core->win, diff --git a/app/tools/gimpeditselectiontool.c b/app/tools/gimpeditselectiontool.c index 33c2a5a442..f0dc7c9113 100644 --- a/app/tools/gimpeditselectiontool.c +++ b/app/tools/gimpeditselectiontool.c @@ -513,11 +513,6 @@ edit_selection_draw (Tool *tool) break; case MaskToLayerTranslate: - if (diff_x < 0) - { - x1 = x1 + 1; - x1 --; - } gdisplay_transform_coords (gdisp, edit_select.x1, edit_select.y1, &x1, &y1, TRUE); gdisplay_transform_coords (gdisp, edit_select.x2, edit_select.y2, &x2, &y2, TRUE); gdk_draw_rectangle (edit_select.core->win, diff --git a/app/tools/paint_core.c b/app/tools/paint_core.c index 497e215b11..22ead286e4 100644 --- a/app/tools/paint_core.c +++ b/app/tools/paint_core.c @@ -187,7 +187,7 @@ paint_core_button_press (tool, bevent, gdisp_ptr) gdisplays_selection_visibility (gdisp->gimage, SelectionPause); /* add motion memory if you press mod1 first ^ perfectmouse */ - if (((bevent->state & GDK_MOD1_MASK) != 0) != (perfectmouse != 0)) + if (perfectmouse == 0) gdk_pointer_grab (gdisp->canvas->window, FALSE, GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, NULL, NULL, bevent->time); diff --git a/app/tools/paintbrush.c b/app/tools/paintbrush.c index 701da9911e..876bfe9471 100644 --- a/app/tools/paintbrush.c +++ b/app/tools/paintbrush.c @@ -279,21 +279,15 @@ paintbrush_options_new (void) return options; } - -#define USE_SPEEDSHOP_CALIPERS 0 #define TIMED_BRUSH 0 -#if USE_SPEEDSHOP_CALIPERS -#include -#endif - void * paintbrush_paint_func (PaintCore *paint_core, GimpDrawable *drawable, int state) { #if TIMED_BRUSH - static GTimer *timer; + static GTimer *timer = NULL; #endif switch (state) { @@ -301,29 +295,58 @@ paintbrush_paint_func (PaintCore *paint_core, #if TIMED_BRUSH timer = g_timer_new(); g_timer_start(timer); -#if USE_SPEEDSHOP_CALIPERS - ssrt_caliper_point(0, "Painting"); -#endif /* USE_SPEEDSHOP_CALIPERS */ #endif /* TIMED_BRUSH */ + if ((paint_core->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) + { + unsigned char *color; + if ((color = gimp_drawable_get_color_at(drawable, paint_core->curx, + paint_core->cury))) + { + if ((paint_core->state & GDK_CONTROL_MASK)) + palette_set_foreground (color[RED_PIX], color[GREEN_PIX], + color [BLUE_PIX]); + else + palette_set_background (color[RED_PIX], color[GREEN_PIX], + color [BLUE_PIX]); + g_free(color); + } + } break; case MOTION_PAINT : - paintbrush_motion (paint_core, drawable, - paintbrush_options->fade_out, - paintbrush_options->use_gradient ? - exp(paintbrush_options->gradient_length/10) : 0, - paintbrush_options->incremental, - paintbrush_options->gradient_type); + if ((paint_core->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK))) + { + unsigned char *color; + if ((color = gimp_drawable_get_color_at(drawable, paint_core->curx, + paint_core->cury))) + { + if ((paint_core->state & GDK_CONTROL_MASK)) + palette_set_foreground (color[RED_PIX], color[GREEN_PIX], + color [BLUE_PIX]); + else + palette_set_background (color[RED_PIX], color[GREEN_PIX], + color [BLUE_PIX]); + g_free(color); + } + } + else + paintbrush_motion (paint_core, drawable, + paintbrush_options->fade_out, + paintbrush_options->use_gradient ? + exp(paintbrush_options->gradient_length/10) : 0, + paintbrush_options->incremental, + paintbrush_options->gradient_type); break; case FINISH_PAINT : #if TIMED_BRUSH -#if USE_SPEEDSHOP_CALIPERS - ssrt_caliper_point(0, "Not Painting Anymore"); -#endif /* USE_SPEEDSHOP_CALIPERS */ - g_timer_stop(timer); - printf("painting took %f:\n", g_timer_elapsed(timer, NULL)); - g_timer_destroy(timer); + if (timer) + { + g_timer_stop(timer); + printf("painting took %f:\n", g_timer_elapsed(timer, NULL)); + g_timer_destroy(timer); + timer = NULL; + } #endif /* TIMED_BRUSH */ break; @@ -459,16 +482,16 @@ paintbrush_non_gui_paint_func (PaintCore *paint_core, gboolean paintbrush_non_gui (GimpDrawable *drawable, - int num_strokes, - double *stroke_array, - double fade_out, - int method, - double gradient_length) + int num_strokes, + double *stroke_array, + double fade_out, + int method, + double gradient_length) { int i; if (paint_core_init (&non_gui_paint_core, drawable, - stroke_array[0], stroke_array[1])) + stroke_array[0], stroke_array[1])) { non_gui_fade_out = fade_out; non_gui_gradient_length = gradient_length; @@ -482,18 +505,18 @@ paintbrush_non_gui (GimpDrawable *drawable, non_gui_paint_core.starty = non_gui_paint_core.lasty = stroke_array[1]; if (num_strokes == 1) - paintbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0); + paintbrush_non_gui_paint_func (&non_gui_paint_core, drawable, 0); for (i = 1; i < num_strokes; i++) - { - non_gui_paint_core.curx = stroke_array[i * 2 + 0]; - non_gui_paint_core.cury = stroke_array[i * 2 + 1]; + { + non_gui_paint_core.curx = stroke_array[i * 2 + 0]; + non_gui_paint_core.cury = stroke_array[i * 2 + 1]; - paint_core_interpolate (&non_gui_paint_core, drawable); + paint_core_interpolate (&non_gui_paint_core, drawable); - non_gui_paint_core.lastx = non_gui_paint_core.curx; - non_gui_paint_core.lasty = non_gui_paint_core.cury; - } + non_gui_paint_core.lastx = non_gui_paint_core.curx; + non_gui_paint_core.lasty = non_gui_paint_core.cury; + } /* Finish the painting */ paint_core_finish (&non_gui_paint_core, drawable, -1); diff --git a/app/undo.c b/app/undo.c index dcdbceb2cc..3d80b12f38 100644 --- a/app/undo.c +++ b/app/undo.c @@ -41,6 +41,9 @@ #include "tile_manager_pvt.h" #include "tile.h" /* ick. */ +#include "libgimp/parasite.h" +#include "gimpparasite.h" + typedef int (* UndoPopFunc) (GImage *, int, int, void *); @@ -75,6 +78,7 @@ int undo_pop_fs_rigor (GImage *, int, int, void *); int undo_pop_fs_relax (GImage *, int, int, void *); int undo_pop_gimage_mod (GImage *, int, int, void *); int undo_pop_guide (GImage *, int, int, void *); +int undo_pop_parasite (GImage *, int, int, void *); /* Free functions */ @@ -93,6 +97,8 @@ void undo_free_fs_rigor (int, void *); void undo_free_fs_relax (int, void *); void undo_free_gimage_mod (int, void *); void undo_free_guide (int, void *); +void undo_free_parasite (int, void *); + /* Sizing functions */ @@ -2099,3 +2105,219 @@ undo_free_guide (int state, g_free (data_ptr); } + + +/************/ +/* Parasite */ + +typedef struct _ParasiteUndo ParasiteUndo; + +struct _ParasiteUndo +{ + GImage *gimage; + GimpDrawable *drawable; + Parasite *parasite; + char *name; +}; + +int +undo_push_image_parasite (GImage *gimage, + void *parasite) +{ + Undo *new; + ParasiteUndo *data; + long size; + + /* increment the dirty flag for this gimage */ + gimage_dirty (gimage); + + size = sizeof (ParasiteUndo); + + if ((new = undo_push (gimage, size, GIMAGE_MOD))) + { + data = g_new (ParasiteUndo, 1); + new->data = data; + new->pop_func = undo_pop_parasite; + new->free_func = undo_free_parasite; + + data->gimage = gimage; + data->drawable = NULL; + data->name = g_strdup(parasite_name(parasite)); + data->parasite = parasite_copy(gimp_image_find_parasite(gimage, data->name)); + + return TRUE; + } + + return FALSE; +} + +int +undo_push_image_parasite_remove (GImage *gimage, + const char *name) +{ + Undo *new; + ParasiteUndo *data; + long size; + + /* increment the dirty flag for this gimage */ + gimage_dirty (gimage); + + size = sizeof (ParasiteUndo); + + if ((new = undo_push (gimage, size, GIMAGE_MOD))) + { + data = g_new (ParasiteUndo, 1); + new->data = data; + new->pop_func = undo_pop_parasite; + new->free_func = undo_free_parasite; + + data->gimage = gimage; + data->drawable = NULL; + data->name = g_strdup(name); + data->parasite = parasite_copy(gimp_image_find_parasite(gimage, data->name)); + + return TRUE; + } + + return FALSE; +} + +int +undo_push_drawable_parasite (GImage *gimage, + GimpDrawable *drawable, + void *parasite) +{ + Undo *new; + ParasiteUndo *data; + long size; + + /* increment the dirty flag for this gimage */ + gimage_dirty (gimage); + + size = sizeof (ParasiteUndo); + + if ((new = undo_push (gimage, size, GIMAGE_MOD))) + { + data = g_new (ParasiteUndo, 1); + new->data = data; + new->pop_func = undo_pop_parasite; + new->free_func = undo_free_parasite; + + data->gimage = NULL; + data->drawable = drawable; + data->name = g_strdup(parasite_name(parasite)); + data->parasite = parasite_copy(gimp_drawable_find_parasite(drawable, data->name)); + return TRUE; + } + + return FALSE; +} + +int +undo_push_drawable_parasite_remove (GImage *gimage, + GimpDrawable *drawable, + const char *name) +{ + Undo *new; + ParasiteUndo *data; + long size; + + /* increment the dirty flag for this gimage */ + gimage_dirty (gimage); + + size = sizeof (ParasiteUndo); + + if ((new = undo_push (gimage, size, GIMAGE_MOD))) + { + data = g_new (ParasiteUndo, 1); + new->data = data; + new->pop_func = undo_pop_parasite; + new->free_func = undo_free_parasite; + + data->gimage = NULL; + data->drawable = drawable; + data->name = g_strdup(name); + data->parasite = parasite_copy(gimp_drawable_find_parasite(drawable, data->name)); + return TRUE; + } + + return FALSE; +} + + +int +undo_pop_parasite (GImage *gimage, + int state, + int type, + void *data_ptr) +{ + ParasiteUndo *data; + Parasite *tmp; + int tmp_ref; + + data = data_ptr; + + tmp = data->parasite; + + if (data->gimage) + { + data->parasite = parasite_copy(gimp_image_find_parasite(gimage, + data->name)); + if (tmp) + parasite_list_add(data->gimage->parasites, tmp); + else + parasite_list_remove(data->gimage->parasites, data->name); + } + else if (data->drawable) + { + data->parasite = parasite_copy(gimp_drawable_find_parasite(data->drawable, + data->name)); + if (tmp) + parasite_list_add(data->drawable->parasites, tmp); + else + parasite_list_remove(data->drawable->parasites, data->name); + } + else + { + data->parasite = parasite_copy(gimp_find_parasite(data->name)); + if (tmp) + gimp_attach_parasite(tmp); + else + gimp_detach_parasite(data->name); + } + + if (tmp) + parasite_free(tmp); + +/* if ((tmp && parasite_is_persistant(tmp)) || */ +/* (data->parasite && parasite_is_persistant(data->parasite))) */ + switch (state) + { + case UNDO: + gimage_clean (gimage); + break; + case REDO: + gimage_dirty (gimage); + break; + } + + return TRUE; +} + + +void +undo_free_parasite (int state, + void *data_ptr) +{ + ParasiteUndo *data; + + data = data_ptr; + + if (data->parasite) + parasite_free (data->parasite); + if (data->name) + g_free (data->name); + + g_free (data_ptr); +} + diff --git a/app/undo.h b/app/undo.h index b679fc31a5..57b53c3062 100644 --- a/app/undo.h +++ b/app/undo.h @@ -79,6 +79,11 @@ int undo_push_fs_rigor (GImage *, int); int undo_push_fs_relax (GImage *, int); int undo_push_gimage_mod (GImage *); int undo_push_guide (GImage *, void *); +int undo_push_image_parasite (GImage *, void *); +int undo_push_drawable_parasite (GImage *, GimpDrawable *, void *); +int undo_push_image_parasite_remove (GImage *, const char *); +int undo_push_drawable_parasite_remove (GImage *, GimpDrawable *, + const char *); int undo_pop (GImage *); int undo_redo (GImage *); diff --git a/libgimp/gimp.h b/libgimp/gimp.h index e12097c588..c1b7ec12fb 100644 --- a/libgimp/gimp.h +++ b/libgimp/gimp.h @@ -421,6 +421,8 @@ void gimp_image_add_layer_mask (gint32 image_ID, void gimp_image_clean_all (gint32 image_ID); void gimp_image_disable_undo (gint32 image_ID); void gimp_image_enable_undo (gint32 image_ID); +void gimp_undo_push_group_start (gint32 image_ID); +void gimp_undo_push_group_end (gint32 image_ID); void gimp_image_clean_all (gint32 image_ID); gint32 gimp_image_flatten (gint32 image_ID); void gimp_image_lower_channel (gint32 image_ID, diff --git a/libgimp/gimpimage.c b/libgimp/gimpimage.c index 6f36f5d215..6ede148fcf 100644 --- a/libgimp/gimpimage.c +++ b/libgimp/gimpimage.c @@ -373,6 +373,34 @@ gimp_image_enable_undo (gint32 image_ID) gimp_destroy_params (return_vals, nreturn_vals); } +void +gimp_undo_push_group_start (gint32 image_ID) +{ + GParam *return_vals; + int nreturn_vals; + + return_vals = gimp_run_procedure ("gimp_undo_push_group_start", + &nreturn_vals, + PARAM_IMAGE, image_ID, + PARAM_END); + + gimp_destroy_params (return_vals, nreturn_vals); +} + +void +gimp_undo_push_group_end (gint32 image_ID) +{ + GParam *return_vals; + int nreturn_vals; + + return_vals = gimp_run_procedure ("gimp_undo_push_group_end", + &nreturn_vals, + PARAM_IMAGE, image_ID, + PARAM_END); + + gimp_destroy_params (return_vals, nreturn_vals); +} + void gimp_image_clean_all (gint32 image_ID) { diff --git a/libgimp/gimpimage_pdb.c b/libgimp/gimpimage_pdb.c index 6f36f5d215..6ede148fcf 100644 --- a/libgimp/gimpimage_pdb.c +++ b/libgimp/gimpimage_pdb.c @@ -373,6 +373,34 @@ gimp_image_enable_undo (gint32 image_ID) gimp_destroy_params (return_vals, nreturn_vals); } +void +gimp_undo_push_group_start (gint32 image_ID) +{ + GParam *return_vals; + int nreturn_vals; + + return_vals = gimp_run_procedure ("gimp_undo_push_group_start", + &nreturn_vals, + PARAM_IMAGE, image_ID, + PARAM_END); + + gimp_destroy_params (return_vals, nreturn_vals); +} + +void +gimp_undo_push_group_end (gint32 image_ID) +{ + GParam *return_vals; + int nreturn_vals; + + return_vals = gimp_run_procedure ("gimp_undo_push_group_end", + &nreturn_vals, + PARAM_IMAGE, image_ID, + PARAM_END); + + gimp_destroy_params (return_vals, nreturn_vals); +} + void gimp_image_clean_all (gint32 image_ID) { diff --git a/libgimp/gimpparasite.c b/libgimp/gimpparasite.c index fe9b517399..b66db47d55 100644 --- a/libgimp/gimpparasite.c +++ b/libgimp/gimpparasite.c @@ -62,7 +62,6 @@ parasite_new (const char *name, guint32 flags, p->name = g_strdup(name); else { - p->name = NULL; g_free (p); return NULL; } @@ -134,6 +133,14 @@ parasite_is_persistent(const Parasite *p) return (p->flags & PARASITE_PERSISTENT); } +int +parasite_is_undoable(const Parasite *p) +{ + if (p == NULL) + return FALSE; + return (p->flags & PARASITE_UNDOABLE); +} + int parasite_has_flag(const Parasite *p, gulong flag) { diff --git a/libgimp/gimpparasite.h b/libgimp/gimpparasite.h index e8683c9711..909c61a779 100644 --- a/libgimp/gimpparasite.h +++ b/libgimp/gimpparasite.h @@ -29,12 +29,15 @@ extern "C" { #endif /* __cplusplus */ #define PARASITE_PERSISTENT 1 +#define PARASITE_UNDOABLE 2 #define PARASITE_ATTACH_PARENT (0x80 << 8) #define PARASITE_PARENT_PERSISTENT (PARASITE_PERSISTENT << 8) +#define PARASITE_PARENT_UNDOABLE (PARASITE_UNDOABLE << 8) #define PARASITE_ATTACH_GRANDPARENT (0x80 << 16) #define PARASITE_GRANDPARENT_PERSISTENT (PARASITE_PERSISTENT << 16) +#define PARASITE_GRANDPARENT_UNDOABLE (PARASITE_UNDOABLE << 16) Parasite *parasite_new (const char *name, guint32 flags, guint32 size, const void *data); @@ -47,6 +50,7 @@ int parasite_compare (const Parasite *a, const Parasite *b); int parasite_is_type (const Parasite *parasite, const char *name); int parasite_is_persistent (const Parasite *p); +int parasite_is_undoable (const Parasite *p); int parasite_has_flag (const Parasite *p, gulong flag); gulong parasite_flags (const Parasite *p); const char *parasite_name (const Parasite *p); diff --git a/libgimp/parasite.c b/libgimp/parasite.c index fe9b517399..b66db47d55 100644 --- a/libgimp/parasite.c +++ b/libgimp/parasite.c @@ -62,7 +62,6 @@ parasite_new (const char *name, guint32 flags, p->name = g_strdup(name); else { - p->name = NULL; g_free (p); return NULL; } @@ -134,6 +133,14 @@ parasite_is_persistent(const Parasite *p) return (p->flags & PARASITE_PERSISTENT); } +int +parasite_is_undoable(const Parasite *p) +{ + if (p == NULL) + return FALSE; + return (p->flags & PARASITE_UNDOABLE); +} + int parasite_has_flag(const Parasite *p, gulong flag) { diff --git a/libgimp/parasite.h b/libgimp/parasite.h index e8683c9711..909c61a779 100644 --- a/libgimp/parasite.h +++ b/libgimp/parasite.h @@ -29,12 +29,15 @@ extern "C" { #endif /* __cplusplus */ #define PARASITE_PERSISTENT 1 +#define PARASITE_UNDOABLE 2 #define PARASITE_ATTACH_PARENT (0x80 << 8) #define PARASITE_PARENT_PERSISTENT (PARASITE_PERSISTENT << 8) +#define PARASITE_PARENT_UNDOABLE (PARASITE_UNDOABLE << 8) #define PARASITE_ATTACH_GRANDPARENT (0x80 << 16) #define PARASITE_GRANDPARENT_PERSISTENT (PARASITE_PERSISTENT << 16) +#define PARASITE_GRANDPARENT_UNDOABLE (PARASITE_UNDOABLE << 16) Parasite *parasite_new (const char *name, guint32 flags, guint32 size, const void *data); @@ -47,6 +50,7 @@ int parasite_compare (const Parasite *a, const Parasite *b); int parasite_is_type (const Parasite *parasite, const char *name); int parasite_is_persistent (const Parasite *p); +int parasite_is_undoable (const Parasite *p); int parasite_has_flag (const Parasite *p, gulong flag); gulong parasite_flags (const Parasite *p); const char *parasite_name (const Parasite *p); diff --git a/libgimpbase/gimpparasite.c b/libgimpbase/gimpparasite.c index fe9b517399..b66db47d55 100644 --- a/libgimpbase/gimpparasite.c +++ b/libgimpbase/gimpparasite.c @@ -62,7 +62,6 @@ parasite_new (const char *name, guint32 flags, p->name = g_strdup(name); else { - p->name = NULL; g_free (p); return NULL; } @@ -134,6 +133,14 @@ parasite_is_persistent(const Parasite *p) return (p->flags & PARASITE_PERSISTENT); } +int +parasite_is_undoable(const Parasite *p) +{ + if (p == NULL) + return FALSE; + return (p->flags & PARASITE_UNDOABLE); +} + int parasite_has_flag(const Parasite *p, gulong flag) { diff --git a/libgimpbase/gimpparasite.h b/libgimpbase/gimpparasite.h index e8683c9711..909c61a779 100644 --- a/libgimpbase/gimpparasite.h +++ b/libgimpbase/gimpparasite.h @@ -29,12 +29,15 @@ extern "C" { #endif /* __cplusplus */ #define PARASITE_PERSISTENT 1 +#define PARASITE_UNDOABLE 2 #define PARASITE_ATTACH_PARENT (0x80 << 8) #define PARASITE_PARENT_PERSISTENT (PARASITE_PERSISTENT << 8) +#define PARASITE_PARENT_UNDOABLE (PARASITE_UNDOABLE << 8) #define PARASITE_ATTACH_GRANDPARENT (0x80 << 16) #define PARASITE_GRANDPARENT_PERSISTENT (PARASITE_PERSISTENT << 16) +#define PARASITE_GRANDPARENT_UNDOABLE (PARASITE_UNDOABLE << 16) Parasite *parasite_new (const char *name, guint32 flags, guint32 size, const void *data); @@ -47,6 +50,7 @@ int parasite_compare (const Parasite *a, const Parasite *b); int parasite_is_type (const Parasite *parasite, const char *name); int parasite_is_persistent (const Parasite *p); +int parasite_is_undoable (const Parasite *p); int parasite_has_flag (const Parasite *p, gulong flag); gulong parasite_flags (const Parasite *p); const char *parasite_name (const Parasite *p); diff --git a/plug-ins/common/rotators.c b/plug-ins/common/rotators.c index a2ed464a72..c18131be1a 100644 --- a/plug-ins/common/rotators.c +++ b/plug-ins/common/rotators.c @@ -252,7 +252,7 @@ static void do_layerrot(GDrawable *drawable, drawable = gimp_drawable_get(drawable->id); } else /* not a layer... probably a channel... abort operation */ - exit; + return; /* If 'preserve transparency' was on, we need to temporatily diff --git a/plug-ins/gdyntext/font_selection.c b/plug-ins/gdyntext/font_selection.c index 2cdbbc2e40..a5cd778152 100644 --- a/plug-ins/gdyntext/font_selection.c +++ b/plug-ins/gdyntext/font_selection.c @@ -99,7 +99,7 @@ static void font_selection_init(FontSelection *fs) fs->font = GTK_WIDGET(fs)->style->font; /* get X font list and setup font names and styles */ -//#define DEBUG_SPAM +/* #define DEBUG_SPAM */ #ifndef DEBUG_SPAM /* FIXME: not only for "-*", do also "*"!!! */ xfontnames = XListFonts(GDK_DISPLAY(), "-*", MAX_FONTS, &num_fonts); diff --git a/plug-ins/gdyntext/gdyntext.c b/plug-ins/gdyntext/gdyntext.c index f32d1f8f8b..5b1e4e24dc 100644 --- a/plug-ins/gdyntext/gdyntext.c +++ b/plug-ins/gdyntext/gdyntext.c @@ -340,11 +340,16 @@ static void gdt_run(char *name, int nparams, GParam *param, int *nreturn_vals, gdtvals.new_layer = !gimp_drawable_has_alpha(gdtvals.drawable_id); break; } + + gimp_undo_push_group_start(gdtvals.image_id); + gdt_render_text(&gdtvals); gdt_set_values(&gdtvals); if (run_mode == RUN_INTERACTIVE) gimp_set_data("plug_in_gdyntext", &gdtvals, sizeof(GdtVals)); values[1].data.d_int32 = gdtvals.layer_id; + + gimp_undo_push_group_end(gdtvals.image_id); } @@ -496,7 +501,7 @@ void gdt_set_values(GdtVals *data) data->spacing); #ifdef GIMP_HAVE_PARASITES - parasite = parasite_new(GDYNTEXT_PARASITE, PARASITE_PERSISTENT, + parasite = parasite_new(GDYNTEXT_PARASITE, PARASITE_PERSISTENT | PARASITE_UNDOABLE, strlen(lname), lname); gimp_drawable_attach_parasite(data->drawable_id, parasite); parasite_free(parasite); @@ -532,9 +537,6 @@ void gdt_render_text(GdtVals *data) GParamColor old_color, text_color; gimp_progress_init("GIMP Dynamic Text"); - ret_vals = gimp_run_procedure("gimp_undo_push_group_start", &nret_vals, - PARAM_IMAGE, data->image_id, PARAM_END); - gimp_destroy_params(ret_vals, nret_vals); /* save and remove current selection */ ret_vals = gimp_run_procedure("gimp_selection_is_empty", &nret_vals, @@ -771,10 +773,6 @@ void gdt_render_text(GdtVals *data) gimp_image_remove_channel(data->image_id, selection_channel); } - ret_vals = gimp_run_procedure("gimp_undo_push_group_end", &nret_vals, - PARAM_IMAGE, data->image_id, PARAM_END); - gimp_destroy_params(ret_vals, nret_vals); - gimp_displays_flush(); gimp_progress_update(100.0); } diff --git a/plug-ins/rcm/rcm_misc.c b/plug-ins/rcm/rcm_misc.c index cf9bece4c9..8bb075ad24 100644 --- a/plug-ins/rcm/rcm_misc.c +++ b/plug-ins/rcm/rcm_misc.c @@ -49,7 +49,7 @@ /*-----------------------------------------------------------------------------------*/ -inline float arctg(float y, float x) +float arctg(float y, float x) { float temp = atan2(y,x); return (temp<0) ? (temp+TP) : temp; @@ -379,7 +379,7 @@ void rcm_render_preview(GtkWidget *preview, gint version) { for (k=0; k<3; k++) { - // transp = reduced->mask[i*RW*bytes+j*bytes+3] / 255.0; + /* transp = reduced->mask[i*RW*bytes+j*bytes+3] / 255.0; */ transp = rgb_array[i*RW*bytes+j*bytes+3] / 255.0; a[3*j+k] = transp * a[3*j+k] + (1-transp) * rcm_fake_transparency(i,j); } diff --git a/plug-ins/rotators/rotators.c b/plug-ins/rotators/rotators.c index a2ed464a72..c18131be1a 100644 --- a/plug-ins/rotators/rotators.c +++ b/plug-ins/rotators/rotators.c @@ -252,7 +252,7 @@ static void do_layerrot(GDrawable *drawable, drawable = gimp_drawable_get(drawable->id); } else /* not a layer... probably a channel... abort operation */ - exit; + return; /* If 'preserve transparency' was on, we need to temporatily diff --git a/plug-ins/waterselect/waterselect.c b/plug-ins/waterselect/waterselect.c index 18c29cb140..aa18df8032 100644 --- a/plug-ins/waterselect/waterselect.c +++ b/plug-ins/waterselect/waterselect.c @@ -483,7 +483,7 @@ proximity_out_event (GtkWidget *widget, GdkEventProximity *event) { #ifdef VERBOSE g_print ("proximity out\n"); -#endif VERBOSE +#endif /* VERBOSE */ return TRUE; }