Commit 28d6f0a2 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/core/gimpedit.[ch] app/core/gimpmodules.[ch] app/core/gimpunits.[ch]

2003-09-15  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpedit.[ch]
	* app/core/gimpmodules.[ch]
	* app/core/gimpunits.[ch]
	* app/text/gimpfonts.[ch]: removed...

	* app/core/gimp-edit.[ch]
	* app/core/gimp-modules.[ch]
	* app/core/gimp-units.[ch]
	* app/text/gimp-fonts.[ch]: ...and added with new names because
	these files operate on members of a Gimp instance and are
	therefore methods of the Gimp object.

	* app/core/Makefile.am
	* app/text/Makefile.am
	* app/display/gimpdisplayshell-dnd.c
	* app/gui/edit-commands.c
	* app/gui/module-browser.c
	* app/gui/preferences-dialog.c
	* app/widgets/gimpbufferview.c
	* app/widgets/gimpdocumentview.c
	* app/widgets/gimptoolbox-dnd.c
	* app/app_procs.c
	* tools/pdbgen/pdb/edit.pdb
	* tools/pdbgen/pdb/fonts.pdb: changed accordingly.

	* app/pdb/edit_cmds.c
	* app/pdb/fonts_cmds.c: regenerated.

	* app/core/gimp.c (gimp_init): don't create gimp->fonts.
	(gimp_initialize): call gimp_fonts_init().
	(gimp_restore): call gimp_fonts_load() instead of _init().

	* app/text/gimp-fonts.c (gimp_fonts_init): don't call
	gimp_fonts_load(), just create gimp->fonts and connect to
	"notify::font-path" of gimp->config.
parent fac3b964
2003-09-15 Michael Natterer <mitch@gimp.org>
* app/core/gimpedit.[ch]
* app/core/gimpmodules.[ch]
* app/core/gimpunits.[ch]
* app/text/gimpfonts.[ch]: removed...
* app/core/gimp-edit.[ch]
* app/core/gimp-modules.[ch]
* app/core/gimp-units.[ch]
* app/text/gimp-fonts.[ch]: ...and added with new names because
these files operate on members of a Gimp instance and are
therefore methods of the Gimp object.
* app/core/Makefile.am
* app/text/Makefile.am
* app/display/gimpdisplayshell-dnd.c
* app/gui/edit-commands.c
* app/gui/module-browser.c
* app/gui/preferences-dialog.c
* app/widgets/gimpbufferview.c
* app/widgets/gimpdocumentview.c
* app/widgets/gimptoolbox-dnd.c
* app/app_procs.c
* tools/pdbgen/pdb/edit.pdb
* tools/pdbgen/pdb/fonts.pdb: changed accordingly.
* app/pdb/edit_cmds.c
* app/pdb/fonts_cmds.c: regenerated.
* app/core/gimp.c (gimp_init): don't create gimp->fonts.
(gimp_initialize): call gimp_fonts_init().
(gimp_restore): call gimp_fonts_load() instead of _init().
* app/text/gimp-fonts.c (gimp_fonts_init): don't call
gimp_fonts_load(), just create gimp->fonts and connect to
"notify::font-path" of gimp->config.
2003-09-15 Sven Neumann <sven@gimp.org>
 
