mirror of https://github.com/GNOME/gimp.git
Added persistent storage of image grid in XCF files.
2003-07-04 Henrik Brix Andersen <brix@gimp.org> Added persistent storage of image grid in XCF files. * app/core/gimpimage.[ch]: removed gimp_image_get_grid() and gimp_image_set_grid() ... * app/core/Makefile.am * app/core/gimpimage-grid.[ch]: ... and added them to these new files. Added gimp_grid_parasite_name(), gimp_grid_to_parasite() and gimp_grid_from_parasite() functions. * app/core/gimpimage-snap.c * app/gui/grid-dialog.c: #include "gimpimage-grid.h" * app/core/gimpimage-undo-push.c: #include "gimpimage-grid.h". (gimp_image_undo_push_image_grid) mark image as dirty. * app/xcf/xcf-save.c (xcf_save_image_props): save GimpGrid object as a parasite. * app/xcf/xcf-load.c (xcf_load_image): load GimpGrid from parasite. * devel-docs/parasites.txt: documented the new "gimp-image-grid" parasite.
This commit is contained in:
parent
156eee04ae
commit
5943f03135
27
ChangeLog
27
ChangeLog
|
@ -1,3 +1,30 @@
|
|||
2003-07-04 Henrik Brix Andersen <brix@gimp.org>
|
||||
|
||||
Added persistent storage of image grid in XCF files.
|
||||
|
||||
* app/core/gimpimage.[ch]: removed gimp_image_get_grid() and
|
||||
gimp_image_set_grid() ...
|
||||
|
||||
* app/core/Makefile.am
|
||||
* app/core/gimpimage-grid.[ch]: ... and added them to these new
|
||||
files. Added gimp_grid_parasite_name(), gimp_grid_to_parasite()
|
||||
and gimp_grid_from_parasite() functions.
|
||||
|
||||
* app/core/gimpimage-snap.c
|
||||
* app/gui/grid-dialog.c: #include "gimpimage-grid.h"
|
||||
|
||||
* app/core/gimpimage-undo-push.c: #include "gimpimage-grid.h".
|
||||
(gimp_image_undo_push_image_grid) mark image as dirty.
|
||||
|
||||
* app/xcf/xcf-save.c (xcf_save_image_props): save GimpGrid object
|
||||
as a parasite.
|
||||
|
||||
* app/xcf/xcf-load.c (xcf_load_image): load GimpGrid from
|
||||
parasite.
|
||||
|
||||
* devel-docs/parasites.txt: documented the new "gimp-image-grid"
|
||||
parasite.
|
||||
|
||||
2003-07-04 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* configure.in
|
||||
|
|
|
@ -103,6 +103,8 @@ libappcore_a_sources = \
|
|||
gimpimage-duplicate.h \
|
||||
gimpimage-flip.c \
|
||||
gimpimage-flip.h \
|
||||
gimpimage-grid.h \
|
||||
gimpimage-grid.c \
|
||||
gimpimage-guides.c \
|
||||
gimpimage-guides.h \
|
||||
gimpimage-mask.c \
|
||||
|
|
|
@ -0,0 +1,129 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* GimpGrid
|
||||
* Copyright (C) 2003 Henrik Brix Andersen <brix@gimp.org>
|
||||
*
|
||||
* 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 "config.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "config/gimpconfig.h"
|
||||
|
||||
#include "gimp.h"
|
||||
#include "gimpgrid.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-grid.h"
|
||||
#include "gimpimage-undo.h"
|
||||
#include "gimpimage-undo-push.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
GimpGrid *
|
||||
gimp_image_get_grid (GimpImage *gimage)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
|
||||
return gimage->grid;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_grid (GimpImage *gimage,
|
||||
GimpGrid *grid,
|
||||
gboolean push_undo)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (grid == NULL || GIMP_IS_GRID (grid));
|
||||
|
||||
if (grid != gimage->grid)
|
||||
{
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_image_grid (gimage, _("Grid"), gimage->grid);
|
||||
|
||||
if (gimage->grid)
|
||||
g_object_unref (gimage->grid);
|
||||
|
||||
gimage->grid = grid;
|
||||
|
||||
if (gimage->grid)
|
||||
g_object_ref (gimage->grid);
|
||||
}
|
||||
|
||||
gimp_image_grid_changed (gimage);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_grid_parasite_name (void)
|
||||
{
|
||||
return "gimp-image-grid";
|
||||
}
|
||||
|
||||
GimpParasite *
|
||||
gimp_grid_to_parasite (const GimpGrid *grid)
|
||||
{
|
||||
GimpParasite *parasite;
|
||||
gchar *str;
|
||||
|
||||
g_return_val_if_fail (GIMP_IS_GRID (grid), NULL);
|
||||
|
||||
str = gimp_config_serialize_to_string (G_OBJECT (grid), NULL);
|
||||
g_return_val_if_fail (str != NULL, NULL);
|
||||
|
||||
parasite = gimp_parasite_new (gimp_grid_parasite_name (),
|
||||
GIMP_PARASITE_PERSISTENT,
|
||||
strlen (str) + 1, str);
|
||||
g_free (str);
|
||||
|
||||
return parasite;
|
||||
}
|
||||
|
||||
GimpGrid *
|
||||
gimp_grid_from_parasite (const GimpParasite *parasite)
|
||||
{
|
||||
GimpGrid *grid;
|
||||
const gchar *str;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_val_if_fail (parasite != NULL, NULL);
|
||||
g_return_val_if_fail (strcmp (gimp_parasite_name (parasite),
|
||||
gimp_grid_parasite_name ()) == 0, NULL);
|
||||
|
||||
str = gimp_parasite_data (parasite);
|
||||
g_return_val_if_fail (str != NULL, NULL);
|
||||
|
||||
grid = g_object_new (GIMP_TYPE_GRID, NULL);
|
||||
|
||||
if (! gimp_config_deserialize_string (G_OBJECT (grid),
|
||||
str,
|
||||
gimp_parasite_data_size (parasite),
|
||||
NULL,
|
||||
&error))
|
||||
{
|
||||
g_warning ("Failed to deserialize grid parasite: %s", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
|
||||
return grid;
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattisbvf
|
||||
*
|
||||
* GimpGrid
|
||||
* Copyright (C) 2003 Henrik Brix Andersen <brix@gimp.org>
|
||||
*
|
||||
* 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 __GIMP_IMAGE_GRID_H__
|
||||
#define __GIMP_IMAGE_GRID_H__
|
||||
|
||||
|
||||
GimpGrid * gimp_image_get_grid (GimpImage *gimage);
|
||||
void gimp_image_set_grid (GimpImage *gimage,
|
||||
GimpGrid *grid,
|
||||
gboolean push_undo);
|
||||
|
||||
const gchar * gimp_grid_parasite_name (void) G_GNUC_CONST;
|
||||
GimpParasite * gimp_grid_to_parasite (const GimpGrid *grid);
|
||||
GimpGrid * gimp_grid_from_parasite (const GimpParasite *parasite);
|
||||
|
||||
|
||||
#endif /* __GIMP_IMAGE_GRID_H__ */
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "gimp.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-grid.h"
|
||||
#include "gimpimage-snap.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "gimpcontext.h"
|
||||
#include "gimpgrid.h"
|
||||
#include "gimpimage-colormap.h"
|
||||
#include "gimpimage-grid.h"
|
||||
#include "gimpimage-guides.h"
|
||||
#include "gimpimage-mask.h"
|
||||
#include "gimpimage-projection.h"
|
||||
|
@ -652,14 +653,11 @@ gimp_image_undo_push_image_grid (GimpImage *gimage,
|
|||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
|
||||
g_return_val_if_fail (grid == NULL || GIMP_IS_GRID (grid), FALSE);
|
||||
|
||||
#ifdef __GNUC__
|
||||
#warning FIXME: mark image as dirty when grid save functionality is added
|
||||
#endif
|
||||
if ((new = gimp_image_undo_push (gimage,
|
||||
sizeof (GridUndo),
|
||||
sizeof (GridUndo),
|
||||
GIMP_UNDO_IMAGE_GRID, undo_desc,
|
||||
FALSE,
|
||||
TRUE,
|
||||
undo_pop_image_grid,
|
||||
undo_free_image_grid)))
|
||||
{
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
#include "gimp.h"
|
||||
#include "gimp-parasites.h"
|
||||
#include "gimpcontext.h"
|
||||
#include "gimpgrid.h"
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-colorhash.h"
|
||||
#include "gimpimage-colormap.h"
|
||||
|
@ -1245,6 +1244,14 @@ gimp_image_get_component_visible (const GimpImage *gimage,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_grid_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
g_signal_emit (gimage, gimp_image_signals[GRID_CHANGED], 0);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_mode_changed (GimpImage *gimage)
|
||||
{
|
||||
|
@ -3243,47 +3250,3 @@ gimp_image_invalidate_channel_previews (GimpImage *gimage)
|
|||
(GFunc) gimp_viewable_invalidate_preview,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
/* grid */
|
||||
|
||||
void
|
||||
gimp_image_grid_changed (GimpImage *gimage)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
|
||||
g_signal_emit (gimage, gimp_image_signals[GRID_CHANGED], 0);
|
||||
}
|
||||
|
||||
GimpGrid *
|
||||
gimp_image_get_grid (GimpImage *gimage)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
|
||||
|
||||
return gimage->grid;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_image_set_grid (GimpImage *gimage,
|
||||
GimpGrid *grid,
|
||||
gboolean push_undo)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_IMAGE (gimage));
|
||||
g_return_if_fail (grid == NULL || GIMP_IS_GRID (grid));
|
||||
|
||||
if (grid != gimage->grid)
|
||||
{
|
||||
if (push_undo)
|
||||
gimp_image_undo_push_image_grid (gimage, _("Grid"), gimage->grid);
|
||||
|
||||
if (gimage->grid)
|
||||
g_object_unref (gimage->grid);
|
||||
|
||||
gimage->grid = grid;
|
||||
|
||||
if (gimage->grid)
|
||||
g_object_ref (gimage->grid);
|
||||
}
|
||||
|
||||
gimp_image_grid_changed (gimage);
|
||||
}
|
||||
|
|
|
@ -486,10 +486,5 @@ GimpLayer * gimp_image_pick_correlate_layer (const GimpImage *gimage,
|
|||
void gimp_image_invalidate_layer_previews (GimpImage *gimage);
|
||||
void gimp_image_invalidate_channel_previews (GimpImage *gimage);
|
||||
|
||||
GimpGrid * gimp_image_get_grid (GimpImage *gimage);
|
||||
void gimp_image_set_grid (GimpImage *gimage,
|
||||
GimpGrid *grid,
|
||||
gboolean push_undo);
|
||||
|
||||
|
||||
#endif /* __GIMP_IMAGE_H__ */
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-grid.h"
|
||||
#include "core/gimpgrid.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-grid.h"
|
||||
#include "core/gimpgrid.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-grid.h"
|
||||
#include "core/gimpimage-guides.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimplayer-floating-sel.h"
|
||||
|
@ -107,15 +108,16 @@ GimpImage *
|
|||
xcf_load_image (Gimp *gimp,
|
||||
XcfInfo *info)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
GimpLayer *layer;
|
||||
GimpChannel *channel;
|
||||
guint32 saved_pos;
|
||||
guint32 offset;
|
||||
gint width;
|
||||
gint height;
|
||||
gint image_type;
|
||||
gint num_successful_elements = 0;
|
||||
GimpImage *gimage;
|
||||
GimpLayer *layer;
|
||||
GimpChannel *channel;
|
||||
GimpParasite *parasite;
|
||||
guint32 saved_pos;
|
||||
guint32 offset;
|
||||
gint width;
|
||||
gint height;
|
||||
gint image_type;
|
||||
gint num_successful_elements = 0;
|
||||
|
||||
/* read in the image width, height and type */
|
||||
info->cp += xcf_read_int32 (info->fp, (guint32 *) &width, 1);
|
||||
|
@ -131,6 +133,23 @@ xcf_load_image (Gimp *gimp,
|
|||
if (!xcf_load_image_props (info, gimage))
|
||||
goto hard_error;
|
||||
|
||||
/* check for a GimpGrid parasite */
|
||||
parasite = gimp_image_parasite_find (GIMP_IMAGE (gimage),
|
||||
gimp_grid_parasite_name ());
|
||||
if (parasite)
|
||||
{
|
||||
GimpGrid *grid = gimp_grid_from_parasite (parasite);
|
||||
|
||||
if (grid)
|
||||
{
|
||||
gimp_parasite_list_remove (GIMP_IMAGE (gimage)->parasites,
|
||||
gimp_parasite_name (parasite));
|
||||
|
||||
gimp_image_set_grid (GIMP_IMAGE (gimage), grid, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
/* read in the offset of the next layer */
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
|
||||
#include "core/gimpchannel.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpgrid.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-grid.h"
|
||||
#include "core/gimpimage-mask.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimplayer-floating-sel.h"
|
||||
|
@ -391,6 +393,8 @@ xcf_save_image_props (XcfInfo *info,
|
|||
GimpImage *gimage,
|
||||
GError **error)
|
||||
{
|
||||
GimpParasite *parasite = NULL;
|
||||
|
||||
/* check and see if we should save the colormap property */
|
||||
if (gimage->cmap)
|
||||
xcf_check_error (xcf_save_prop (info, gimage, PROP_COLORMAP, error,
|
||||
|
@ -425,6 +429,27 @@ xcf_save_image_props (XcfInfo *info,
|
|||
xcf_check_error (xcf_save_prop (info, gimage, PROP_USER_UNIT,
|
||||
error, gimage->unit));
|
||||
|
||||
if (GIMP_IS_GRID (gimage->grid))
|
||||
{
|
||||
GimpGrid *grid = gimp_image_get_grid (gimage);
|
||||
|
||||
parasite = gimp_grid_to_parasite (grid);
|
||||
gimp_parasite_list_add (GIMP_IMAGE (gimage)->parasites, parasite);
|
||||
}
|
||||
|
||||
if (gimp_parasite_list_length (GIMP_IMAGE (gimage)->parasites) > 0)
|
||||
{
|
||||
xcf_check_error (xcf_save_prop (info, gimage, PROP_PARASITES, error,
|
||||
GIMP_IMAGE (gimage)->parasites));
|
||||
}
|
||||
|
||||
if (parasite)
|
||||
{
|
||||
gimp_parasite_list_remove (GIMP_IMAGE (gimage)->parasites,
|
||||
gimp_parasite_name (parasite));
|
||||
gimp_parasite_free (parasite);
|
||||
}
|
||||
|
||||
xcf_check_error (xcf_save_prop (info, gimage, PROP_END, error));
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -76,6 +76,12 @@ Global data follows no strict rules.
|
|||
think of ;-) Determines how one index from each dimension is
|
||||
selected (until we have pinpointed the brush to use).
|
||||
|
||||
"gimp-image-grid" (IMAGE, PERSISTENT)
|
||||
The GimpGrid object serialized to a string. Saved as parasite
|
||||
to keep the XCF files backwards compatible. Although gimp-1.2
|
||||
does not know how to handle the image grid, it keeps the grid
|
||||
information intact.
|
||||
|
||||
"gimp-text-layer" (LAYER, PERSISTENT)
|
||||
The associated GimpText object serialized to a string. For
|
||||
convenience the string is terminated by a trailing '\0'.
|
||||
|
|
Loading…
Reference in New Issue