gimp/app/xcf/xcf-load.c

1816 lines
52 KiB
C
Raw Normal View History

/* GIMP - The GNU 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 "config.h"
#include <stdio.h>
#include <string.h> /* strcmp, memcmp */
added app/display/ and app/plug-in/. Empty for now except for the types 2001-08-17 Michael Natterer <mitch@gimp.org> * configure.in: added app/display/ and app/plug-in/. Empty for now except for the types files. * app/Makefile.am * app/appenums.h * app/apptypes.h: removed. * app/display/Makefile.am * app/display/display-types.h * app/plug-in/Makefile.am * app/plug-in/plug-in-types.h * app/gui/Makefile.am * app/gui/gui-types.h * app/pdb/Makefile.am * app/pdb/pdb-types.h: new files for typedefs. * app/appenv.h: added MessageHandlerType and StackTraceMode here. * app/undo_types.h: moved undo struct typedefs here. * app/tools/tools-types.h * app/core/core-types.h: added some enums and Tattoo here (renamed to GimpTattoo). * app/gdisplay.h: temp_hack: #include "display/display-types.h" * app/gimphelp.c: s/gtk_idle_add/g_idle_add/ * app/gimprc.c: don't use "gimprc" in token handlers but the passed "val1p" and "val2p". * app/image_map.[ch]: cleanup in preparation of making a GObject out of it. * app/base/pixel-region.[ch]: no need to pass the PixelRegionIterator around as void pointer. * app/core/gimp.[ch] * app/core/gimpcontext.[ch] * app/core/gimptoolinfo.[ch] * app/tools/tool_manager.c * app/widgets/gimpdnd.c: added the standard_tool_info to the Gimp object. * app/batch.c * app/file-open.c * app/file-save.c * app/file-utils.c * app/interface.c * app/main.c * app/path.[ch] * app/pathP.h * app/plug_in.h * app/core/gimpdrawable.[ch] * app/core/gimpimage-mask.c * app/core/gimpimage.[ch] * app/core/gimplayer.c * app/gui/color-area.c * app/gui/color-notebook.c * app/gui/colormap-dialog.c * app/gui/dialogs-commands.c * app/gui/dialogs-constructors.c * app/gui/error-console-dialog.c * app/gui/gradient-editor.c * app/gui/gradient-select.c * app/gui/indicator-area.c * app/gui/info-dialog.c * app/gui/palette-editor.c * app/gui/palette-select.c * app/gui/pattern-select.c * app/gui/session.c * app/gui/splash.c * app/gui/view-commands.c * app/tools/gimpinktool-blob.c * app/widgets/gimpcolorpanel.c * app/widgets/gimpdockbook.c * app/widgets/gimppreview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c: changed accordingly: s/Tattoo/GimpTattoo/, include the new types files, include <glib-object.h> instead of >gtk/gtk.h>. Bad hacks to get rid of SELECTION_OFF and friends in core/ (will be replaced ba a signal soon). * tools/pdbgen/Makefile.am: changed list of headers scanned for enums accordingly. * app/pdb/procedural_db.c * tools/pdbgen/app.pl * tools/pdbgen/pdb/channel.pdb * tools/pdbgen/pdb/display.pdb * tools/pdbgen/pdb/gradient_select.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/pattern_select.pdb: same fixes as above, added hacks to ensure that all foo-types.h files are included before all other gimp internal includes, include "pdb-types.h" unconditionally. * tools/pdbgen/enums.pl * app/pdb/*_cmds.c: regenerated.
2001-08-17 22:27:31 +08:00
#include <glib-object.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpcolor/gimpcolor.h"
#include "core/core-types.h"
#include "base/tile.h"
#include "base/tile-manager.h"
#include "base/tile-manager-private.h"
Finally landed the new GimpConfig based gimprc parser. It's not finished 2002-11-18 Sven Neumann <sven@gimp.org> Finally landed the new GimpConfig based gimprc parser. It's not finished yet but we need to start somewhere. This release removes the old gimprc.[ch] files. The gimprc format changes slightly, but the changes are minimal. The Preferences dialog is temporarily disabled since it still needs to be ported. If you are are afraid, stay away from CVS for a few days ;-) * app/Makefile.am * app/gimprc.[ch]: removed the old gimprc system. * app/base/Makefile.am * app/base/base-config.[ch]: removed these files in favor of config/gimpbaseconfig.[ch]. * app/core/Makefile.am * app/core/gimpcoreconfig.[ch]: removed these files in favor of config/gimpcoreconfig.[ch]. * app/config/Makefile.am * app/config/config-types.h: moved typedefs into this new file. * app/config/gimpbaseconfig.[ch] * app/config/gimpcoreconfig.[ch] * app/config/gimpdisplayconfig.[ch] * app/config/gimpguiconfig.[ch] * app/config/gimprc.[ch] * app/config/test-config.c: brought into shape for real use. * app/base/base-types.h: include config/config-types.h here. Added a global GimpBaseConfig *base_config variable to ease migration. * app/gui/Makefile.am: temporarily disabled the preferences dialog. * app/app_procs.c * app/undo.c * app/undo_history.c * app/base/base.[ch] * app/base/gimphistogram.c * app/base/pixel-processor.c * app/base/temp-buf.c * app/base/tile-cache.c * app/core/core-types.h * app/core/gimp-documents.c * app/core/gimp.c * app/core/gimpbrush.c * app/core/gimpbrushgenerated.c * app/core/gimpcontext.c * app/core/gimpdrawable-transform.c * app/core/gimpimage-new.c * app/core/gimpimage.c * app/core/gimpimagefile.c * app/core/gimpmodules.c * app/core/gimppattern.c * app/display/Makefile.am * app/display/gimpdisplay-handlers.c * app/display/gimpdisplay.[ch] * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-handlers.c * app/display/gimpdisplayshell-layer-select.c * app/display/gimpdisplayshell-render.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/display/gimpdisplayshell-selection.c * app/display/gimpdisplayshell.[ch] * app/display/gimpnavigationview.c * app/file/file-save.c * app/gui/device-status-dialog.c * app/gui/dialogs-constructors.c * app/gui/file-commands.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/file-save-dialog.c * app/gui/gui.c * app/gui/menus.c * app/gui/paths-dialog.c * app/gui/resize-dialog.c * app/gui/session.c * app/gui/test-commands.c * app/gui/tips-dialog.c * app/gui/tips-dialog.h * app/gui/user-install-dialog.c * app/gui/view-commands.c * app/paint/gimppaintcore.c * app/plug-in/plug-in.c * app/plug-in/plug-ins.c * app/tools/gimpbezierselecttool.c * app/tools/gimpbucketfilltool.c * app/tools/gimpcolorpickertool.c * app/tools/gimpcroptool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpfuzzyselecttool.c * app/tools/gimpinktool.c * app/tools/gimpmagnifytool.c * app/tools/gimpmeasuretool.c * app/tools/gimppainttool.c * app/tools/gimppathtool.c * app/tools/gimptexttool.[ch] * app/tools/selection_options.c * app/tools/tools.c * app/tools/transform_options.c * app/widgets/gimphelp.c * app/widgets/gimpitemfactory.c * app/widgets/gimpselectioneditor.c * app/xcf/xcf-load.c * tools/pdbgen/pdb/fileops.pdb * tools/pdbgen/pdb/gimprc.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/transform_tools.pdb: use the new config system instead of the old gimprc stuff. * etc/gimprc.in * etc/gimprc_user.in: adapted to the new gimprc format. Will update the man-page later... * app/pdb/fileops_cmds.c * app/pdb/gimprc_cmds.c * app/pdb/image_cmds.c * app/pdb/layer_cmds.c * app/pdb/transform_tools_cmds.c * libgimp/gimpgimprc_pdb.c: regenerated.
2002-11-19 04:50:31 +08:00
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimpcontainer.h"
#include "core/gimpdrawable.h"
removed the grid parasite related functions from here ... 2003-10-10 Henrik Brix Andersen <brix@gimp.org> * app/core/gimpimage-grid.[ch]: removed the grid parasite related functions from here ... * app/core/gimpgrid.[ch]: ... and added them here. While I was at it I also changed PROP_TYPE to PROP_STYLE and added blurbs to the properties * app/xcf/xcf-load.c * app/display/gimpdisplayshell.c: changed accordingly * app/widgets/Makefile.am * po/POTFILES.in * app/widgets/widgets-types.h * app/widgets/gimpgrideditor.[ch]: added a new GimpGridEditor widget - with a work-around for the fact that gimp_prop_coordinated_new() doesn't accept boundaries * app/gui/grid-dialog.h * app/gui/grid-dialog.c (grid_dialog_new): use the new GimpGridEditor widget, take a GimpImage as function parameter, assume GimpImages always have a GimpGrid. This simplifies the grid dialog. * app/gui/image-commands.c (image_configure_grid_cmd_callback): changed accordingly * app/core/core-types.h: moved typedef GimpGrid from here ... * app/config/config-types.h: ... to here to be able to use it in GimpCoreConfig * app/config/gimprc-blurbs.h * app/config/gimpcoreconfig.[ch]: added default_grid member * app/widgets/gimphelp-ids.h * themes/Default/images/preferences/Makefile.am * themes/Default/images/default-grid.png * app/gui/preferences-dialog.c: added UI for specifying default image grid * app/core/gimpimage.c (gimp_image_new): create a GimpGrid from core_config->default_grid * app/gui/image-menu.c (image_menu_update): the grid/guide entries in <Image>/View/ should always be sensitive ... * app/display/gimpdisplayshell.c (gimp_display_shell_init): ... but the grid entries should be disabled by default
2003-10-10 22:11:47 +08:00
#include "core/gimpgrid.h"
#include "core/gimpimage.h"
#include "core/gimpimage-colormap.h"
#include "core/gimpimage-grid.h"
include the new "paint-funcs/paint-funcs-types.h". 2001-11-28 Michael Natterer <mitch@gimp.org> * app/base/base-types.h: include the new "paint-funcs/paint-funcs-types.h". * app/paint-funcs/Makefile.am * app/paint-funcs/paint-funcs-types.h: new file. Includes "base/base-types.h". * app/paint-funcs/paint-funcs.[ch]: removed the enums here, include "paint-funcs-types.h". * app/widgets/widgets-types.h: include "display/display-types.h" * app/display/display-types.h: include "widgets/widgets-types.h". * app/tools/tools-types.h: include "display/display-types.h" * app/gui/gui-types.h: include "tools/tools-types.h". The order of namespaces/dependencies should be (but is not): (base, paint-funcs) -> (core, file, xcf, pdb) -> (widgets, display) -> tools -> gui * app/path.c: include "tools/tools-types.h". * app/core/Makefile.am * app/core/gimpimage-guides.[ch] * app/core/gimpimage-merge.[ch] * app/core/gimpimage-resize.[ch] * app/core/gimpimage-scale.[ch]: new files. * app/core/gimpimage.[ch]: removed the stuff which is in the new files. Reordered all functions in both the .h and .c files, commented the groups of functions. * app/core/gimpcontainer.c: create the handler_id using a counter, not the address of a pointer, because the address *may* be the same twice, added debugging output. * app/core/gimpviewable.[ch]: added primitive support for getting a preview GdkPixbuf. * app/nav_window.c * app/undo.c * app/undo_history.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-mask.[ch] * app/display/gimpdisplay.c * app/display/gimpdisplayshell-callbacks.c * app/display/gimpdisplayshell-dnd.c * app/display/gimpdisplayshell-render.c * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-scroll.c * app/gui/image-commands.c * app/gui/info-window.c * app/gui/layers-commands.c * app/gui/palette-import-dialog.c * app/tools/gimpbycolorselecttool.c * app/tools/gimpeditselectiontool.c * app/tools/gimpmeasuretool.c * app/tools/gimpmovetool.c * app/widgets/gimpcontainerview-utils.c * app/xcf/xcf-load.c: changed accordingly, some cleanup. * tools/pdbgen/pdb/guides.pdb * tools/pdbgen/pdb/image.pdb: changed accordingly, reordered functions. * app/plug_in.c: set the labels of the "Repeat" and "Re-Show" menu items to the name of the last plug-in (Fixes #50986). * app/display/gimpdisplayshell.[ch]: set the labels of "Undo" and "Redo" to the resp. undo names. Much simplified the WM icon stuff by removing most code and using gimp_viewable_get_new_preview_pixbuf(). * app/widgets/gimpbrushfactoryview.c: forgot to assign the GQuark returned by gimp_container_add_handler(). * app/pdb/guides_cmds.c * app/pdb/image_cmds.c * libgimp/gimpimage_pdb.[ch]: regenerated.
2001-11-29 01:51:06 +08:00
#include "core/gimpimage-guides.h"
#include "core/gimpimage-sample-points.h"
#include "core/gimplayer.h"
#include "core/gimplayer-floating-sel.h"
#include "core/gimplayermask.h"
#include "core/gimpparasitelist.h"
#include "core/gimpprogress.h"
#include "core/gimpselection.h"
removed gimp_config_copy_properties() and added the more intelligent 2003-10-14 Sven Neumann <sven@gimp.org> * app/config/gimpconfig-utils.[ch]: removed gimp_config_copy_properties() and added the more intelligent gimp_config_sync() instead. * app/config/Makefile.am * app/config/config-types.h * app/config/gimpcoreconfig.[ch] * app/config/gimprc-blurbs.h: replaced default image properties with a single GimpTemplate object property. Changed the set_property function to not replace aggregate objects but call gimp_config_sync() instead. * app/tools/gimptextoptions.c (gimp_text_options_set_property): same change here. * app/config/gimpconfig.[ch]: changed return value of gimp_config_duplicate() to gpointer to avoid some casts that only made the code harder to read. * app/widgets/gimptemplateeditor.[ch]: don't keep an internal copy here but edit the GimpTemplate passed when the editor was constructed. * app/gui/preferences-dialog.c: use a GimpTemplateEditor to allow editing of the default image paramaters. * app/config/gimprc.c * app/core/core-types.h * app/core/gimp.c * app/core/gimpimage-duplicate.c * app/core/gimpimage-grid.c * app/core/gimpimage-new.c * app/core/gimpimage-undo-push.c * app/core/gimpimage.c * app/core/gimptemplate.[ch] * app/gui/file-new-dialog.c * app/gui/grid-dialog.c * app/gui/info-window.c * app/gui/resize-dialog.c * app/gui/templates-commands.[ch] * app/gui/tool-options-commands.c * app/text/gimptextlayer.c * app/text/gimptextlayer.c * app/tools/gimptexttool.c * app/widgets/gimptemplateview.c * app/xcf/xcf-load.c: changed accordingly.
2003-10-14 23:20:59 +08:00
#include "core/gimptemplate.h"
app/Makefile.am app/gimpunit.c removed... 2001-07-11 Michael Natterer <mitch@gimp.org> * app/Makefile.am * app/gimpunit.c * app/unitrc.h: removed... * app/core/Makefile.am * app/core/gimpunit.[ch]: ...re-added here. * app/core/gimp.[ch]: added the image and drawable hash tables, next_image_ID, next_guide_ID and next_drawable_ID, added a GimpCoreConfig pointer which is now initalized dynamically. * app/core/gimpcoreconfig.[ch]: don't provide a global core_config variable any more (need to access gimp->config now). * app/gdisplay.[ch] * app/core/gimpdrawable.[ch] * app/core/gimpimage.[ch]: removed all global variables from gimpimage.c and gimpdrawable.c, pass a Gimp* to all *_get_by_ID() functions. * tools/pdbgen/app.pl: pass Gimp* to all _get_by_ID() functions. * app/app_procs.c * app/file-open.c * app/file-save.c * app/gimprc.c * app/libgimp_glue.c * app/module_db.c * app/plug_in.c * app/undo.c * app/user_install.c * app/core/core-types.h * app/core/gimpcontext.c * app/core/gimpimage-crop.c * app/core/gimpimage-new.c * app/core/gimpparasite.c * app/gui/file-new-dialog.c * app/gui/file-open-dialog.c * app/gui/info-window.c * app/gui/preferences-dialog.c * app/gui/resize-dialog.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * app/widgets/gimpdnd.c * app/pdb/channel_cmds.c * app/pdb/color_cmds.c * app/pdb/convert_cmds.c * app/pdb/display_cmds.c * app/pdb/drawable_cmds.c * app/pdb/edit_cmds.c * app/pdb/fileops_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/guides_cmds.c * app/pdb/image_cmds.c * app/pdb/layer_cmds.c * app/pdb/parasite_cmds.c * app/pdb/paths_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/tools_cmds.c * app/pdb/undo_cmds.c * app/pdb/unit_cmds.c * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/unit.pdb: changed accordingly.
2001-07-11 20:39:49 +08:00
#include "core/gimpunit.h"
#include "text/gimptextlayer.h"
#include "text/gimptextlayer-xcf.h"
#include "vectors/gimpanchor.h"
#include "vectors/gimpstroke.h"
#include "vectors/gimpbezierstroke.h"
#include "vectors/gimpvectors.h"
#include "vectors/gimpvectors-compat.h"
#include "xcf-private.h"
#include "xcf-load.h"
#include "xcf-read.h"
#include "xcf-seek.h"
#include "gimp-intl.h"
/* #define GIMP_XCF_PATH_DEBUG */
static gboolean xcf_load_image_props (XcfInfo *info,
GimpImage *image);
static gboolean xcf_load_layer_props (XcfInfo *info,
GimpImage *image,
GimpLayer *layer,
gboolean *apply_mask,
gboolean *edit_mask,
gboolean *show_mask,
guint32 *text_layer_flags);
static gboolean xcf_load_channel_props (XcfInfo *info,
GimpImage *image,
GimpChannel **channel);
static gboolean xcf_load_prop (XcfInfo *info,
PropType *prop_type,
guint32 *prop_size);
static GimpLayer * xcf_load_layer (XcfInfo *info,
GimpImage *image);
static GimpChannel * xcf_load_channel (XcfInfo *info,
GimpImage *image);
static GimpLayerMask * xcf_load_layer_mask (XcfInfo *info,
GimpImage *image);
static gboolean xcf_load_hierarchy (XcfInfo *info,
TileManager *tiles);
static gboolean xcf_load_level (XcfInfo *info,
TileManager *tiles);
static gboolean xcf_load_tile (XcfInfo *info,
Tile *tile);
static gboolean xcf_load_tile_rle (XcfInfo *info,
Tile *tile,
gint data_length);
static GimpParasite * xcf_load_parasite (XcfInfo *info);
static gboolean xcf_load_old_paths (XcfInfo *info,
GimpImage *image);
static gboolean xcf_load_old_path (XcfInfo *info,
GimpImage *image);
static gboolean xcf_load_vectors (XcfInfo *info,
GimpImage *image);
static gboolean xcf_load_vector (XcfInfo *info,
GimpImage *image);
#define xcf_progress_update(info) G_STMT_START \
{ \
if (info->progress) \
gimp_progress_pulse (info->progress); \
} G_STMT_END
GimpImage *
xcf_load_image (Gimp *gimp,
XcfInfo *info,
GError **error)
{
GimpImage *image;
GimpLayer *layer;
GimpChannel *channel;
const 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);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &height, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &image_type, 1);
image = gimp_create_image (gimp, width, height, image_type, FALSE);
gimp_image_undo_disable (image);
xcf_progress_update (info);
/* read the image properties */
if (! xcf_load_image_props (info, image))
goto hard_error;
/* check for a GimpGrid parasite */
parasite = gimp_image_parasite_find (GIMP_IMAGE (image),
gimp_grid_parasite_name ());
if (parasite)
{
GimpGrid *grid = gimp_grid_from_parasite (parasite);
if (grid)
{
gimp_parasite_list_remove (GIMP_IMAGE (image)->parasites,
gimp_parasite_name (parasite));
gimp_image_set_grid (GIMP_IMAGE (image), grid, FALSE);
}
}
xcf_progress_update (info);
while (TRUE)
{
/* read in the offset of the next layer */
info->cp += xcf_read_int32 (info->fp, &offset, 1);
/* if the offset is 0 then we are at the end
* of the layer list.
*/
if (offset == 0)
break;
/* save the current position as it is where the
* next layer offset is stored.
*/
saved_pos = info->cp;
/* seek to the layer offset */
if (! xcf_seek_pos (info, offset, NULL))
goto error;
/* read in the layer */
layer = xcf_load_layer (info, image);
if (!layer)
goto error;
num_successful_elements++;
xcf_progress_update (info);
/* add the layer to the image if its not the floating selection */
if (layer != info->floating_sel)
gimp_image_add_layer (image, layer,
gimp_container_num_children (image->layers));
/* restore the saved position so we'll be ready to
* read the next offset.
*/
if (! xcf_seek_pos (info, saved_pos, NULL))
goto error;
}
while (TRUE)
{
/* read in the offset of the next channel */
info->cp += xcf_read_int32 (info->fp, &offset, 1);
/* if the offset is 0 then we are at the end
* of the channel list.
*/
if (offset == 0)
break;
/* save the current position as it is where the
* next channel offset is stored.
*/
saved_pos = info->cp;
/* seek to the channel offset */
if (! xcf_seek_pos (info, offset, NULL))
goto error;
/* read in the layer */
channel = xcf_load_channel (info, image);
if (!channel)
goto error;
num_successful_elements++;
xcf_progress_update (info);
/* add the channel to the image if its not the selection */
if (channel != image->selection_mask)
gimp_image_add_channel (image, channel,
gimp_container_num_children (image->channels));
/* restore the saved position so we'll be ready to
* read the next offset.
*/
if (! xcf_seek_pos (info, saved_pos, NULL))
goto error;
}
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
if (info->floating_sel && info->floating_sel_drawable)
floating_sel_attach (info->floating_sel, info->floating_sel_drawable);
if (info->active_layer)
gimp_image_set_active_layer (image, info->active_layer);
if (info->active_channel)
gimp_image_set_active_channel (image, info->active_channel);
gimp_image_set_filename (image, info->filename);
if (info->tattoo_state > 0)
gimp_image_set_tattoo_state (image, info->tattoo_state);
gimp_image_undo_enable (image);
return image;
error:
if (num_successful_elements == 0)
goto hard_error;
Added message severities and make sure all messages are routed through a 2006-10-09 Michael Natterer <mitch@gimp.org> Added message severities and make sure all messages are routed through a central function, so redirecting to the error console or stderr work again: * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, WARNING, ERROR }. * app/core/gimp.[ch] (gimp_message) (gimp_message_valist): added severity parameter. Changed "GimpProgress *progress" parameter to "GObject *handler", where "handler" can be either a GimpProgress, a GtkWidget or NULL. * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor --console-messages again. Always dispatch to the GUI message handler first if it exists. * app/gui/gui-message.[ch]: pass severity parameters around. (gui_message_error_dialog): if "handler" is a progress, dispatch the message to it first. If it is a widget (and *not* a progress), use a GtkMessageDialog on top of that widget's toplevel. Fall back to the usual GimpErrorDialog otherwise. * app/core/gimpprogress.[ch] (gimp_progress_message): added severity parameter. Also added boolean return value to the virtual function so it can decide to fail if it can't handle the message. * app/display/gimpdisplay.c: implement GimpProgress::message() and redirect the message to GimpDisplayShell. * app/display/gimpdisplayshell-progress.c: implement GimpProgress::message() and redirect the message to GimpStatusbar if it is not an error and if the status bar is visible. * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), but fail on messages that contain a newline. Show the right icons for the message severities (work in progress). * app/display/gimpdisplayshell.[ch]: removed gimp_display_shell_message() and its _valist() variant. * app/widgets/gimperrorconsole.[ch]: show the right icons for the message severities. * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): return TRUE to swallow all messages. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_show_message_dialog(). Added gimp_get_message_stock_id(). * app/errors.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/select-commands.c * app/actions/text-editor-commands.c * app/actions/vectors-commands.c * app/core/gimpimage-convert.c * app/core/gimpimagefile.c * app/dialogs/convert-dialog.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/palette-import-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/pdb/gimppdb.c * app/plug-in/gimpplugin.c * app/tools/gimpimagemaptool.c * app/tools/gimptool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimppdbdialog.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/palette.pdb: added severity parameter to gimp_message() calls. Convert all calls to gimp_show_message_dialog() and gimp_display_shell_message() to gimp_message(). Also converted some more g_message() calls. * app/pdb/brush_cmds.c * app/pdb/gradient_cmds.c * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/palette_cmds.c: regenerated.
2006-10-09 16:17:22 +08:00
gimp_message (gimp, G_OBJECT (info->progress), GIMP_MESSAGE_WARNING,
_("This XCF file is corrupt! I have loaded as much "
"of it as I can, but it is incomplete."));
gimp_image_undo_enable (image);
return image;
hard_error:
g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
_("This XCF file is corrupt! I could not even "
"salvage any partial image data from it."));
g_object_unref (image);
return NULL;
}
static gboolean
xcf_load_image_props (XcfInfo *info,
GimpImage *image)
{
PropType prop_type;
guint32 prop_size;
while (TRUE)
{
if (! xcf_load_prop (info, &prop_type, &prop_size))
return FALSE;
switch (prop_type)
{
case PROP_END:
return TRUE;
case PROP_COLORMAP:
{
guint32 n_colors;
guchar cmap[GIMP_IMAGE_COLORMAP_SIZE];
info->cp += xcf_read_int32 (info->fp, &n_colors, 1);
if (info->file_version == 0)
{
gint i;
gimp_message (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_WARNING,
_("XCF warning: version 0 of XCF file format\n"
"did not save indexed colormaps correctly.\n"
"Substituting grayscale map."));
if (! xcf_seek_pos (info, info->cp + n_colors, NULL))
return FALSE;
for (i = 0; i < n_colors; i++)
{
cmap[i * 3 + 0] = i;
cmap[i * 3 + 1] = i;
cmap[i * 3 + 2] = i;
}
}
else
{
info->cp += xcf_read_int8 (info->fp, cmap, n_colors * 3);
}
/* only set color map if image is not indexed, this is
* just sanity checking to make sure gimp doesn't end up
* with an image state that is impossible.
*/
if (gimp_image_base_type (image) == GIMP_INDEXED)
gimp_image_set_colormap (image, cmap, n_colors, FALSE);
}
break;
case PROP_COMPRESSION:
{
guint8 compression;
info->cp += xcf_read_int8 (info->fp, (guint8 *) &compression, 1);
if ((compression != COMPRESS_NONE) &&
(compression != COMPRESS_RLE) &&
(compression != COMPRESS_ZLIB) &&
(compression != COMPRESS_FRACTAL))
{
Added message severities and make sure all messages are routed through a 2006-10-09 Michael Natterer <mitch@gimp.org> Added message severities and make sure all messages are routed through a central function, so redirecting to the error console or stderr work again: * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, WARNING, ERROR }. * app/core/gimp.[ch] (gimp_message) (gimp_message_valist): added severity parameter. Changed "GimpProgress *progress" parameter to "GObject *handler", where "handler" can be either a GimpProgress, a GtkWidget or NULL. * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor --console-messages again. Always dispatch to the GUI message handler first if it exists. * app/gui/gui-message.[ch]: pass severity parameters around. (gui_message_error_dialog): if "handler" is a progress, dispatch the message to it first. If it is a widget (and *not* a progress), use a GtkMessageDialog on top of that widget's toplevel. Fall back to the usual GimpErrorDialog otherwise. * app/core/gimpprogress.[ch] (gimp_progress_message): added severity parameter. Also added boolean return value to the virtual function so it can decide to fail if it can't handle the message. * app/display/gimpdisplay.c: implement GimpProgress::message() and redirect the message to GimpDisplayShell. * app/display/gimpdisplayshell-progress.c: implement GimpProgress::message() and redirect the message to GimpStatusbar if it is not an error and if the status bar is visible. * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), but fail on messages that contain a newline. Show the right icons for the message severities (work in progress). * app/display/gimpdisplayshell.[ch]: removed gimp_display_shell_message() and its _valist() variant. * app/widgets/gimperrorconsole.[ch]: show the right icons for the message severities. * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): return TRUE to swallow all messages. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_show_message_dialog(). Added gimp_get_message_stock_id(). * app/errors.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/select-commands.c * app/actions/text-editor-commands.c * app/actions/vectors-commands.c * app/core/gimpimage-convert.c * app/core/gimpimagefile.c * app/dialogs/convert-dialog.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/palette-import-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/pdb/gimppdb.c * app/plug-in/gimpplugin.c * app/tools/gimpimagemaptool.c * app/tools/gimptool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimppdbdialog.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/palette.pdb: added severity parameter to gimp_message() calls. Convert all calls to gimp_show_message_dialog() and gimp_display_shell_message() to gimp_message(). Also converted some more g_message() calls. * app/pdb/brush_cmds.c * app/pdb/gradient_cmds.c * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/palette_cmds.c: regenerated.
2006-10-09 16:17:22 +08:00
gimp_message (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_ERROR,
"Unknown compression type: %d",
(int) compression);
return FALSE;
}
info->compression = compression;
}
break;
case PROP_GUIDES:
{
gint32 position;
gint8 orientation;
gint i, nguides;
nguides = prop_size / (4 + 1);
for (i = 0; i < nguides; i++)
{
info->cp += xcf_read_int32 (info->fp,
(guint32 *) &position, 1);
info->cp += xcf_read_int8 (info->fp,
(guint8 *) &orientation, 1);
/* skip -1 guides from old XCFs */
if (position < 0)
continue;
switch (orientation)
{
case XCF_ORIENTATION_HORIZONTAL:
gimp_image_add_hguide (image, position, FALSE);
break;
case XCF_ORIENTATION_VERTICAL:
gimp_image_add_vguide (image, position, FALSE);
break;
default:
Added message severities and make sure all messages are routed through a 2006-10-09 Michael Natterer <mitch@gimp.org> Added message severities and make sure all messages are routed through a central function, so redirecting to the error console or stderr work again: * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, WARNING, ERROR }. * app/core/gimp.[ch] (gimp_message) (gimp_message_valist): added severity parameter. Changed "GimpProgress *progress" parameter to "GObject *handler", where "handler" can be either a GimpProgress, a GtkWidget or NULL. * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor --console-messages again. Always dispatch to the GUI message handler first if it exists. * app/gui/gui-message.[ch]: pass severity parameters around. (gui_message_error_dialog): if "handler" is a progress, dispatch the message to it first. If it is a widget (and *not* a progress), use a GtkMessageDialog on top of that widget's toplevel. Fall back to the usual GimpErrorDialog otherwise. * app/core/gimpprogress.[ch] (gimp_progress_message): added severity parameter. Also added boolean return value to the virtual function so it can decide to fail if it can't handle the message. * app/display/gimpdisplay.c: implement GimpProgress::message() and redirect the message to GimpDisplayShell. * app/display/gimpdisplayshell-progress.c: implement GimpProgress::message() and redirect the message to GimpStatusbar if it is not an error and if the status bar is visible. * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), but fail on messages that contain a newline. Show the right icons for the message severities (work in progress). * app/display/gimpdisplayshell.[ch]: removed gimp_display_shell_message() and its _valist() variant. * app/widgets/gimperrorconsole.[ch]: show the right icons for the message severities. * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): return TRUE to swallow all messages. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_show_message_dialog(). Added gimp_get_message_stock_id(). * app/errors.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/select-commands.c * app/actions/text-editor-commands.c * app/actions/vectors-commands.c * app/core/gimpimage-convert.c * app/core/gimpimagefile.c * app/dialogs/convert-dialog.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/palette-import-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/pdb/gimppdb.c * app/plug-in/gimpplugin.c * app/tools/gimpimagemaptool.c * app/tools/gimptool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimppdbdialog.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/palette.pdb: added severity parameter to gimp_message() calls. Convert all calls to gimp_show_message_dialog() and gimp_display_shell_message() to gimp_message(). Also converted some more g_message() calls. * app/pdb/brush_cmds.c * app/pdb/gradient_cmds.c * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/palette_cmds.c: regenerated.
2006-10-09 16:17:22 +08:00
gimp_message (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_WARNING,
"Guide orientation out of range in XCF file");
continue;
}
}
/* this is silly as the order of guides doesn't really matter,
* but it restores the list to it's original order, which
* cannot be wrong --Mitch
*/
image->guides = g_list_reverse (image->guides);
}
break;
case PROP_SAMPLE_POINTS:
{
gint32 x, y;
gint i, n_sample_points;
n_sample_points = prop_size / (4 + 4);
for (i = 0; i < n_sample_points; i++)
{
info->cp += xcf_read_int32 (info->fp, (guint32 *) &x, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &y, 1);
gimp_image_add_sample_point_at_pos (image, x, y, FALSE);
}
}
break;
case PROP_RESOLUTION:
{
gfloat xres, yres;
info->cp += xcf_read_float (info->fp, &xres, 1);
info->cp += xcf_read_float (info->fp, &yres, 1);
if (xres < GIMP_MIN_RESOLUTION || xres > GIMP_MAX_RESOLUTION ||
yres < GIMP_MIN_RESOLUTION || yres > GIMP_MAX_RESOLUTION)
{
Added message severities and make sure all messages are routed through a 2006-10-09 Michael Natterer <mitch@gimp.org> Added message severities and make sure all messages are routed through a central function, so redirecting to the error console or stderr work again: * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, WARNING, ERROR }. * app/core/gimp.[ch] (gimp_message) (gimp_message_valist): added severity parameter. Changed "GimpProgress *progress" parameter to "GObject *handler", where "handler" can be either a GimpProgress, a GtkWidget or NULL. * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor --console-messages again. Always dispatch to the GUI message handler first if it exists. * app/gui/gui-message.[ch]: pass severity parameters around. (gui_message_error_dialog): if "handler" is a progress, dispatch the message to it first. If it is a widget (and *not* a progress), use a GtkMessageDialog on top of that widget's toplevel. Fall back to the usual GimpErrorDialog otherwise. * app/core/gimpprogress.[ch] (gimp_progress_message): added severity parameter. Also added boolean return value to the virtual function so it can decide to fail if it can't handle the message. * app/display/gimpdisplay.c: implement GimpProgress::message() and redirect the message to GimpDisplayShell. * app/display/gimpdisplayshell-progress.c: implement GimpProgress::message() and redirect the message to GimpStatusbar if it is not an error and if the status bar is visible. * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), but fail on messages that contain a newline. Show the right icons for the message severities (work in progress). * app/display/gimpdisplayshell.[ch]: removed gimp_display_shell_message() and its _valist() variant. * app/widgets/gimperrorconsole.[ch]: show the right icons for the message severities. * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): return TRUE to swallow all messages. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_show_message_dialog(). Added gimp_get_message_stock_id(). * app/errors.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/select-commands.c * app/actions/text-editor-commands.c * app/actions/vectors-commands.c * app/core/gimpimage-convert.c * app/core/gimpimagefile.c * app/dialogs/convert-dialog.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/palette-import-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/pdb/gimppdb.c * app/plug-in/gimpplugin.c * app/tools/gimpimagemaptool.c * app/tools/gimptool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimppdbdialog.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/palette.pdb: added severity parameter to gimp_message() calls. Convert all calls to gimp_show_message_dialog() and gimp_display_shell_message() to gimp_message(). Also converted some more g_message() calls. * app/pdb/brush_cmds.c * app/pdb/gradient_cmds.c * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/palette_cmds.c: regenerated.
2006-10-09 16:17:22 +08:00
gimp_message (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_WARNING,
"Warning, resolution out of range in XCF file");
xres = image->gimp->config->default_image->xresolution;
yres = image->gimp->config->default_image->yresolution;
}
image->xresolution = xres;
image->yresolution = yres;
}
break;
case PROP_TATTOO:
{
info->cp += xcf_read_int32 (info->fp, &info->tattoo_state, 1);
}
break;
case PROP_PARASITES:
{
glong base = info->cp;
GimpParasite *p;
while (info->cp - base < prop_size)
{
p = xcf_load_parasite (info);
gimp_image_parasite_attach (image, p);
gimp_parasite_free (p);
}
if (info->cp - base != prop_size)
Added message severities and make sure all messages are routed through a 2006-10-09 Michael Natterer <mitch@gimp.org> Added message severities and make sure all messages are routed through a central function, so redirecting to the error console or stderr work again: * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, WARNING, ERROR }. * app/core/gimp.[ch] (gimp_message) (gimp_message_valist): added severity parameter. Changed "GimpProgress *progress" parameter to "GObject *handler", where "handler" can be either a GimpProgress, a GtkWidget or NULL. * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor --console-messages again. Always dispatch to the GUI message handler first if it exists. * app/gui/gui-message.[ch]: pass severity parameters around. (gui_message_error_dialog): if "handler" is a progress, dispatch the message to it first. If it is a widget (and *not* a progress), use a GtkMessageDialog on top of that widget's toplevel. Fall back to the usual GimpErrorDialog otherwise. * app/core/gimpprogress.[ch] (gimp_progress_message): added severity parameter. Also added boolean return value to the virtual function so it can decide to fail if it can't handle the message. * app/display/gimpdisplay.c: implement GimpProgress::message() and redirect the message to GimpDisplayShell. * app/display/gimpdisplayshell-progress.c: implement GimpProgress::message() and redirect the message to GimpStatusbar if it is not an error and if the status bar is visible. * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), but fail on messages that contain a newline. Show the right icons for the message severities (work in progress). * app/display/gimpdisplayshell.[ch]: removed gimp_display_shell_message() and its _valist() variant. * app/widgets/gimperrorconsole.[ch]: show the right icons for the message severities. * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): return TRUE to swallow all messages. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_show_message_dialog(). Added gimp_get_message_stock_id(). * app/errors.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/select-commands.c * app/actions/text-editor-commands.c * app/actions/vectors-commands.c * app/core/gimpimage-convert.c * app/core/gimpimagefile.c * app/dialogs/convert-dialog.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/palette-import-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/pdb/gimppdb.c * app/plug-in/gimpplugin.c * app/tools/gimpimagemaptool.c * app/tools/gimptool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimppdbdialog.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/palette.pdb: added severity parameter to gimp_message() calls. Convert all calls to gimp_show_message_dialog() and gimp_display_shell_message() to gimp_message(). Also converted some more g_message() calls. * app/pdb/brush_cmds.c * app/pdb/gradient_cmds.c * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/palette_cmds.c: regenerated.
2006-10-09 16:17:22 +08:00
gimp_message (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_WARNING,
"Error while loading an image's parasites");
}
break;
case PROP_UNIT:
{
guint32 unit;
info->cp += xcf_read_int32 (info->fp, &unit, 1);
if ((unit <= GIMP_UNIT_PIXEL) ||
(unit >= _gimp_unit_get_number_of_built_in_units (image->gimp)))
{
Added message severities and make sure all messages are routed through a 2006-10-09 Michael Natterer <mitch@gimp.org> Added message severities and make sure all messages are routed through a central function, so redirecting to the error console or stderr work again: * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, WARNING, ERROR }. * app/core/gimp.[ch] (gimp_message) (gimp_message_valist): added severity parameter. Changed "GimpProgress *progress" parameter to "GObject *handler", where "handler" can be either a GimpProgress, a GtkWidget or NULL. * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor --console-messages again. Always dispatch to the GUI message handler first if it exists. * app/gui/gui-message.[ch]: pass severity parameters around. (gui_message_error_dialog): if "handler" is a progress, dispatch the message to it first. If it is a widget (and *not* a progress), use a GtkMessageDialog on top of that widget's toplevel. Fall back to the usual GimpErrorDialog otherwise. * app/core/gimpprogress.[ch] (gimp_progress_message): added severity parameter. Also added boolean return value to the virtual function so it can decide to fail if it can't handle the message. * app/display/gimpdisplay.c: implement GimpProgress::message() and redirect the message to GimpDisplayShell. * app/display/gimpdisplayshell-progress.c: implement GimpProgress::message() and redirect the message to GimpStatusbar if it is not an error and if the status bar is visible. * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), but fail on messages that contain a newline. Show the right icons for the message severities (work in progress). * app/display/gimpdisplayshell.[ch]: removed gimp_display_shell_message() and its _valist() variant. * app/widgets/gimperrorconsole.[ch]: show the right icons for the message severities. * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): return TRUE to swallow all messages. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_show_message_dialog(). Added gimp_get_message_stock_id(). * app/errors.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/select-commands.c * app/actions/text-editor-commands.c * app/actions/vectors-commands.c * app/core/gimpimage-convert.c * app/core/gimpimagefile.c * app/dialogs/convert-dialog.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/palette-import-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/pdb/gimppdb.c * app/plug-in/gimpplugin.c * app/tools/gimpimagemaptool.c * app/tools/gimptool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimppdbdialog.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/palette.pdb: added severity parameter to gimp_message() calls. Convert all calls to gimp_show_message_dialog() and gimp_display_shell_message() to gimp_message(). Also converted some more g_message() calls. * app/pdb/brush_cmds.c * app/pdb/gradient_cmds.c * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/palette_cmds.c: regenerated.
2006-10-09 16:17:22 +08:00
gimp_message (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_WARNING,
"Warning, unit out of range in XCF file, "
"falling back to inches");
unit = GIMP_UNIT_INCH;
}
image->resolution_unit = unit;
}
break;
case PROP_PATHS:
xcf_load_old_paths (info, image);
break;
case PROP_USER_UNIT:
{
gchar *unit_strings[5];
float factor;
guint32 digits;
GimpUnit unit;
gint num_units;
gint i;
info->cp += xcf_read_float (info->fp, &factor, 1);
info->cp += xcf_read_int32 (info->fp, &digits, 1);
info->cp += xcf_read_string (info->fp, unit_strings, 5);
for (i = 0; i < 5; i++)
if (unit_strings[i] == NULL)
unit_strings[i] = g_strdup ("");
num_units = _gimp_unit_get_number_of_units (image->gimp);
for (unit = _gimp_unit_get_number_of_built_in_units (image->gimp);
unit < num_units; unit++)
{
/* if the factor and the identifier match some unit
* in unitrc, use the unitrc unit
*/
if ((ABS (_gimp_unit_get_factor (image->gimp,
unit) - factor) < 1e-5) &&
(strcmp (unit_strings[0],
_gimp_unit_get_identifier (image->gimp,
unit)) == 0))
{
break;
}
}
/* no match */
if (unit == num_units)
unit = _gimp_unit_new (image->gimp,
unit_strings[0],
factor,
digits,
unit_strings[1],
unit_strings[2],
unit_strings[3],
unit_strings[4]);
image->resolution_unit = unit;
for (i = 0; i < 5; i++)
g_free (unit_strings[i]);
}
break;
case PROP_VECTORS:
{
guint32 base = info->cp;
if (xcf_load_vectors (info, image))
{
if (base + prop_size != info->cp)
{
g_printerr ("Mismatch in PROP_VECTORS size: "
"skipping %d bytes.\n",
base + prop_size - info->cp);
xcf_seek_pos (info, base + prop_size, NULL);
}
}
else
{
/* skip silently since we don't understand the format and
* xcf_load_vectors already explained what was wrong
*/
xcf_seek_pos (info, base + prop_size, NULL);
}
}
break;
default:
#ifdef GIMP_UNSTABLE
g_printerr ("unexpected/unknown image property: %d (skipping)\n",
prop_type);
#endif
{
gsize size = prop_size;
guint8 buf[16];
guint amount;
while (size > 0)
{
if (feof (info->fp))
return FALSE;
amount = MIN (16, size);
info->cp += xcf_read_int8 (info->fp, buf, amount);
size -= MIN (16, amount);
}
}
break;
}
}
return FALSE;
}
static gboolean
xcf_load_layer_props (XcfInfo *info,
GimpImage *image,
GimpLayer *layer,
gboolean *apply_mask,
gboolean *edit_mask,
gboolean *show_mask,
guint32 *text_layer_flags)
{
PropType prop_type;
guint32 prop_size;
while (TRUE)
{
if (! xcf_load_prop (info, &prop_type, &prop_size))
return FALSE;
switch (prop_type)
{
case PROP_END:
return TRUE;
case PROP_ACTIVE_LAYER:
info->active_layer = layer;
break;
case PROP_FLOATING_SELECTION:
info->floating_sel = layer;
info->cp +=
xcf_read_int32 (info->fp,
2003-04-10 22:37:06 +08:00
(guint32 *) &info->floating_sel_offset, 1);
break;
case PROP_OPACITY:
{
guint32 opacity;
info->cp += xcf_read_int32 (info->fp, &opacity, 1);
gimp_layer_set_opacity (layer, (gdouble) opacity / 255.0, FALSE);
}
break;
case PROP_VISIBLE:
{
gboolean visible;
info->cp += xcf_read_int32 (info->fp, (guint32 *) &visible, 1);
gimp_item_set_visible (GIMP_ITEM (layer), visible, FALSE);
}
break;
case PROP_LINKED:
{
gboolean linked;
info->cp += xcf_read_int32 (info->fp, (guint32 *) &linked, 1);
gimp_item_set_linked (GIMP_ITEM (layer), linked, FALSE);
}
break;
app/actions/layers-actions.c app/actions/layers-commands.[ch] 2005-07-10 Michael Natterer <mitch@gimp.org> * app/actions/layers-actions.c * app/actions/layers-commands.[ch] * app/core/core-enums.[ch] * app/core/gimpimage-undo-push.[ch] * app/core/gimplayer-floating-sel.c * app/core/gimplayer.[ch] * app/text/gimptextlayer-xcf.c * app/widgets/gimphelp-ids.h * app/widgets/gimplayertreeview.[ch] * app/xcf/xcf-load.c * app/xcf/xcf-private.h * app/xcf/xcf-save.c * tools/pdbgen/pdb/layer.pdb * menus/image-menu.xml.in * libgimp/gimp.def: did a global s/preserve_trans/lock_alpha/ in preparation for more layer locking flags. * app/pdb/procedural_db.c * libgimp/gimplayer.[ch]: added compat stuff for preserve_trans. * app/pdb/layer_cmds.c * libgimp/gimplayer_pdb.[ch]: regenerated. * plug-ins/common/colortoalpha.c * plug-ins/common/iwarp.c * plug-ins/common/psd.c * plug-ins/common/psd_save.c * plug-ins/common/psp.c * plug-ins/common/rotate.c * plug-ins/common/threshold_alpha.c * plug-ins/common/vpropagate.c * plug-ins/script-fu/scripts/3d-outline.scm * plug-ins/script-fu/scripts/alien-glow-bar.scm * plug-ins/script-fu/scripts/alien-glow-bullet.scm * plug-ins/script-fu/scripts/alien-glow-logo.scm * plug-ins/script-fu/scripts/basic1-logo.scm * plug-ins/script-fu/scripts/basic2-logo.scm * plug-ins/script-fu/scripts/beveled-pattern-button.scm * plug-ins/script-fu/scripts/blend-anim.scm * plug-ins/script-fu/scripts/blended-logo.scm * plug-ins/script-fu/scripts/bovinated-logo.scm * plug-ins/script-fu/scripts/burn-in-anim.scm * plug-ins/script-fu/scripts/carved-logo.scm * plug-ins/script-fu/scripts/chalk.scm * plug-ins/script-fu/scripts/chip-away.scm * plug-ins/script-fu/scripts/comic-logo.scm * plug-ins/script-fu/scripts/coolmetal-logo.scm * plug-ins/script-fu/scripts/crystal-logo.scm * plug-ins/script-fu/scripts/drop-shadow.scm * plug-ins/script-fu/scripts/gimp-headers.scm * plug-ins/script-fu/scripts/gimp-labels.scm * plug-ins/script-fu/scripts/glowing-logo.scm * plug-ins/script-fu/scripts/gradient-bevel-logo.scm * plug-ins/script-fu/scripts/image-structure.scm * plug-ins/script-fu/scripts/neon-logo.scm * plug-ins/script-fu/scripts/perspective-shadow.scm * plug-ins/script-fu/scripts/starburst-logo.scm * plug-ins/script-fu/scripts/starscape-logo.scm * plug-ins/script-fu/scripts/textured-logo.scm * plug-ins/script-fu/scripts/title-header.scm * plug-ins/script-fu/scripts/waves-anim.scm * plug-ins/xjt/xjt.c: changed accordingly.
2005-07-11 05:17:22 +08:00
case PROP_LOCK_ALPHA:
{
gboolean lock_alpha;
info->cp += xcf_read_int32 (info->fp, (guint32 *) &lock_alpha, 1);
gimp_layer_set_lock_alpha (layer, lock_alpha, FALSE);
}
break;
case PROP_APPLY_MASK:
info->cp += xcf_read_int32 (info->fp, (guint32 *) apply_mask, 1);
break;
case PROP_EDIT_MASK:
info->cp += xcf_read_int32 (info->fp, (guint32 *) edit_mask, 1);
break;
case PROP_SHOW_MASK:
info->cp += xcf_read_int32 (info->fp, (guint32 *) show_mask, 1);
break;
case PROP_OFFSETS:
info->cp +=
xcf_read_int32 (info->fp,
(guint32 *) &GIMP_ITEM (layer)->offset_x, 1);
info->cp +=
xcf_read_int32 (info->fp,
(guint32 *) &GIMP_ITEM (layer)->offset_y, 1);
break;
case PROP_MODE:
{
guint32 mode;
info->cp += xcf_read_int32 (info->fp, &mode, 1);
gimp_layer_set_mode (layer, (GimpLayerModeEffects) mode, FALSE);
}
break;
case PROP_TATTOO:
{
GimpTattoo tattoo;
info->cp += xcf_read_int32 (info->fp, (guint32 *) &tattoo, 1);
gimp_item_set_tattoo (GIMP_ITEM (layer), tattoo);
}
break;
case PROP_PARASITES:
{
glong base = info->cp;
GimpParasite *p;
while (info->cp - base < prop_size)
{
p = xcf_load_parasite (info);
gimp_item_parasite_attach (GIMP_ITEM (layer), p);
gimp_parasite_free (p);
}
if (info->cp - base != prop_size)
Added message severities and make sure all messages are routed through a 2006-10-09 Michael Natterer <mitch@gimp.org> Added message severities and make sure all messages are routed through a central function, so redirecting to the error console or stderr work again: * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, WARNING, ERROR }. * app/core/gimp.[ch] (gimp_message) (gimp_message_valist): added severity parameter. Changed "GimpProgress *progress" parameter to "GObject *handler", where "handler" can be either a GimpProgress, a GtkWidget or NULL. * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor --console-messages again. Always dispatch to the GUI message handler first if it exists. * app/gui/gui-message.[ch]: pass severity parameters around. (gui_message_error_dialog): if "handler" is a progress, dispatch the message to it first. If it is a widget (and *not* a progress), use a GtkMessageDialog on top of that widget's toplevel. Fall back to the usual GimpErrorDialog otherwise. * app/core/gimpprogress.[ch] (gimp_progress_message): added severity parameter. Also added boolean return value to the virtual function so it can decide to fail if it can't handle the message. * app/display/gimpdisplay.c: implement GimpProgress::message() and redirect the message to GimpDisplayShell. * app/display/gimpdisplayshell-progress.c: implement GimpProgress::message() and redirect the message to GimpStatusbar if it is not an error and if the status bar is visible. * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), but fail on messages that contain a newline. Show the right icons for the message severities (work in progress). * app/display/gimpdisplayshell.[ch]: removed gimp_display_shell_message() and its _valist() variant. * app/widgets/gimperrorconsole.[ch]: show the right icons for the message severities. * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): return TRUE to swallow all messages. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_show_message_dialog(). Added gimp_get_message_stock_id(). * app/errors.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/select-commands.c * app/actions/text-editor-commands.c * app/actions/vectors-commands.c * app/core/gimpimage-convert.c * app/core/gimpimagefile.c * app/dialogs/convert-dialog.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/palette-import-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/pdb/gimppdb.c * app/plug-in/gimpplugin.c * app/tools/gimpimagemaptool.c * app/tools/gimptool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimppdbdialog.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/palette.pdb: added severity parameter to gimp_message() calls. Convert all calls to gimp_show_message_dialog() and gimp_display_shell_message() to gimp_message(). Also converted some more g_message() calls. * app/pdb/brush_cmds.c * app/pdb/gradient_cmds.c * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/palette_cmds.c: regenerated.
2006-10-09 16:17:22 +08:00
gimp_message (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_WARNING,
"Error while loading a layer's parasites");
}
break;
case PROP_TEXT_LAYER_FLAGS:
info->cp += xcf_read_int32 (info->fp, text_layer_flags, 1);
break;
default:
#ifdef GIMP_UNSTABLE
g_printerr ("unexpected/unknown layer property: %d (skipping)\n",
prop_type);
#endif
{
gsize size = prop_size;
guint8 buf[16];
guint amount;
while (size > 0)
{
if (feof (info->fp))
return FALSE;
amount = MIN (16, size);
info->cp += xcf_read_int8 (info->fp, buf, amount);
size -= MIN (16, amount);
}
}
break;
}
}
return FALSE;
}
static gboolean
xcf_load_channel_props (XcfInfo *info,
GimpImage *image,
GimpChannel **channel)
{
PropType prop_type;
guint32 prop_size;
while (TRUE)
{
if (! xcf_load_prop (info, &prop_type, &prop_size))
return FALSE;
switch (prop_type)
{
case PROP_END:
return TRUE;
case PROP_ACTIVE_CHANNEL:
info->active_channel = *channel;
break;
case PROP_SELECTION:
g_object_unref (image->selection_mask);
image->selection_mask =
gimp_selection_new (image,
gimp_item_width (GIMP_ITEM (*channel)),
gimp_item_height (GIMP_ITEM (*channel)));
g_object_ref_sink (image->selection_mask);
tile_manager_unref (GIMP_DRAWABLE (image->selection_mask)->tiles);
GIMP_DRAWABLE (image->selection_mask)->tiles =
GIMP_DRAWABLE (*channel)->tiles;
GIMP_DRAWABLE (*channel)->tiles = NULL;
g_object_unref (*channel);
*channel = image->selection_mask;
(*channel)->boundary_known = FALSE;
(*channel)->bounds_known = FALSE;
break;
case PROP_OPACITY:
{
guint32 opacity;
info->cp += xcf_read_int32 (info->fp, &opacity, 1);
gimp_channel_set_opacity (*channel, opacity / 255.0, FALSE);
}
break;
case PROP_VISIBLE:
{
gboolean visible;
info->cp += xcf_read_int32 (info->fp, (guint32 *) &visible, 1);
gimp_item_set_visible (GIMP_ITEM (*channel),
visible ? TRUE : FALSE, FALSE);
}
break;
case PROP_LINKED:
{
gboolean linked;
info->cp += xcf_read_int32 (info->fp, (guint32 *) &linked, 1);
gimp_item_set_linked (GIMP_ITEM (*channel),
linked ? TRUE : FALSE, FALSE);
}
break;
case PROP_SHOW_MASKED:
{
gboolean show_masked;
info->cp += xcf_read_int32 (info->fp, (guint32 *) &show_masked, 1);
gimp_channel_set_show_masked (*channel, show_masked);
}
break;
case PROP_COLOR:
{
guchar col[3];
info->cp += xcf_read_int8 (info->fp, (guint8 *) col, 3);
gimp_rgb_set_uchar (&(*channel)->color, col[0], col[1], col[2]);
}
break;
case PROP_TATTOO:
{
GimpTattoo tattoo;
info->cp += xcf_read_int32 (info->fp, (guint32 *) &tattoo, 1);
gimp_item_set_tattoo (GIMP_ITEM (*channel), tattoo);
}
break;
case PROP_PARASITES:
{
glong base = info->cp;
GimpParasite *p;
while ((info->cp - base) < prop_size)
{
p = xcf_load_parasite (info);
gimp_item_parasite_attach (GIMP_ITEM (*channel), p);
gimp_parasite_free (p);
}
if (info->cp - base != prop_size)
Added message severities and make sure all messages are routed through a 2006-10-09 Michael Natterer <mitch@gimp.org> Added message severities and make sure all messages are routed through a central function, so redirecting to the error console or stderr work again: * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, WARNING, ERROR }. * app/core/gimp.[ch] (gimp_message) (gimp_message_valist): added severity parameter. Changed "GimpProgress *progress" parameter to "GObject *handler", where "handler" can be either a GimpProgress, a GtkWidget or NULL. * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor --console-messages again. Always dispatch to the GUI message handler first if it exists. * app/gui/gui-message.[ch]: pass severity parameters around. (gui_message_error_dialog): if "handler" is a progress, dispatch the message to it first. If it is a widget (and *not* a progress), use a GtkMessageDialog on top of that widget's toplevel. Fall back to the usual GimpErrorDialog otherwise. * app/core/gimpprogress.[ch] (gimp_progress_message): added severity parameter. Also added boolean return value to the virtual function so it can decide to fail if it can't handle the message. * app/display/gimpdisplay.c: implement GimpProgress::message() and redirect the message to GimpDisplayShell. * app/display/gimpdisplayshell-progress.c: implement GimpProgress::message() and redirect the message to GimpStatusbar if it is not an error and if the status bar is visible. * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), but fail on messages that contain a newline. Show the right icons for the message severities (work in progress). * app/display/gimpdisplayshell.[ch]: removed gimp_display_shell_message() and its _valist() variant. * app/widgets/gimperrorconsole.[ch]: show the right icons for the message severities. * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): return TRUE to swallow all messages. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_show_message_dialog(). Added gimp_get_message_stock_id(). * app/errors.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/select-commands.c * app/actions/text-editor-commands.c * app/actions/vectors-commands.c * app/core/gimpimage-convert.c * app/core/gimpimagefile.c * app/dialogs/convert-dialog.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/palette-import-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/pdb/gimppdb.c * app/plug-in/gimpplugin.c * app/tools/gimpimagemaptool.c * app/tools/gimptool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimppdbdialog.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/palette.pdb: added severity parameter to gimp_message() calls. Convert all calls to gimp_show_message_dialog() and gimp_display_shell_message() to gimp_message(). Also converted some more g_message() calls. * app/pdb/brush_cmds.c * app/pdb/gradient_cmds.c * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/palette_cmds.c: regenerated.
2006-10-09 16:17:22 +08:00
gimp_message (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_WARNING,
"Error while loading a channel's parasites");
}
break;
default:
#ifdef GIMP_UNSTABLE
g_printerr ("unexpected/unknown channel property: %d (skipping)\n",
prop_type);
#endif
{
gsize size = prop_size;
guint8 buf[16];
guint amount;
while (size > 0)
{
if (feof (info->fp))
return FALSE;
amount = MIN (16, size);
info->cp += xcf_read_int8 (info->fp, buf, amount);
size -= MIN (16, amount);
}
}
break;
}
}
return FALSE;
}
static gboolean
xcf_load_prop (XcfInfo *info,
PropType *prop_type,
guint32 *prop_size)
{
if (G_UNLIKELY (xcf_read_int32 (info->fp, (guint32 *) prop_type, 1) != 4))
return FALSE;
info->cp += 4;
if (G_UNLIKELY (xcf_read_int32 (info->fp, (guint32 *) prop_size, 1) != 4))
return FALSE;
info->cp += 4;
return TRUE;
}
static GimpLayer *
xcf_load_layer (XcfInfo *info,
GimpImage *image)
{
GimpLayer *layer;
GimpLayerMask *layer_mask;
guint32 hierarchy_offset;
guint32 layer_mask_offset;
gboolean apply_mask = TRUE;
gboolean edit_mask = FALSE;
gboolean show_mask = FALSE;
gboolean active;
gboolean floating;
guint32 text_layer_flags = 0;
gint width;
gint height;
gint type;
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
gboolean is_fs_drawable;
gchar *name;
/* check and see if this is the drawable the floating selection
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
* is attached to. if it is then we'll do the attachment in our caller.
*/
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
is_fs_drawable = (info->cp == info->floating_sel_offset);
/* read in the layer width, height, type and name */
2003-04-10 22:37:06 +08:00
info->cp += xcf_read_int32 (info->fp, (guint32 *) &width, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &height, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &type, 1);
info->cp += xcf_read_string (info->fp, &name, 1);
/* create a new layer */
layer = gimp_layer_new (image, width, height,
app/core/Makefile.am new file that holds enums that are registered with 2001-12-08 Sven Neumann <sven@gimp.org> * app/core/Makefile.am * app/core/core-enums.h: new file that holds enums that are registered with the type system and is used to generate core-enums.c. * app/core/core-types.h: include core-enums.h * app/base/base-types.h: namespace cleanup. Prefix all enumeration types with Gimp and their values with GIMP. Moved GimpLayerModeEffects enum ... * app/base/base-enums.h: ... here. * app/image_map.c * app/base/temp-buf.c * app/core/gimpcontext.[ch] * app/core/gimpdrawable-transform.c * app/core/gimpdrawable.c * app/core/gimpedit.c * app/core/gimpimage-mask.c * app/core/gimpimage-merge.c * app/core/gimpimage-new.c * app/core/gimpimage-projection.c * app/core/gimpimage.[ch] * app/core/gimplayer.[ch] * app/display/gimpdisplayshell-dnd.c * app/display/gimpdisplayshell-render.c * app/gui/brush-select.c * app/gui/layers-commands.c * app/gui/preferences-dialog.c * app/gui/toolbox.c * app/paint-funcs/paint-funcs.[ch] * app/tools/gimpconvolvetool.c * app/tools/gimperasertool.c * app/tools/gimpiscissorstool.c * app/tools/gimppainttool.[ch] * app/tools/gimptexttool.c * app/tools/paint_options.c * app/widgets/gimplayerlistview.c * app/widgets/gimpwidgets-constructors.[ch] * app/xcf/xcf-load.c * tools/pdbgen/pdb/brush_select.pdb * tools/pdbgen/pdb/brushes.pdb * tools/pdbgen/pdb/color.pdb * tools/pdbgen/pdb/layer.pdb * tools/pdbgen/pdb/tools.pdb: changed accordingly. * libgimpbase/gimpbasetypes.h: no need to chop GIMP prefix off the enums any longer. * app/pdb/brush_select_cmds.c * app/pdb/brushes_cmds.c * app/pdb/color_cmds.c * app/pdb/layer_cmds.c * app/pdb/message_cmds.c * app/pdb/procedural_db_cmds.c * app/pdb/tools_cmds.c * libgimp/gimpenums.h * plug-ins/script-fu/script-fu-constants.c * tools/pdbgen/enums.pl: regenerated. * app/gimprc.c: removed code to parse for "plug_in" keyword which was left over from some very early gimp days. * app/plug-in/plug-in.[ch]: removed now unused function plug_in_add().
2001-12-09 07:12:59 +08:00
type, name, 255, GIMP_NORMAL_MODE);
g_free (name);
if (! layer)
return NULL;
/* read in the layer properties */
if (! xcf_load_layer_props (info, image, layer,
&apply_mask, &edit_mask, &show_mask,
&text_layer_flags))
goto error;
xcf_progress_update (info);
/* call the evil text layer hack that might change our layer pointer */
active = (info->active_layer == layer);
floating = (info->floating_sel == layer);
if (gimp_text_layer_xcf_load_hack (&layer))
{
gimp_text_layer_set_xcf_flags (GIMP_TEXT_LAYER (layer),
text_layer_flags);
if (active)
info->active_layer = layer;
if (floating)
info->floating_sel = 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))
goto error;
if (! xcf_load_hierarchy (info,
gimp_drawable_get_tiles (GIMP_DRAWABLE (layer))))
goto error;
xcf_progress_update (info);
/* read in the layer mask */
if (layer_mask_offset != 0)
{
if (! xcf_seek_pos (info, layer_mask_offset, NULL))
goto error;
layer_mask = xcf_load_layer_mask (info, image);
if (! layer_mask)
goto error;
xcf_progress_update (info);
gimp_layer_mask_set_apply (layer_mask, apply_mask, FALSE);
gimp_layer_mask_set_edit (layer_mask, edit_mask);
gimp_layer_mask_set_show (layer_mask, show_mask, FALSE);
gimp_layer_add_mask (layer, layer_mask, FALSE);
}
/* attach the floating selection... */
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
if (is_fs_drawable)
info->floating_sel_drawable = GIMP_DRAWABLE (layer);
return layer;
error:
g_object_unref (layer);
return NULL;
}
static GimpChannel *
xcf_load_channel (XcfInfo *info,
GimpImage *image)
{
GimpChannel *channel;
guint32 hierarchy_offset;
gint width;
gint height;
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
gboolean is_fs_drawable;
gchar *name;
GimpRGB color = { 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE };
/* check and see if this is the drawable the floating selection
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
* is attached to. if it is then we'll do the attachment in our caller.
*/
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
is_fs_drawable = (info->cp == info->floating_sel_offset);
/* read in the layer width, height and name */
2003-04-10 22:37:06 +08:00
info->cp += xcf_read_int32 (info->fp, (guint32 *) &width, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &height, 1);
info->cp += xcf_read_string (info->fp, &name, 1);
/* create a new channel */
channel = gimp_channel_new (image, width, height, name, &color);
g_free (name);
if (!channel)
return NULL;
/* read in the channel properties */
if (!xcf_load_channel_props (info, image, &channel))
goto error;
xcf_progress_update (info);
/* read the hierarchy and layer mask offsets */
info->cp += xcf_read_int32 (info->fp, &hierarchy_offset, 1);
/* read in the hierarchy */
if (!xcf_seek_pos (info, hierarchy_offset, NULL))
goto error;
if (!xcf_load_hierarchy (info,
gimp_drawable_get_tiles (GIMP_DRAWABLE (channel))))
goto error;
xcf_progress_update (info);
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
if (is_fs_drawable)
info->floating_sel_drawable = GIMP_DRAWABLE (channel);
return channel;
error:
g_object_unref (channel);
return NULL;
}
static GimpLayerMask *
xcf_load_layer_mask (XcfInfo *info,
GimpImage *image)
{
GimpLayerMask *layer_mask;
GimpChannel *channel;
guint32 hierarchy_offset;
gint width;
gint height;
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
gboolean is_fs_drawable;
gchar *name;
GimpRGB color = { 0.0, 0.0, 0.0, GIMP_OPACITY_OPAQUE };
/* check and see if this is the drawable the floating selection
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
* is attached to. if it is then we'll do the attachment in our caller.
*/
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
is_fs_drawable = (info->cp == info->floating_sel_offset);
/* read in the layer width, height and name */
2003-04-10 22:37:06 +08:00
info->cp += xcf_read_int32 (info->fp, (guint32 *) &width, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &height, 1);
info->cp += xcf_read_string (info->fp, &name, 1);
/* create a new layer mask */
layer_mask = gimp_layer_mask_new (image, width, height, name, &color);
g_free (name);
if (!layer_mask)
return NULL;
/* read in the layer_mask properties */
channel = GIMP_CHANNEL (layer_mask);
if (!xcf_load_channel_props (info, image, &channel))
goto error;
xcf_progress_update (info);
/* read the hierarchy and layer mask offsets */
info->cp += xcf_read_int32 (info->fp, &hierarchy_offset, 1);
/* read in the hierarchy */
if (! xcf_seek_pos (info, hierarchy_offset, NULL))
goto error;
if (!xcf_load_hierarchy (info,
gimp_drawable_get_tiles (GIMP_DRAWABLE (layer_mask))))
goto error;
xcf_progress_update (info);
/* attach the floating selection... */
add the layer to the image before pasting to it. Fixes bug #132504. 2004-01-26 Michael Natterer <mitch@gimp.org> * plug-ins/script-fu/scripts/unsharp-mask.scm: add the layer to the image before pasting to it. Fixes bug #132504. Fixed the underlying problem: make it impossible to attach floating selections to drawables which are not currently part of the image's layer or channel stacks. Also cleaned up image <-> floating_sel interaction: * app/core/gimplayer-floating-sel.[ch] (floating_sel_attach): added assertion that the drawable is part of the image (see below). Don't call gimp_image_floating_selection_changed(), it's emitted by gimp_image_add_layer() now. (floating_sel_remove) (floating_sel_anchor): don't emit "floating_selection_changed", it's emitted by gimp_image_remove_layer() now. (floating_sel_anchor): removed the fix for bug #132162 because gimp_image_remove_layer() behaves correctly now (see below). Renamed floating_sel_reset() to floating_sel_activate_drawable(). Added g_return_if_fail() all over the place. * app/core/gimpimage.[ch]: added new function gimp_image_owns_item() which return TRUE if the passed item is part of the image. (gimp_image_add_layer): emit "floating_selection_changed" here if needed. (gimp_image_remove_layer): emit "floating_selection_changed" if needed, don't try to activate a layer if we called floating_sel_activate_drawable(). This is the real fix for bug #132162. * app/core/gimpimage-undo-push.c (undo_pop_layer): apply the same fixes as to gimp_image_add,remove_layer(). Don't call gimp_drawable_invalidate_preview() on the previously active layer because that's done by gimp_image_set_active_layer() now. * app/xcf/xcf-load.c: remember the "floating_sel_drawable" in the XcfInfo struct and attach it *after* all layers and channels are loaded to avoid attaching the floating selection to an out-of-image drawable. * app/core/gimp-edit.c (gimp_edit_paste) * app/core/gimpdrawable-transform.c (gimp_drawable_transform_affine, gimp_drawable_transform_flip, gimp_drawable_transform_rotate) * app/core/gimpselection.c (gimp_selection_float) * app/text/gimptext-compat.c (text_render): added checks for gimp_image_owns_item() in all functions which can produce floating selections. * tools/pdbgen/pdb/edit.pdb * tools/pdbgen/pdb/floating_sel.pdb * tools/pdbgen/pdb/selection.pdb * tools/pdbgen/pdb/text_tool.pdb * tools/pdbgen/pdb/transform_tools.pdb: added checks for gimp_item_owns_image() and return an execution error if invoked with a drawable which is not part of the image. * app/pdb/edit_cmds.c * app/pdb/floating_sel_cmds.c * app/pdb/selection_cmds.c * app/pdb/text_tool_cmds.c * app/pdb/transform_tools_cmds.c: regenerated.
2004-01-26 23:34:47 +08:00
if (is_fs_drawable)
info->floating_sel_drawable = GIMP_DRAWABLE (layer_mask);
return layer_mask;
error:
g_object_unref (layer_mask);
return NULL;
}
static gboolean
xcf_load_hierarchy (XcfInfo *info,
TileManager *tiles)
{
guint32 saved_pos;
guint32 offset;
guint32 junk;
gint width;
gint height;
gint bpp;
info->cp += xcf_read_int32 (info->fp, (guint32 *) &width, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &height, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &bpp, 1);
/* make sure the values in the file correspond to the values
* calculated when the TileManager was created.
*/
if (width != tile_manager_width (tiles) ||
height != tile_manager_height (tiles) ||
bpp != tile_manager_bpp (tiles))
return FALSE;
/* load in the levels...we make sure that the number of levels
* calculated when the TileManager was created is the same
* as the number of levels found in the file.
*/
info->cp += xcf_read_int32 (info->fp, &offset, 1); /* top level */
/* discard offsets for layers below first, if any.
*/
do
{
info->cp += xcf_read_int32 (info->fp, &junk, 1);
}
while (junk != 0);
/* save the current position as it is where the
* next level offset is stored.
*/
saved_pos = info->cp;
/* seek to the level offset */
if (!xcf_seek_pos (info, offset, NULL))
return FALSE;
/* read in the level */
if (!xcf_load_level (info, tiles))
return FALSE;
/* restore the saved position so we'll be ready to
* read the next offset.
*/
if (!xcf_seek_pos (info, saved_pos, NULL))
return FALSE;
return TRUE;
}
static gboolean
xcf_load_level (XcfInfo *info,
TileManager *tiles)
{
guint32 saved_pos;
guint32 offset, offset2;
guint ntiles;
gint width;
gint height;
gint i;
gint fail;
Tile *previous;
Tile *tile;
2003-04-10 22:37:06 +08:00
info->cp += xcf_read_int32 (info->fp, (guint32 *) &width, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &height, 1);
if (width != tile_manager_width (tiles) ||
height != tile_manager_height (tiles))
return FALSE;
/* read in the first tile offset.
* if it is '0', then this tile level is empty
* and we can simply return.
*/
info->cp += xcf_read_int32 (info->fp, &offset, 1);
if (offset == 0)
return TRUE;
/* Initialise the reference for the in-memory tile-compression
*/
previous = NULL;
ntiles = tiles->ntile_rows * tiles->ntile_cols;
for (i = 0; i < ntiles; i++)
{
fail = FALSE;
if (offset == 0)
{
Added message severities and make sure all messages are routed through a 2006-10-09 Michael Natterer <mitch@gimp.org> Added message severities and make sure all messages are routed through a central function, so redirecting to the error console or stderr work again: * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, WARNING, ERROR }. * app/core/gimp.[ch] (gimp_message) (gimp_message_valist): added severity parameter. Changed "GimpProgress *progress" parameter to "GObject *handler", where "handler" can be either a GimpProgress, a GtkWidget or NULL. * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor --console-messages again. Always dispatch to the GUI message handler first if it exists. * app/gui/gui-message.[ch]: pass severity parameters around. (gui_message_error_dialog): if "handler" is a progress, dispatch the message to it first. If it is a widget (and *not* a progress), use a GtkMessageDialog on top of that widget's toplevel. Fall back to the usual GimpErrorDialog otherwise. * app/core/gimpprogress.[ch] (gimp_progress_message): added severity parameter. Also added boolean return value to the virtual function so it can decide to fail if it can't handle the message. * app/display/gimpdisplay.c: implement GimpProgress::message() and redirect the message to GimpDisplayShell. * app/display/gimpdisplayshell-progress.c: implement GimpProgress::message() and redirect the message to GimpStatusbar if it is not an error and if the status bar is visible. * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), but fail on messages that contain a newline. Show the right icons for the message severities (work in progress). * app/display/gimpdisplayshell.[ch]: removed gimp_display_shell_message() and its _valist() variant. * app/widgets/gimperrorconsole.[ch]: show the right icons for the message severities. * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): return TRUE to swallow all messages. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_show_message_dialog(). Added gimp_get_message_stock_id(). * app/errors.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/select-commands.c * app/actions/text-editor-commands.c * app/actions/vectors-commands.c * app/core/gimpimage-convert.c * app/core/gimpimagefile.c * app/dialogs/convert-dialog.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/palette-import-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/pdb/gimppdb.c * app/plug-in/gimpplugin.c * app/tools/gimpimagemaptool.c * app/tools/gimptool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimppdbdialog.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/palette.pdb: added severity parameter to gimp_message() calls. Convert all calls to gimp_show_message_dialog() and gimp_display_shell_message() to gimp_message(). Also converted some more g_message() calls. * app/pdb/brush_cmds.c * app/pdb/gradient_cmds.c * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/palette_cmds.c: regenerated.
2006-10-09 16:17:22 +08:00
gimp_message (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_ERROR,
"not enough tiles found in level");
return FALSE;
}
/* save the current position as it is where the
* next tile offset is stored.
*/
saved_pos = info->cp;
/* read in the offset of the next tile so we can calculate the amount
of data needed for this tile*/
info->cp += xcf_read_int32 (info->fp, &offset2, 1);
/* if the offset is 0 then we need to read in the maximum possible
allowing for negative compression */
if (offset2 == 0)
offset2 = offset + TILE_WIDTH * TILE_WIDTH * 4 * 1.5;
/* 1.5 is probably more
than we need to allow */
/* seek to the tile offset */
if (! xcf_seek_pos (info, offset, NULL))
return FALSE;
/* get the tile from the tile manager */
tile = tile_manager_get (tiles, i, TRUE, TRUE);
/* read in the tile */
switch (info->compression)
{
case COMPRESS_NONE:
if (!xcf_load_tile (info, tile))
fail = TRUE;
break;
case COMPRESS_RLE:
if (!xcf_load_tile_rle (info, tile, offset2 - offset))
fail = TRUE;
break;
case COMPRESS_ZLIB:
g_error ("xcf: zlib compression unimplemented");
fail = TRUE;
break;
case COMPRESS_FRACTAL:
g_error ("xcf: fractal compression unimplemented");
fail = TRUE;
break;
}
if (fail)
{
tile_release (tile, TRUE);
return FALSE;
}
/* To potentially save memory, we compare the
* newly-fetched tile against the last one, and
* if they're the same we copy-on-write mirror one against
* the other.
*/
if (previous != NULL)
{
tile_lock (previous);
if (tile_ewidth (tile) == tile_ewidth (previous) &&
tile_eheight (tile) == tile_eheight (previous) &&
tile_bpp (tile) == tile_bpp (previous) &&
memcmp (tile_data_pointer (tile, 0, 0),
tile_data_pointer (previous, 0, 0),
tile_size (tile)) == 0)
tile_manager_map (tiles, i, previous);
tile_release (previous, FALSE);
}
tile_release (tile, TRUE);
previous = tile_manager_get (tiles, i, FALSE, FALSE);
/* restore the saved position so we'll be ready to
* read the next offset.
*/
if (!xcf_seek_pos (info, saved_pos, NULL))
return FALSE;
/* read in the offset of the next tile */
info->cp += xcf_read_int32 (info->fp, &offset, 1);
}
if (offset != 0)
{
Added message severities and make sure all messages are routed through a 2006-10-09 Michael Natterer <mitch@gimp.org> Added message severities and make sure all messages are routed through a central function, so redirecting to the error console or stderr work again: * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, WARNING, ERROR }. * app/core/gimp.[ch] (gimp_message) (gimp_message_valist): added severity parameter. Changed "GimpProgress *progress" parameter to "GObject *handler", where "handler" can be either a GimpProgress, a GtkWidget or NULL. * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor --console-messages again. Always dispatch to the GUI message handler first if it exists. * app/gui/gui-message.[ch]: pass severity parameters around. (gui_message_error_dialog): if "handler" is a progress, dispatch the message to it first. If it is a widget (and *not* a progress), use a GtkMessageDialog on top of that widget's toplevel. Fall back to the usual GimpErrorDialog otherwise. * app/core/gimpprogress.[ch] (gimp_progress_message): added severity parameter. Also added boolean return value to the virtual function so it can decide to fail if it can't handle the message. * app/display/gimpdisplay.c: implement GimpProgress::message() and redirect the message to GimpDisplayShell. * app/display/gimpdisplayshell-progress.c: implement GimpProgress::message() and redirect the message to GimpStatusbar if it is not an error and if the status bar is visible. * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), but fail on messages that contain a newline. Show the right icons for the message severities (work in progress). * app/display/gimpdisplayshell.[ch]: removed gimp_display_shell_message() and its _valist() variant. * app/widgets/gimperrorconsole.[ch]: show the right icons for the message severities. * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): return TRUE to swallow all messages. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_show_message_dialog(). Added gimp_get_message_stock_id(). * app/errors.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/select-commands.c * app/actions/text-editor-commands.c * app/actions/vectors-commands.c * app/core/gimpimage-convert.c * app/core/gimpimagefile.c * app/dialogs/convert-dialog.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/palette-import-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/pdb/gimppdb.c * app/plug-in/gimpplugin.c * app/tools/gimpimagemaptool.c * app/tools/gimptool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimppdbdialog.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/palette.pdb: added severity parameter to gimp_message() calls. Convert all calls to gimp_show_message_dialog() and gimp_display_shell_message() to gimp_message(). Also converted some more g_message() calls. * app/pdb/brush_cmds.c * app/pdb/gradient_cmds.c * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/palette_cmds.c: regenerated.
2006-10-09 16:17:22 +08:00
gimp_message (info->gimp, G_OBJECT (info->progress), GIMP_MESSAGE_ERROR,
"encountered garbage after reading level: %d", offset);
return FALSE;
}
return TRUE;
}
static gboolean
xcf_load_tile (XcfInfo *info,
Tile *tile)
{
info->cp += xcf_read_int8 (info->fp, tile_data_pointer (tile, 0, 0),
tile_size (tile));
return TRUE;
}
static gboolean
xcf_load_tile_rle (XcfInfo *info,
Tile *tile,
int data_length)
{
guchar *data;
guchar val;
gint size;
gint count;
gint length;
gint bpp;
gint i, j;
gint nmemb_read_successfully;
guchar *xcfdata, *xcfodata, *xcfdatalimit;
/* Workaround for bug #357809: avoid crashing on g_malloc() and skip
* this tile (return TRUE without storing data) as if it did not
* contain any data. It is better than returning FALSE, which would
* skip the whole hierarchy while there may still be some valid
* tiles in the file.
*/
if (data_length <= 0)
return TRUE;
data = tile_data_pointer (tile, 0, 0);
bpp = tile_bpp (tile);
xcfdata = xcfodata = g_malloc (data_length);
/* we have to use fread instead of xcf_read_* because we may be
reading past the end of the file here */
2003-04-10 22:37:06 +08:00
nmemb_read_successfully = fread ((gchar *) xcfdata, sizeof (gchar),
data_length, info->fp);
info->cp += nmemb_read_successfully;
xcfdatalimit = &xcfodata[nmemb_read_successfully - 1];
for (i = 0; i < bpp; i++)
{
2003-04-10 22:37:06 +08:00
data = (guchar *) tile_data_pointer (tile, 0, 0) + i;
size = tile_ewidth (tile) * tile_eheight (tile);
count = 0;
while (size > 0)
{
if (xcfdata > xcfdatalimit)
{
goto bogus_rle;
}
val = *xcfdata++;
length = val;
if (length >= 128)
{
length = 255 - (length - 1);
if (length == 128)
{
if (xcfdata >= xcfdatalimit)
{
goto bogus_rle;
}
length = (*xcfdata << 8) + xcfdata[1];
xcfdata += 2;
}
count += length;
size -= length;
if (size < 0)
{
goto bogus_rle;
}
if (&xcfdata[length-1] > xcfdatalimit)
{
goto bogus_rle;
}
while (length-- > 0)
{
*data = *xcfdata++;
data += bpp;
}
}
else
{
length += 1;
if (length == 128)
{
if (xcfdata >= xcfdatalimit)
{
goto bogus_rle;
}
length = (*xcfdata << 8) + xcfdata[1];
xcfdata += 2;
}
count += length;
size -= length;
if (size < 0)
{
goto bogus_rle;
}
if (xcfdata > xcfdatalimit)
{
goto bogus_rle;
}
val = *xcfdata++;
for (j = 0; j < length; j++)
{
*data = val;
data += bpp;
}
}
}
}
g_free (xcfodata);
return TRUE;
bogus_rle:
if (xcfodata)
g_free (xcfodata);
return FALSE;
}
static GimpParasite *
xcf_load_parasite (XcfInfo *info)
{
GimpParasite *parasite;
gchar *name;
guint32 flags;
guint32 size;
gpointer data;
info->cp += xcf_read_string (info->fp, &name, 1);
info->cp += xcf_read_int32 (info->fp, &flags, 1);
info->cp += xcf_read_int32 (info->fp, &size, 1);
data = g_new (gchar, size);
info->cp += xcf_read_int8 (info->fp, data, size);
parasite = gimp_parasite_new (name, flags, size, data);
g_free (name);
g_free (data);
return parasite;
}
static gboolean
xcf_load_old_paths (XcfInfo *info,
GimpImage *image)
{
guint32 num_paths;
guint32 last_selected_row;
GimpVectors *active_vectors;
info->cp += xcf_read_int32 (info->fp, &last_selected_row, 1);
info->cp += xcf_read_int32 (info->fp, &num_paths, 1);
while (num_paths-- > 0)
xcf_load_old_path (info, image);
active_vectors = (GimpVectors *)
gimp_container_get_child_by_index (image->vectors, last_selected_row);
if (active_vectors)
gimp_image_set_active_vectors (image, active_vectors);
return TRUE;
}
static gboolean
xcf_load_old_path (XcfInfo *info,
GimpImage *image)
{
gchar *name;
guint32 locked;
guint8 state;
guint32 closed;
guint32 num_points;
guint32 version; /* changed from num_paths */
GimpTattoo tattoo = 0;
GimpVectors *vectors;
GimpVectorsCompatPoint *points;
gint i;
info->cp += xcf_read_string (info->fp, &name, 1);
info->cp += xcf_read_int32 (info->fp, &locked, 1);
info->cp += xcf_read_int8 (info->fp, &state, 1);
info->cp += xcf_read_int32 (info->fp, &closed, 1);
info->cp += xcf_read_int32 (info->fp, &num_points, 1);
info->cp += xcf_read_int32 (info->fp, &version, 1);
if (version == 2)
{
guint32 dummy;
/* Had extra type field and points are stored as doubles */
info->cp += xcf_read_int32 (info->fp, (guint32 *) &dummy, 1);
}
else if (version == 3)
{
guint32 dummy;
/* Has extra tatto field */
info->cp += xcf_read_int32 (info->fp, (guint32 *) &dummy, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &tattoo, 1);
}
else if (version != 1)
{
g_warning ("Unknown path type. Possibly corrupt XCF file");
return FALSE;
}
/* skip empty compatibility paths */
if (num_points == 0)
return FALSE;
points = g_new0 (GimpVectorsCompatPoint, num_points);
for (i = 0; i < num_points; i++)
{
if (version == 1)
{
gint32 x;
gint32 y;
info->cp += xcf_read_int32 (info->fp, &points[i].type, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &x, 1);
info->cp += xcf_read_int32 (info->fp, (guint32 *) &y, 1);
points[i].x = x;
points[i].y = y;
}
else
{
gfloat x;
gfloat y;
info->cp += xcf_read_int32 (info->fp, &points[i].type, 1);
info->cp += xcf_read_float (info->fp, &x, 1);
info->cp += xcf_read_float (info->fp, &y, 1);
points[i].x = x;
points[i].y = y;
}
}
vectors = gimp_vectors_compat_new (image, name, points, num_points, closed);
g_free (name);
g_free (points);
gimp_item_set_linked (GIMP_ITEM (vectors), locked, FALSE);
if (tattoo)
gimp_item_set_tattoo (GIMP_ITEM (vectors), tattoo);
gimp_image_add_vectors (image, vectors,
gimp_container_num_children (image->vectors));
return TRUE;
}
static gboolean
xcf_load_vectors (XcfInfo *info,
GimpImage *image)
{
guint32 version;
guint32 active_index;
guint32 num_paths;
GimpVectors *active_vectors;
guint32 base;
#ifdef GIMP_XCF_PATH_DEBUG
g_printerr ("xcf_load_vectors\n");
#endif
base = info->cp;
info->cp += xcf_read_int32 (info->fp, &version, 1);
if (version != 1)
{
Added message severities and make sure all messages are routed through a 2006-10-09 Michael Natterer <mitch@gimp.org> Added message severities and make sure all messages are routed through a central function, so redirecting to the error console or stderr work again: * app/core/core-enums.[ch]: added enum GimpMessageSeverity { INFO, WARNING, ERROR }. * app/core/gimp.[ch] (gimp_message) (gimp_message_valist): added severity parameter. Changed "GimpProgress *progress" parameter to "GObject *handler", where "handler" can be either a GimpProgress, a GtkWidget or NULL. * app/core/gimp-gui.[ch] (gimp_show_message): ditto. Honor --console-messages again. Always dispatch to the GUI message handler first if it exists. * app/gui/gui-message.[ch]: pass severity parameters around. (gui_message_error_dialog): if "handler" is a progress, dispatch the message to it first. If it is a widget (and *not* a progress), use a GtkMessageDialog on top of that widget's toplevel. Fall back to the usual GimpErrorDialog otherwise. * app/core/gimpprogress.[ch] (gimp_progress_message): added severity parameter. Also added boolean return value to the virtual function so it can decide to fail if it can't handle the message. * app/display/gimpdisplay.c: implement GimpProgress::message() and redirect the message to GimpDisplayShell. * app/display/gimpdisplayshell-progress.c: implement GimpProgress::message() and redirect the message to GimpStatusbar if it is not an error and if the status bar is visible. * app/display/gimpstatusbar.[ch]: implement GimpProgress::message(), but fail on messages that contain a newline. Show the right icons for the message severities (work in progress). * app/display/gimpdisplayshell.[ch]: removed gimp_display_shell_message() and its _valist() variant. * app/widgets/gimperrorconsole.[ch]: show the right icons for the message severities. * app/widgets/gimpthumbbox.c (gimp_thumb_box_progress_message): return TRUE to swallow all messages. * app/widgets/gimpwidgets-utils.[ch]: removed gimp_show_message_dialog(). Added gimp_get_message_stock_id(). * app/errors.c * app/actions/edit-commands.c * app/actions/error-console-commands.c * app/actions/file-commands.c * app/actions/select-commands.c * app/actions/text-editor-commands.c * app/actions/vectors-commands.c * app/core/gimpimage-convert.c * app/core/gimpimagefile.c * app/dialogs/convert-dialog.c * app/dialogs/file-open-dialog.c * app/dialogs/file-open-location-dialog.c * app/dialogs/file-save-dialog.c * app/dialogs/palette-import-dialog.c * app/dialogs/stroke-dialog.c * app/display/gimpdisplayshell-dnd.c * app/pdb/gimppdb.c * app/plug-in/gimpplugin.c * app/tools/gimpimagemaptool.c * app/tools/gimptool.c * app/tools/gimpvectortool.c * app/widgets/gimpactionview.c * app/widgets/gimpcontrollerlist.c * app/widgets/gimppdbdialog.c * app/widgets/gimpvectorstreeview.c * app/xcf/xcf-load.c * app/xcf/xcf-save.c * app/xcf/xcf.c * tools/pdbgen/pdb/brush.pdb * tools/pdbgen/pdb/gradient.pdb * tools/pdbgen/pdb/image.pdb * tools/pdbgen/pdb/message.pdb * tools/pdbgen/pdb/palette.pdb: added severity parameter to gimp_message() calls. Convert all calls to gimp_show_message_dialog() and gimp_display_shell_message() to gimp_message(). Also converted some more g_message() calls. * app/pdb/brush_cmds.c * app/pdb/gradient_cmds.c * app/pdb/image_cmds.c * app/pdb/message_cmds.c * app/pdb/palette_cmds.c: regenerated.
2006-10-09 16:17:22 +08:00
gimp_message (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_WARNING,
"Unknown vectors version: %d (skipping)", version);
return FALSE;
}
info->cp += xcf_read_int32 (info->fp, &active_index, 1);
info->cp += xcf_read_int32 (info->fp, &num_paths, 1);
#ifdef GIMP_XCF_PATH_DEBUG
g_printerr ("%d paths (active: %d)\n", num_paths, active_index);
#endif
while (num_paths-- > 0)
if (! xcf_load_vector (info, image))
return FALSE;
active_vectors = (GimpVectors *)
gimp_container_get_child_by_index (image->vectors, active_index);
if (active_vectors)
gimp_image_set_active_vectors (image, active_vectors);
#ifdef GIMP_XCF_PATH_DEBUG
g_printerr ("xcf_load_vectors: loaded %d bytes\n", info->cp - base);
#endif
return TRUE;
}
static gboolean
xcf_load_vector (XcfInfo *info,
GimpImage *image)
{
gchar *name;
GimpTattoo tattoo = 0;
guint32 visible;
guint32 linked;
guint32 num_parasites;
guint32 num_strokes;
GimpVectors *vectors;
gint i;
#ifdef GIMP_XCF_PATH_DEBUG
g_printerr ("xcf_load_vector\n");
#endif
info->cp += xcf_read_string (info->fp, &name, 1);
info->cp += xcf_read_int32 (info->fp, &tattoo, 1);
info->cp += xcf_read_int32 (info->fp, &visible, 1);
info->cp += xcf_read_int32 (info->fp, &linked, 1);
info->cp += xcf_read_int32 (info->fp, &num_parasites, 1);
info->cp += xcf_read_int32 (info->fp, &num_strokes, 1);
#ifdef GIMP_XCF_PATH_DEBUG
g_printerr ("name: %s, tattoo: %d, visible: %d, linked: %d, "
"num_parasites %d, num_strokes %d\n",
name, tattoo, visible, linked, num_parasites, num_strokes);
#endif
vectors = gimp_vectors_new (image, name);
gimp_item_set_visible (GIMP_ITEM (vectors), visible, FALSE);
gimp_item_set_linked (GIMP_ITEM (vectors), linked, FALSE);
if (tattoo)
gimp_item_set_tattoo (GIMP_ITEM (vectors), tattoo);
for (i = 0; i < num_parasites; i++)
{
GimpParasite *parasite = xcf_load_parasite (info);
if (! parasite)
return FALSE;
gimp_item_parasite_attach (GIMP_ITEM (vectors), parasite);
gimp_parasite_free (parasite);
}
for (i = 0; i < num_strokes; i++)
{
guint32 stroke_type_id;
guint32 closed;
guint32 num_axes;
guint32 num_control_points;
guint32 type;
gfloat coords[6] = GIMP_COORDS_DEFAULT_VALUES;
GimpStroke *stroke;
gint j;
GValueArray *control_points;
GValue value = { 0, };
GimpAnchor anchor;
GType stroke_type;
g_value_init (&value, GIMP_TYPE_ANCHOR);
info->cp += xcf_read_int32 (info->fp, &stroke_type_id, 1);
info->cp += xcf_read_int32 (info->fp, &closed, 1);
info->cp += xcf_read_int32 (info->fp, &num_axes, 1);
info->cp += xcf_read_int32 (info->fp, &num_control_points, 1);
#ifdef GIMP_XCF_PATH_DEBUG
g_printerr ("stroke_type: %d, closed: %d, num_axes %d, len %d\n",
stroke_type_id, closed, num_axes, num_control_points);
#endif
switch (stroke_type_id)
{
case XCF_STROKETYPE_BEZIER_STROKE:
stroke_type = GIMP_TYPE_BEZIER_STROKE;
break;
default:
g_printerr ("skipping unknown stroke type\n");
xcf_seek_pos (info,
info->cp + 4 * num_axes * num_control_points,
NULL);
continue;
}
if (num_axes < 2 || num_axes > 6)
{
g_printerr ("bad number of axes in stroke description\n");
return FALSE;
}
control_points = g_value_array_new (num_control_points);
anchor.selected = FALSE;
for (j = 0; j < num_control_points; j++)
{
info->cp += xcf_read_int32 (info->fp, &type, 1);
info->cp += xcf_read_float (info->fp, coords, num_axes);
anchor.type = type;
anchor.position.x = coords[0];
anchor.position.y = coords[1];
anchor.position.pressure = coords[2];
anchor.position.xtilt = coords[3];
anchor.position.ytilt = coords[4];
anchor.position.wheel = coords[5];
g_value_set_boxed (&value, &anchor);
g_value_array_append (control_points, &value);
#ifdef GIMP_XCF_PATH_DEBUG
g_printerr ("Anchor: %d, (%f, %f, %f, %f, %f, %f)\n", type,
coords[0], coords[1], coords[2], coords[3],
coords[4], coords[5]);
#endif
}
g_value_unset (&value);
stroke = g_object_new (stroke_type,
"closed", closed,
"control-points", control_points,
NULL);
gimp_vectors_stroke_add (vectors, stroke);
}
gimp_image_add_vectors (image, vectors,
gimp_container_num_children (image->vectors));
return TRUE;
}