* app/config/gimpxmlparser.c: fixed inline documentation.
......@@ -27,12 +27,12 @@
#include "gui-types.h"
#include "core/gimp.h"
#include "core/gimp-edit.h"
#include "core/gimpbuffer.h"
#include "core/gimpcontainer.h"
#include "core/gimpcontext.h"
#include "core/gimpdrawable.h"
#include "core/gimpdrawable-bucket-fill.h"
#include "core/gimpedit.h"
#include "core/gimpimage.h"
#include "core/gimpimage-undo.h"
#include "core/gimptoolinfo.h"
......
......@@ -41,7 +41,7 @@
#include "config/gimprc.h"
#include "core/gimp.h"
#include "core/gimpunits.h"
#include "core/gimp-units.h"
#include "plug-in/plug-ins.h"
......
......@@ -24,12 +24,18 @@ libappcore_a_sources = \
gimp.h \
gimp-documents.c \
gimp-documents.h \
gimp-edit.c \
gimp-edit.h \
gimp-gradients.c \
gimp-gradients.h \
gimp-modules.c \
gimp-modules.h \
gimp-parasites.c \
gimp-parasites.h \
gimp-templates.c \
gimp-templates.h \
gimp-units.c \
gimp-units.h \
gimp-utils.c \
gimp-utils.h \
gimpbrush.c \
......@@ -81,8 +87,6 @@ libappcore_a_sources = \
gimpdrawable-transform.h \
gimpdrawable-transform-utils.c \
gimpdrawable-transform-utils.h \
gimpedit.c \
gimpedit.h \
gimpenvirontable.h \
gimpenvirontable.c \
gimpgradient.c \
......@@ -157,8 +161,6 @@ libappcore_a_sources = \
gimplayermask.h \
gimplist.c \
gimplist.h \
gimpmodules.c \
gimpmodules.h \
gimpobject.c \
gimpobject.h \
gimppaintinfo.c \
......@@ -186,8 +188,6 @@ libappcore_a_sources = \
gimptooloptions.h \
gimpunit.c \
gimpunit.h \
gimpunits.c \
gimpunits.h \
gimpundo.c \
gimpundo.h \
gimpundostack.c \
......
......@@ -31,10 +31,10 @@
#include "paint-funcs/paint-funcs.h"
#include "gimp.h"
#include "gimp-edit.h"
#include "gimpbuffer.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpedit.h"
#include "gimpimage.h"
#include "gimpimage-mask.h"
#include "gimpimage-undo.h"
......
......@@ -42,7 +42,7 @@
#include "config/gimpscanner.h"
#include "gimp.h"
#include "gimpmodules.h"
#include "gimp-modules.h"
#include "gimp-intl.h"
......
......@@ -28,8 +28,8 @@
#include "core-types.h"
#include "gimp.h"
#include "gimp-units.h"
#include "gimpunit.h"
#include "gimpunits.h"
#include "config/gimpconfigwriter.h"
#include "config/gimpscanner.h"
......@@ -37,7 +37,7 @@
#include "gimp-intl.h"
/*
/*
* All deserialize functions return G_TOKEN_LEFT_PAREN on success,
* or the GTokenType they would have expected but didn't get.
*/
......
......@@ -36,16 +36,17 @@
#include "paint/paint.h"
#include "text/gimpfontlist.h"
#include "text/gimpfonts.h"
#include "text/gimp-fonts.h"
#include "xcf/xcf.h"
#include "gimp.h"
#include "gimp-documents.h"
#include "gimp-gradients.h"
#include "gimp-modules.h"
#include "gimp-parasites.h"
#include "gimp-templates.h"
#include "gimp-units.h"
#include "gimpbrush.h"
#include "gimpbrushgenerated.h"
#include "gimpbrushpipe.h"
......@@ -59,13 +60,11 @@
#include "gimpimagefile.h"
#include "gimplist.h"
#include "gimpmarshal.h"
#include "gimpmodules.h"
#include "gimppalette.h"
#include "gimppattern.h"
#include "gimpparasitelist.h"
#include "gimptemplate.h"
#include "gimptoolinfo.h"
#include "gimpunits.h"
#include "gimp-intl.h"
......@@ -237,9 +236,7 @@ gimp_init (Gimp *gimp)
GIMP_CONTAINER_POLICY_STRONG);
gimp_object_set_name (GIMP_OBJECT (gimp->named_buffers), "named buffers");
gimp->fonts = gimp_font_list_new (72.0, 72.0);
gimp_object_set_name (GIMP_OBJECT (gimp->fonts), "fonts");
gimp->fonts = NULL;
gimp->brush_factory = NULL;
gimp->pattern_factory = NULL;
gimp->gradient_factory = NULL;
......@@ -696,6 +693,8 @@ gimp_initialize (Gimp *gimp,
g_return_if_fail (status_callback != NULL);
g_return_if_fail (GIMP_IS_CORE_CONFIG (gimp->config));
gimp_fonts_init (gimp);
gimp->brush_factory =
gimp_data_factory_new (gimp,
GIMP_TYPE_BRUSH,
......@@ -806,7 +805,7 @@ gimp_restore (Gimp *gimp,
/* initialize the list of gimp fonts */
(* status_callback) (NULL, _("Fonts"), 0.70);
gimp_fonts_init (gimp);
gimp_fonts_load (gimp);
/* initialize the document history */
(* status_callback) (NULL, _("Documents"), 0.80);
......
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <stdlib.h>
#include <glib-object.h>
#include "core-types.h"
#include "base/pixel-region.h"
#include "base/tile-manager.h"
#include "base/tile-manager-crop.h"
#include "paint-funcs/paint-funcs.h"
#include "gimp.h"
#include "gimpbuffer.h"
#include "gimpchannel.h"
#include "gimpcontext.h"
#include "gimpedit.h"
#include "gimpimage.h"
#include "gimpimage-mask.h"
#include "gimpimage-undo.h"
#include "gimplayer.h"
#include "gimplayer-floating-sel.h"
#include "gimplist.h"
#include "gimp-intl.h"
const GimpBuffer *
gimp_edit_cut (GimpImage *gimage,
GimpDrawable *drawable)
{
TileManager *tiles;
gboolean empty;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
/* Start a group undo */
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_CUT,
_("Cut"));
/* See if the gimage mask is empty */
empty = gimp_channel_is_empty (gimp_image_get_mask (gimage));
/* Next, cut the mask portion from the gimage */
tiles = gimp_image_mask_extract (gimage, drawable, TRUE, FALSE, TRUE);
if (tiles)
gimage->gimp->have_current_cut_buffer = TRUE;
/* Only crop if the gimage mask wasn't empty */
if (tiles && ! empty)
{
TileManager *crop;
crop = tile_manager_crop (tiles, 0);
if (crop != tiles)
{
tile_manager_unref (tiles);
tiles = crop;
}
}
/* end the group undo */
gimp_image_undo_group_end (gimage);
if (tiles)
{
/* Free the old global edit buffer */
if (gimage->gimp->global_buffer)
g_object_unref (gimage->gimp->global_buffer);
/* Set the global edit buffer */
gimage->gimp->global_buffer = gimp_buffer_new (tiles,
"Global Buffer",
FALSE);
return gimage->gimp->global_buffer;
}
return NULL;
}
const GimpBuffer *
gimp_edit_copy (GimpImage *gimage,
GimpDrawable *drawable)
{
TileManager *tiles;
gboolean empty;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL);
/* Start a group undo */
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_COPY,
_("Copy"));
/* See if the gimage mask is empty */
empty = gimp_channel_is_empty (gimp_image_get_mask (gimage));
/* First, copy the masked portion of the gimage */
tiles = gimp_image_mask_extract (gimage, drawable, FALSE, FALSE, TRUE);
if (tiles)
gimage->gimp->have_current_cut_buffer = TRUE;
/* Only crop if the gimage mask wasn't empty */
if (tiles && ! empty)
{
TileManager *crop;
crop = tile_manager_crop (tiles, 0);
if (crop != tiles)
{
tile_manager_unref (tiles);
tiles = crop;
}
}
/* end the group undo */
gimp_image_undo_group_end (gimage);
if (tiles)
{
/* Free the old global edit buffer */
if (gimage->gimp->global_buffer)
g_object_unref (gimage->gimp->global_buffer);
/* Set the global edit buffer */
gimage->gimp->global_buffer = gimp_buffer_new (tiles,
"Global Buffer",
FALSE);
return gimage->gimp->global_buffer;
}
return NULL;
}
GimpLayer *
gimp_edit_paste (GimpImage *gimage,
GimpDrawable *drawable,
GimpBuffer *paste,
gboolean paste_into)
{
GimpLayer *layer;
GimpImageType type;
gint x1, y1, x2, y2;
gint cx, cy;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
g_return_val_if_fail (! drawable || GIMP_IS_DRAWABLE (drawable), NULL);
/* Make a new layer: if drawable == NULL,
* user is pasting into an empty image.
*/
if (drawable)
type = gimp_drawable_type_with_alpha (drawable);
else
type = gimp_image_base_type_with_alpha (gimage);
layer = gimp_layer_new_from_tiles (paste->tiles,
gimage,
type,
_("Pasted Layer"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (! layer)
return NULL;
/* Start a group undo */
gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_EDIT_PASTE,
_("Paste"));
/* Set the offsets to the center of the image */
if (drawable)
{
gimp_item_offsets (GIMP_ITEM (drawable), &cx, &cy);
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
cx += (x1 + x2) >> 1;
cy += (y1 + y2) >> 1;
}
else
{
cx = gimage->width >> 1;
cy = gimage->height >> 1;
}
GIMP_ITEM (layer)->offset_x = cx - (GIMP_ITEM (layer)->width >> 1);
GIMP_ITEM (layer)->offset_y = cy - (GIMP_ITEM (layer)->height >> 1);
/* If there is a selection mask clear it--
* this might not always be desired, but in general,
* it seems like the correct behavior.
*/
if (! gimp_channel_is_empty (gimp_image_get_mask (gimage)) && ! paste_into)
gimp_channel_clear (gimp_image_get_mask (gimage), NULL, TRUE);
/* if there's a drawable, add a new floating selection */
if (drawable != NULL)
{
floating_sel_attach (layer, drawable);
}
else
{
gimp_item_set_image (GIMP_ITEM (layer), gimage);
gimp_image_add_layer (gimage, layer, 0);
}
/* end the group undo */
gimp_image_undo_group_end (gimage);
return layer;
}
GimpImage *
gimp_edit_paste_as_new (Gimp *gimp,
GimpImage *invoke,
GimpBuffer *paste)
{
GimpImage *gimage;
GimpLayer *layer;
/* create a new image (always of type GIMP_RGB) */
gimage = gimp_create_image (gimp,
gimp_buffer_get_width (paste),
gimp_buffer_get_height (paste),
GIMP_RGB,
TRUE);
gimp_image_undo_disable (gimage);
if (invoke)
{
gimp_image_set_resolution (gimage,
invoke->xresolution, invoke->yresolution);
gimp_image_set_unit (gimage, invoke->unit);
}
layer = gimp_layer_new_from_tiles (paste->tiles,
gimage,
gimp_image_base_type_with_alpha (gimage),
_("Pasted Layer"),
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
if (layer)
{
gimp_item_set_image (GIMP_ITEM (layer), gimage);
gimp_image_add_layer (gimage, layer, 0);
gimp_image_undo_enable (gimage);
gimp_create_display (gimp, gimage, 0x0101);
g_object_unref (gimage);
return gimage;
}
return NULL;
}
gboolean
gimp_edit_clear (GimpImage *gimage,
GimpDrawable *drawable)
{
TileManager *buf_tiles;
PixelRegion bufPR;
gint x1, y1, x2, y2;
guchar col[MAX_CHANNELS];
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
gimp_image_get_background (gimage, drawable, col);
if (gimp_drawable_has_alpha (drawable))
col [gimp_drawable_bytes (drawable) - 1] = OPAQUE_OPACITY;
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
if (!(x2 - x1) || !(y2 - y1))
return TRUE; /* nothing to do, but the clear succeded */
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1),
gimp_drawable_bytes (drawable));
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
color_region (&bufPR, col);
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
gimp_image_apply_image (gimage, drawable, &bufPR,
TRUE, _("Clear"),
GIMP_OPACITY_OPAQUE, GIMP_ERASE_MODE,
NULL, x1, y1);
/* update the image */
gimp_drawable_update (drawable,
x1, y1,
(x2 - x1), (y2 - y1));
/* free the temporary tiles */
tile_manager_unref (buf_tiles);
return TRUE;
}
gboolean
gimp_edit_fill (GimpImage *gimage,
GimpDrawable *drawable,
GimpFillType fill_type)
{
TileManager *buf_tiles;
PixelRegion bufPR;
gint x1, y1, x2, y2;
guchar col[MAX_CHANNELS];
const gchar *undo_desc;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE);
g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), FALSE);
if (gimp_drawable_has_alpha (drawable))
col [gimp_drawable_bytes (drawable) - 1] = OPAQUE_OPACITY;
g_print ("fill_type: %d\n", fill_type);
switch (fill_type)
{
case GIMP_FOREGROUND_FILL:
gimp_image_get_foreground (gimage, drawable, col);
undo_desc = _("Fill with FG Color");
break;
case GIMP_BACKGROUND_FILL:
gimp_image_get_background (gimage, drawable, col);
undo_desc = _("Fill with BG Color");
break;
case GIMP_WHITE_FILL:
col[RED_PIX] = 255;
col[GREEN_PIX] = 255;
col[BLUE_PIX] = 255;
undo_desc = _("Fill with White");
break;
case GIMP_TRANSPARENT_FILL:
col[RED_PIX] = 0;
col[GREEN_PIX] = 0;
col[BLUE_PIX] = 0;
if (gimp_drawable_has_alpha (drawable))
col [gimp_drawable_bytes (drawable) - 1] = TRANSPARENT_OPACITY;
undo_desc = _("Fill with Transparency");
break;
case GIMP_NO_FILL:
return TRUE; /* nothing to do, but the fill succeded */
default:
g_warning ("%s: unknown fill type", G_GNUC_PRETTY_FUNCTION);
gimp_image_get_background (gimage, drawable, col);
undo_desc = _("Fill with BG Color");
break;
}
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
if (!(x2 - x1) || !(y2 - y1))
return TRUE; /* nothing to do, but the fill succeded */
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1),
gimp_drawable_bytes (drawable));
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), TRUE);
color_region (&bufPR, col);
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
gimp_image_apply_image (gimage, drawable, &bufPR,
TRUE, undo_desc,
GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE,
NULL, x1, y1);
/* update the image */
gimp_drawable_update (drawable,
x1, y1,
(x2 - x1), (y2 - y1));
/* free the temporary tiles */
tile_manager_unref (buf_tiles);
return TRUE;
}
/* The GIMP -- an image manipulation program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the