mirror of https://github.com/GNOME/gimp.git
broken pipe in the middle of the last commit...
* app/xcf/xcf-save.c: when saving a text layer, store an extra parasite that holds all information about the text. * app/xcf/xcf-load.c: if a "gimp-text-layer" parasite is found and it can be successfully deserialized to a GimpText object, convert the layer to a text layer and remove the parasite. * devel-docs/parasites.txt: documented the new "gimp-text-layer" parasite.
This commit is contained in:
parent
6b5e42def3
commit
35a57d0148
|
@ -46,6 +46,9 @@
|
|||
#include "core/gimpparasitelist.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "text/gimptextlayer.h"
|
||||
#include "text/gimptext-parasite.h"
|
||||
|
||||
#include "vectors/gimpvectors.h"
|
||||
#include "vectors/gimpvectors-compat.h"
|
||||
|
||||
|
@ -724,6 +727,7 @@ xcf_load_layer (XcfInfo *info,
|
|||
{
|
||||
GimpLayer *layer;
|
||||
GimpLayerMask *layer_mask;
|
||||
GimpParasite *parasite;
|
||||
guint32 hierarchy_offset;
|
||||
guint32 layer_mask_offset;
|
||||
gboolean apply_mask;
|
||||
|
@ -751,23 +755,47 @@ xcf_load_layer (XcfInfo *info,
|
|||
layer = gimp_layer_new (gimage, width, height,
|
||||
type, name, 255, GIMP_NORMAL_MODE);
|
||||
g_free (name);
|
||||
if (!layer)
|
||||
if (! layer)
|
||||
return NULL;
|
||||
|
||||
/* read in the layer properties */
|
||||
if (!xcf_load_layer_props (info, gimage, layer,
|
||||
&apply_mask, &edit_mask, &show_mask))
|
||||
if (! xcf_load_layer_props (info, gimage, layer,
|
||||
&apply_mask, &edit_mask, &show_mask))
|
||||
goto error;
|
||||
|
||||
/* check for a gimp-text parasite */
|
||||
parasite = gimp_item_parasite_find (GIMP_ITEM (layer),
|
||||
gimp_text_parasite_name ());
|
||||
if (parasite)
|
||||
{
|
||||
GimpText *text = gimp_text_from_parasite (parasite);
|
||||
|
||||
if (text)
|
||||
{
|
||||
gboolean active;
|
||||
|
||||
gimp_parasite_list_remove (GIMP_ITEM (layer)->parasites,
|
||||
gimp_parasite_name (parasite));
|
||||
|
||||
active = (info->active_layer == layer);
|
||||
|
||||
/* convert the layer to a text layer */
|
||||
layer = gimp_text_layer_from_layer (layer, text);
|
||||
|
||||
if (active)
|
||||
info->active_layer = layer;
|
||||
}
|
||||
}
|
||||
|
||||
/* read the hierarchy and layer mask offsets */
|
||||
info->cp += xcf_read_int32 (info->fp, &hierarchy_offset, 1);
|
||||
info->cp += xcf_read_int32 (info->fp, &layer_mask_offset, 1);
|
||||
|
||||
/* read in the hierarchy */
|
||||
if (!xcf_seek_pos (info, hierarchy_offset, NULL))
|
||||
if (! xcf_seek_pos (info, hierarchy_offset, NULL))
|
||||
goto error;
|
||||
|
||||
if (!xcf_load_hierarchy (info, GIMP_DRAWABLE(layer)->tiles))
|
||||
if (! xcf_load_hierarchy (info, GIMP_DRAWABLE (layer)->tiles))
|
||||
goto error;
|
||||
|
||||
/* read in the layer mask */
|
||||
|
@ -777,7 +805,7 @@ xcf_load_layer (XcfInfo *info,
|
|||
goto error;
|
||||
|
||||
layer_mask = xcf_load_layer_mask (info, gimage);
|
||||
if (!layer_mask)
|
||||
if (! layer_mask)
|
||||
goto error;
|
||||
|
||||
/* set the offsets of the layer_mask */
|
||||
|
|
|
@ -43,6 +43,9 @@
|
|||
#include "core/gimpparasitelist.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "text/gimptextlayer.h"
|
||||
#include "text/gimptext-parasite.h"
|
||||
|
||||
#include "vectors/gimpvectors.h"
|
||||
#include "vectors/gimpvectors-compat.h"
|
||||
|
||||
|
@ -407,7 +410,7 @@ xcf_save_image_props (XcfInfo *info,
|
|||
xcf_check_error (xcf_save_prop (info, gimage, PROP_TATTOO, error,
|
||||
gimage->tattoo_state));
|
||||
|
||||
if (gimp_parasite_list_length(gimage->parasites) > 0)
|
||||
if (gimp_parasite_list_length (gimage->parasites) > 0)
|
||||
xcf_check_error (xcf_save_prop (info, gimage, PROP_PARASITES,
|
||||
error, gimage->parasites));
|
||||
|
||||
|
@ -433,6 +436,8 @@ xcf_save_layer_props (XcfInfo *info,
|
|||
GimpLayer *layer,
|
||||
GError **error)
|
||||
{
|
||||
GimpParasite *parasite = NULL;
|
||||
|
||||
if (layer == gimp_image_get_active_layer (gimage))
|
||||
xcf_check_error (xcf_save_prop (info, gimage, PROP_ACTIVE_LAYER, error));
|
||||
|
||||
|
@ -479,9 +484,26 @@ xcf_save_layer_props (XcfInfo *info,
|
|||
xcf_check_error (xcf_save_prop (info, gimage, PROP_TATTOO, error,
|
||||
GIMP_ITEM (layer)->tattoo));
|
||||
|
||||
if (GIMP_IS_TEXT_LAYER (layer))
|
||||
{
|
||||
GimpText *text = gimp_text_layer_get_text (GIMP_TEXT_LAYER (layer));
|
||||
|
||||
parasite = gimp_text_to_parasite (text);
|
||||
gimp_parasite_list_add (GIMP_ITEM (layer)->parasites, parasite);
|
||||
}
|
||||
|
||||
if (gimp_parasite_list_length (GIMP_ITEM (layer)->parasites) > 0)
|
||||
xcf_check_error (xcf_save_prop (info, gimage, PROP_PARASITES, error,
|
||||
GIMP_ITEM (layer)->parasites));
|
||||
{
|
||||
xcf_check_error (xcf_save_prop (info, gimage, PROP_PARASITES, error,
|
||||
GIMP_ITEM (layer)->parasites));
|
||||
}
|
||||
|
||||
if (parasite)
|
||||
{
|
||||
gimp_parasite_list_remove (GIMP_ITEM (layer)->parasites,
|
||||
gimp_parasite_name (parasite));
|
||||
gimp_parasite_free (parasite);
|
||||
}
|
||||
|
||||
xcf_check_error (xcf_save_prop (info, gimage, PROP_END, error));
|
||||
|
||||
|
@ -936,7 +958,7 @@ xcf_save_layer (XcfInfo *info,
|
|||
/* check and see if this is the drawable that the floating
|
||||
* selection is attached to.
|
||||
*/
|
||||
if (GIMP_DRAWABLE(layer) == info->floating_sel_drawable)
|
||||
if (GIMP_DRAWABLE (layer) == info->floating_sel_drawable)
|
||||
{
|
||||
saved_pos = info->cp;
|
||||
xcf_check_error (xcf_seek_pos (info, info->floating_sel_offset, error));
|
||||
|
|
|
@ -76,6 +76,13 @@ 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-text-layer" (LAYER, PERSISTENT)
|
||||
The associated GimpText object serialized to a string. For
|
||||
convenience the string is terminated by a trailing '\0'.
|
||||
The idea of using a parasite for text layers is to keep the XCF
|
||||
files backward compatible. Although gimp-1.2 doesn't know how
|
||||
to handle the text layer, it keeps the parasite intact.
|
||||
|
||||
"tiff-save-options" (IMAGE)
|
||||
The TiffSaveVals structure from the TIFF plugin.
|
||||
|
||||
|
|
Loading…
Reference in New Issue