Commit a84d697b authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

don't add the image to the image container, don't call undo_free().

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

	* app/gimage.c: don't add the image to the image container,
	don't call undo_free().

	* app/core/gimp.[ch]: add new images to gimp->images, optionally
	attach the comment parasite.

	* app/core/gimpedit.c
	* app/core/gimpimage-duplicate.c
	* app/core/gimpimage-new.c
	* app/gui/file-open-dialog.c
	* app/gui/toolbox.c
	* tools/pdbgen/pdb/image.pdb
	* app/pdb/image_cmds.c
	* app/xcf/xcf-load.c: call gimp_create_image() and/or
	gimp_create_display(), don't attach a comment parasite.

	* app/core/gimpimage.c: call undo_free() in "destroy".

	* app/file-open.c
	* app/gui/palette-import-dialog.c
	* app/xcf/xcf-save.c: don't #include "gimage.h"
parent a0014f7e
2001-07-05 Michael Natterer <mitch@gimp.org>
* app/gimage.c: don't add the image to the image container,
don't call undo_free().
* app/core/gimp.[ch]: add new images to gimp->images, optionally
attach the comment parasite.
* app/core/gimpedit.c
* app/core/gimpimage-duplicate.c
* app/core/gimpimage-new.c
* app/gui/file-open-dialog.c
* app/gui/toolbox.c
* tools/pdbgen/pdb/image.pdb
* app/pdb/image_cmds.c
* app/xcf/xcf-load.c: call gimp_create_image() and/or
gimp_create_display(), don't attach a comment parasite.
* app/core/gimpimage.c: call undo_free() in "destroy".
* app/file-open.c
* app/gui/palette-import-dialog.c
* app/xcf/xcf-save.c: don't #include "gimage.h"
2001-07-05 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
* app/image_new.[ch]: removed...
* app/core/Makefile.am
* app/core/core-types.h
* app/core/gimpimage-new.[ch]: ...and (partly) added here.
......
......@@ -22,7 +22,6 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "core-types.h"
......@@ -47,10 +46,6 @@
#include "app_procs.h"
#include "drawable.h"
#include "floating_sel.h"
#include "gdisplay.h"
#include "gimage.h"
#include "gimpparasite.h"
#include "gimprc.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
......@@ -249,14 +244,13 @@ gimp_edit_paste_as_new (Gimp *gimp,
{
GimpImage *gimage;
GimpLayer *layer;
GimpParasite *comment_parasite;
GDisplay *gdisp;
/* create a new image (always of type RGB) */
gimage = gimage_new (gimp,
tile_manager_width (paste),
tile_manager_height (paste),
RGB);
gimage = gimp_create_image (gimp,
tile_manager_width (paste),
tile_manager_height (paste),
RGB,
TRUE);
gimp_image_undo_disable (gimage);
if (invoke)
......@@ -266,16 +260,6 @@ gimp_edit_paste_as_new (Gimp *gimp,
gimp_image_set_unit (gimage, invoke->unit);
}
if (gimprc.default_comment)
{
comment_parasite = gimp_parasite_new ("gimp-comment",
GIMP_PARASITE_PERSISTENT,
strlen (gimprc.default_comment)+1,
(gpointer) gimprc.default_comment);
gimp_image_parasite_attach (gimage, comment_parasite);
gimp_parasite_free (comment_parasite);
}
layer = gimp_layer_new_from_tiles (gimage,
gimp_image_base_type_with_alpha (gimage),
paste,
......@@ -290,8 +274,7 @@ gimp_edit_paste_as_new (Gimp *gimp,
gimp_image_undo_enable (gimage);
gdisp = gdisplay_new (gimage, 0x0101);
gimp_context_set_display (gimp_context_get_user (), gdisp);
gimp_create_display (gimp, gimage);
return gimage;
}
......
......@@ -20,6 +20,8 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "core-types.h"
#include "base/tile-manager.h"
......@@ -323,7 +325,8 @@ GimpImage *
gimp_create_image (Gimp *gimp,
gint width,
gint height,
GimpImageBaseType type)
GimpImageBaseType type,
gboolean attach_comment)
{
GimpImage *gimage;
......@@ -332,6 +335,20 @@ gimp_create_image (Gimp *gimp,
gimage = gimage_new (gimp, width, height, type);
gimp_container_add (gimp->images, GIMP_OBJECT (gimage));
if (attach_comment && gimprc.default_comment)
{
GimpParasite *parasite;
parasite = gimp_parasite_new ("gimp-comment",
GIMP_PARASITE_PERSISTENT,
strlen (gimprc.default_comment) + 1,
gimprc.default_comment);
gimp_image_parasite_attach (gimage, parasite);
gimp_parasite_free (parasite);
}
return gimage;
}
......
......@@ -80,7 +80,8 @@ void gimp_shutdown (Gimp *gimp);
GimpImage * gimp_create_image (Gimp *gimp,
gint width,
gint height,
GimpImageBaseType type);
GimpImageBaseType type,
gboolean attach_comment);
void gimp_create_display (Gimp *gimp,
GimpImage *gimage);
......
......@@ -22,7 +22,6 @@
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "core-types.h"
......@@ -47,10 +46,6 @@
#include "app_procs.h"
#include "drawable.h"
#include "floating_sel.h"
#include "gdisplay.h"
#include "gimage.h"
#include "gimpparasite.h"
#include "gimprc.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
......@@ -249,14 +244,13 @@ gimp_edit_paste_as_new (Gimp *gimp,
{
GimpImage *gimage;
GimpLayer *layer;
GimpParasite *comment_parasite;
GDisplay *gdisp;
/* create a new image (always of type RGB) */
gimage = gimage_new (gimp,
tile_manager_width (paste),
tile_manager_height (paste),
RGB);
gimage = gimp_create_image (gimp,
tile_manager_width (paste),
tile_manager_height (paste),
RGB,
TRUE);
gimp_image_undo_disable (gimage);
if (invoke)
......@@ -266,16 +260,6 @@ gimp_edit_paste_as_new (Gimp *gimp,
gimp_image_set_unit (gimage, invoke->unit);
}
if (gimprc.default_comment)
{
comment_parasite = gimp_parasite_new ("gimp-comment",
GIMP_PARASITE_PERSISTENT,
strlen (gimprc.default_comment)+1,
(gpointer) gimprc.default_comment);
gimp_image_parasite_attach (gimage, comment_parasite);
gimp_parasite_free (comment_parasite);
}
layer = gimp_layer_new_from_tiles (gimage,
gimp_image_base_type_with_alpha (gimage),
paste,
......@@ -290,8 +274,7 @@ gimp_edit_paste_as_new (Gimp *gimp,
gimp_image_undo_enable (gimage);
gdisp = gdisplay_new (gimage, 0x0101);
gimp_context_set_display (gimp_context_get_user (), gdisp);
gimp_create_display (gimp, gimage);
return gimage;
}
......
......@@ -34,17 +34,18 @@
/* FIXME: remove the Path <-> BezierSelect dependency */
#include "tools/tools-types.h"
#include "app_procs.h"
#include "drawable.h"
#include "floating_sel.h"
#include "gdisplay.h"
#include "gimage.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpimage.h"
#include "gimpimage-duplicate.h"
#include "gimpimage-new.h"
#include "gimplayer.h"
#include "gimplist.h"
#include "app_procs.h"
#include "drawable.h"
#include "floating_sel.h"
#include "gdisplay.h"
#include "parasitelist.h"
#include "path.h"
......@@ -75,9 +76,10 @@ gimp_image_duplicate (GimpImage *gimage)
gimp_set_busy_until_idle ();
/* Create a new image */
new_gimage = gimage_new (gimage->gimp,
gimage->width, gimage->height,
gimage->base_type);
new_gimage = gimp_create_image (gimage->gimp,
gimage->width, gimage->height,
gimage->base_type,
FALSE);
gimp_image_undo_disable (new_gimage);
/* Copy resolution and unit information */
......
......@@ -491,6 +491,8 @@ gimp_image_destroy (GtkObject *object)
g_list_foreach (gimage->guides, (GFunc) g_free, NULL);
g_list_free (gimage->guides);
undo_free (gimage);
gtk_object_unref (GTK_OBJECT (gimage->new_undo_stack));
gtk_object_unref (GTK_OBJECT (gimage->new_redo_stack));
}
......
......@@ -491,6 +491,8 @@ gimp_image_destroy (GtkObject *object)
g_list_foreach (gimage->guides, (GFunc) g_free, NULL);
g_list_free (gimage->guides);
undo_free (gimage);
gtk_object_unref (GTK_OBJECT (gimage->new_undo_stack));
gtk_object_unref (GTK_OBJECT (gimage->new_redo_stack));
}
......
......@@ -229,7 +229,6 @@ gimp_image_new_create_image (Gimp *gimp,
GimpImage *gimage;
GimpLayer *layer;
GimpImageType type;
GimpParasite *comment_parasite;
gint width, height;
g_return_val_if_fail (values != NULL, NULL);
......@@ -251,21 +250,14 @@ gimp_image_new_create_image (Gimp *gimp,
break;
}
gimage = gimp_create_image (gimp, values->width, values->height, values->type);
gimage = gimp_create_image (gimp,
values->width, values->height,
values->type,
TRUE);
gimp_image_set_resolution (gimage, values->xresolution, values->yresolution);
gimp_image_set_unit (gimage, values->unit);
if (gimprc.default_comment)
{
comment_parasite = gimp_parasite_new ("gimp-comment",
GIMP_PARASITE_PERSISTENT,
strlen (gimprc.default_comment) + 1,
(gpointer) gimprc.default_comment);
gimp_image_parasite_attach (gimage, comment_parasite);
gimp_parasite_free (comment_parasite);
}
width = gimp_image_get_width (gimage);
height = gimp_image_get_height (gimage);
......
......@@ -491,6 +491,8 @@ gimp_image_destroy (GtkObject *object)
g_list_foreach (gimage->guides, (GFunc) g_free, NULL);
g_list_free (gimage->guides);
undo_free (gimage);
gtk_object_unref (GTK_OBJECT (gimage->new_undo_stack));
gtk_object_unref (GTK_OBJECT (gimage->new_redo_stack));
}
......
......@@ -491,6 +491,8 @@ gimp_image_destroy (GtkObject *object)
g_list_foreach (gimage->guides, (GFunc) g_free, NULL);
g_list_free (gimage->guides);
undo_free (gimage);
gtk_object_unref (GTK_OBJECT (gimage->new_undo_stack));
gtk_object_unref (GTK_OBJECT (gimage->new_redo_stack));
}
......
......@@ -491,6 +491,8 @@ gimp_image_destroy (GtkObject *object)
g_list_foreach (gimage->guides, (GFunc) g_free, NULL);
g_list_free (gimage->guides);
undo_free (gimage);
gtk_object_unref (GTK_OBJECT (gimage->new_undo_stack));
gtk_object_unref (GTK_OBJECT (gimage->new_redo_stack));
}
......
......@@ -491,6 +491,8 @@ gimp_image_destroy (GtkObject *object)
g_list_foreach (gimage->guides, (GFunc) g_free, NULL);
g_list_free (gimage->guides);
undo_free (gimage);
gtk_object_unref (GTK_OBJECT (gimage->new_undo_stack));
gtk_object_unref (GTK_OBJECT (gimage->new_redo_stack));
}
......
......@@ -491,6 +491,8 @@ gimp_image_destroy (GtkObject *object)
g_list_foreach (gimage->guides, (GFunc) g_free, NULL);
g_list_free (gimage->guides);
undo_free (gimage);
gtk_object_unref (GTK_OBJECT (gimage->new_undo_stack));
gtk_object_unref (GTK_OBJECT (gimage->new_redo_stack));
}
......
......@@ -42,6 +42,7 @@
#include "base/temp-buf.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
......@@ -53,7 +54,6 @@
#include "dialog_handler.h"
#include "docindex.h"
#include "gdisplay.h"
#include "gimage.h"
#include "gimprc.h"
#include "file-open.h"
#include "file-utils.h"
......@@ -242,7 +242,6 @@ file_open_with_proc_and_display (gchar *filename,
PlugInProcDef *file_proc)
{
GimpImage *gimage;
GDisplay *gdisplay;
gchar *absolute;
gint status;
......@@ -260,11 +259,7 @@ file_open_with_proc_and_display (gchar *filename,
gimp_image_clean_all (gimage);
/* display the image */
gdisplay = gdisplay_new (gimage, 0x0101);
/* always activate the first display */
if (g_slist_length (display_list) == 1)
gimp_context_set_display (gimp_context_get_user (), gdisplay);
gimp_create_display (gimage->gimp, gimage);
absolute = file_open_absolute_filename (filename);
......
......@@ -43,7 +43,6 @@
#include "palette-import-dialog.h"
#include "app_procs.h"
#include "gimage.h"
#include "libgimp/gimpintl.h"
......
......@@ -62,7 +62,6 @@
#include "core/gimpimage.h"
#include "app_procs.h"
#include "gimage.h"
#include "gimprc.h"
#include "file-open.h"
#include "file-utils.h"
......
......@@ -62,7 +62,6 @@
#include "core/gimpimage.h"
#include "app_procs.h"
#include "gimage.h"
#include "gimprc.h"
#include "file-open.h"
#include "file-utils.h"
......
......@@ -88,8 +88,6 @@ gimage_new (Gimp *gimp,
GTK_SIGNAL_FUNC (gimage_cmap_change_handler),
NULL);
gimp_container_add (gimp->images, GIMP_OBJECT (gimage));
return gimage;
}
......@@ -114,9 +112,6 @@ gimage_dirty_handler (GimpImage *gimage)
static void
gimage_destroy_handler (GimpImage *gimage)
{
/* free the undo list */
undo_free (gimage);
/* check if this is the last image */
if (gimp_container_num_children (gimage->gimp->images) == 1)
{
......
......@@ -42,6 +42,7 @@
#include "base/temp-buf.h"
#include "core/gimp.h"
#include "core/gimpcontext.h"
#include "core/gimpimage.h"
......@@ -53,7 +54,6 @@
#include "dialog_handler.h"
#include "docindex.h"
#include "gdisplay.h"
#include "gimage.h"
#include "gimprc.h"
#include "file-open.h"
#include "file-utils.h"
......@@ -242,7 +242,6 @@ file_open_with_proc_and_display (gchar *filename,
PlugInProcDef *file_proc)
{
GimpImage *gimage;
GDisplay *gdisplay;
gchar *absolute;
gint status;
......@@ -260,11 +259,7 @@ file_open_with_proc_and_display (gchar *filename,
gimp_image_clean_all (gimage);
/* display the image */
gdisplay = gdisplay_new (gimage, 0x0101);
/* always activate the first display */
if (g_slist_length (display_list) == 1)
gimp_context_set_display (gimp_context_get_user (), gdisplay);
gimp_create_display (gimage->gimp, gimage);
absolute = file_open_absolute_filename (filename);
......
......@@ -43,7 +43,6 @@
#include "palette-import-dialog.h"
#include "app_procs.h"
#include "gimage.h"
#include "libgimp/gimpintl.h"
......
......@@ -57,7 +57,6 @@
#include "app_procs.h"
#include "appenv.h"
#include "gimage.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
......@@ -513,7 +512,10 @@ toolbox_drop_drawable (GtkWidget *widget,
type = RGB; break;
}
new_gimage = gimage_new (the_gimp, width, height, type);
new_gimage = gimp_create_image (gimage->gimp,
width, height,
type,
FALSE);
gimp_image_undo_disable (new_gimage);
if (type == INDEXED) /* copy the colormap */
......@@ -566,10 +568,9 @@ toolbox_drop_drawable (GtkWidget *widget,
gimp_image_add_layer (new_gimage, new_layer, 0);
gimp_context_set_display (gimp_context_get_user (),
gdisplay_new (new_gimage, 0x0101));
gimp_image_undo_enable (new_gimage);
gimp_create_display (gimage->gimp, new_gimage);
}
static void
......
......@@ -42,7 +42,6 @@
#include "core/gimplist.h"
#include "drawable.h"
#include "gdisplay.h"
#include "gimage.h"
#include "libgimp/gimpintl.h"
#include "libgimpbase/gimpbase.h"
......@@ -266,7 +265,7 @@ image_new_invoker (Gimp *gimp,
success = FALSE;
if (success)
success = (gimage = gimage_new (gimp, width, height, type)) != NULL;
success = (gimage = gimp_create_image (gimp, width, height, type, FALSE)) != NULL;
return_args = procedural_db_return_args (&image_new_proc, success);
......
......@@ -57,7 +57,6 @@
#include "app_procs.h"
#include "appenv.h"
#include "gimage.h"
#include "gimprc.h"
#include "libgimp/gimpintl.h"
......@@ -513,7 +512,10 @@ toolbox_drop_drawable (GtkWidget *widget,
type = RGB; break;
}
new_gimage = gimage_new (the_gimp, width, height, type);
new_gimage = gimp_create_image (gimage->gimp,
width, height,
type,
FALSE);
gimp_image_undo_disable (new_gimage);
if (type == INDEXED) /* copy the colormap */
......@@ -566,10 +568,9 @@ toolbox_drop_drawable (GtkWidget *widget,
gimp_image_add_layer (new_gimage, new_layer, 0);
gimp_context_set_display (gimp_context_get_user (),
gdisplay_new (new_gimage, 0x0101));
gimp_image_undo_enable (new_gimage);
gimp_create_display (gimage->gimp, new_gimage);
}
static void
......
......@@ -32,6 +32,7 @@
#include "base/tile-manager.h"
#include "base/tile-manager-private.h"
#include "core/gimp.h"
#include "core/gimpchannel.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable.h"
......@@ -45,7 +46,6 @@
#include "xcf-seek.h"
#include "floating_sel.h"
#include "gimage.h"
#include "gimprc.h"
#include "parasitelist.h"
#include "path.h"
......@@ -253,10 +253,10 @@ xcf_load_image (Gimp *gimp,
info->cp += xcf_read_int32 (info->fp, (guint32 *) &height, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &image_type, 1);
/* create a new gimage */
gimage = gimage_new (gimp, width, height, image_type);
if (!gimage)
return NULL;
gimage = gimp_create_image (gimp,
width, height,
image_type,
FALSE);
/* read the image properties */
if (!xcf_load_image_props (info, gimage))
......
......@@ -46,7 +46,6 @@
#include "xcf-write.h"
#include "floating_sel.h"
#include "gimage.h"
#include "gimprc.h"
#include "parasitelist.h"
#include "path.h"
......
......@@ -264,7 +264,7 @@ HELP
%invoke = (
code => <<'CODE'
success = (gimage = gimage_new (gimp, width, height, type)) != NULL;
success = (gimage = gimp_create_image (gimp, width, height, type, FALSE)) != NULL;
CODE
);
}
......@@ -1456,8 +1456,7 @@ CODE
}
@headers = qw(<string.h> "gimage.h" "core/gimp.h"
"core/gimpcontainer.h"
@headers = qw(<string.h> "core/gimp.h" "core/gimpcontainer.h"
"core/gimplist.h" "base/temp-buf.h"
"libgimpmath/gimpmath.h" "libgimpbase/gimpbase.h"
"libgimp/gimpintl.h");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment