From ef3e162eae4b0a2d7fa3dd79dee26aee1981cefd Mon Sep 17 00:00:00 2001 From: Lauri Alanko Date: Tue, 30 Jun 1998 15:31:32 +0000 Subject: [PATCH] start collecting some core stuff to libgimpim.a Started separating crud out of drawables. Isolated the id system of images entirely within pdb. Even the window titles and menus use pointers instead of ids. Should at least remind people that this is a developers' version. :) --- ChangeLog | 48 ++ app/Makefile.am | 10 +- app/actions/help-commands.c | 10 +- app/actions/plug-in-commands.c | 6 +- app/blend.c | 2 +- app/bucket_fill.c | 3 +- app/channel.h | 3 +- app/clone.c | 10 +- app/commands.c | 10 +- app/core/gimpchannel-combine.h | 3 +- app/core/gimpchannel.h | 3 +- app/core/gimpdrawable-blend.c | 2 +- app/core/gimpdrawable-invert.c | 2 +- app/core/gimpdrawable.c | 543 +++++++++++++++++++ app/core/gimpdrawable.h | 75 +++ app/core/gimpimage-guides.c | 10 +- app/core/gimpimage-guides.h | 11 - app/core/gimpimage-mask.c | 4 +- app/core/gimpimage-merge.c | 10 +- app/core/gimpimage-merge.h | 11 - app/core/gimpimage-projection.c | 10 +- app/core/gimpimage-projection.h | 11 - app/core/gimpimage-resize.c | 10 +- app/core/gimpimage-resize.h | 11 - app/core/gimpimage-scale.c | 10 +- app/core/gimpimage-scale.h | 11 - app/core/gimpimage.c | 10 +- app/core/gimpimage.h | 11 - app/core/gimplayer-floating-sel.c | 7 +- app/core/gimplayer.c | 11 +- app/core/gimplayer.h | 8 +- app/core/gimpobject.h | 1 - app/core/gimpprojection-construct.c | 10 +- app/core/gimpprojection-construct.h | 11 - app/core/gimpprojection.c | 11 +- app/disp_callbacks.c | 2 +- app/display/gimpdisplay-callbacks.c | 2 +- app/display/gimpdisplay.c | 11 +- app/display/gimpdisplayshell-callbacks.c | 2 +- app/display/gimpdisplayshell-draw.c | 7 +- app/display/gimpdisplayshell-draw.h | 3 +- app/display/gimpdisplayshell.c | 7 +- app/display/gimpdisplayshell.h | 3 +- app/drawable.c | 633 ++--------------------- app/drawable.h | 75 +-- app/drawable_cmds.c | 2 +- app/drawable_pvt.h | 33 +- app/fileops.c | 2 +- app/floating_sel.c | 7 +- app/gdisplay.c | 11 +- app/gimage.c | 46 +- app/gimage_cmds.c | 50 +- app/gimage_mask.c | 4 +- app/gimpchannel.h | 3 +- app/gimpdrawable-invert.c | 2 +- app/gimpdrawable.c | 543 +++++++++++++++++++ app/gimpdrawable.h | 75 +++ app/gimpdrawableF.h | 6 + app/gimpdrawableP.h | 62 +++ app/gimpimage.c | 10 +- app/gimpimage.h | 11 - app/gimpimageP.h | 2 - app/gimplayer.c | 11 +- app/gimplayer.h | 8 +- app/gimpobject.h | 1 - app/gui/commands.c | 10 +- app/gui/help-commands.c | 10 +- app/gui/layers-dialog.c | 2 +- app/gui/plug-in-commands.c | 6 +- app/gui/plug-in-menus.c | 6 +- app/indexed_palette.c | 2 +- app/interface.c | 7 +- app/interface.h | 3 +- app/invert.c | 2 +- app/layer.c | 11 +- app/layer.h | 8 +- app/layers_dialog.c | 2 +- app/menus/plug-in-menus.c | 6 +- app/paint/gimpclone.c | 10 +- app/paint/gimpsourcecore.c | 10 +- app/plug-in/gimpplugin-message.c | 6 +- app/plug-in/gimpplugin-progress.c | 6 +- app/plug-in/gimpplugin.c | 6 +- app/plug-in/gimppluginmanager-call.c | 6 +- app/plug-in/gimppluginmanager-run.c | 6 +- app/plug-in/gimppluginmanager.c | 6 +- app/plug-in/gimppluginshm.c | 6 +- app/plug-in/plug-in-def.c | 6 +- app/plug-in/plug-in-message.c | 6 +- app/plug-in/plug-in-params.c | 6 +- app/plug-in/plug-in-progress.c | 6 +- app/plug-in/plug-in-run.c | 6 +- app/plug-in/plug-in-shm.c | 6 +- app/plug-in/plug-in.c | 6 +- app/plug-in/plug-ins.c | 6 +- app/plug_in.c | 6 +- app/procedural_db.c | 52 ++ app/procedural_db.h | 8 + app/tools/blend.c | 2 +- app/tools/bucket_fill.c | 3 +- app/tools/clone.c | 10 +- app/tools/gimpblendtool.c | 2 +- app/tools/gimpbucketfilltool.c | 3 +- app/tools/gimpclonetool.c | 10 +- app/tools/gimpsourcetool.c | 10 +- app/tools/transform_core.c | 6 +- app/transform_core.c | 6 +- app/xcf.c | 2 +- app/xcf/xcf.c | 2 +- 109 files changed, 1777 insertions(+), 1083 deletions(-) create mode 100644 app/core/gimpdrawable.c create mode 100644 app/core/gimpdrawable.h create mode 100644 app/gimpdrawable.c create mode 100644 app/gimpdrawable.h create mode 100644 app/gimpdrawableF.h create mode 100644 app/gimpdrawableP.h diff --git a/ChangeLog b/ChangeLog index be833546f7..b6c13f5220 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,51 @@ +Tue Jun 30 18:08:01 EEST 1998 Lauri Alanko + + * app/Makefile.am: start collecting some core stuff to libgimpim.a + * app/gdisplay.c (gdisplays_update_area): remove an (apparently) + redundant display area + + * app/drawable.c: + * app/drawable.h: + * app/gimpdrawable.c: + * app/gimpdrawable.h: + * app/gimpdrawableF.h: + * app/gimpdrawableP.h: + + Started separating crud out of drawables. + + * app/blend.c: + * app/bucket_fill.c: + * app/channel.h: + * app/clone.c: + * app/commands.c: + * app/disp_callbacks.c: + * app/drawable_cmds.c: + * app/drawable_pvt.h: + * app/fileops.c: + * app/floating_sel.c: + * app/gimage.c: + * app/gimage_cmds.c: + * app/gimage_mask.c: + * app/gimpimage.c: + * app/gimpimage.h: + * app/gimpimageP.h: + * app/indexed_palette.c: + * app/interface.c: + * app/interface.h: + * app/invert.c: + * app/layer.c: + * app/layer.h: + * app/layers_dialog.c: + * app/plug_in.c: + * app/procedural_db.c: + * app/procedural_db.h: + * app/transform_core.c: + * app/xcf.c: + + Isolated the id system of images entirely within pdb. Even the + window titles and menus use pointers instead of ids. Should at + least remind people that this is a developers' version. :) + Tue Jun 30 04:00:38 EEST 1998 Lauri Alanko * app/commands.c: diff --git a/app/Makefile.am b/app/Makefile.am index 0096664366..caf811acd2 100644 --- a/app/Makefile.am +++ b/app/Makefile.am @@ -3,6 +3,9 @@ scriptdata = bin_PROGRAMS = gimp +noinst_LIBRARIES = libgimpim.a + +libgimpim_a_SOURCES = gimpobject.c gimpimage.c gimpsignal.c gimpdrawable.c gimp_SOURCES = \ about_dialog.c \ @@ -139,14 +142,8 @@ gimp_SOURCES = \ gimage_mask.h \ gimage_mask_cmds.c \ gimage_mask_cmds.h \ - gimpimage.c \ - gimpimage.h \ - gimpobject.c \ - gimpobject.h \ gimprc.c \ gimprc.h \ - gimpsignal.c \ - gimpsignal.h \ global_edit.c \ global_edit.h \ gradient.c \ @@ -313,6 +310,7 @@ INCLUDES = \ -I$(includedir) LDADD = \ + libgimpim.a \ $(top_builddir)/libgimp/libgimpi.a \ $(GTK_LIBS) \ $(THREAD_LIBS) \ diff --git a/app/actions/help-commands.c b/app/actions/help-commands.c index b3175afbb3..1b900a633b 100644 --- a/app/actions/help-commands.c +++ b/app/actions/help-commands.c @@ -70,7 +70,7 @@ typedef struct { GtkWidget * shell; Resize * resize; - int gimage_id; + GimpImage* gimage; } ImageResize; /* external functions */ @@ -724,7 +724,7 @@ image_resize_cmd_callback (GtkWidget *widget, /* the ImageResize structure */ image_resize = (ImageResize *) g_malloc (sizeof (ImageResize)); - image_resize->gimage_id = gdisp->gimage->ID; + image_resize->gimage = gdisp->gimage; image_resize->resize = resize_widget_new (ResizeWidget, gdisp->gimage->width, gdisp->gimage->height); /* the dialog */ @@ -771,7 +771,7 @@ image_scale_cmd_callback (GtkWidget *widget, /* the ImageResize structure */ image_scale = (ImageResize *) g_malloc (sizeof (ImageResize)); - image_scale->gimage_id = gdisp->gimage->ID; + image_scale->gimage = gdisp->gimage; image_scale->resize = resize_widget_new (ScaleWidget, gdisp->gimage->width, gdisp->gimage->height); /* the dialog */ @@ -1052,7 +1052,7 @@ image_resize_callback (GtkWidget *w, GImage *gimage; image_resize = (ImageResize *) client_data; - if ((gimage = gimage_get_ID (image_resize->gimage_id)) != NULL) + if ((gimage = image_resize->gimage) != NULL) { if (image_resize->resize->width > 0 && image_resize->resize->height > 0) @@ -1084,7 +1084,7 @@ image_scale_callback (GtkWidget *w, GImage *gimage; image_scale = (ImageResize *) client_data; - if ((gimage = gimage_get_ID (image_scale->gimage_id)) != NULL) + if ((gimage = image_scale->gimage) != NULL) { if (image_scale->resize->width > 0 && image_scale->resize->height > 0) diff --git a/app/actions/plug-in-commands.c b/app/actions/plug-in-commands.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/actions/plug-in-commands.c +++ b/app/actions/plug-in-commands.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/blend.c b/app/blend.c index 2e3463fd1b..73cd0077be 100644 --- a/app/blend.c +++ b/app/blend.c @@ -602,7 +602,7 @@ blend_button_release (Tool *tool, { return_vals = procedural_db_run_proc ("gimp_blend", &nreturn_vals, - PDB_IMAGE, gimage->ID, + PDB_IMAGE, pdb_image_to_id(gimage), PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gimage)), PDB_INT32, (gint32) blend_options->blend_mode, PDB_INT32, (gint32) blend_options->paint_mode, diff --git a/app/bucket_fill.c b/app/bucket_fill.c index c2c9eeecf2..09b46b3e1d 100644 --- a/app/bucket_fill.c +++ b/app/bucket_fill.c @@ -313,7 +313,8 @@ bucket_fill_button_release (tool, bevent, gdisp_ptr) return_vals = procedural_db_run_proc ("gimp_bucket_fill", &nreturn_vals, - PDB_IMAGE, gdisp->gimage->ID, + PDB_IMAGE, + pdb_image_to_id(gdisp->gimage), PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gdisp->gimage)), PDB_INT32, (gint32) fill_mode, PDB_INT32, (gint32) bucket_options->paint_mode, diff --git a/app/channel.h b/app/channel.h index ef1c381d88..c13b31677a 100644 --- a/app/channel.h +++ b/app/channel.h @@ -122,7 +122,6 @@ void channel_invalidate_bounds (Channel *); extern int channel_get_count; -/* from drawable.c */ -Channel * drawable_channel (GimpDrawable *); +#define drawable_channel GIMP_IS_CHANNEL #endif /* __CHANNEL_H__ */ diff --git a/app/clone.c b/app/clone.c index 9fecd23555..c43438fc35 100644 --- a/app/clone.c +++ b/app/clone.c @@ -72,7 +72,7 @@ static int offset_x = 0; /* */ static int offset_y = 0; /* offset for cloning */ static int first = TRUE; static int trans_tx, trans_ty; /* transformed target */ -static int src_gdisp_ID = -1; /* ID of source gdisplay */ +static GDisplay* the_src_gdisp = NULL; /* ID of source gdisplay */ static GimpDrawable * src_drawable_ = NULL; /* source drawable */ static CloneOptions *clone_options = NULL; @@ -217,7 +217,7 @@ clone_paint_func (PaintCore *paint_core, case INIT_PAINT : if (paint_core->state & ControlMask) { - src_gdisp_ID = gdisp->ID; + the_src_gdisp = gdisp; src_drawable_ = drawable; src_x = paint_core->curx; src_y = paint_core->cury; @@ -241,11 +241,11 @@ clone_paint_func (PaintCore *paint_core, } /* Calculate the coordinates of the target */ - src_gdisp = gdisplay_get_ID (src_gdisp_ID); + src_gdisp = the_src_gdisp; if (!src_gdisp) { - src_gdisp_ID = gdisp->ID; - src_gdisp = gdisplay_get_ID (src_gdisp_ID); + the_src_gdisp = gdisp; + src_gdisp = the_src_gdisp; } /* Find the target cursor's location onscreen */ diff --git a/app/commands.c b/app/commands.c index b3175afbb3..1b900a633b 100644 --- a/app/commands.c +++ b/app/commands.c @@ -70,7 +70,7 @@ typedef struct { GtkWidget * shell; Resize * resize; - int gimage_id; + GimpImage* gimage; } ImageResize; /* external functions */ @@ -724,7 +724,7 @@ image_resize_cmd_callback (GtkWidget *widget, /* the ImageResize structure */ image_resize = (ImageResize *) g_malloc (sizeof (ImageResize)); - image_resize->gimage_id = gdisp->gimage->ID; + image_resize->gimage = gdisp->gimage; image_resize->resize = resize_widget_new (ResizeWidget, gdisp->gimage->width, gdisp->gimage->height); /* the dialog */ @@ -771,7 +771,7 @@ image_scale_cmd_callback (GtkWidget *widget, /* the ImageResize structure */ image_scale = (ImageResize *) g_malloc (sizeof (ImageResize)); - image_scale->gimage_id = gdisp->gimage->ID; + image_scale->gimage = gdisp->gimage; image_scale->resize = resize_widget_new (ScaleWidget, gdisp->gimage->width, gdisp->gimage->height); /* the dialog */ @@ -1052,7 +1052,7 @@ image_resize_callback (GtkWidget *w, GImage *gimage; image_resize = (ImageResize *) client_data; - if ((gimage = gimage_get_ID (image_resize->gimage_id)) != NULL) + if ((gimage = image_resize->gimage) != NULL) { if (image_resize->resize->width > 0 && image_resize->resize->height > 0) @@ -1084,7 +1084,7 @@ image_scale_callback (GtkWidget *w, GImage *gimage; image_scale = (ImageResize *) client_data; - if ((gimage = gimage_get_ID (image_scale->gimage_id)) != NULL) + if ((gimage = image_scale->gimage) != NULL) { if (image_scale->resize->width > 0 && image_scale->resize->height > 0) diff --git a/app/core/gimpchannel-combine.h b/app/core/gimpchannel-combine.h index ef1c381d88..c13b31677a 100644 --- a/app/core/gimpchannel-combine.h +++ b/app/core/gimpchannel-combine.h @@ -122,7 +122,6 @@ void channel_invalidate_bounds (Channel *); extern int channel_get_count; -/* from drawable.c */ -Channel * drawable_channel (GimpDrawable *); +#define drawable_channel GIMP_IS_CHANNEL #endif /* __CHANNEL_H__ */ diff --git a/app/core/gimpchannel.h b/app/core/gimpchannel.h index ef1c381d88..c13b31677a 100644 --- a/app/core/gimpchannel.h +++ b/app/core/gimpchannel.h @@ -122,7 +122,6 @@ void channel_invalidate_bounds (Channel *); extern int channel_get_count; -/* from drawable.c */ -Channel * drawable_channel (GimpDrawable *); +#define drawable_channel GIMP_IS_CHANNEL #endif /* __CHANNEL_H__ */ diff --git a/app/core/gimpdrawable-blend.c b/app/core/gimpdrawable-blend.c index 2e3463fd1b..73cd0077be 100644 --- a/app/core/gimpdrawable-blend.c +++ b/app/core/gimpdrawable-blend.c @@ -602,7 +602,7 @@ blend_button_release (Tool *tool, { return_vals = procedural_db_run_proc ("gimp_blend", &nreturn_vals, - PDB_IMAGE, gimage->ID, + PDB_IMAGE, pdb_image_to_id(gimage), PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gimage)), PDB_INT32, (gint32) blend_options->blend_mode, PDB_INT32, (gint32) blend_options->paint_mode, diff --git a/app/core/gimpdrawable-invert.c b/app/core/gimpdrawable-invert.c index 82db12a1c7..3455bb3564 100644 --- a/app/core/gimpdrawable-invert.c +++ b/app/core/gimpdrawable-invert.c @@ -48,7 +48,7 @@ image_invert (gimage_ptr) return_vals = procedural_db_run_proc ("gimp_invert", &nreturn_vals, - PDB_IMAGE, gimage->ID, + PDB_IMAGE, pdb_image_to_id(gimage), PDB_DRAWABLE, drawable_ID (drawable), PDB_END); diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c new file mode 100644 index 0000000000..5bdfc29fb8 --- /dev/null +++ b/app/core/gimpdrawable.c @@ -0,0 +1,543 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "gimpdrawableP.h" +#include "gimpsignal.h" +#include "gimage.h" +#include "gimage_mask.h" +#include "undo.h" + + +enum { + INVALIDATE_PREVIEW, + LAST_SIGNAL +}; + + +static void gimp_drawable_class_init (GimpDrawableClass *klass); +static void gimp_drawable_init (GimpDrawable *drawable); +static void gimp_drawable_destroy (GtkObject *object); + +static guint gimp_drawable_signals[LAST_SIGNAL] = { 0 }; + +static GimpDrawableClass *parent_class = NULL; + + +GtkType +gimp_drawable_get_type () +{ + static GtkType type; + GIMP_TYPE_INIT(type, + GimpDrawable, + GimpDrawableClass, + gimp_drawable_init, + gimp_drawable_class_init, + GIMP_TYPE_OBJECT); + return type; +} + +static void +gimp_drawable_class_init (GimpDrawableClass *class) +{ + GtkObjectClass *object_class; + GtkType type=GIMP_TYPE_DRAWABLE; + object_class = GTK_OBJECT_CLASS(class); + parent_class = gtk_type_class (GIMP_TYPE_OBJECT); + + gimp_drawable_signals[INVALIDATE_PREVIEW] = + gimp_signal_new ("invalidate_pr", GTK_RUN_LAST, type, + GTK_SIGNAL_OFFSET(GimpDrawableClass, + invalidate_preview), + gimp_sigtype_void); + + gtk_object_class_add_signals (object_class, gimp_drawable_signals, LAST_SIGNAL); + + object_class->destroy = gimp_drawable_destroy; +} + + +/* + * Static variables + */ +int global_drawable_ID = 1; +static GHashTable *gimp_drawable_table = NULL; + +/**************************/ +/* Function definitions */ + +GimpDrawable* +gimp_drawable_get_ID (int drawable_id) +{ + if (gimp_drawable_table == NULL) + return NULL; + + return (GimpDrawable*) g_hash_table_lookup (gimp_drawable_table, + (gpointer) drawable_id); +} + +void +gimp_drawable_apply_image (GimpDrawable *drawable, + int x1, int y1, int x2, int y2, + TileManager *tiles, int sparse) +{ + if (drawable) + { + if (! tiles) + undo_push_image (drawable->gimage, drawable, + x1, y1, x2, y2); + else + undo_push_image_mod (drawable->gimage, drawable, + x1, y1, x2, y2, tiles, sparse); + } +} + + +void +gimp_drawable_merge_shadow (GimpDrawable *drawable, int undo) +{ + GImage *gimage; + PixelRegion shadowPR; + int x1, y1, x2, y2; + + if (! drawable) + return; + + if (! (gimage = gimp_drawable_gimage (drawable))) + return; + + /* A useful optimization here is to limit the update to the + * extents of the selection mask, as it cannot extend beyond + * them. + */ + gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + pixel_region_init (&shadowPR, gimage->shadow, x1, y1, + (x2 - x1), (y2 - y1), FALSE); + gimage_apply_image (gimage, drawable, &shadowPR, undo, OPAQUE_OPACITY, + REPLACE_MODE, NULL, x1, y1); +} + + +void +gimp_drawable_fill (GimpDrawable *drawable, guchar r, guchar g, + guchar b, guchar a) +{ + GImage *gimage; + PixelRegion destPR; + guchar c[MAX_CHANNELS]; + guchar i; + + + g_assert(GIMP_IS_DRAWABLE(drawable)); + gimage=gimp_drawable_gimage(drawable); + g_assert(gimage); + + switch (gimp_drawable_type (drawable)) + { + case RGB_GIMAGE: case RGBA_GIMAGE: + c[RED_PIX] = r; + c[GREEN_PIX] = g; + c[BLUE_PIX] = b; + if (gimp_drawable_type (drawable) == RGBA_GIMAGE) + c[ALPHA_PIX] = a; + break; + case GRAY_GIMAGE: case GRAYA_GIMAGE: + c[GRAY_PIX] = r; + if (gimp_drawable_type (drawable) == GRAYA_GIMAGE) + c[ALPHA_G_PIX] = a; + break; + case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: + c[RED_PIX] = r; + c[GREEN_PIX] = g; + c[BLUE_PIX] = b; + gimage_transform_color (gimage, drawable, c, &i, RGB); + c[INDEXED_PIX] = i; + if (gimp_drawable_type (drawable) == INDEXEDA_GIMAGE) + c[ALPHA_I_PIX] = a; + break; + default: + g_message ("Can't fill unknown image type."); + break; + } + + pixel_region_init (&destPR, + gimp_drawable_data (drawable), + 0, 0, + gimp_drawable_width (drawable), + gimp_drawable_height (drawable), + TRUE); + color_region (&destPR, c); + +} + + +int +gimp_drawable_mask_bounds (GimpDrawable *drawable, + int *x1, int *y1, int *x2, int *y2) +{ + GImage *gimage; + int off_x, off_y; + + if (! drawable) + return FALSE; + + if (! (gimage = gimp_drawable_gimage (drawable))) + return FALSE; + + if (gimage_mask_bounds (gimage, x1, y1, x2, y2)) + { + gimp_drawable_offsets (drawable, &off_x, &off_y); + *x1 = CLAMP (*x1 - off_x, 0, gimp_drawable_width (drawable)); + *y1 = CLAMP (*y1 - off_y, 0, gimp_drawable_height (drawable)); + *x2 = CLAMP (*x2 - off_x, 0, gimp_drawable_width (drawable)); + *y2 = CLAMP (*y2 - off_y, 0, gimp_drawable_height (drawable)); + return TRUE; + } + else + { + *x2 = gimp_drawable_width (drawable); + *y2 = gimp_drawable_height (drawable); + return FALSE; + } +} + + +void +gimp_drawable_invalidate_preview (GimpDrawable *drawable) +{ + GImage *gimage; + + if (! drawable) + return; + + drawable->preview_valid = FALSE; +#if 0 + gtk_signal_emit (GTK_OBJECT(drawable), gimp_drawable_signals[INVALIDATE_PREVIEW]); +#endif + gimage = gimp_drawable_gimage (drawable); + if (gimage) + { + gimage->comp_preview_valid[0] = FALSE; + gimage->comp_preview_valid[1] = FALSE; + gimage->comp_preview_valid[2] = FALSE; + } +} + + +int +gimp_drawable_dirty (GimpDrawable *drawable) +{ + if (drawable) + return drawable->dirty = (drawable->dirty < 0) ? 2 : drawable->dirty + 1; + else + return 0; +} + + +int +gimp_drawable_clean (GimpDrawable *drawable) +{ + if (drawable) + return drawable->dirty = (drawable->dirty <= 0) ? 0 : drawable->dirty - 1; + else + return 0; +} + + +GimpImage * +gimp_drawable_gimage (GimpDrawable *drawable) +{ + g_assert(GIMP_IS_DRAWABLE(drawable)); + + return drawable->gimage; +} + + +int +gimp_drawable_type (GimpDrawable *drawable) +{ + if (drawable) + return drawable->type; + else + return -1; +} + +int +gimp_drawable_has_alpha (GimpDrawable *drawable) +{ + if (drawable) + return drawable->has_alpha; + else + return FALSE; +} + + +int +gimp_drawable_visible (GimpDrawable *drawable) +{ + return drawable->visible; +} + +char * +gimp_drawable_name (GimpDrawable *drawable) +{ + return drawable->name; +} + +int +gimp_drawable_type_with_alpha (GimpDrawable *drawable) +{ + int type = gimp_drawable_type (drawable); + int has_alpha = gimp_drawable_has_alpha (drawable); + + if (has_alpha) + return type; + else + switch (type) + { + case RGB_GIMAGE: + return RGBA_GIMAGE; break; + case GRAY_GIMAGE: + return GRAYA_GIMAGE; break; + case INDEXED_GIMAGE: + return INDEXEDA_GIMAGE; break; + } + return 0; +} + + +int +gimp_drawable_color (GimpDrawable *drawable) +{ + if (gimp_drawable_type (drawable) == RGBA_GIMAGE || + gimp_drawable_type (drawable) == RGB_GIMAGE) + return 1; + else + return 0; +} + + +int +gimp_drawable_gray (GimpDrawable *drawable) +{ + if (gimp_drawable_type (drawable) == GRAYA_GIMAGE || + gimp_drawable_type (drawable) == GRAY_GIMAGE) + return 1; + else + return 0; +} + + +int +gimp_drawable_indexed (GimpDrawable *drawable) +{ + if (gimp_drawable_type (drawable) == INDEXEDA_GIMAGE || + gimp_drawable_type (drawable) == INDEXED_GIMAGE) + return 1; + else + return 0; +} + + +TileManager * +gimp_drawable_data (GimpDrawable *drawable) +{ + if (drawable) + return drawable->tiles; + else + return NULL; +} + + +TileManager * +gimp_drawable_shadow (GimpDrawable *drawable) +{ + GImage *gimage; + + if (! (gimage = gimp_drawable_gimage (drawable))) + return NULL; + + if (drawable) + return gimage_shadow (gimage, drawable->width, drawable->height, + drawable->bytes); + else + return NULL; +} + + +int +gimp_drawable_bytes (GimpDrawable *drawable) +{ + if (drawable) + return drawable->bytes; + else + return -1; +} + + +int +gimp_drawable_width (GimpDrawable *drawable) +{ + if (drawable) + return drawable->width; + else + return -1; +} + + +int +gimp_drawable_height (GimpDrawable *drawable) +{ + if (drawable) + return drawable->height; + else + return -1; +} + + +void +gimp_drawable_offsets (GimpDrawable *drawable, int *off_x, int *off_y) +{ + if (drawable) + { + *off_x = drawable->offset_x; + *off_y = drawable->offset_y; + } + else + *off_x = *off_y = 0; +} + +unsigned char * +gimp_drawable_cmap (GimpDrawable *drawable) +{ + GImage *gimage; + + if ((gimage = gimp_drawable_gimage (drawable))) + return gimage->cmap; + else + return NULL; +} + + +void +gimp_drawable_deallocate (GimpDrawable *drawable) +{ + if (drawable->tiles) + tile_manager_destroy (drawable->tiles); +} + +static void +gimp_drawable_init (GimpDrawable *drawable) +{ + drawable->name = NULL; + drawable->tiles = NULL; + drawable->visible = FALSE; + drawable->width = drawable->height = 0; + drawable->offset_x = drawable->offset_y = 0; + drawable->bytes = 0; + drawable->dirty = FALSE; + drawable->gimage = NULL; + drawable->type = -1; + drawable->has_alpha = FALSE; + drawable->preview = NULL; + drawable->preview_valid = FALSE; + + drawable->ID = global_drawable_ID++; + if (gimp_drawable_table == NULL) + gimp_drawable_table = g_hash_table_new (g_direct_hash, NULL); + g_hash_table_insert (gimp_drawable_table, (gpointer) drawable->ID, + (gpointer) drawable); +} + +static void +gimp_drawable_destroy (GtkObject *object) +{ + GimpDrawable *drawable; + g_return_if_fail (object != NULL); + g_return_if_fail (GIMP_IS_DRAWABLE (object)); + + drawable = GIMP_DRAWABLE (object); + + g_hash_table_remove (gimp_drawable_table, (gpointer) drawable->ID); + + if (drawable->name) + g_free (drawable->name); + + if (drawable->tiles) + tile_manager_destroy (drawable->tiles); + + if (drawable->preview) + temp_buf_free (drawable->preview); + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (*GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + +void +gimp_drawable_configure (GimpDrawable *drawable, + GimpImage* gimage, int width, int height, + int type, char *name) +{ + int bpp; + int alpha; + + if (!name) + name = "unnamed"; + + switch (type) + { + case RGB_GIMAGE: + bpp = 3; alpha = 0; break; + case GRAY_GIMAGE: + bpp = 1; alpha = 0; break; + case RGBA_GIMAGE: + bpp = 4; alpha = 1; break; + case GRAYA_GIMAGE: + bpp = 2; alpha = 1; break; + case INDEXED_GIMAGE: + bpp = 1; alpha = 0; break; + case INDEXEDA_GIMAGE: + bpp = 2; alpha = 1; break; + default: + g_message ("Layer type %d not supported.", type); + return; + } + + if (drawable->name) + g_free (drawable->name); + drawable->name = g_strdup(name); + drawable->width = width; + drawable->height = height; + drawable->bytes = bpp; + drawable->type = type; + drawable->has_alpha = alpha; + drawable->offset_x = 0; + drawable->offset_y = 0; + + if (drawable->tiles) + tile_manager_destroy (drawable->tiles); + drawable->tiles = tile_manager_new (width, height, bpp); + drawable->dirty = FALSE; + drawable->visible = TRUE; + + drawable->gimage = gimage; + + /* preview variables */ + drawable->preview = NULL; + drawable->preview_valid = FALSE; +} + diff --git a/app/core/gimpdrawable.h b/app/core/gimpdrawable.h new file mode 100644 index 0000000000..65404ecc4f --- /dev/null +++ b/app/core/gimpdrawable.h @@ -0,0 +1,75 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef __GIMPDRAWABLE_H__ +#define __GIMPDRAWABLE_H__ + +#include "gimpobject.h" +#include "gimpdrawableF.h" +#include "tile_manager.h" +#include "temp_buf.h" +#include "gimpimageF.h" + +#define GIMP_TYPE_DRAWABLE (gimp_drawable_get_type ()) +#define GIMP_DRAWABLE(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE, GimpDrawable)) +#define GIMP_IS_DRAWABLE(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE)) + +GtkType gimp_drawable_get_type (void); + +typedef enum +{ + BACKGROUND_FILL, + WHITE_FILL, + TRANSPARENT_FILL, + NO_FILL +} GimpFillType; + + +/* drawable access functions */ +void gimp_drawable_apply_image (GimpDrawable *, + int, int, int, int, + TileManager *, int); +void gimp_drawable_merge_shadow (GimpDrawable *, int); +void gimp_drawable_fill (GimpDrawable *drawable, guchar r, guchar g, + guchar b, guchar a); + +int gimp_drawable_mask_bounds (GimpDrawable *, + int *, int *, int *, int *); +void gimp_drawable_invalidate_preview (GimpDrawable *); +int gimp_drawable_dirty (GimpDrawable *); +int gimp_drawable_clean (GimpDrawable *); +int gimp_drawable_type (GimpDrawable *); +int gimp_drawable_has_alpha (GimpDrawable *); +int gimp_drawable_type_with_alpha (GimpDrawable *); +int gimp_drawable_color (GimpDrawable *); +int gimp_drawable_gray (GimpDrawable *); +int gimp_drawable_indexed (GimpDrawable *); +TileManager * gimp_drawable_data (GimpDrawable *); +TileManager * gimp_drawable_shadow (GimpDrawable *); +int gimp_drawable_bytes (GimpDrawable *); +int gimp_drawable_width (GimpDrawable *); +int gimp_drawable_height (GimpDrawable *); +int gimp_drawable_visible (GimpDrawable *); +void gimp_drawable_offsets (GimpDrawable *, int *, int *); +unsigned char * gimp_drawable_cmap (GimpDrawable *); +char * gimp_drawable_name (GimpDrawable *); + +GimpDrawable * gimp_drawable_get_ID (int); +void gimp_drawable_deallocate (GimpDrawable *); +GimpImage * gimp_drawable_gimage (GimpDrawable*); + +#endif /* __GIMPDRAWABLE_H__ */ diff --git a/app/core/gimpimage-guides.c b/app/core/gimpimage-guides.c index a7b18a4787..1c8372545a 100644 --- a/app/core/gimpimage-guides.c +++ b/app/core/gimpimage-guides.c @@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int * /* If the drawable is a channel (a saved selection, etc.) * make sure that the alpha channel is not valid */ - if (drawable_channel (drawable) != NULL) + if (GIMP_IS_CHANNEL (drawable)) active[ALPHA_G_PIX] = 0; /* no alpha values in channels */ else { /* otherwise, check whether preserve transparency is * enabled in the layer and if the layer has alpha */ - if ((layer = drawable_layer (drawable))) - if (layer_has_alpha (layer) && layer->preserve_trans) - active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0; + if (GIMP_IS_LAYER (drawable)){ + layer=GIMP_LAYER(drawable); + if (layer_has_alpha (layer) && layer->preserve_trans) + active[drawable_bytes (drawable) - 1] = 0; + } } } diff --git a/app/core/gimpimage-guides.h b/app/core/gimpimage-guides.h index 7f1b9dd716..b61966a6dd 100644 --- a/app/core/gimpimage-guides.h +++ b/app/core/gimpimage-guides.h @@ -50,14 +50,6 @@ typedef enum } GimpImageBaseType; - - -/* the image fill types */ -#define BACKGROUND_FILL 0 -#define WHITE_FILL 1 -#define TRANSPARENT_FILL 2 -#define NO_FILL 3 - #define COLORMAP_SIZE 768 #define HORIZONTAL_GUIDE 1 @@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *); void gimp_image_invalidate_previews (void); -/* from drawable.c */ -/* Ugly! */ -GimpImage * drawable_gimage (GimpDrawable*); #endif diff --git a/app/core/gimpimage-mask.c b/app/core/gimpimage-mask.c index c09546bb11..ba7d6ff460 100644 --- a/app/core/gimpimage-mask.c +++ b/app/core/gimpimage-mask.c @@ -297,8 +297,8 @@ gimage_mask_extract (gimage, drawable, cut_gimage, keep_indexed) */ if (cut_gimage && drawable_layer (drawable)) { - if (layer_is_floating_sel (drawable_layer (drawable))) - floating_sel_remove (drawable_layer (drawable)); + if (layer_is_floating_sel (GIMP_LAYER (drawable))) + floating_sel_remove (GIMP_LAYER (drawable)); else gimage_remove_layer (gimage, GIMP_LAYER (drawable)); } diff --git a/app/core/gimpimage-merge.c b/app/core/gimpimage-merge.c index a7b18a4787..1c8372545a 100644 --- a/app/core/gimpimage-merge.c +++ b/app/core/gimpimage-merge.c @@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int * /* If the drawable is a channel (a saved selection, etc.) * make sure that the alpha channel is not valid */ - if (drawable_channel (drawable) != NULL) + if (GIMP_IS_CHANNEL (drawable)) active[ALPHA_G_PIX] = 0; /* no alpha values in channels */ else { /* otherwise, check whether preserve transparency is * enabled in the layer and if the layer has alpha */ - if ((layer = drawable_layer (drawable))) - if (layer_has_alpha (layer) && layer->preserve_trans) - active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0; + if (GIMP_IS_LAYER (drawable)){ + layer=GIMP_LAYER(drawable); + if (layer_has_alpha (layer) && layer->preserve_trans) + active[drawable_bytes (drawable) - 1] = 0; + } } } diff --git a/app/core/gimpimage-merge.h b/app/core/gimpimage-merge.h index 7f1b9dd716..b61966a6dd 100644 --- a/app/core/gimpimage-merge.h +++ b/app/core/gimpimage-merge.h @@ -50,14 +50,6 @@ typedef enum } GimpImageBaseType; - - -/* the image fill types */ -#define BACKGROUND_FILL 0 -#define WHITE_FILL 1 -#define TRANSPARENT_FILL 2 -#define NO_FILL 3 - #define COLORMAP_SIZE 768 #define HORIZONTAL_GUIDE 1 @@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *); void gimp_image_invalidate_previews (void); -/* from drawable.c */ -/* Ugly! */ -GimpImage * drawable_gimage (GimpDrawable*); #endif diff --git a/app/core/gimpimage-projection.c b/app/core/gimpimage-projection.c index a7b18a4787..1c8372545a 100644 --- a/app/core/gimpimage-projection.c +++ b/app/core/gimpimage-projection.c @@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int * /* If the drawable is a channel (a saved selection, etc.) * make sure that the alpha channel is not valid */ - if (drawable_channel (drawable) != NULL) + if (GIMP_IS_CHANNEL (drawable)) active[ALPHA_G_PIX] = 0; /* no alpha values in channels */ else { /* otherwise, check whether preserve transparency is * enabled in the layer and if the layer has alpha */ - if ((layer = drawable_layer (drawable))) - if (layer_has_alpha (layer) && layer->preserve_trans) - active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0; + if (GIMP_IS_LAYER (drawable)){ + layer=GIMP_LAYER(drawable); + if (layer_has_alpha (layer) && layer->preserve_trans) + active[drawable_bytes (drawable) - 1] = 0; + } } } diff --git a/app/core/gimpimage-projection.h b/app/core/gimpimage-projection.h index 7f1b9dd716..b61966a6dd 100644 --- a/app/core/gimpimage-projection.h +++ b/app/core/gimpimage-projection.h @@ -50,14 +50,6 @@ typedef enum } GimpImageBaseType; - - -/* the image fill types */ -#define BACKGROUND_FILL 0 -#define WHITE_FILL 1 -#define TRANSPARENT_FILL 2 -#define NO_FILL 3 - #define COLORMAP_SIZE 768 #define HORIZONTAL_GUIDE 1 @@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *); void gimp_image_invalidate_previews (void); -/* from drawable.c */ -/* Ugly! */ -GimpImage * drawable_gimage (GimpDrawable*); #endif diff --git a/app/core/gimpimage-resize.c b/app/core/gimpimage-resize.c index a7b18a4787..1c8372545a 100644 --- a/app/core/gimpimage-resize.c +++ b/app/core/gimpimage-resize.c @@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int * /* If the drawable is a channel (a saved selection, etc.) * make sure that the alpha channel is not valid */ - if (drawable_channel (drawable) != NULL) + if (GIMP_IS_CHANNEL (drawable)) active[ALPHA_G_PIX] = 0; /* no alpha values in channels */ else { /* otherwise, check whether preserve transparency is * enabled in the layer and if the layer has alpha */ - if ((layer = drawable_layer (drawable))) - if (layer_has_alpha (layer) && layer->preserve_trans) - active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0; + if (GIMP_IS_LAYER (drawable)){ + layer=GIMP_LAYER(drawable); + if (layer_has_alpha (layer) && layer->preserve_trans) + active[drawable_bytes (drawable) - 1] = 0; + } } } diff --git a/app/core/gimpimage-resize.h b/app/core/gimpimage-resize.h index 7f1b9dd716..b61966a6dd 100644 --- a/app/core/gimpimage-resize.h +++ b/app/core/gimpimage-resize.h @@ -50,14 +50,6 @@ typedef enum } GimpImageBaseType; - - -/* the image fill types */ -#define BACKGROUND_FILL 0 -#define WHITE_FILL 1 -#define TRANSPARENT_FILL 2 -#define NO_FILL 3 - #define COLORMAP_SIZE 768 #define HORIZONTAL_GUIDE 1 @@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *); void gimp_image_invalidate_previews (void); -/* from drawable.c */ -/* Ugly! */ -GimpImage * drawable_gimage (GimpDrawable*); #endif diff --git a/app/core/gimpimage-scale.c b/app/core/gimpimage-scale.c index a7b18a4787..1c8372545a 100644 --- a/app/core/gimpimage-scale.c +++ b/app/core/gimpimage-scale.c @@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int * /* If the drawable is a channel (a saved selection, etc.) * make sure that the alpha channel is not valid */ - if (drawable_channel (drawable) != NULL) + if (GIMP_IS_CHANNEL (drawable)) active[ALPHA_G_PIX] = 0; /* no alpha values in channels */ else { /* otherwise, check whether preserve transparency is * enabled in the layer and if the layer has alpha */ - if ((layer = drawable_layer (drawable))) - if (layer_has_alpha (layer) && layer->preserve_trans) - active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0; + if (GIMP_IS_LAYER (drawable)){ + layer=GIMP_LAYER(drawable); + if (layer_has_alpha (layer) && layer->preserve_trans) + active[drawable_bytes (drawable) - 1] = 0; + } } } diff --git a/app/core/gimpimage-scale.h b/app/core/gimpimage-scale.h index 7f1b9dd716..b61966a6dd 100644 --- a/app/core/gimpimage-scale.h +++ b/app/core/gimpimage-scale.h @@ -50,14 +50,6 @@ typedef enum } GimpImageBaseType; - - -/* the image fill types */ -#define BACKGROUND_FILL 0 -#define WHITE_FILL 1 -#define TRANSPARENT_FILL 2 -#define NO_FILL 3 - #define COLORMAP_SIZE 768 #define HORIZONTAL_GUIDE 1 @@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *); void gimp_image_invalidate_previews (void); -/* from drawable.c */ -/* Ugly! */ -GimpImage * drawable_gimage (GimpDrawable*); #endif diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index a7b18a4787..1c8372545a 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int * /* If the drawable is a channel (a saved selection, etc.) * make sure that the alpha channel is not valid */ - if (drawable_channel (drawable) != NULL) + if (GIMP_IS_CHANNEL (drawable)) active[ALPHA_G_PIX] = 0; /* no alpha values in channels */ else { /* otherwise, check whether preserve transparency is * enabled in the layer and if the layer has alpha */ - if ((layer = drawable_layer (drawable))) - if (layer_has_alpha (layer) && layer->preserve_trans) - active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0; + if (GIMP_IS_LAYER (drawable)){ + layer=GIMP_LAYER(drawable); + if (layer_has_alpha (layer) && layer->preserve_trans) + active[drawable_bytes (drawable) - 1] = 0; + } } } diff --git a/app/core/gimpimage.h b/app/core/gimpimage.h index 7f1b9dd716..b61966a6dd 100644 --- a/app/core/gimpimage.h +++ b/app/core/gimpimage.h @@ -50,14 +50,6 @@ typedef enum } GimpImageBaseType; - - -/* the image fill types */ -#define BACKGROUND_FILL 0 -#define WHITE_FILL 1 -#define TRANSPARENT_FILL 2 -#define NO_FILL 3 - #define COLORMAP_SIZE 768 #define HORIZONTAL_GUIDE 1 @@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *); void gimp_image_invalidate_previews (void); -/* from drawable.c */ -/* Ugly! */ -GimpImage * drawable_gimage (GimpDrawable*); #endif diff --git a/app/core/gimplayer-floating-sel.c b/app/core/gimplayer-floating-sel.c index a56e112b24..3aad02051c 100644 --- a/app/core/gimplayer-floating-sel.c +++ b/app/core/gimplayer-floating-sel.c @@ -131,7 +131,6 @@ floating_sel_reset (layer) Layer *layer; { GImage *gimage; - LayerMask *lm; if (! (gimage = drawable_gimage (GIMP_DRAWABLE(layer)))) return; @@ -139,8 +138,10 @@ floating_sel_reset (layer) /* set the underlying drawable to active */ if (drawable_layer ( (layer->fs.drawable))) gimage_set_active_layer (gimage, GIMP_LAYER (layer->fs.drawable)); - else if ((lm = drawable_layer_mask ( (layer->fs.drawable)))) - gimage_set_active_layer (gimage, lm->layer); + else if (GIMP_IS_LAYER_MASK(layer->fs.drawable)) + gimage_set_active_layer (gimage, + GIMP_LAYER_MASK(layer->fs.drawable) + ->layer); else if (drawable_channel ( (layer->fs.drawable))) { gimage_set_active_channel (gimage, GIMP_CHANNEL(layer->fs.drawable)); diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c index 27aae01f4e..68ac3c0eec 100644 --- a/app/core/gimplayer.c +++ b/app/core/gimplayer.c @@ -655,10 +655,8 @@ layer_add_alpha (layer) GIMP_DRAWABLE(layer)->bytes = GIMP_DRAWABLE(layer)->bytes + 1; GIMP_DRAWABLE(layer)->has_alpha = TYPE_HAS_ALPHA (type); - /* update gdisplay titles to reflect the possibility of - * this layer being the only layer in the gimage - */ - gdisplays_update_title (GIMP_DRAWABLE(layer)->gimage); + gtk_signal_emit_by_name(GTK_OBJECT(gimp_drawable_gimage(GIMP_DRAWABLE(layer))), + "restructure"); } @@ -893,7 +891,7 @@ layer_invalidate_boundary (layer) Channel *mask; /* first get the selection mask channel */ - if (! (gimage = GIMP_DRAWABLE(layer)->gimage)) + if (! (gimage = drawable_gimage(GIMP_DRAWABLE(layer)))) return; /* Turn the current selection off */ @@ -909,7 +907,8 @@ layer_invalidate_boundary (layer) } /* clear the affected region surrounding the layer */ - gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage, SelectionLayerOff); + /* gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage, + SelectionLayerOff); */ } diff --git a/app/core/gimplayer.h b/app/core/gimplayer.h index bf2774ac84..0217806491 100644 --- a/app/core/gimplayer.h +++ b/app/core/gimplayer.h @@ -138,9 +138,11 @@ TempBuf * layer_mask_preview (Layer *, int, int); void layer_invalidate_previews (GimpImage*); -/* from drawable.c */ -Layer * drawable_layer (GimpDrawable *); -LayerMask * drawable_layer_mask (GimpDrawable *); +/* temp thingies.. dynamic downcast. GTK_NO_CHECK_CASTS must not be + defined */ + +#define drawable_layer GIMP_IS_LAYER +#define drawable_layer_mask GIMP_IS_LAYER_MASK /* from channel.c */ void channel_layer_alpha (Channel *, Layer *); diff --git a/app/core/gimpobject.h b/app/core/gimpobject.h index 35ac815878..a496fdef32 100644 --- a/app/core/gimpobject.h +++ b/app/core/gimpobject.h @@ -4,7 +4,6 @@ #include #include "gimpobjectF.h" - #define GIMP_TYPE_OBJECT gimp_object_get_type() #define GIMP_OBJECT(obj) GTK_CHECK_CAST (obj, GIMP_TYPE_OBJECT, GimpObject) diff --git a/app/core/gimpprojection-construct.c b/app/core/gimpprojection-construct.c index a7b18a4787..1c8372545a 100644 --- a/app/core/gimpprojection-construct.c +++ b/app/core/gimpprojection-construct.c @@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int * /* If the drawable is a channel (a saved selection, etc.) * make sure that the alpha channel is not valid */ - if (drawable_channel (drawable) != NULL) + if (GIMP_IS_CHANNEL (drawable)) active[ALPHA_G_PIX] = 0; /* no alpha values in channels */ else { /* otherwise, check whether preserve transparency is * enabled in the layer and if the layer has alpha */ - if ((layer = drawable_layer (drawable))) - if (layer_has_alpha (layer) && layer->preserve_trans) - active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0; + if (GIMP_IS_LAYER (drawable)){ + layer=GIMP_LAYER(drawable); + if (layer_has_alpha (layer) && layer->preserve_trans) + active[drawable_bytes (drawable) - 1] = 0; + } } } diff --git a/app/core/gimpprojection-construct.h b/app/core/gimpprojection-construct.h index 7f1b9dd716..b61966a6dd 100644 --- a/app/core/gimpprojection-construct.h +++ b/app/core/gimpprojection-construct.h @@ -50,14 +50,6 @@ typedef enum } GimpImageBaseType; - - -/* the image fill types */ -#define BACKGROUND_FILL 0 -#define WHITE_FILL 1 -#define TRANSPARENT_FILL 2 -#define NO_FILL 3 - #define COLORMAP_SIZE 768 #define HORIZONTAL_GUIDE 1 @@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *); void gimp_image_invalidate_previews (void); -/* from drawable.c */ -/* Ugly! */ -GimpImage * drawable_gimage (GimpDrawable*); #endif diff --git a/app/core/gimpprojection.c b/app/core/gimpprojection.c index cac16d39ff..f58b3f6ed3 100644 --- a/app/core/gimpprojection.c +++ b/app/core/gimpprojection.c @@ -131,7 +131,7 @@ gdisplay_new (GimpImage *gimage, display_list = g_slist_append (display_list, (void *) gdisp); /* create the shell for the image */ - create_display_shell (gdisp->ID, gimage->width, gimage->height, + create_display_shell (gdisp, gimage->width, gimage->height, title, gimage_base_type (gimage)); /* set the gdisplay colormap type and install the appropriate colormap */ @@ -178,9 +178,9 @@ gdisplay_format_title (GimpImage *gimage, image_type_str = NULL; } - sprintf (title, "%s" "-%d" ".%d (%s)", + sprintf (title, "%s" "-%p" ".%d (%s)", prune_filename (gimage_filename (gimage)), - /*gimage->ID,*/ + gimage, gimage->instance_count, image_type_str); } @@ -201,7 +201,7 @@ gdisplay_delete (GDisplay *gdisp) if (active_tool && active_tool->gdisp_ptr) { tool_gdisp = active_tool->gdisp_ptr; - if (gdisp->ID == tool_gdisp->ID) { + if (gdisp == tool_gdisp) { active_tool->drawable = NULL; active_tool->gdisp_ptr = NULL; } @@ -1289,9 +1289,12 @@ gdisplays_update_area (GimpImage* gimage, */ gdisplay_add_update_area (gdisp, x, y, w, h); + /* Seems like this isn't needed, it's done in + gdisplay_flush. -la gdisplay_transform_coords (gdisp, x, y, &x1, &y1, 0); gdisplay_transform_coords (gdisp, x + w, y + h, &x2, &y2, 0); gdisplay_add_display_area (gdisp, x1, y1, (x2 - x1), (y2 - y1)); + */ } list = g_slist_next (list); } diff --git a/app/disp_callbacks.c b/app/disp_callbacks.c index eb239649ec..ead4584243 100644 --- a/app/disp_callbacks.c +++ b/app/disp_callbacks.c @@ -208,7 +208,7 @@ gdisplay_canvas_events (GtkWidget *canvas, /* if (active_tool->gdisp_ptr) { tool_gdisp = active_tool->gdisp_ptr; - if (tool_gdisp->ID != gdisp->ID) { + if (tool_gdisp != gdisp) { tools_initialize (active_tool->type, gdisp); active_tool->drawable = gimage_active_drawable(gdisp->gimage); } diff --git a/app/display/gimpdisplay-callbacks.c b/app/display/gimpdisplay-callbacks.c index eb239649ec..ead4584243 100644 --- a/app/display/gimpdisplay-callbacks.c +++ b/app/display/gimpdisplay-callbacks.c @@ -208,7 +208,7 @@ gdisplay_canvas_events (GtkWidget *canvas, /* if (active_tool->gdisp_ptr) { tool_gdisp = active_tool->gdisp_ptr; - if (tool_gdisp->ID != gdisp->ID) { + if (tool_gdisp != gdisp) { tools_initialize (active_tool->type, gdisp); active_tool->drawable = gimage_active_drawable(gdisp->gimage); } diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index cac16d39ff..f58b3f6ed3 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -131,7 +131,7 @@ gdisplay_new (GimpImage *gimage, display_list = g_slist_append (display_list, (void *) gdisp); /* create the shell for the image */ - create_display_shell (gdisp->ID, gimage->width, gimage->height, + create_display_shell (gdisp, gimage->width, gimage->height, title, gimage_base_type (gimage)); /* set the gdisplay colormap type and install the appropriate colormap */ @@ -178,9 +178,9 @@ gdisplay_format_title (GimpImage *gimage, image_type_str = NULL; } - sprintf (title, "%s" "-%d" ".%d (%s)", + sprintf (title, "%s" "-%p" ".%d (%s)", prune_filename (gimage_filename (gimage)), - /*gimage->ID,*/ + gimage, gimage->instance_count, image_type_str); } @@ -201,7 +201,7 @@ gdisplay_delete (GDisplay *gdisp) if (active_tool && active_tool->gdisp_ptr) { tool_gdisp = active_tool->gdisp_ptr; - if (gdisp->ID == tool_gdisp->ID) { + if (gdisp == tool_gdisp) { active_tool->drawable = NULL; active_tool->gdisp_ptr = NULL; } @@ -1289,9 +1289,12 @@ gdisplays_update_area (GimpImage* gimage, */ gdisplay_add_update_area (gdisp, x, y, w, h); + /* Seems like this isn't needed, it's done in + gdisplay_flush. -la gdisplay_transform_coords (gdisp, x, y, &x1, &y1, 0); gdisplay_transform_coords (gdisp, x + w, y + h, &x2, &y2, 0); gdisplay_add_display_area (gdisp, x1, y1, (x2 - x1), (y2 - y1)); + */ } list = g_slist_next (list); } diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index eb239649ec..ead4584243 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -208,7 +208,7 @@ gdisplay_canvas_events (GtkWidget *canvas, /* if (active_tool->gdisp_ptr) { tool_gdisp = active_tool->gdisp_ptr; - if (tool_gdisp->ID != gdisp->ID) { + if (tool_gdisp != gdisp) { tools_initialize (active_tool->type, gdisp); active_tool->drawable = gimage_active_drawable(gdisp->gimage); } diff --git a/app/display/gimpdisplayshell-draw.c b/app/display/gimpdisplayshell-draw.c index 44b733466f..ae168a9589 100644 --- a/app/display/gimpdisplayshell-draw.c +++ b/app/display/gimpdisplayshell-draw.c @@ -542,7 +542,7 @@ toolbox_raise_callback (GtkWidget *widget, void -create_display_shell (int gdisp_id, +create_display_shell (GDisplay* gdisp, int width, int height, char *title, @@ -550,7 +550,6 @@ create_display_shell (int gdisp_id, { static GtkWidget *image_popup_menu = NULL; static GtkAccelGroup *image_accel_group = NULL; - GDisplay *gdisp; GtkWidget *vbox; GtkWidget *table; GtkWidget *table_inner; @@ -561,10 +560,6 @@ create_display_shell (int gdisp_id, int scalesrc, scaledest; int contextid; - /* Get the gdisplay */ - if (! (gdisp = gdisplay_get_ID (gdisp_id))) - return; - /* adjust the initial scale -- so that window fits on screen */ { s_width = gdk_screen_width (); diff --git a/app/display/gimpdisplayshell-draw.h b/app/display/gimpdisplayshell-draw.h index f14b3dbbbc..5d1cd9301a 100644 --- a/app/display/gimpdisplayshell-draw.h +++ b/app/display/gimpdisplayshell-draw.h @@ -19,6 +19,7 @@ #define __INTERFACE_H__ #include "tools.h" +#include "gdisplay.h" /* typedefs */ typedef void (*QueryFunc) (GtkWidget *, gpointer, gpointer); @@ -34,7 +35,7 @@ GdkPixmap * create_tool_pixmap (GtkWidget *, ToolType); void create_toolbox (void); void toolbox_free (void); void toolbox_raise_callback (GtkWidget *, gpointer); -void create_display_shell (int, int, int, char *, int); +void create_display_shell (GDisplay* , int, int, char *, int); void position_dialog (GtkWidget *, gpointer, gpointer); void center_dialog (GtkWidget *, gpointer, gpointer); GtkWidget * query_string_box (char *, char *, char *, QueryFunc, gpointer); diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index 44b733466f..ae168a9589 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -542,7 +542,7 @@ toolbox_raise_callback (GtkWidget *widget, void -create_display_shell (int gdisp_id, +create_display_shell (GDisplay* gdisp, int width, int height, char *title, @@ -550,7 +550,6 @@ create_display_shell (int gdisp_id, { static GtkWidget *image_popup_menu = NULL; static GtkAccelGroup *image_accel_group = NULL; - GDisplay *gdisp; GtkWidget *vbox; GtkWidget *table; GtkWidget *table_inner; @@ -561,10 +560,6 @@ create_display_shell (int gdisp_id, int scalesrc, scaledest; int contextid; - /* Get the gdisplay */ - if (! (gdisp = gdisplay_get_ID (gdisp_id))) - return; - /* adjust the initial scale -- so that window fits on screen */ { s_width = gdk_screen_width (); diff --git a/app/display/gimpdisplayshell.h b/app/display/gimpdisplayshell.h index f14b3dbbbc..5d1cd9301a 100644 --- a/app/display/gimpdisplayshell.h +++ b/app/display/gimpdisplayshell.h @@ -19,6 +19,7 @@ #define __INTERFACE_H__ #include "tools.h" +#include "gdisplay.h" /* typedefs */ typedef void (*QueryFunc) (GtkWidget *, gpointer, gpointer); @@ -34,7 +35,7 @@ GdkPixmap * create_tool_pixmap (GtkWidget *, ToolType); void create_toolbox (void); void toolbox_free (void); void toolbox_raise_callback (GtkWidget *, gpointer); -void create_display_shell (int, int, int, char *, int); +void create_display_shell (GDisplay* , int, int, char *, int); void position_dialog (GtkWidget *, gpointer, gpointer); void center_dialog (GtkWidget *, gpointer, gpointer); GtkWidget * query_string_box (char *, char *, char *, QueryFunc, gpointer); diff --git a/app/drawable.c b/app/drawable.c index b180e35c96..7713a3f27c 100644 --- a/app/drawable.c +++ b/app/drawable.c @@ -1,3 +1,4 @@ + /* The GIMP -- an image manipulation program * Copyright (C) 1995 Spencer Kimball and Peter Mattis * @@ -15,104 +16,12 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include -#include -#include -#include -#include "appenv.h" -#include "channel.h" + #include "drawable.h" -#include "errors.h" -#include "floating_sel.h" -#include "gimage.h" -#include "gimage_mask.h" -#include "gdisplay.h" -#include "layer.h" -#include "palette.h" -#include "undo.h" - #include "drawable_pvt.h" - -enum { - INVALIDATE_PREVIEW, - LAST_SIGNAL -}; - - -static void gimp_drawable_class_init (GimpDrawableClass *klass); -static void gimp_drawable_init (GimpDrawable *drawable); -static void gimp_drawable_destroy (GtkObject *object); - -static gint drawable_signals[LAST_SIGNAL] = { 0 }; - -static GimpDrawableClass *parent_class = NULL; - - -GtkType -gimp_drawable_get_type () -{ - static GtkType drawable_type = 0; - - if (!drawable_type) - { - GtkTypeInfo drawable_info = - { - "GimpDrawable", - sizeof (GimpDrawable), - sizeof (GimpDrawableClass), - (GtkClassInitFunc) gimp_drawable_class_init, - (GtkObjectInitFunc) gimp_drawable_init, - /* reversed_1 */ NULL, - /* reversed_2 */ NULL, - (GtkClassInitFunc) NULL, - }; - - drawable_type = gtk_type_unique (gtk_data_get_type (), &drawable_info); - } - - return drawable_type; -} - -static void -gimp_drawable_class_init (GimpDrawableClass *class) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass*) class; - parent_class = gtk_type_class (gtk_data_get_type ()); - - drawable_signals[INVALIDATE_PREVIEW] = - gtk_signal_new ("invalidate_preview", - GTK_RUN_LAST, - object_class->type, - GTK_SIGNAL_OFFSET (GimpDrawableClass, invalidate_preview), - gtk_signal_default_marshaller, - GTK_TYPE_NONE, 0); - - gtk_object_class_add_signals (object_class, (guint *)drawable_signals, LAST_SIGNAL); - - object_class->destroy = gimp_drawable_destroy; -} - - -/* - * Static variables - */ -int global_drawable_ID = 1; -static GHashTable *drawable_table = NULL; - -/**************************/ -/* Function definitions */ - -GimpDrawable* -drawable_get_ID (int drawable_id) -{ - if (drawable_table == NULL) - return NULL; - - return (GimpDrawable*) g_hash_table_lookup (drawable_table, - (gpointer) drawable_id); -} +#include "palette.h" +#include "gimpimageF.h" +#include "gdisplay.h" int drawable_ID (GimpDrawable *drawable) @@ -121,529 +30,45 @@ drawable_ID (GimpDrawable *drawable) } void -drawable_apply_image (GimpDrawable *drawable, - int x1, int y1, int x2, int y2, - TileManager *tiles, int sparse) -{ - if (drawable) - { - if (! tiles) - undo_push_image (drawable->gimage, drawable, - x1, y1, x2, y2); - else - undo_push_image_mod (drawable->gimage, drawable, - x1, y1, x2, y2, tiles, sparse); - } +drawable_fill (GimpDrawable *drawable, int fill_type){ + guchar r,g,b,a; + a=255; + switch(fill_type){ + case BACKGROUND_FILL: + palette_get_background(&r, &g, &b); + break; + case WHITE_FILL: + r=g=b=255; + break; + case TRANSPARENT_FILL: + a=r=g=b=0; + break; + case NO_FILL: + return; + } + gimp_drawable_fill(drawable,r,g,b,a); + drawable_update (drawable, 0, 0, + gimp_drawable_width (drawable), + gimp_drawable_height (drawable)); } - -void -drawable_merge_shadow (GimpDrawable *drawable, int undo) -{ - GImage *gimage; - PixelRegion shadowPR; - int x1, y1, x2, y2; - - if (! drawable) - return; - - if (! (gimage = drawable_gimage (drawable))) - return; - - /* A useful optimization here is to limit the update to the - * extents of the selection mask, as it cannot extend beyond - * them. - */ - drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); - pixel_region_init (&shadowPR, gimage->shadow, x1, y1, - (x2 - x1), (y2 - y1), FALSE); - gimage_apply_image (gimage, drawable, &shadowPR, undo, OPAQUE_OPACITY, - REPLACE_MODE, NULL, x1, y1); -} - - -void -drawable_fill (GimpDrawable *drawable, int fill_type) -{ - GImage *gimage; - PixelRegion destPR; - unsigned char c[MAX_CHANNELS]; - unsigned char i, r, g, b, a; - - if (! drawable) - return; - - if (! (gimage = drawable_gimage (drawable))) - return; - - a = 255; - - /* a gimage_fill affects the active layer */ - switch (fill_type) - { - case BACKGROUND_FILL: - palette_get_background (&r, &g, &b); - a = 255; - break; - case WHITE_FILL: - a = r = g = b = 255; - break; - case TRANSPARENT_FILL: - r = g = b = a = 0; - break; - case NO_FILL: - return; - break; - } - - switch (drawable_type (drawable)) - { - case RGB_GIMAGE: case RGBA_GIMAGE: - c[RED_PIX] = r; - c[GREEN_PIX] = g; - c[BLUE_PIX] = b; - if (drawable_type (drawable) == RGBA_GIMAGE) - c[ALPHA_PIX] = a; - break; - case GRAY_GIMAGE: case GRAYA_GIMAGE: - c[GRAY_PIX] = r; - if (drawable_type (drawable) == GRAYA_GIMAGE) - c[ALPHA_G_PIX] = a; - break; - case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: - c[RED_PIX] = r; - c[GREEN_PIX] = g; - c[BLUE_PIX] = b; - gimage_transform_color (gimage, drawable, c, &i, RGB); - c[INDEXED_PIX] = i; - if (drawable_type (drawable) == INDEXEDA_GIMAGE) - c[ALPHA_I_PIX] = a; - break; - default: - g_message ("Can't fill unknown image type."); - break; - } - - pixel_region_init (&destPR, - drawable_data (drawable), - 0, 0, - drawable_width (drawable), - drawable_height (drawable), - TRUE); - color_region (&destPR, c); - - /* Update the filled area */ - drawable_update (drawable, 0, 0, - drawable_width (drawable), - drawable_height (drawable)); -} - - void drawable_update (GimpDrawable *drawable, int x, int y, int w, int h) { - GImage *gimage; + GimpImage *gimage; int offset_x, offset_y; if (! drawable) return; - if (! (gimage = drawable_gimage (drawable))) + if (! (gimage = gimp_drawable_gimage (drawable))) return; - drawable_offsets (drawable, &offset_x, &offset_y); + gimp_drawable_offsets (drawable, &offset_x, &offset_y); x += offset_x; y += offset_y; gdisplays_update_area (gimage, x, y, w, h); /* invalidate the preview */ - drawable_invalidate_preview (drawable); + gimp_drawable_invalidate_preview (drawable); } - - -int -drawable_mask_bounds (GimpDrawable *drawable, - int *x1, int *y1, int *x2, int *y2) -{ - GImage *gimage; - int off_x, off_y; - - if (! drawable) - return FALSE; - - if (! (gimage = drawable_gimage (drawable))) - return FALSE; - - if (gimage_mask_bounds (gimage, x1, y1, x2, y2)) - { - drawable_offsets (drawable, &off_x, &off_y); - *x1 = BOUNDS (*x1 - off_x, 0, drawable_width (drawable)); - *y1 = BOUNDS (*y1 - off_y, 0, drawable_height (drawable)); - *x2 = BOUNDS (*x2 - off_x, 0, drawable_width (drawable)); - *y2 = BOUNDS (*y2 - off_y, 0, drawable_height (drawable)); - return TRUE; - } - else - { - *x2 = drawable_width (drawable); - *y2 = drawable_height (drawable); - return FALSE; - } -} - - -void -drawable_invalidate_preview (GimpDrawable *drawable) -{ - GImage *gimage; - - if (! drawable) - return; - - drawable->preview_valid = FALSE; - - gtk_signal_emit (GTK_OBJECT(drawable), drawable_signals[INVALIDATE_PREVIEW]); - - gimage = drawable_gimage (drawable); - if (gimage) - { - gimage->comp_preview_valid[0] = FALSE; - gimage->comp_preview_valid[1] = FALSE; - gimage->comp_preview_valid[2] = FALSE; - } -} - - -int -drawable_dirty (GimpDrawable *drawable) -{ - if (drawable) - return drawable->dirty = (drawable->dirty < 0) ? 2 : drawable->dirty + 1; - else - return 0; -} - - -int -drawable_clean (GimpDrawable *drawable) -{ - if (drawable) - return drawable->dirty = (drawable->dirty <= 0) ? 0 : drawable->dirty - 1; - else - return 0; -} - - -GImage * -drawable_gimage (GimpDrawable *drawable) -{ - if (drawable) - return drawable->gimage; - else - return NULL; -} - - -int -drawable_type (GimpDrawable *drawable) -{ - if (drawable) - return drawable->type; - else - return -1; -} - -int -drawable_has_alpha (GimpDrawable *drawable) -{ - if (drawable) - return drawable->has_alpha; - else - return FALSE; -} - - -int -drawable_visible (GimpDrawable *drawable) -{ - return drawable->visible; -} - -char * -drawable_name (GimpDrawable *drawable) -{ - return drawable->name; -} - -int -drawable_type_with_alpha (GimpDrawable *drawable) -{ - int type = drawable_type (drawable); - int has_alpha = drawable_has_alpha (drawable); - - if (has_alpha) - return type; - else - switch (type) - { - case RGB_GIMAGE: - return RGBA_GIMAGE; break; - case GRAY_GIMAGE: - return GRAYA_GIMAGE; break; - case INDEXED_GIMAGE: - return INDEXEDA_GIMAGE; break; - } - return 0; -} - - -int -drawable_color (GimpDrawable *drawable) -{ - if (drawable_type (drawable) == RGBA_GIMAGE || - drawable_type (drawable) == RGB_GIMAGE) - return 1; - else - return 0; -} - - -int -drawable_gray (GimpDrawable *drawable) -{ - if (drawable_type (drawable) == GRAYA_GIMAGE || - drawable_type (drawable) == GRAY_GIMAGE) - return 1; - else - return 0; -} - - -int -drawable_indexed (GimpDrawable *drawable) -{ - if (drawable_type (drawable) == INDEXEDA_GIMAGE || - drawable_type (drawable) == INDEXED_GIMAGE) - return 1; - else - return 0; -} - - -TileManager * -drawable_data (GimpDrawable *drawable) -{ - if (drawable) - return drawable->tiles; - else - return NULL; -} - - -TileManager * -drawable_shadow (GimpDrawable *drawable) -{ - GImage *gimage; - - if (! (gimage = drawable_gimage (drawable))) - return NULL; - - if (drawable) - return gimage_shadow (gimage, drawable->width, drawable->height, - drawable->bytes); - else - return NULL; -} - - -int -drawable_bytes (GimpDrawable *drawable) -{ - if (drawable) - return drawable->bytes; - else - return -1; -} - - -int -drawable_width (GimpDrawable *drawable) -{ - if (drawable) - return drawable->width; - else - return -1; -} - - -int -drawable_height (GimpDrawable *drawable) -{ - if (drawable) - return drawable->height; - else - return -1; -} - - -void -drawable_offsets (GimpDrawable *drawable, int *off_x, int *off_y) -{ - if (drawable) - { - *off_x = drawable->offset_x; - *off_y = drawable->offset_y; - } - else - *off_x = *off_y = 0; -} - -unsigned char * -drawable_cmap (GimpDrawable *drawable) -{ - GImage *gimage; - - if ((gimage = drawable_gimage (drawable))) - return gimage->cmap; - else - return NULL; -} - - -Layer * -drawable_layer (GimpDrawable *drawable) -{ - if (drawable && GIMP_IS_LAYER(drawable)) - return GIMP_LAYER (drawable); - else - return NULL; -} - - -LayerMask * -drawable_layer_mask (GimpDrawable *drawable) -{ - if (drawable && GIMP_IS_LAYER_MASK(drawable)) - return GIMP_LAYER_MASK(drawable); - else - return NULL; -} - - -Channel * -drawable_channel (GimpDrawable *drawable) -{ - if (drawable && GIMP_IS_CHANNEL(drawable)) - return GIMP_CHANNEL(drawable); - else - return NULL; -} - -void -drawable_deallocate (GimpDrawable *drawable) -{ - if (drawable->tiles) - tile_manager_destroy (drawable->tiles); -} - -static void -gimp_drawable_init (GimpDrawable *drawable) -{ - drawable->name = NULL; - drawable->tiles = NULL; - drawable->visible = FALSE; - drawable->width = drawable->height = 0; - drawable->offset_x = drawable->offset_y = 0; - drawable->bytes = 0; - drawable->dirty = FALSE; - drawable->gimage = NULL; - drawable->type = -1; - drawable->has_alpha = FALSE; - drawable->preview = NULL; - drawable->preview_valid = FALSE; - - drawable->ID = global_drawable_ID++; - if (drawable_table == NULL) - drawable_table = g_hash_table_new (g_direct_hash, NULL); - g_hash_table_insert (drawable_table, (gpointer) drawable->ID, - (gpointer) drawable); -} - -static void -gimp_drawable_destroy (GtkObject *object) -{ - GimpDrawable *drawable; - g_return_if_fail (object != NULL); - g_return_if_fail (GIMP_IS_DRAWABLE (object)); - - drawable = GIMP_DRAWABLE (object); - - g_hash_table_remove (drawable_table, (gpointer) drawable->ID); - - if (drawable->name) - g_free (drawable->name); - - if (drawable->tiles) - tile_manager_destroy (drawable->tiles); - - if (drawable->preview) - temp_buf_free (drawable->preview); - - if (GTK_OBJECT_CLASS (parent_class)->destroy) - (*GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - -void -gimp_drawable_configure (GimpDrawable *drawable, - GimpImage* gimage, int width, int height, - int type, char *name) -{ - int bpp; - int alpha; - - if (!name) - name = "unnamed"; - - switch (type) - { - case RGB_GIMAGE: - bpp = 3; alpha = 0; break; - case GRAY_GIMAGE: - bpp = 1; alpha = 0; break; - case RGBA_GIMAGE: - bpp = 4; alpha = 1; break; - case GRAYA_GIMAGE: - bpp = 2; alpha = 1; break; - case INDEXED_GIMAGE: - bpp = 1; alpha = 0; break; - case INDEXEDA_GIMAGE: - bpp = 2; alpha = 1; break; - default: - g_message ("Layer type %d not supported.", type); - return; - } - - if (drawable->name) - g_free (drawable->name); - drawable->name = g_strdup(name); - drawable->width = width; - drawable->height = height; - drawable->bytes = bpp; - drawable->type = type; - drawable->has_alpha = alpha; - drawable->offset_x = 0; - drawable->offset_y = 0; - - if (drawable->tiles) - tile_manager_destroy (drawable->tiles); - drawable->tiles = tile_manager_new (width, height, bpp); - drawable->dirty = FALSE; - drawable->visible = TRUE; - - drawable->gimage = gimage; - - /* preview variables */ - drawable->preview = NULL; - drawable->preview_valid = FALSE; -} - diff --git a/app/drawable.h b/app/drawable.h index d583099480..185f74b10f 100644 --- a/app/drawable.h +++ b/app/drawable.h @@ -18,56 +18,37 @@ #ifndef __DRAWABLE_H__ #define __DRAWABLE_H__ -#include -#include "tile_manager.h" -#include "temp_buf.h" -#include "gimpimageF.h" +#include "gimpdrawable.h" -#define GIMP_TYPE_DRAWABLE (gimp_drawable_get_type ()) -#define GIMP_DRAWABLE(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE, GimpDrawable)) -#define GIMP_DRAWABLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE, GimpDrawableClass)) -#define GIMP_IS_DRAWABLE(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE)) -#define GIMP_IS_DRAWABLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE)) +int drawable_ID (GimpDrawable *); +void drawable_fill (GimpDrawable *drawable, int fill_type); +void drawable_update (GimpDrawable *drawable, int x, int y, int w, int h); -typedef struct _GimpDrawable GimpDrawable; -typedef struct _GimpDrawableClass GimpDrawableClass; -GtkType gimp_drawable_get_type (void); +#define drawable_apply_image gimp_drawable_apply_image +#define drawable_merge_shadow gimp_drawable_merge_shadow +#define drawable_mask_bounds gimp_drawable_mask_bounds +#define drawable_invalidate_preview gimp_drawable_invalidate_preview +#define drawable_dirty gimp_drawable_dirty +#define drawable_clean gimp_drawable_clean +#define drawable_type gimp_drawable_type +#define drawable_has_alpha gimp_drawable_has_alpha +#define drawable_type_with_alpha gimp_drawable_type_with_alpha +#define drawable_color gimp_drawable_color +#define drawable_gray gimp_drawable_gray +#define drawable_indexed gimp_drawable_indexed +#define drawable_data gimp_drawable_data +#define drawable_shadow gimp_drawable_shadow +#define drawable_bytes gimp_drawable_bytes +#define drawable_width gimp_drawable_width +#define drawable_height gimp_drawable_height +#define drawable_visible gimp_drawable_visible +#define drawable_offsets gimp_drawable_offsets +#define drawable_cmap gimp_drawable_cmap +#define drawable_name gimp_drawable_name -/* drawable access functions */ -int drawable_ID (GimpDrawable *); -void drawable_apply_image (GimpDrawable *, - int, int, int, int, - TileManager *, int); -void drawable_merge_shadow (GimpDrawable *, int); -void drawable_fill (GimpDrawable *, int); -void drawable_update (GimpDrawable *, - int, int, int, int); -int drawable_mask_bounds (GimpDrawable *, - int *, int *, int *, int *); -void drawable_invalidate_preview (GimpDrawable *); -int drawable_dirty (GimpDrawable *); -int drawable_clean (GimpDrawable *); -int drawable_type (GimpDrawable *); -int drawable_has_alpha (GimpDrawable *); -int drawable_type_with_alpha (GimpDrawable *); -int drawable_color (GimpDrawable *); -int drawable_gray (GimpDrawable *); -int drawable_indexed (GimpDrawable *); -TileManager * drawable_data (GimpDrawable *); -TileManager * drawable_shadow (GimpDrawable *); -int drawable_bytes (GimpDrawable *); -int drawable_width (GimpDrawable *); -int drawable_height (GimpDrawable *); -int drawable_visible (GimpDrawable *); -void drawable_offsets (GimpDrawable *, int *, int *); -unsigned char * drawable_cmap (GimpDrawable *); -char * drawable_name (GimpDrawable *); - -GimpDrawable * drawable_get_ID (int); -void drawable_deallocate (GimpDrawable *); -void gimp_drawable_configure (GimpDrawable *, - GimpImage*, - int, int, int, char *); +#define drawable_get_ID gimp_drawable_get_ID +#define drawable_deallocate gimp_drawable_deallocate +#define drawable_gimage gimp_drawable_gimage #endif /* __DRAWABLE_H__ */ diff --git a/app/drawable_cmds.c b/app/drawable_cmds.c index 8241dfe49c..d0eec8966f 100644 --- a/app/drawable_cmds.c +++ b/app/drawable_cmds.c @@ -336,7 +336,7 @@ drawable_gimage_invoker (Argument *args) return_args = procedural_db_return_args (&drawable_gimage_proc, success); if (success) - return_args[1].value.pdb_int = gimage->ID; + return_args[1].value.pdb_int = pdb_image_to_id(gimage); return return_args; } diff --git a/app/drawable_pvt.h b/app/drawable_pvt.h index 9c23b4c62c..bee474fdf5 100644 --- a/app/drawable_pvt.h +++ b/app/drawable_pvt.h @@ -18,37 +18,6 @@ #ifndef __DRAWABLE_PVT_H__ #define __DRAWABLE_PVT_H__ -#include -#include "tile_manager.h" -#include "temp_buf.h" - -struct _GimpDrawable -{ - GtkData data; - - char *name; /* name of drawable */ - TileManager *tiles; /* tiles for drawable data */ - int visible; /* controls visibility */ - int width, height; /* size of drawable */ - int offset_x, offset_y; /* offset of layer in image */ - - int bytes; /* bytes per pixel */ - int dirty; /* dirty bit */ - int ID; /* provides a unique ID */ - GimpImage* gimage; /* gimage owner */ - int type; /* type of drawable */ - int has_alpha; /* drawable has alpha */ - - /* Preview variables */ - TempBuf *preview; /* preview of the channel */ - int preview_valid; /* is the preview valid? */ -}; - -struct _GimpDrawableClass -{ - GtkDataClass parent_class; - - void (*invalidate_preview) (GtkObject *); -}; +#include "gimpdrawableP.h" #endif /* __DRAWABLE_PVT_H__ */ diff --git a/app/fileops.c b/app/fileops.c index 61a8deb6a0..d2fe2ca6b7 100644 --- a/app/fileops.c +++ b/app/fileops.c @@ -785,7 +785,7 @@ file_save (GimpImage* gimage, args[i].arg_type = proc->args[i].arg_type; args[0].value.pdb_int = 0; - args[1].value.pdb_int = the_gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(the_gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gimage)); args[3].value.pdb_pointer = filename; args[4].value.pdb_pointer = raw_filename; diff --git a/app/floating_sel.c b/app/floating_sel.c index a56e112b24..3aad02051c 100644 --- a/app/floating_sel.c +++ b/app/floating_sel.c @@ -131,7 +131,6 @@ floating_sel_reset (layer) Layer *layer; { GImage *gimage; - LayerMask *lm; if (! (gimage = drawable_gimage (GIMP_DRAWABLE(layer)))) return; @@ -139,8 +138,10 @@ floating_sel_reset (layer) /* set the underlying drawable to active */ if (drawable_layer ( (layer->fs.drawable))) gimage_set_active_layer (gimage, GIMP_LAYER (layer->fs.drawable)); - else if ((lm = drawable_layer_mask ( (layer->fs.drawable)))) - gimage_set_active_layer (gimage, lm->layer); + else if (GIMP_IS_LAYER_MASK(layer->fs.drawable)) + gimage_set_active_layer (gimage, + GIMP_LAYER_MASK(layer->fs.drawable) + ->layer); else if (drawable_channel ( (layer->fs.drawable))) { gimage_set_active_channel (gimage, GIMP_CHANNEL(layer->fs.drawable)); diff --git a/app/gdisplay.c b/app/gdisplay.c index cac16d39ff..f58b3f6ed3 100644 --- a/app/gdisplay.c +++ b/app/gdisplay.c @@ -131,7 +131,7 @@ gdisplay_new (GimpImage *gimage, display_list = g_slist_append (display_list, (void *) gdisp); /* create the shell for the image */ - create_display_shell (gdisp->ID, gimage->width, gimage->height, + create_display_shell (gdisp, gimage->width, gimage->height, title, gimage_base_type (gimage)); /* set the gdisplay colormap type and install the appropriate colormap */ @@ -178,9 +178,9 @@ gdisplay_format_title (GimpImage *gimage, image_type_str = NULL; } - sprintf (title, "%s" "-%d" ".%d (%s)", + sprintf (title, "%s" "-%p" ".%d (%s)", prune_filename (gimage_filename (gimage)), - /*gimage->ID,*/ + gimage, gimage->instance_count, image_type_str); } @@ -201,7 +201,7 @@ gdisplay_delete (GDisplay *gdisp) if (active_tool && active_tool->gdisp_ptr) { tool_gdisp = active_tool->gdisp_ptr; - if (gdisp->ID == tool_gdisp->ID) { + if (gdisp == tool_gdisp) { active_tool->drawable = NULL; active_tool->gdisp_ptr = NULL; } @@ -1289,9 +1289,12 @@ gdisplays_update_area (GimpImage* gimage, */ gdisplay_add_update_area (gdisp, x, y, w, h); + /* Seems like this isn't needed, it's done in + gdisplay_flush. -la gdisplay_transform_coords (gdisp, x, y, &x1, &y1, 0); gdisplay_transform_coords (gdisp, x + w, y + h, &x2, &y2, 0); gdisplay_add_display_area (gdisp, x1, y1, (x2 - x1), (y2 - y1)); + */ } list = g_slist_next (list); } diff --git a/app/gimage.c b/app/gimage.c index 667fd53b8c..15f902fada 100644 --- a/app/gimage.c +++ b/app/gimage.c @@ -8,7 +8,7 @@ #include "drawable.h" #include "gdisplay.h" - +#include "procedural_db.h" #include "palette.h" #include "undo.h" @@ -23,18 +23,6 @@ to proper places. That is, the handlers should be moved to layers_dialog, gdisplay, tools, etc.. */ -/* Todo: obliterate the idiotic id system. We get rid of lotsa list - lookups, and it clears the code.. */ - -static int global_gimage_ID = 1; - -/* Any global vars like this are damn well app-specific, and don't - belong in class implementations */ - -/* To do: a more generic "set" class */ - -GSList* image_list; - static void gimage_dirty_handler (GimpImage* gimage); static void gimage_destroy_handler (GimpImage* gimage); static void gimage_rename_handler (GimpImage* gimage); @@ -42,7 +30,10 @@ static void gimage_resize_handler (GimpImage* gimage); static void gimage_restructure_handler (GimpImage* gimage); static void gimage_repaint_handler (GimpImage* gimage, gint, gint, gint, gint); +/* This is the app's global context of "all images".. This should be + unglobalized, too */ +static GSList* image_list; GImage* gimage_new(int width, int height, GimpImageBaseType base_type) @@ -61,11 +52,9 @@ gimage_new(int width, int height, GimpImageBaseType base_type) GTK_SIGNAL_FUNC(gimage_restructure_handler), NULL); gtk_signal_connect (GTK_OBJECT (gimage), "repaint", GTK_SIGNAL_FUNC(gimage_repaint_handler), NULL); - - gimage->ref_count = 0; - gimage->ID = global_gimage_ID ++; - image_list = g_slist_append (image_list, gimage); - + + image_list=g_slist_prepend(image_list, gimage); + pdb_add_image(gimage); lc_dialog_update_image_list (); indexed_palette_update_image_list (); return gimage; @@ -74,20 +63,7 @@ gimage_new(int width, int height, GimpImageBaseType base_type) GImage* gimage_get_ID (gint ID) { - GSList *tmp = image_list; - GimpImage *gimage; - - while (tmp) - { - gimage = (GimpImage *) tmp->data; - if (gimage->ID == ID) - return gimage; - - tmp = g_slist_next (tmp); - } - - return NULL; - + return pdb_id_to_image(ID); } @@ -121,7 +97,7 @@ gimage_dirty_handler (GimpImage* gimage){ if (active_tool && !active_tool->preserve) { GDisplay* gdisp = active_tool->gdisp_ptr; if (gdisp) { - if (gdisp->gimage->ID == gimage->ID) + if (gdisp->gimage == gimage) tools_initialize (active_tool->type, gdisp); else tools_initialize (active_tool->type, NULL); @@ -132,10 +108,12 @@ gimage_dirty_handler (GimpImage* gimage){ static void gimage_destroy_handler (GimpImage* gimage) { + /* free the undo list */ undo_free (gimage); - image_list = g_slist_remove (image_list, (void *) gimage); + pdb_remove_image(gimage); + image_list=g_slist_remove(image_list, gimage); lc_dialog_update_image_list (); indexed_palette_update_image_list (); diff --git a/app/gimage_cmds.c b/app/gimage_cmds.c index cc6c30bd67..a2d98b04aa 100644 --- a/app/gimage_cmds.c +++ b/app/gimage_cmds.c @@ -33,7 +33,6 @@ static int int_value; static int success; static Argument *return_args; -extern GSList * image_list; static GImage * duplicate (GImage *gimage); @@ -41,37 +40,40 @@ static Argument * channel_ops_duplicate_invoker (Argument *args); /************************/ /* GIMAGE_LIST_IMAGES */ +/* Yuup, this is somewhat unsmooth, to say the least */ + +static void +gimlist_cb(gpointer im, gpointer data){ + GSList** l=(GSList**)data; + *l=g_slist_prepend(*l, im); +} + static Argument * gimage_list_images_invoker (Argument *args) { - GSList *list; + GSList *list=NULL; int num_images; int *image_ids; Argument *return_args; - success = TRUE; - return_args = procedural_db_return_args (&gimage_get_layers_proc, success); + return_args = procedural_db_return_args (&gimage_get_layers_proc, TRUE); - if (success) + gimage_foreach(gimlist_cb, &list); + + num_images = g_slist_length (list); + image_ids = NULL; + + if (num_images) { - list = image_list; - num_images = g_slist_length (list); - image_ids = NULL; - - if (num_images) - { - int i; - - image_ids = (int *) g_malloc (sizeof (int) * num_images); - - for (i = 0; i < num_images; i++, list = g_slist_next (list)) - image_ids[i] = ((GImage *) list->data)->ID; - } - - return_args[1].value.pdb_int = num_images; - return_args[2].value.pdb_pointer = image_ids; + int i; + image_ids = (int *) g_malloc (sizeof (int) * num_images); + for (i = 0; i < num_images; i++, list = g_slist_next (list)) + image_ids[i] = pdb_image_to_id(GIMP_IMAGE(list->data)); + } - + return_args[1].value.pdb_int = num_images; + return_args[2].value.pdb_pointer = image_ids; + g_slist_free(list); return return_args; } @@ -160,7 +162,7 @@ gimage_new_invoker (Argument *args) return_args = procedural_db_return_args (&gimage_new_proc, success); if (success) - return_args[1].value.pdb_int = gimage->ID; + return_args[1].value.pdb_int = pdb_image_to_id(gimage); return return_args; } @@ -3399,7 +3401,7 @@ channel_ops_duplicate_invoker (Argument *args) return_args = procedural_db_return_args (&channel_ops_duplicate_proc, success); if (success) - return_args[1].value.pdb_int = new_gimage->ID; + return_args[1].value.pdb_int = pdb_image_to_id(new_gimage); return return_args; } diff --git a/app/gimage_mask.c b/app/gimage_mask.c index c09546bb11..ba7d6ff460 100644 --- a/app/gimage_mask.c +++ b/app/gimage_mask.c @@ -297,8 +297,8 @@ gimage_mask_extract (gimage, drawable, cut_gimage, keep_indexed) */ if (cut_gimage && drawable_layer (drawable)) { - if (layer_is_floating_sel (drawable_layer (drawable))) - floating_sel_remove (drawable_layer (drawable)); + if (layer_is_floating_sel (GIMP_LAYER (drawable))) + floating_sel_remove (GIMP_LAYER (drawable)); else gimage_remove_layer (gimage, GIMP_LAYER (drawable)); } diff --git a/app/gimpchannel.h b/app/gimpchannel.h index ef1c381d88..c13b31677a 100644 --- a/app/gimpchannel.h +++ b/app/gimpchannel.h @@ -122,7 +122,6 @@ void channel_invalidate_bounds (Channel *); extern int channel_get_count; -/* from drawable.c */ -Channel * drawable_channel (GimpDrawable *); +#define drawable_channel GIMP_IS_CHANNEL #endif /* __CHANNEL_H__ */ diff --git a/app/gimpdrawable-invert.c b/app/gimpdrawable-invert.c index 82db12a1c7..3455bb3564 100644 --- a/app/gimpdrawable-invert.c +++ b/app/gimpdrawable-invert.c @@ -48,7 +48,7 @@ image_invert (gimage_ptr) return_vals = procedural_db_run_proc ("gimp_invert", &nreturn_vals, - PDB_IMAGE, gimage->ID, + PDB_IMAGE, pdb_image_to_id(gimage), PDB_DRAWABLE, drawable_ID (drawable), PDB_END); diff --git a/app/gimpdrawable.c b/app/gimpdrawable.c new file mode 100644 index 0000000000..5bdfc29fb8 --- /dev/null +++ b/app/gimpdrawable.c @@ -0,0 +1,543 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#include "gimpdrawableP.h" +#include "gimpsignal.h" +#include "gimage.h" +#include "gimage_mask.h" +#include "undo.h" + + +enum { + INVALIDATE_PREVIEW, + LAST_SIGNAL +}; + + +static void gimp_drawable_class_init (GimpDrawableClass *klass); +static void gimp_drawable_init (GimpDrawable *drawable); +static void gimp_drawable_destroy (GtkObject *object); + +static guint gimp_drawable_signals[LAST_SIGNAL] = { 0 }; + +static GimpDrawableClass *parent_class = NULL; + + +GtkType +gimp_drawable_get_type () +{ + static GtkType type; + GIMP_TYPE_INIT(type, + GimpDrawable, + GimpDrawableClass, + gimp_drawable_init, + gimp_drawable_class_init, + GIMP_TYPE_OBJECT); + return type; +} + +static void +gimp_drawable_class_init (GimpDrawableClass *class) +{ + GtkObjectClass *object_class; + GtkType type=GIMP_TYPE_DRAWABLE; + object_class = GTK_OBJECT_CLASS(class); + parent_class = gtk_type_class (GIMP_TYPE_OBJECT); + + gimp_drawable_signals[INVALIDATE_PREVIEW] = + gimp_signal_new ("invalidate_pr", GTK_RUN_LAST, type, + GTK_SIGNAL_OFFSET(GimpDrawableClass, + invalidate_preview), + gimp_sigtype_void); + + gtk_object_class_add_signals (object_class, gimp_drawable_signals, LAST_SIGNAL); + + object_class->destroy = gimp_drawable_destroy; +} + + +/* + * Static variables + */ +int global_drawable_ID = 1; +static GHashTable *gimp_drawable_table = NULL; + +/**************************/ +/* Function definitions */ + +GimpDrawable* +gimp_drawable_get_ID (int drawable_id) +{ + if (gimp_drawable_table == NULL) + return NULL; + + return (GimpDrawable*) g_hash_table_lookup (gimp_drawable_table, + (gpointer) drawable_id); +} + +void +gimp_drawable_apply_image (GimpDrawable *drawable, + int x1, int y1, int x2, int y2, + TileManager *tiles, int sparse) +{ + if (drawable) + { + if (! tiles) + undo_push_image (drawable->gimage, drawable, + x1, y1, x2, y2); + else + undo_push_image_mod (drawable->gimage, drawable, + x1, y1, x2, y2, tiles, sparse); + } +} + + +void +gimp_drawable_merge_shadow (GimpDrawable *drawable, int undo) +{ + GImage *gimage; + PixelRegion shadowPR; + int x1, y1, x2, y2; + + if (! drawable) + return; + + if (! (gimage = gimp_drawable_gimage (drawable))) + return; + + /* A useful optimization here is to limit the update to the + * extents of the selection mask, as it cannot extend beyond + * them. + */ + gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2); + pixel_region_init (&shadowPR, gimage->shadow, x1, y1, + (x2 - x1), (y2 - y1), FALSE); + gimage_apply_image (gimage, drawable, &shadowPR, undo, OPAQUE_OPACITY, + REPLACE_MODE, NULL, x1, y1); +} + + +void +gimp_drawable_fill (GimpDrawable *drawable, guchar r, guchar g, + guchar b, guchar a) +{ + GImage *gimage; + PixelRegion destPR; + guchar c[MAX_CHANNELS]; + guchar i; + + + g_assert(GIMP_IS_DRAWABLE(drawable)); + gimage=gimp_drawable_gimage(drawable); + g_assert(gimage); + + switch (gimp_drawable_type (drawable)) + { + case RGB_GIMAGE: case RGBA_GIMAGE: + c[RED_PIX] = r; + c[GREEN_PIX] = g; + c[BLUE_PIX] = b; + if (gimp_drawable_type (drawable) == RGBA_GIMAGE) + c[ALPHA_PIX] = a; + break; + case GRAY_GIMAGE: case GRAYA_GIMAGE: + c[GRAY_PIX] = r; + if (gimp_drawable_type (drawable) == GRAYA_GIMAGE) + c[ALPHA_G_PIX] = a; + break; + case INDEXED_GIMAGE: case INDEXEDA_GIMAGE: + c[RED_PIX] = r; + c[GREEN_PIX] = g; + c[BLUE_PIX] = b; + gimage_transform_color (gimage, drawable, c, &i, RGB); + c[INDEXED_PIX] = i; + if (gimp_drawable_type (drawable) == INDEXEDA_GIMAGE) + c[ALPHA_I_PIX] = a; + break; + default: + g_message ("Can't fill unknown image type."); + break; + } + + pixel_region_init (&destPR, + gimp_drawable_data (drawable), + 0, 0, + gimp_drawable_width (drawable), + gimp_drawable_height (drawable), + TRUE); + color_region (&destPR, c); + +} + + +int +gimp_drawable_mask_bounds (GimpDrawable *drawable, + int *x1, int *y1, int *x2, int *y2) +{ + GImage *gimage; + int off_x, off_y; + + if (! drawable) + return FALSE; + + if (! (gimage = gimp_drawable_gimage (drawable))) + return FALSE; + + if (gimage_mask_bounds (gimage, x1, y1, x2, y2)) + { + gimp_drawable_offsets (drawable, &off_x, &off_y); + *x1 = CLAMP (*x1 - off_x, 0, gimp_drawable_width (drawable)); + *y1 = CLAMP (*y1 - off_y, 0, gimp_drawable_height (drawable)); + *x2 = CLAMP (*x2 - off_x, 0, gimp_drawable_width (drawable)); + *y2 = CLAMP (*y2 - off_y, 0, gimp_drawable_height (drawable)); + return TRUE; + } + else + { + *x2 = gimp_drawable_width (drawable); + *y2 = gimp_drawable_height (drawable); + return FALSE; + } +} + + +void +gimp_drawable_invalidate_preview (GimpDrawable *drawable) +{ + GImage *gimage; + + if (! drawable) + return; + + drawable->preview_valid = FALSE; +#if 0 + gtk_signal_emit (GTK_OBJECT(drawable), gimp_drawable_signals[INVALIDATE_PREVIEW]); +#endif + gimage = gimp_drawable_gimage (drawable); + if (gimage) + { + gimage->comp_preview_valid[0] = FALSE; + gimage->comp_preview_valid[1] = FALSE; + gimage->comp_preview_valid[2] = FALSE; + } +} + + +int +gimp_drawable_dirty (GimpDrawable *drawable) +{ + if (drawable) + return drawable->dirty = (drawable->dirty < 0) ? 2 : drawable->dirty + 1; + else + return 0; +} + + +int +gimp_drawable_clean (GimpDrawable *drawable) +{ + if (drawable) + return drawable->dirty = (drawable->dirty <= 0) ? 0 : drawable->dirty - 1; + else + return 0; +} + + +GimpImage * +gimp_drawable_gimage (GimpDrawable *drawable) +{ + g_assert(GIMP_IS_DRAWABLE(drawable)); + + return drawable->gimage; +} + + +int +gimp_drawable_type (GimpDrawable *drawable) +{ + if (drawable) + return drawable->type; + else + return -1; +} + +int +gimp_drawable_has_alpha (GimpDrawable *drawable) +{ + if (drawable) + return drawable->has_alpha; + else + return FALSE; +} + + +int +gimp_drawable_visible (GimpDrawable *drawable) +{ + return drawable->visible; +} + +char * +gimp_drawable_name (GimpDrawable *drawable) +{ + return drawable->name; +} + +int +gimp_drawable_type_with_alpha (GimpDrawable *drawable) +{ + int type = gimp_drawable_type (drawable); + int has_alpha = gimp_drawable_has_alpha (drawable); + + if (has_alpha) + return type; + else + switch (type) + { + case RGB_GIMAGE: + return RGBA_GIMAGE; break; + case GRAY_GIMAGE: + return GRAYA_GIMAGE; break; + case INDEXED_GIMAGE: + return INDEXEDA_GIMAGE; break; + } + return 0; +} + + +int +gimp_drawable_color (GimpDrawable *drawable) +{ + if (gimp_drawable_type (drawable) == RGBA_GIMAGE || + gimp_drawable_type (drawable) == RGB_GIMAGE) + return 1; + else + return 0; +} + + +int +gimp_drawable_gray (GimpDrawable *drawable) +{ + if (gimp_drawable_type (drawable) == GRAYA_GIMAGE || + gimp_drawable_type (drawable) == GRAY_GIMAGE) + return 1; + else + return 0; +} + + +int +gimp_drawable_indexed (GimpDrawable *drawable) +{ + if (gimp_drawable_type (drawable) == INDEXEDA_GIMAGE || + gimp_drawable_type (drawable) == INDEXED_GIMAGE) + return 1; + else + return 0; +} + + +TileManager * +gimp_drawable_data (GimpDrawable *drawable) +{ + if (drawable) + return drawable->tiles; + else + return NULL; +} + + +TileManager * +gimp_drawable_shadow (GimpDrawable *drawable) +{ + GImage *gimage; + + if (! (gimage = gimp_drawable_gimage (drawable))) + return NULL; + + if (drawable) + return gimage_shadow (gimage, drawable->width, drawable->height, + drawable->bytes); + else + return NULL; +} + + +int +gimp_drawable_bytes (GimpDrawable *drawable) +{ + if (drawable) + return drawable->bytes; + else + return -1; +} + + +int +gimp_drawable_width (GimpDrawable *drawable) +{ + if (drawable) + return drawable->width; + else + return -1; +} + + +int +gimp_drawable_height (GimpDrawable *drawable) +{ + if (drawable) + return drawable->height; + else + return -1; +} + + +void +gimp_drawable_offsets (GimpDrawable *drawable, int *off_x, int *off_y) +{ + if (drawable) + { + *off_x = drawable->offset_x; + *off_y = drawable->offset_y; + } + else + *off_x = *off_y = 0; +} + +unsigned char * +gimp_drawable_cmap (GimpDrawable *drawable) +{ + GImage *gimage; + + if ((gimage = gimp_drawable_gimage (drawable))) + return gimage->cmap; + else + return NULL; +} + + +void +gimp_drawable_deallocate (GimpDrawable *drawable) +{ + if (drawable->tiles) + tile_manager_destroy (drawable->tiles); +} + +static void +gimp_drawable_init (GimpDrawable *drawable) +{ + drawable->name = NULL; + drawable->tiles = NULL; + drawable->visible = FALSE; + drawable->width = drawable->height = 0; + drawable->offset_x = drawable->offset_y = 0; + drawable->bytes = 0; + drawable->dirty = FALSE; + drawable->gimage = NULL; + drawable->type = -1; + drawable->has_alpha = FALSE; + drawable->preview = NULL; + drawable->preview_valid = FALSE; + + drawable->ID = global_drawable_ID++; + if (gimp_drawable_table == NULL) + gimp_drawable_table = g_hash_table_new (g_direct_hash, NULL); + g_hash_table_insert (gimp_drawable_table, (gpointer) drawable->ID, + (gpointer) drawable); +} + +static void +gimp_drawable_destroy (GtkObject *object) +{ + GimpDrawable *drawable; + g_return_if_fail (object != NULL); + g_return_if_fail (GIMP_IS_DRAWABLE (object)); + + drawable = GIMP_DRAWABLE (object); + + g_hash_table_remove (gimp_drawable_table, (gpointer) drawable->ID); + + if (drawable->name) + g_free (drawable->name); + + if (drawable->tiles) + tile_manager_destroy (drawable->tiles); + + if (drawable->preview) + temp_buf_free (drawable->preview); + + if (GTK_OBJECT_CLASS (parent_class)->destroy) + (*GTK_OBJECT_CLASS (parent_class)->destroy) (object); +} + +void +gimp_drawable_configure (GimpDrawable *drawable, + GimpImage* gimage, int width, int height, + int type, char *name) +{ + int bpp; + int alpha; + + if (!name) + name = "unnamed"; + + switch (type) + { + case RGB_GIMAGE: + bpp = 3; alpha = 0; break; + case GRAY_GIMAGE: + bpp = 1; alpha = 0; break; + case RGBA_GIMAGE: + bpp = 4; alpha = 1; break; + case GRAYA_GIMAGE: + bpp = 2; alpha = 1; break; + case INDEXED_GIMAGE: + bpp = 1; alpha = 0; break; + case INDEXEDA_GIMAGE: + bpp = 2; alpha = 1; break; + default: + g_message ("Layer type %d not supported.", type); + return; + } + + if (drawable->name) + g_free (drawable->name); + drawable->name = g_strdup(name); + drawable->width = width; + drawable->height = height; + drawable->bytes = bpp; + drawable->type = type; + drawable->has_alpha = alpha; + drawable->offset_x = 0; + drawable->offset_y = 0; + + if (drawable->tiles) + tile_manager_destroy (drawable->tiles); + drawable->tiles = tile_manager_new (width, height, bpp); + drawable->dirty = FALSE; + drawable->visible = TRUE; + + drawable->gimage = gimage; + + /* preview variables */ + drawable->preview = NULL; + drawable->preview_valid = FALSE; +} + diff --git a/app/gimpdrawable.h b/app/gimpdrawable.h new file mode 100644 index 0000000000..65404ecc4f --- /dev/null +++ b/app/gimpdrawable.h @@ -0,0 +1,75 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef __GIMPDRAWABLE_H__ +#define __GIMPDRAWABLE_H__ + +#include "gimpobject.h" +#include "gimpdrawableF.h" +#include "tile_manager.h" +#include "temp_buf.h" +#include "gimpimageF.h" + +#define GIMP_TYPE_DRAWABLE (gimp_drawable_get_type ()) +#define GIMP_DRAWABLE(obj) (GTK_CHECK_CAST ((obj), GIMP_TYPE_DRAWABLE, GimpDrawable)) +#define GIMP_IS_DRAWABLE(obj) (GTK_CHECK_TYPE ((obj), GIMP_TYPE_DRAWABLE)) + +GtkType gimp_drawable_get_type (void); + +typedef enum +{ + BACKGROUND_FILL, + WHITE_FILL, + TRANSPARENT_FILL, + NO_FILL +} GimpFillType; + + +/* drawable access functions */ +void gimp_drawable_apply_image (GimpDrawable *, + int, int, int, int, + TileManager *, int); +void gimp_drawable_merge_shadow (GimpDrawable *, int); +void gimp_drawable_fill (GimpDrawable *drawable, guchar r, guchar g, + guchar b, guchar a); + +int gimp_drawable_mask_bounds (GimpDrawable *, + int *, int *, int *, int *); +void gimp_drawable_invalidate_preview (GimpDrawable *); +int gimp_drawable_dirty (GimpDrawable *); +int gimp_drawable_clean (GimpDrawable *); +int gimp_drawable_type (GimpDrawable *); +int gimp_drawable_has_alpha (GimpDrawable *); +int gimp_drawable_type_with_alpha (GimpDrawable *); +int gimp_drawable_color (GimpDrawable *); +int gimp_drawable_gray (GimpDrawable *); +int gimp_drawable_indexed (GimpDrawable *); +TileManager * gimp_drawable_data (GimpDrawable *); +TileManager * gimp_drawable_shadow (GimpDrawable *); +int gimp_drawable_bytes (GimpDrawable *); +int gimp_drawable_width (GimpDrawable *); +int gimp_drawable_height (GimpDrawable *); +int gimp_drawable_visible (GimpDrawable *); +void gimp_drawable_offsets (GimpDrawable *, int *, int *); +unsigned char * gimp_drawable_cmap (GimpDrawable *); +char * gimp_drawable_name (GimpDrawable *); + +GimpDrawable * gimp_drawable_get_ID (int); +void gimp_drawable_deallocate (GimpDrawable *); +GimpImage * gimp_drawable_gimage (GimpDrawable*); + +#endif /* __GIMPDRAWABLE_H__ */ diff --git a/app/gimpdrawableF.h b/app/gimpdrawableF.h new file mode 100644 index 0000000000..f90245bff3 --- /dev/null +++ b/app/gimpdrawableF.h @@ -0,0 +1,6 @@ +#ifndef __GIMPDRAWABLEF_H__ +#define __GIMPDRAWABLEF_H__ + +typedef struct _GimpDrawable GimpDrawable; + +#endif diff --git a/app/gimpdrawableP.h b/app/gimpdrawableP.h new file mode 100644 index 0000000000..37ee6397c4 --- /dev/null +++ b/app/gimpdrawableP.h @@ -0,0 +1,62 @@ +/* The GIMP -- an image manipulation program + * Copyright (C) 1995 Spencer Kimball and Peter Mattis + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ +#ifndef __GIMPDRAWABLEP_H__ +#define __GIMPDRAWABLEP_H__ + +#include "gimpobjectP.h" +#include "gimpdrawable.h" + +struct _GimpDrawable +{ + GimpObject data; + + char *name; /* name of drawable */ + TileManager *tiles; /* tiles for drawable data */ + int visible; /* controls visibility */ + int width, height; /* size of drawable */ + int offset_x, offset_y; /* offset of layer in image */ + + int bytes; /* bytes per pixel */ + int dirty; /* dirty bit */ + int ID; /* provides a unique ID */ + GimpImage* gimage; /* gimage owner */ + int type; /* type of drawable */ + int has_alpha; /* drawable has alpha */ + + /* Preview variables */ + TempBuf *preview; /* preview of the channel */ + int preview_valid; /* is the preview valid? */ +}; + +struct _GimpDrawableClass +{ + GimpObjectClass parent_class; + + void (*invalidate_preview) (GtkObject *); +}; + +typedef struct _GimpDrawableClass GimpDrawableClass; + +#define GIMP_DRAWABLE_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GIMP_TYPE_DRAWABLE, GimpDrawableClass)) + +#define GIMP_IS_DRAWABLE_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_DRAWABLE)) + +void gimp_drawable_configure (GimpDrawable *, GimpImage*, + gint, gint, gint, gchar*); + +#endif /* __GIMPDRAWABLEP_H__ */ diff --git a/app/gimpimage.c b/app/gimpimage.c index a7b18a4787..1c8372545a 100644 --- a/app/gimpimage.c +++ b/app/gimpimage.c @@ -1156,16 +1156,18 @@ gimp_image_get_active_channels (GimpImage *gimage, GimpDrawable *drawable, int * /* If the drawable is a channel (a saved selection, etc.) * make sure that the alpha channel is not valid */ - if (drawable_channel (drawable) != NULL) + if (GIMP_IS_CHANNEL (drawable)) active[ALPHA_G_PIX] = 0; /* no alpha values in channels */ else { /* otherwise, check whether preserve transparency is * enabled in the layer and if the layer has alpha */ - if ((layer = drawable_layer (drawable))) - if (layer_has_alpha (layer) && layer->preserve_trans) - active[drawable_bytes (GIMP_DRAWABLE(layer)) - 1] = 0; + if (GIMP_IS_LAYER (drawable)){ + layer=GIMP_LAYER(drawable); + if (layer_has_alpha (layer) && layer->preserve_trans) + active[drawable_bytes (drawable) - 1] = 0; + } } } diff --git a/app/gimpimage.h b/app/gimpimage.h index 7f1b9dd716..b61966a6dd 100644 --- a/app/gimpimage.h +++ b/app/gimpimage.h @@ -50,14 +50,6 @@ typedef enum } GimpImageBaseType; - - -/* the image fill types */ -#define BACKGROUND_FILL 0 -#define WHITE_FILL 1 -#define TRANSPARENT_FILL 2 -#define NO_FILL 3 - #define COLORMAP_SIZE 768 #define HORIZONTAL_GUIDE 1 @@ -207,9 +199,6 @@ void gimp_image_invalidate_preview (GimpImage *); void gimp_image_invalidate_previews (void); -/* from drawable.c */ -/* Ugly! */ -GimpImage * drawable_gimage (GimpDrawable*); #endif diff --git a/app/gimpimageP.h b/app/gimpimageP.h index 31c9e96903..1da031855c 100644 --- a/app/gimpimageP.h +++ b/app/gimpimageP.h @@ -32,8 +32,6 @@ struct _GimpImage TileManager *shadow; /* shadow buffer tiles */ - int ID; /* Unique gimp_image identifier */ - /* Projection attributes */ int flat; /* Is the gimp_image flat? */ int construct_flag; /* flag for construction */ diff --git a/app/gimplayer.c b/app/gimplayer.c index 27aae01f4e..68ac3c0eec 100644 --- a/app/gimplayer.c +++ b/app/gimplayer.c @@ -655,10 +655,8 @@ layer_add_alpha (layer) GIMP_DRAWABLE(layer)->bytes = GIMP_DRAWABLE(layer)->bytes + 1; GIMP_DRAWABLE(layer)->has_alpha = TYPE_HAS_ALPHA (type); - /* update gdisplay titles to reflect the possibility of - * this layer being the only layer in the gimage - */ - gdisplays_update_title (GIMP_DRAWABLE(layer)->gimage); + gtk_signal_emit_by_name(GTK_OBJECT(gimp_drawable_gimage(GIMP_DRAWABLE(layer))), + "restructure"); } @@ -893,7 +891,7 @@ layer_invalidate_boundary (layer) Channel *mask; /* first get the selection mask channel */ - if (! (gimage = GIMP_DRAWABLE(layer)->gimage)) + if (! (gimage = drawable_gimage(GIMP_DRAWABLE(layer)))) return; /* Turn the current selection off */ @@ -909,7 +907,8 @@ layer_invalidate_boundary (layer) } /* clear the affected region surrounding the layer */ - gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage, SelectionLayerOff); + /* gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage, + SelectionLayerOff); */ } diff --git a/app/gimplayer.h b/app/gimplayer.h index bf2774ac84..0217806491 100644 --- a/app/gimplayer.h +++ b/app/gimplayer.h @@ -138,9 +138,11 @@ TempBuf * layer_mask_preview (Layer *, int, int); void layer_invalidate_previews (GimpImage*); -/* from drawable.c */ -Layer * drawable_layer (GimpDrawable *); -LayerMask * drawable_layer_mask (GimpDrawable *); +/* temp thingies.. dynamic downcast. GTK_NO_CHECK_CASTS must not be + defined */ + +#define drawable_layer GIMP_IS_LAYER +#define drawable_layer_mask GIMP_IS_LAYER_MASK /* from channel.c */ void channel_layer_alpha (Channel *, Layer *); diff --git a/app/gimpobject.h b/app/gimpobject.h index 35ac815878..a496fdef32 100644 --- a/app/gimpobject.h +++ b/app/gimpobject.h @@ -4,7 +4,6 @@ #include #include "gimpobjectF.h" - #define GIMP_TYPE_OBJECT gimp_object_get_type() #define GIMP_OBJECT(obj) GTK_CHECK_CAST (obj, GIMP_TYPE_OBJECT, GimpObject) diff --git a/app/gui/commands.c b/app/gui/commands.c index b3175afbb3..1b900a633b 100644 --- a/app/gui/commands.c +++ b/app/gui/commands.c @@ -70,7 +70,7 @@ typedef struct { GtkWidget * shell; Resize * resize; - int gimage_id; + GimpImage* gimage; } ImageResize; /* external functions */ @@ -724,7 +724,7 @@ image_resize_cmd_callback (GtkWidget *widget, /* the ImageResize structure */ image_resize = (ImageResize *) g_malloc (sizeof (ImageResize)); - image_resize->gimage_id = gdisp->gimage->ID; + image_resize->gimage = gdisp->gimage; image_resize->resize = resize_widget_new (ResizeWidget, gdisp->gimage->width, gdisp->gimage->height); /* the dialog */ @@ -771,7 +771,7 @@ image_scale_cmd_callback (GtkWidget *widget, /* the ImageResize structure */ image_scale = (ImageResize *) g_malloc (sizeof (ImageResize)); - image_scale->gimage_id = gdisp->gimage->ID; + image_scale->gimage = gdisp->gimage; image_scale->resize = resize_widget_new (ScaleWidget, gdisp->gimage->width, gdisp->gimage->height); /* the dialog */ @@ -1052,7 +1052,7 @@ image_resize_callback (GtkWidget *w, GImage *gimage; image_resize = (ImageResize *) client_data; - if ((gimage = gimage_get_ID (image_resize->gimage_id)) != NULL) + if ((gimage = image_resize->gimage) != NULL) { if (image_resize->resize->width > 0 && image_resize->resize->height > 0) @@ -1084,7 +1084,7 @@ image_scale_callback (GtkWidget *w, GImage *gimage; image_scale = (ImageResize *) client_data; - if ((gimage = gimage_get_ID (image_scale->gimage_id)) != NULL) + if ((gimage = image_scale->gimage) != NULL) { if (image_scale->resize->width > 0 && image_scale->resize->height > 0) diff --git a/app/gui/help-commands.c b/app/gui/help-commands.c index b3175afbb3..1b900a633b 100644 --- a/app/gui/help-commands.c +++ b/app/gui/help-commands.c @@ -70,7 +70,7 @@ typedef struct { GtkWidget * shell; Resize * resize; - int gimage_id; + GimpImage* gimage; } ImageResize; /* external functions */ @@ -724,7 +724,7 @@ image_resize_cmd_callback (GtkWidget *widget, /* the ImageResize structure */ image_resize = (ImageResize *) g_malloc (sizeof (ImageResize)); - image_resize->gimage_id = gdisp->gimage->ID; + image_resize->gimage = gdisp->gimage; image_resize->resize = resize_widget_new (ResizeWidget, gdisp->gimage->width, gdisp->gimage->height); /* the dialog */ @@ -771,7 +771,7 @@ image_scale_cmd_callback (GtkWidget *widget, /* the ImageResize structure */ image_scale = (ImageResize *) g_malloc (sizeof (ImageResize)); - image_scale->gimage_id = gdisp->gimage->ID; + image_scale->gimage = gdisp->gimage; image_scale->resize = resize_widget_new (ScaleWidget, gdisp->gimage->width, gdisp->gimage->height); /* the dialog */ @@ -1052,7 +1052,7 @@ image_resize_callback (GtkWidget *w, GImage *gimage; image_resize = (ImageResize *) client_data; - if ((gimage = gimage_get_ID (image_resize->gimage_id)) != NULL) + if ((gimage = image_resize->gimage) != NULL) { if (image_resize->resize->width > 0 && image_resize->resize->height > 0) @@ -1084,7 +1084,7 @@ image_scale_callback (GtkWidget *w, GImage *gimage; image_scale = (ImageResize *) client_data; - if ((gimage = gimage_get_ID (image_scale->gimage_id)) != NULL) + if ((gimage = image_scale->gimage) != NULL) { if (image_scale->resize->width > 0 && image_scale->resize->height > 0) diff --git a/app/gui/layers-dialog.c b/app/gui/layers-dialog.c index a0fadf1ce7..61112d6b47 100644 --- a/app/gui/layers-dialog.c +++ b/app/gui/layers-dialog.c @@ -776,7 +776,7 @@ create_image_menu_cb (gpointer im, gpointer d) image_name = prune_filename (gimage_filename (gimage)); menu_item_label = (char *) g_malloc (strlen (image_name) + 15); - sprintf (menu_item_label, "%s-%d", image_name, gimage->ID); + sprintf (menu_item_label, "%s-%p", image_name, gimage); menu_item = gtk_menu_item_new_with_label (menu_item_label); gtk_signal_connect (GTK_OBJECT (menu_item), "activate", (GtkSignalFunc) data->callback, diff --git a/app/gui/plug-in-commands.c b/app/gui/plug-in-commands.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/gui/plug-in-commands.c +++ b/app/gui/plug-in-commands.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/gui/plug-in-menus.c b/app/gui/plug-in-menus.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/gui/plug-in-menus.c +++ b/app/gui/plug-in-menus.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/indexed_palette.c b/app/indexed_palette.c index 289d804ccd..7daf52b6e2 100644 --- a/app/indexed_palette.c +++ b/app/indexed_palette.c @@ -485,7 +485,7 @@ create_image_menu_cb (gpointer im, gpointer d) image_name = prune_filename (gimage_filename (gimage)); menu_item_label = (char *) g_malloc (strlen (image_name) + 15); - sprintf (menu_item_label, "%s-%d", image_name, gimage->ID); + sprintf (menu_item_label, "%s-%p", image_name, gimage); menu_item = gtk_menu_item_new_with_label (menu_item_label); gtk_signal_connect (GTK_OBJECT (menu_item), "activate", (GtkSignalFunc) data->callback, diff --git a/app/interface.c b/app/interface.c index 44b733466f..ae168a9589 100644 --- a/app/interface.c +++ b/app/interface.c @@ -542,7 +542,7 @@ toolbox_raise_callback (GtkWidget *widget, void -create_display_shell (int gdisp_id, +create_display_shell (GDisplay* gdisp, int width, int height, char *title, @@ -550,7 +550,6 @@ create_display_shell (int gdisp_id, { static GtkWidget *image_popup_menu = NULL; static GtkAccelGroup *image_accel_group = NULL; - GDisplay *gdisp; GtkWidget *vbox; GtkWidget *table; GtkWidget *table_inner; @@ -561,10 +560,6 @@ create_display_shell (int gdisp_id, int scalesrc, scaledest; int contextid; - /* Get the gdisplay */ - if (! (gdisp = gdisplay_get_ID (gdisp_id))) - return; - /* adjust the initial scale -- so that window fits on screen */ { s_width = gdk_screen_width (); diff --git a/app/interface.h b/app/interface.h index f14b3dbbbc..5d1cd9301a 100644 --- a/app/interface.h +++ b/app/interface.h @@ -19,6 +19,7 @@ #define __INTERFACE_H__ #include "tools.h" +#include "gdisplay.h" /* typedefs */ typedef void (*QueryFunc) (GtkWidget *, gpointer, gpointer); @@ -34,7 +35,7 @@ GdkPixmap * create_tool_pixmap (GtkWidget *, ToolType); void create_toolbox (void); void toolbox_free (void); void toolbox_raise_callback (GtkWidget *, gpointer); -void create_display_shell (int, int, int, char *, int); +void create_display_shell (GDisplay* , int, int, char *, int); void position_dialog (GtkWidget *, gpointer, gpointer); void center_dialog (GtkWidget *, gpointer, gpointer); GtkWidget * query_string_box (char *, char *, char *, QueryFunc, gpointer); diff --git a/app/invert.c b/app/invert.c index 82db12a1c7..3455bb3564 100644 --- a/app/invert.c +++ b/app/invert.c @@ -48,7 +48,7 @@ image_invert (gimage_ptr) return_vals = procedural_db_run_proc ("gimp_invert", &nreturn_vals, - PDB_IMAGE, gimage->ID, + PDB_IMAGE, pdb_image_to_id(gimage), PDB_DRAWABLE, drawable_ID (drawable), PDB_END); diff --git a/app/layer.c b/app/layer.c index 27aae01f4e..68ac3c0eec 100644 --- a/app/layer.c +++ b/app/layer.c @@ -655,10 +655,8 @@ layer_add_alpha (layer) GIMP_DRAWABLE(layer)->bytes = GIMP_DRAWABLE(layer)->bytes + 1; GIMP_DRAWABLE(layer)->has_alpha = TYPE_HAS_ALPHA (type); - /* update gdisplay titles to reflect the possibility of - * this layer being the only layer in the gimage - */ - gdisplays_update_title (GIMP_DRAWABLE(layer)->gimage); + gtk_signal_emit_by_name(GTK_OBJECT(gimp_drawable_gimage(GIMP_DRAWABLE(layer))), + "restructure"); } @@ -893,7 +891,7 @@ layer_invalidate_boundary (layer) Channel *mask; /* first get the selection mask channel */ - if (! (gimage = GIMP_DRAWABLE(layer)->gimage)) + if (! (gimage = drawable_gimage(GIMP_DRAWABLE(layer)))) return; /* Turn the current selection off */ @@ -909,7 +907,8 @@ layer_invalidate_boundary (layer) } /* clear the affected region surrounding the layer */ - gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage, SelectionLayerOff); + /* gdisplays_selection_visibility (GIMP_DRAWABLE(layer)->gimage, + SelectionLayerOff); */ } diff --git a/app/layer.h b/app/layer.h index bf2774ac84..0217806491 100644 --- a/app/layer.h +++ b/app/layer.h @@ -138,9 +138,11 @@ TempBuf * layer_mask_preview (Layer *, int, int); void layer_invalidate_previews (GimpImage*); -/* from drawable.c */ -Layer * drawable_layer (GimpDrawable *); -LayerMask * drawable_layer_mask (GimpDrawable *); +/* temp thingies.. dynamic downcast. GTK_NO_CHECK_CASTS must not be + defined */ + +#define drawable_layer GIMP_IS_LAYER +#define drawable_layer_mask GIMP_IS_LAYER_MASK /* from channel.c */ void channel_layer_alpha (Channel *, Layer *); diff --git a/app/layers_dialog.c b/app/layers_dialog.c index a0fadf1ce7..61112d6b47 100644 --- a/app/layers_dialog.c +++ b/app/layers_dialog.c @@ -776,7 +776,7 @@ create_image_menu_cb (gpointer im, gpointer d) image_name = prune_filename (gimage_filename (gimage)); menu_item_label = (char *) g_malloc (strlen (image_name) + 15); - sprintf (menu_item_label, "%s-%d", image_name, gimage->ID); + sprintf (menu_item_label, "%s-%p", image_name, gimage); menu_item = gtk_menu_item_new_with_label (menu_item_label); gtk_signal_connect (GTK_OBJECT (menu_item), "activate", (GtkSignalFunc) data->callback, diff --git a/app/menus/plug-in-menus.c b/app/menus/plug-in-menus.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/menus/plug-in-menus.c +++ b/app/menus/plug-in-menus.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/paint/gimpclone.c b/app/paint/gimpclone.c index 9fecd23555..c43438fc35 100644 --- a/app/paint/gimpclone.c +++ b/app/paint/gimpclone.c @@ -72,7 +72,7 @@ static int offset_x = 0; /* */ static int offset_y = 0; /* offset for cloning */ static int first = TRUE; static int trans_tx, trans_ty; /* transformed target */ -static int src_gdisp_ID = -1; /* ID of source gdisplay */ +static GDisplay* the_src_gdisp = NULL; /* ID of source gdisplay */ static GimpDrawable * src_drawable_ = NULL; /* source drawable */ static CloneOptions *clone_options = NULL; @@ -217,7 +217,7 @@ clone_paint_func (PaintCore *paint_core, case INIT_PAINT : if (paint_core->state & ControlMask) { - src_gdisp_ID = gdisp->ID; + the_src_gdisp = gdisp; src_drawable_ = drawable; src_x = paint_core->curx; src_y = paint_core->cury; @@ -241,11 +241,11 @@ clone_paint_func (PaintCore *paint_core, } /* Calculate the coordinates of the target */ - src_gdisp = gdisplay_get_ID (src_gdisp_ID); + src_gdisp = the_src_gdisp; if (!src_gdisp) { - src_gdisp_ID = gdisp->ID; - src_gdisp = gdisplay_get_ID (src_gdisp_ID); + the_src_gdisp = gdisp; + src_gdisp = the_src_gdisp; } /* Find the target cursor's location onscreen */ diff --git a/app/paint/gimpsourcecore.c b/app/paint/gimpsourcecore.c index 9fecd23555..c43438fc35 100644 --- a/app/paint/gimpsourcecore.c +++ b/app/paint/gimpsourcecore.c @@ -72,7 +72,7 @@ static int offset_x = 0; /* */ static int offset_y = 0; /* offset for cloning */ static int first = TRUE; static int trans_tx, trans_ty; /* transformed target */ -static int src_gdisp_ID = -1; /* ID of source gdisplay */ +static GDisplay* the_src_gdisp = NULL; /* ID of source gdisplay */ static GimpDrawable * src_drawable_ = NULL; /* source drawable */ static CloneOptions *clone_options = NULL; @@ -217,7 +217,7 @@ clone_paint_func (PaintCore *paint_core, case INIT_PAINT : if (paint_core->state & ControlMask) { - src_gdisp_ID = gdisp->ID; + the_src_gdisp = gdisp; src_drawable_ = drawable; src_x = paint_core->curx; src_y = paint_core->cury; @@ -241,11 +241,11 @@ clone_paint_func (PaintCore *paint_core, } /* Calculate the coordinates of the target */ - src_gdisp = gdisplay_get_ID (src_gdisp_ID); + src_gdisp = the_src_gdisp; if (!src_gdisp) { - src_gdisp_ID = gdisp->ID; - src_gdisp = gdisplay_get_ID (src_gdisp_ID); + the_src_gdisp = gdisp; + src_gdisp = the_src_gdisp; } /* Find the target cursor's location onscreen */ diff --git a/app/plug-in/gimpplugin-message.c b/app/plug-in/gimpplugin-message.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/gimpplugin-message.c +++ b/app/plug-in/gimpplugin-message.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/gimpplugin-progress.c b/app/plug-in/gimpplugin-progress.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/gimpplugin-progress.c +++ b/app/plug-in/gimpplugin-progress.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/gimpplugin.c b/app/plug-in/gimpplugin.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/gimpplugin.c +++ b/app/plug-in/gimpplugin.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/gimppluginmanager-call.c b/app/plug-in/gimppluginmanager-call.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/gimppluginmanager-call.c +++ b/app/plug-in/gimppluginmanager-call.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/gimppluginmanager-run.c b/app/plug-in/gimppluginmanager-run.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/gimppluginmanager-run.c +++ b/app/plug-in/gimppluginmanager-run.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/gimppluginmanager.c b/app/plug-in/gimppluginmanager.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/gimppluginmanager.c +++ b/app/plug-in/gimppluginmanager.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/gimppluginshm.c b/app/plug-in/gimppluginshm.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/gimppluginshm.c +++ b/app/plug-in/gimppluginshm.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/plug-in-def.c b/app/plug-in/plug-in-def.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/plug-in-def.c +++ b/app/plug-in/plug-in-def.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/plug-in-message.c b/app/plug-in/plug-in-message.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/plug-in-message.c +++ b/app/plug-in/plug-in-message.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/plug-in-params.c b/app/plug-in/plug-in-params.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/plug-in-params.c +++ b/app/plug-in/plug-in-params.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/plug-in-progress.c b/app/plug-in/plug-in-progress.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/plug-in-progress.c +++ b/app/plug-in/plug-in-progress.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/plug-in-run.c b/app/plug-in/plug-in-run.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/plug-in-run.c +++ b/app/plug-in/plug-in-run.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/plug-in-shm.c b/app/plug-in/plug-in-shm.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/plug-in-shm.c +++ b/app/plug-in/plug-in-shm.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/plug-in.c b/app/plug-in/plug-in.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/plug-in.c +++ b/app/plug-in/plug-in.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug-in/plug-ins.c b/app/plug-in/plug-ins.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug-in/plug-ins.c +++ b/app/plug-in/plug-ins.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/plug_in.c b/app/plug_in.c index 1f7abd0b03..b9fa9fae7b 100644 --- a/app/plug_in.c +++ b/app/plug_in.c @@ -1157,7 +1157,7 @@ plug_in_repeat (int with_interface) /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = (with_interface ? RUN_INTERACTIVE : RUN_WITH_LAST_VALS); - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); /* run the plug-in procedure */ @@ -2211,7 +2211,7 @@ plug_in_callback (GtkWidget *widget, /* initialize the first 3 plug-in arguments */ args[0].value.pdb_int = RUN_INTERACTIVE; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else @@ -2232,7 +2232,7 @@ plug_in_callback (GtkWidget *widget, { gdisp_ID = gdisplay->ID; - args[1].value.pdb_int = gdisplay->gimage->ID; + args[1].value.pdb_int = pdb_image_to_id(gdisplay->gimage); args[2].value.pdb_int = drawable_ID (gimage_active_drawable (gdisplay->gimage)); } else diff --git a/app/procedural_db.c b/app/procedural_db.c index c16e5d1589..6653f8f951 100644 --- a/app/procedural_db.c +++ b/app/procedural_db.c @@ -69,6 +69,7 @@ static Argument * procedural_db_query (Argument *); static void procedural_db_query_entry (gpointer, gpointer, gpointer); static int match_strings (regex_t *, char *); static guint procedural_db_hash_func (gconstpointer key); +static void pdb_id_init (void); /* Local data */ @@ -528,6 +529,7 @@ procedural_db_init () if (!procedural_ht) procedural_ht = g_hash_table_new (procedural_db_hash_func, g_str_equal); + pdb_id_init (); } void @@ -1244,3 +1246,53 @@ procedural_db_hash_func (gconstpointer key) return result; } + + +/* The id system's remnants ... */ + +static gint next_image_id; +static gint next_drawable_id; +static gint next_display_id; + +static GHashTable* image_hash; +static GHashTable* drawable_hash; +static GHashTable* display_hash; + +static guint id_hash_func(gconstpointer id){ + return *((guint*)id); +} + +static gboolean id_cmp_func(gconstpointer id1, gconstpointer id2){ + return (*((guint*)id1)==*((guint*)id2)); +} + +static void pdb_id_init (void){ + image_hash=g_hash_table_new(id_hash_func, id_cmp_func); + drawable_hash=g_hash_table_new(id_hash_func, id_cmp_func); + display_hash=g_hash_table_new(id_hash_func, id_cmp_func); +} + +void pdb_add_image(GimpImage* gimage){ + guint* id=g_new(gint,1); + *id=next_image_id++; + gtk_object_set_data(GTK_OBJECT(gimage), "pdb_id", id); + g_hash_table_insert(image_hash, id, gimage); +} + +gint pdb_image_to_id(GimpImage* gimage){ + guint *id=gtk_object_get_data(GTK_OBJECT(gimage), "pdb_id"); + return id?(gint)*id:-1; +} + +GimpImage* pdb_id_to_image(gint id){ + return g_hash_table_lookup(image_hash, &id); +} + + +void pdb_remove_image(GimpImage* image){ + guint* id=gtk_object_get_data(GTK_OBJECT(image), "pdb_id"); + gtk_object_remove_data(GTK_OBJECT(image), "pdb_id"); + g_hash_table_remove(image_hash, id); + g_free(id); +} + diff --git a/app/procedural_db.h b/app/procedural_db.h index f0c7c64221..8559d54656 100644 --- a/app/procedural_db.h +++ b/app/procedural_db.h @@ -18,6 +18,8 @@ #ifndef __PROCEDURAL_DB_H__ #define __PROCEDURAL_DB_H__ +#include "gimpimageF.h" + /* Procedural database types */ typedef enum { @@ -190,5 +192,11 @@ Argument * procedural_db_return_args (ProcRecord *, int); void procedural_db_destroy_args (Argument *, int); +void pdb_add_image(GimpImage* gimage); +gint pdb_image_to_id(GimpImage* gimage); +GimpImage* pdb_id_to_image(gint id); +void pdb_remove_image(GimpImage* image); + + #endif /* __PROCEDURAL_DB_H__ */ diff --git a/app/tools/blend.c b/app/tools/blend.c index 2e3463fd1b..73cd0077be 100644 --- a/app/tools/blend.c +++ b/app/tools/blend.c @@ -602,7 +602,7 @@ blend_button_release (Tool *tool, { return_vals = procedural_db_run_proc ("gimp_blend", &nreturn_vals, - PDB_IMAGE, gimage->ID, + PDB_IMAGE, pdb_image_to_id(gimage), PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gimage)), PDB_INT32, (gint32) blend_options->blend_mode, PDB_INT32, (gint32) blend_options->paint_mode, diff --git a/app/tools/bucket_fill.c b/app/tools/bucket_fill.c index c2c9eeecf2..09b46b3e1d 100644 --- a/app/tools/bucket_fill.c +++ b/app/tools/bucket_fill.c @@ -313,7 +313,8 @@ bucket_fill_button_release (tool, bevent, gdisp_ptr) return_vals = procedural_db_run_proc ("gimp_bucket_fill", &nreturn_vals, - PDB_IMAGE, gdisp->gimage->ID, + PDB_IMAGE, + pdb_image_to_id(gdisp->gimage), PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gdisp->gimage)), PDB_INT32, (gint32) fill_mode, PDB_INT32, (gint32) bucket_options->paint_mode, diff --git a/app/tools/clone.c b/app/tools/clone.c index 9fecd23555..c43438fc35 100644 --- a/app/tools/clone.c +++ b/app/tools/clone.c @@ -72,7 +72,7 @@ static int offset_x = 0; /* */ static int offset_y = 0; /* offset for cloning */ static int first = TRUE; static int trans_tx, trans_ty; /* transformed target */ -static int src_gdisp_ID = -1; /* ID of source gdisplay */ +static GDisplay* the_src_gdisp = NULL; /* ID of source gdisplay */ static GimpDrawable * src_drawable_ = NULL; /* source drawable */ static CloneOptions *clone_options = NULL; @@ -217,7 +217,7 @@ clone_paint_func (PaintCore *paint_core, case INIT_PAINT : if (paint_core->state & ControlMask) { - src_gdisp_ID = gdisp->ID; + the_src_gdisp = gdisp; src_drawable_ = drawable; src_x = paint_core->curx; src_y = paint_core->cury; @@ -241,11 +241,11 @@ clone_paint_func (PaintCore *paint_core, } /* Calculate the coordinates of the target */ - src_gdisp = gdisplay_get_ID (src_gdisp_ID); + src_gdisp = the_src_gdisp; if (!src_gdisp) { - src_gdisp_ID = gdisp->ID; - src_gdisp = gdisplay_get_ID (src_gdisp_ID); + the_src_gdisp = gdisp; + src_gdisp = the_src_gdisp; } /* Find the target cursor's location onscreen */ diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c index 2e3463fd1b..73cd0077be 100644 --- a/app/tools/gimpblendtool.c +++ b/app/tools/gimpblendtool.c @@ -602,7 +602,7 @@ blend_button_release (Tool *tool, { return_vals = procedural_db_run_proc ("gimp_blend", &nreturn_vals, - PDB_IMAGE, gimage->ID, + PDB_IMAGE, pdb_image_to_id(gimage), PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gimage)), PDB_INT32, (gint32) blend_options->blend_mode, PDB_INT32, (gint32) blend_options->paint_mode, diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c index c2c9eeecf2..09b46b3e1d 100644 --- a/app/tools/gimpbucketfilltool.c +++ b/app/tools/gimpbucketfilltool.c @@ -313,7 +313,8 @@ bucket_fill_button_release (tool, bevent, gdisp_ptr) return_vals = procedural_db_run_proc ("gimp_bucket_fill", &nreturn_vals, - PDB_IMAGE, gdisp->gimage->ID, + PDB_IMAGE, + pdb_image_to_id(gdisp->gimage), PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gdisp->gimage)), PDB_INT32, (gint32) fill_mode, PDB_INT32, (gint32) bucket_options->paint_mode, diff --git a/app/tools/gimpclonetool.c b/app/tools/gimpclonetool.c index 9fecd23555..c43438fc35 100644 --- a/app/tools/gimpclonetool.c +++ b/app/tools/gimpclonetool.c @@ -72,7 +72,7 @@ static int offset_x = 0; /* */ static int offset_y = 0; /* offset for cloning */ static int first = TRUE; static int trans_tx, trans_ty; /* transformed target */ -static int src_gdisp_ID = -1; /* ID of source gdisplay */ +static GDisplay* the_src_gdisp = NULL; /* ID of source gdisplay */ static GimpDrawable * src_drawable_ = NULL; /* source drawable */ static CloneOptions *clone_options = NULL; @@ -217,7 +217,7 @@ clone_paint_func (PaintCore *paint_core, case INIT_PAINT : if (paint_core->state & ControlMask) { - src_gdisp_ID = gdisp->ID; + the_src_gdisp = gdisp; src_drawable_ = drawable; src_x = paint_core->curx; src_y = paint_core->cury; @@ -241,11 +241,11 @@ clone_paint_func (PaintCore *paint_core, } /* Calculate the coordinates of the target */ - src_gdisp = gdisplay_get_ID (src_gdisp_ID); + src_gdisp = the_src_gdisp; if (!src_gdisp) { - src_gdisp_ID = gdisp->ID; - src_gdisp = gdisplay_get_ID (src_gdisp_ID); + the_src_gdisp = gdisp; + src_gdisp = the_src_gdisp; } /* Find the target cursor's location onscreen */ diff --git a/app/tools/gimpsourcetool.c b/app/tools/gimpsourcetool.c index 9fecd23555..c43438fc35 100644 --- a/app/tools/gimpsourcetool.c +++ b/app/tools/gimpsourcetool.c @@ -72,7 +72,7 @@ static int offset_x = 0; /* */ static int offset_y = 0; /* offset for cloning */ static int first = TRUE; static int trans_tx, trans_ty; /* transformed target */ -static int src_gdisp_ID = -1; /* ID of source gdisplay */ +static GDisplay* the_src_gdisp = NULL; /* ID of source gdisplay */ static GimpDrawable * src_drawable_ = NULL; /* source drawable */ static CloneOptions *clone_options = NULL; @@ -217,7 +217,7 @@ clone_paint_func (PaintCore *paint_core, case INIT_PAINT : if (paint_core->state & ControlMask) { - src_gdisp_ID = gdisp->ID; + the_src_gdisp = gdisp; src_drawable_ = drawable; src_x = paint_core->curx; src_y = paint_core->cury; @@ -241,11 +241,11 @@ clone_paint_func (PaintCore *paint_core, } /* Calculate the coordinates of the target */ - src_gdisp = gdisplay_get_ID (src_gdisp_ID); + src_gdisp = the_src_gdisp; if (!src_gdisp) { - src_gdisp_ID = gdisp->ID; - src_gdisp = gdisplay_get_ID (src_gdisp_ID); + the_src_gdisp = gdisp; + src_gdisp = the_src_gdisp; } /* Find the target cursor's location onscreen */ diff --git a/app/tools/transform_core.c b/app/tools/transform_core.c index 1a8d0e4c0e..ea80dc0f69 100644 --- a/app/tools/transform_core.c +++ b/app/tools/transform_core.c @@ -1260,8 +1260,10 @@ transform_core_paste (gimage, drawable, tiles, new_layer) } else { - if ((layer = drawable_layer ( (drawable))) == NULL) - return NULL; + if (GIMP_IS_LAYER(drawable)) + layer=GIMP_LAYER(drawable); + else + return NULL; layer_add_alpha (layer); floating_layer = gimage_floating_sel (gimage); diff --git a/app/transform_core.c b/app/transform_core.c index 1a8d0e4c0e..ea80dc0f69 100644 --- a/app/transform_core.c +++ b/app/transform_core.c @@ -1260,8 +1260,10 @@ transform_core_paste (gimage, drawable, tiles, new_layer) } else { - if ((layer = drawable_layer ( (drawable))) == NULL) - return NULL; + if (GIMP_IS_LAYER(drawable)) + layer=GIMP_LAYER(drawable); + else + return NULL; layer_add_alpha (layer); floating_layer = gimage_floating_sel (gimage); diff --git a/app/xcf.c b/app/xcf.c index c61c369906..13eaa714e0 100644 --- a/app/xcf.c +++ b/app/xcf.c @@ -343,7 +343,7 @@ xcf_load_invoker (Argument *args) return_args = procedural_db_return_args (&xcf_plug_in_load_proc.db_info, success); if (success) - return_args[1].value.pdb_int = gimage->ID; + return_args[1].value.pdb_int = pdb_image_to_id(gimage); return return_args; } diff --git a/app/xcf/xcf.c b/app/xcf/xcf.c index c61c369906..13eaa714e0 100644 --- a/app/xcf/xcf.c +++ b/app/xcf/xcf.c @@ -343,7 +343,7 @@ xcf_load_invoker (Argument *args) return_args = procedural_db_return_args (&xcf_plug_in_load_proc.db_info, success); if (success) - return_args[1].value.pdb_int = gimage->ID; + return_args[1].value.pdb_int = pdb_image_to_id(gimage); return return_args; }