1997-11-25 06:05:25 +08:00
|
|
|
/* 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
|
1998-04-13 13:44:11 +08:00
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "appenv.h"
|
|
|
|
#include "drawable.h"
|
1999-08-26 12:39:21 +08:00
|
|
|
#include "image_new.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "floating_sel.h"
|
|
|
|
#include "gdisplay.h"
|
|
|
|
#include "gimage.h"
|
|
|
|
#include "gimage_mask.h"
|
1999-09-28 01:58:10 +08:00
|
|
|
#include "gimpui.h"
|
1997-11-25 06:05:25 +08:00
|
|
|
#include "global_edit.h"
|
|
|
|
#include "layer.h"
|
|
|
|
#include "paint_funcs.h"
|
|
|
|
#include "tools.h"
|
|
|
|
#include "undo.h"
|
|
|
|
|
1998-11-23 22:47:09 +08:00
|
|
|
#include "libgimp/gimpintl.h"
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
#include "tile_manager_pvt.h"
|
|
|
|
#include "drawable_pvt.h"
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
typedef enum
|
|
|
|
{
|
1999-07-07 18:55:48 +08:00
|
|
|
PASTE,
|
|
|
|
PASTE_INTO,
|
|
|
|
PASTE_AS_NEW
|
|
|
|
} PasteAction;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The named paste dialog */
|
|
|
|
typedef struct _PasteNamedDlg PasteNamedDlg;
|
1999-10-27 02:27:27 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
struct _PasteNamedDlg
|
|
|
|
{
|
|
|
|
GtkWidget *shell;
|
|
|
|
GtkWidget *list;
|
|
|
|
GDisplay *gdisp;
|
1999-07-07 18:55:48 +08:00
|
|
|
PasteAction action;
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/* The named buffer structure... */
|
|
|
|
typedef struct _named_buffer NamedBuffer;
|
|
|
|
|
|
|
|
struct _named_buffer
|
|
|
|
{
|
|
|
|
TileManager * buf;
|
|
|
|
char * name;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* The named buffer list */
|
1998-01-29 16:03:27 +08:00
|
|
|
GSList * named_buffers = NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* The global edit buffer */
|
|
|
|
TileManager * global_buf = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* Crop the buffer to the size of pixels with non-zero transparency */
|
|
|
|
|
|
|
|
TileManager *
|
|
|
|
crop_buffer (TileManager *tiles,
|
|
|
|
int border)
|
|
|
|
{
|
|
|
|
PixelRegion PR;
|
|
|
|
TileManager *new_tiles;
|
|
|
|
int bytes, alpha;
|
|
|
|
unsigned char * data;
|
|
|
|
int empty;
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
int x, y;
|
|
|
|
int ex, ey;
|
|
|
|
int found;
|
|
|
|
void * pr;
|
|
|
|
unsigned char black[MAX_CHANNELS] = { 0, 0, 0, 0 };
|
|
|
|
|
1998-08-16 03:17:36 +08:00
|
|
|
bytes = tiles->bpp;
|
1997-11-25 06:05:25 +08:00
|
|
|
alpha = bytes - 1;
|
|
|
|
|
|
|
|
/* go through and calculate the bounds */
|
1998-08-16 03:17:36 +08:00
|
|
|
x1 = tiles->width;
|
|
|
|
y1 = tiles->height;
|
1997-11-25 06:05:25 +08:00
|
|
|
x2 = 0;
|
|
|
|
y2 = 0;
|
|
|
|
|
|
|
|
pixel_region_init (&PR, tiles, 0, 0, x1, y1, FALSE);
|
|
|
|
for (pr = pixel_regions_register (1, &PR); pr != NULL; pr = pixel_regions_process (pr))
|
|
|
|
{
|
|
|
|
data = PR.data + alpha;
|
|
|
|
ex = PR.x + PR.w;
|
|
|
|
ey = PR.y + PR.h;
|
|
|
|
|
|
|
|
for (y = PR.y; y < ey; y++)
|
|
|
|
{
|
|
|
|
found = FALSE;
|
|
|
|
for (x = PR.x; x < ex; x++, data+=bytes)
|
|
|
|
if (*data)
|
|
|
|
{
|
|
|
|
if (x < x1)
|
|
|
|
x1 = x;
|
|
|
|
if (x > x2)
|
|
|
|
x2 = x;
|
|
|
|
found = TRUE;
|
|
|
|
}
|
|
|
|
if (found)
|
|
|
|
{
|
|
|
|
if (y < y1)
|
|
|
|
y1 = y;
|
|
|
|
if (y > y2)
|
|
|
|
y2 = y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-08-16 03:17:36 +08:00
|
|
|
x2 = BOUNDS (x2 + 1, 0, tiles->width);
|
|
|
|
y2 = BOUNDS (y2 + 1, 0, tiles->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-08-16 03:17:36 +08:00
|
|
|
empty = (x1 == tiles->width && y1 == tiles->height);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* If there are no visible pixels, return NULL */
|
|
|
|
if (empty)
|
|
|
|
new_tiles = NULL;
|
|
|
|
/* If no cropping, return original buffer */
|
1998-08-16 03:17:36 +08:00
|
|
|
else if (x1 == 0 && y1 == 0 && x2 == tiles->width &&
|
|
|
|
y2 == tiles->height && border == 0)
|
1997-11-25 06:05:25 +08:00
|
|
|
new_tiles = tiles;
|
|
|
|
/* Otherwise, crop the original area */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PixelRegion srcPR, destPR;
|
|
|
|
int new_width, new_height;
|
|
|
|
|
|
|
|
new_width = (x2 - x1) + border * 2;
|
|
|
|
new_height = (y2 - y1) + border * 2;
|
|
|
|
new_tiles = tile_manager_new (new_width, new_height, bytes);
|
|
|
|
|
|
|
|
/* If there is a border, make sure to clear the new tiles first */
|
|
|
|
if (border)
|
|
|
|
{
|
|
|
|
pixel_region_init (&destPR, new_tiles, 0, 0, new_width, border, TRUE);
|
|
|
|
color_region (&destPR, black);
|
|
|
|
pixel_region_init (&destPR, new_tiles, 0, border, border, (y2 - y1), TRUE);
|
|
|
|
color_region (&destPR, black);
|
|
|
|
pixel_region_init (&destPR, new_tiles, new_width - border, border, border, (y2 - y1), TRUE);
|
|
|
|
color_region (&destPR, black);
|
|
|
|
pixel_region_init (&destPR, new_tiles, 0, new_height - border, new_width, border, TRUE);
|
|
|
|
color_region (&destPR, black);
|
|
|
|
}
|
|
|
|
|
|
|
|
pixel_region_init (&srcPR, tiles, x1, y1, (x2 - x1), (y2 - y1), FALSE);
|
|
|
|
pixel_region_init (&destPR, new_tiles, border, border, (x2 - x1), (y2 - y1), TRUE);
|
|
|
|
|
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
|
|
|
|
new_tiles->x = x1;
|
|
|
|
new_tiles->y = y1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return new_tiles;
|
|
|
|
}
|
|
|
|
|
|
|
|
TileManager *
|
|
|
|
edit_cut (GImage *gimage,
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
TileManager *cut;
|
|
|
|
TileManager *cropped_cut;
|
|
|
|
int empty;
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
if (!gimage || drawable == NULL)
|
1997-11-25 06:05:25 +08:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* Start a group undo */
|
|
|
|
undo_push_group_start (gimage, EDIT_CUT_UNDO);
|
|
|
|
|
|
|
|
/* See if the gimage mask is empty */
|
|
|
|
empty = gimage_mask_is_empty (gimage);
|
|
|
|
|
|
|
|
/* Next, cut the mask portion from the gimage */
|
1998-01-22 15:02:57 +08:00
|
|
|
cut = gimage_mask_extract (gimage, drawable, TRUE, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Only crop if the gimage mask wasn't empty */
|
|
|
|
if (cut && empty == FALSE)
|
|
|
|
{
|
|
|
|
cropped_cut = crop_buffer (cut, 0);
|
|
|
|
|
|
|
|
if (cropped_cut != cut)
|
|
|
|
tile_manager_destroy (cut);
|
|
|
|
}
|
|
|
|
else if (cut)
|
|
|
|
cropped_cut = cut;
|
|
|
|
else
|
|
|
|
cropped_cut = NULL;
|
|
|
|
|
1999-08-26 12:39:21 +08:00
|
|
|
if (cut)
|
|
|
|
image_new_reset_current_cut_buffer ();
|
1998-06-13 03:43:55 +08:00
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* end the group undo */
|
|
|
|
undo_push_group_end (gimage);
|
|
|
|
|
|
|
|
if (cropped_cut)
|
|
|
|
{
|
|
|
|
/* Free the old global edit buffer */
|
|
|
|
if (global_buf)
|
|
|
|
tile_manager_destroy (global_buf);
|
|
|
|
/* Set the global edit buffer */
|
|
|
|
global_buf = cropped_cut;
|
|
|
|
|
|
|
|
return cropped_cut;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
TileManager *
|
|
|
|
edit_copy (GImage *gimage,
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
TileManager * copy;
|
|
|
|
TileManager * cropped_copy;
|
|
|
|
int empty;
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
if (!gimage || drawable == NULL)
|
1997-11-25 06:05:25 +08:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
/* See if the gimage mask is empty */
|
|
|
|
empty = gimage_mask_is_empty (gimage);
|
|
|
|
|
|
|
|
/* First, copy the masked portion of the gimage */
|
1998-01-22 15:02:57 +08:00
|
|
|
copy = gimage_mask_extract (gimage, drawable, FALSE, FALSE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Only crop if the gimage mask wasn't empty */
|
|
|
|
if (copy && empty == FALSE)
|
|
|
|
{
|
|
|
|
cropped_copy = crop_buffer (copy, 0);
|
|
|
|
|
|
|
|
if (cropped_copy != copy)
|
|
|
|
tile_manager_destroy (copy);
|
|
|
|
}
|
|
|
|
else if (copy)
|
|
|
|
cropped_copy = copy;
|
|
|
|
else
|
|
|
|
cropped_copy = NULL;
|
|
|
|
|
1998-06-13 03:43:55 +08:00
|
|
|
if(copy)
|
1999-08-26 12:39:21 +08:00
|
|
|
image_new_reset_current_cut_buffer();
|
1998-06-13 03:43:55 +08:00
|
|
|
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (cropped_copy)
|
|
|
|
{
|
|
|
|
/* Free the old global edit buffer */
|
|
|
|
if (global_buf)
|
|
|
|
tile_manager_destroy (global_buf);
|
|
|
|
/* Set the global edit buffer */
|
|
|
|
global_buf = cropped_copy;
|
|
|
|
|
|
|
|
return cropped_copy;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
1998-06-30 09:14:36 +08:00
|
|
|
GimpLayer*
|
1999-07-07 04:43:52 +08:00
|
|
|
edit_paste (GImage *gimage,
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable,
|
1999-07-07 04:43:52 +08:00
|
|
|
TileManager *paste,
|
|
|
|
int paste_into)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
Layer * float_layer;
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
int cx, cy;
|
|
|
|
|
|
|
|
/* Make a new floating layer */
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-19 07:41:39 +08:00
|
|
|
float_layer = layer_from_tiles (gimage, drawable, paste, _("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (float_layer)
|
|
|
|
{
|
|
|
|
/* Start a group undo */
|
|
|
|
undo_push_group_start (gimage, EDIT_PASTE_UNDO);
|
|
|
|
|
|
|
|
/* Set the offsets to the center of the image */
|
1998-01-22 15:02:57 +08:00
|
|
|
drawable_offsets ( (drawable), &cx, &cy);
|
|
|
|
drawable_mask_bounds ( (drawable), &x1, &y1, &x2, &y2);
|
1997-11-25 06:05:25 +08:00
|
|
|
cx += (x1 + x2) >> 1;
|
|
|
|
cy += (y1 + y2) >> 1;
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
GIMP_DRAWABLE(float_layer)->offset_x = cx - (GIMP_DRAWABLE(float_layer)->width >> 1);
|
|
|
|
GIMP_DRAWABLE(float_layer)->offset_y = cy - (GIMP_DRAWABLE(float_layer)->height >> 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* If there is a selection mask clear it--
|
|
|
|
* this might not always be desired, but in general,
|
|
|
|
* it seems like the correct behavior.
|
|
|
|
*/
|
|
|
|
if (! gimage_mask_is_empty (gimage) && !paste_into)
|
|
|
|
channel_clear (gimage_get_mask (gimage));
|
|
|
|
|
|
|
|
/* add a new floating selection */
|
1998-01-22 15:02:57 +08:00
|
|
|
floating_sel_attach (float_layer, drawable);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* end the group undo */
|
|
|
|
undo_push_group_end (gimage);
|
|
|
|
|
1998-06-30 09:14:36 +08:00
|
|
|
return float_layer;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
else
|
1998-06-30 09:14:36 +08:00
|
|
|
return NULL;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
1999-07-07 04:43:52 +08:00
|
|
|
|
|
|
|
int
|
|
|
|
edit_paste_as_new (GImage *invoke,
|
|
|
|
TileManager *paste)
|
|
|
|
{
|
|
|
|
GImage *gimage;
|
|
|
|
GimpDrawable *drawable;
|
|
|
|
Layer *layer;
|
|
|
|
Layer *float_layer;
|
|
|
|
GDisplay *gdisp;
|
|
|
|
|
|
|
|
if (!global_buf)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* create a new image */
|
|
|
|
gimage = gimage_new (paste->width, paste->height, invoke->base_type);
|
|
|
|
gimp_image_set_resolution (gimage, invoke->xresolution, invoke->yresolution);
|
|
|
|
gimp_image_set_unit (gimage, invoke->unit);
|
|
|
|
|
|
|
|
layer = layer_new (gimage, gimage->width, gimage->height,
|
|
|
|
(invoke->base_type == RGB) ? RGBA_GIMAGE : GRAYA_GIMAGE,
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-19 07:41:39 +08:00
|
|
|
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
|
1999-07-07 04:43:52 +08:00
|
|
|
|
|
|
|
/* add the new layer to the image */
|
|
|
|
gimage_disable_undo (gimage);
|
|
|
|
gimage_add_layer (gimage, layer, 0);
|
|
|
|
drawable = gimage_active_drawable (gimage);
|
|
|
|
drawable_fill (GIMP_DRAWABLE (drawable), TRANSPARENT_FILL);
|
|
|
|
|
|
|
|
/* make a new floating layer */
|
|
|
|
float_layer = layer_from_tiles (gimage, drawable, paste,
|
Actually use the enum types GimpImageType, GimpImageBaseType,
* app/*.[ch]: Actually use the enum types GimpImageType,
GimpImageBaseType, LayerModeEffects, PaintApplicationMode,
BrushApplicationMode, GimpFillType and ConvertPaletteType, instead
of just int or gint. Hopefully I catched most of the places
where these should be used.
Add an enum ConvolutionType, suffix the too general constants
NORMAL, ABSOLUTE and NEGATIVE with _CONVOL. Use NORMAL_MODE
instead of NORMAL in some places (this was what was intended). Fix
some minor gccisms.
* app/apptypes.h: New file. This file contains the above
enumeration types, and some opaque struct typedefs. It was
necessary to collect these in one header that doesn't include
other headers, because when we started using the above mentioned
types in the headers, all hell broke loose because of the
spaghetti-like cross-inclusion mess between headers.
(An example: Header A includes header B, which includes header C
which includes A. B uses a type defined in A. This is not defined,
because A hasn't defined it yet at the point where it includes B,
and A included from B of course is skipped as we already are
reading A.)
1999-08-19 07:41:39 +08:00
|
|
|
_("Pasted Layer"), OPAQUE_OPACITY, NORMAL_MODE);
|
1999-07-07 04:43:52 +08:00
|
|
|
|
|
|
|
/* add the new floating selection */
|
|
|
|
floating_sel_attach (float_layer, drawable);
|
|
|
|
floating_sel_anchor (float_layer);
|
|
|
|
gimage_enable_undo (gimage);
|
|
|
|
gdisp = gdisplay_new (gimage, 0x0101);
|
|
|
|
gimp_context_set_display (gimp_context_get_user (), gdisp);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-06-30 09:14:36 +08:00
|
|
|
gboolean
|
1997-11-25 06:05:25 +08:00
|
|
|
edit_clear (GImage *gimage,
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
TileManager *buf_tiles;
|
|
|
|
PixelRegion bufPR;
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
unsigned char col[MAX_CHANNELS];
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
if (!gimage || drawable == NULL)
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
gimage_get_background (gimage, drawable, col);
|
|
|
|
if (drawable_has_alpha (drawable))
|
1998-01-25 09:24:46 +08:00
|
|
|
col [drawable_bytes (drawable) - 1] = OPAQUE_OPACITY;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (!(x2 - x1) || !(y2 - y1))
|
|
|
|
return FALSE;
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), drawable_bytes (drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
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);
|
1998-01-25 09:24:46 +08:00
|
|
|
gimage_apply_image (gimage, drawable, &bufPR, 1, OPAQUE_OPACITY,
|
1997-11-25 06:05:25 +08:00
|
|
|
ERASE_MODE, NULL, x1, y1);
|
|
|
|
|
|
|
|
/* update the image */
|
1998-01-22 15:02:57 +08:00
|
|
|
drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* free the temporary tiles */
|
|
|
|
tile_manager_destroy (buf_tiles);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-06-30 09:14:36 +08:00
|
|
|
gboolean
|
1997-11-25 06:05:25 +08:00
|
|
|
edit_fill (GImage *gimage,
|
1998-01-22 15:02:57 +08:00
|
|
|
GimpDrawable *drawable)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
TileManager *buf_tiles;
|
|
|
|
PixelRegion bufPR;
|
|
|
|
int x1, y1, x2, y2;
|
|
|
|
unsigned char col[MAX_CHANNELS];
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
if (!gimage || drawable == NULL)
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
gimage_get_background (gimage, drawable, col);
|
|
|
|
if (drawable_has_alpha (drawable))
|
1998-01-25 09:24:46 +08:00
|
|
|
col [drawable_bytes (drawable) - 1] = OPAQUE_OPACITY;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (!(x2 - x1) || !(y2 - y1))
|
|
|
|
return FALSE;
|
|
|
|
|
1998-01-22 15:02:57 +08:00
|
|
|
buf_tiles = tile_manager_new ((x2 - x1), (y2 - y1), drawable_bytes (drawable));
|
1997-11-25 06:05:25 +08:00
|
|
|
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);
|
1998-01-25 09:24:46 +08:00
|
|
|
gimage_apply_image (gimage, drawable, &bufPR, 1, OPAQUE_OPACITY,
|
1997-11-25 06:05:25 +08:00
|
|
|
NORMAL_MODE, NULL, x1, y1);
|
|
|
|
|
|
|
|
/* update the image */
|
1998-01-22 15:02:57 +08:00
|
|
|
drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* free the temporary tiles */
|
|
|
|
tile_manager_destroy (buf_tiles);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
global_edit_cut (void *gdisp_ptr)
|
|
|
|
{
|
|
|
|
GDisplay *gdisp;
|
|
|
|
|
|
|
|
/* stop any active tool */
|
|
|
|
gdisp = (GDisplay *) gdisp_ptr;
|
|
|
|
active_tool_control (HALT, gdisp_ptr);
|
|
|
|
|
|
|
|
if (!edit_cut (gdisp->gimage, gimage_active_drawable (gdisp->gimage)))
|
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* flush the display */
|
|
|
|
gdisplays_flush ();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
global_edit_copy (void *gdisp_ptr)
|
|
|
|
{
|
|
|
|
GDisplay *gdisp;
|
|
|
|
|
|
|
|
gdisp = (GDisplay *) gdisp_ptr;
|
|
|
|
|
|
|
|
if (!edit_copy (gdisp->gimage, gimage_active_drawable (gdisp->gimage)))
|
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
global_edit_paste (void *gdisp_ptr,
|
|
|
|
int paste_into)
|
|
|
|
{
|
|
|
|
GDisplay *gdisp;
|
|
|
|
|
|
|
|
/* stop any active tool */
|
|
|
|
gdisp = (GDisplay *) gdisp_ptr;
|
|
|
|
active_tool_control (HALT, gdisp_ptr);
|
|
|
|
|
1999-07-07 04:43:52 +08:00
|
|
|
if (!edit_paste (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
|
|
|
global_buf, paste_into))
|
1997-11-25 06:05:25 +08:00
|
|
|
return FALSE;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* flush the display */
|
|
|
|
gdisplays_flush ();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-07-07 04:43:52 +08:00
|
|
|
int
|
|
|
|
global_edit_paste_as_new (void *gdisp_ptr)
|
|
|
|
{
|
|
|
|
GDisplay *gdisp;
|
|
|
|
|
|
|
|
if (!global_buf)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* stop any active tool */
|
|
|
|
gdisp = (GDisplay *) gdisp_ptr;
|
|
|
|
active_tool_control (HALT, gdisp_ptr);
|
|
|
|
|
|
|
|
return (edit_paste_as_new (gdisp->gimage, global_buf));
|
|
|
|
}
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
void
|
|
|
|
global_edit_free ()
|
|
|
|
{
|
|
|
|
if (global_buf)
|
|
|
|
tile_manager_destroy (global_buf);
|
|
|
|
|
|
|
|
global_buf = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*********************************************/
|
|
|
|
/* Named buffer operations */
|
|
|
|
|
|
|
|
static void
|
|
|
|
set_list_of_named_buffers (GtkWidget *list_widget)
|
|
|
|
{
|
1998-01-29 16:03:27 +08:00
|
|
|
GSList *list;
|
1997-11-25 06:05:25 +08:00
|
|
|
NamedBuffer *nb;
|
|
|
|
GtkWidget *list_item;
|
|
|
|
|
|
|
|
gtk_list_clear_items (GTK_LIST (list_widget), 0, -1);
|
|
|
|
list = named_buffers;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
nb = (NamedBuffer *) list->data;
|
1998-01-29 16:03:27 +08:00
|
|
|
list = g_slist_next (list);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
list_item = gtk_list_item_new_with_label (nb->name);
|
|
|
|
gtk_container_add (GTK_CONTAINER (list_widget), list_item);
|
|
|
|
gtk_widget_show (list_item);
|
|
|
|
gtk_object_set_user_data (GTK_OBJECT (list_item), (gpointer) nb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-07-07 18:55:48 +08:00
|
|
|
named_buffer_paste_foreach (GtkWidget *w,
|
|
|
|
gpointer client_data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PasteNamedDlg *pn_dlg;
|
|
|
|
NamedBuffer *nb;
|
|
|
|
|
|
|
|
if (w->state == GTK_STATE_SELECTED)
|
|
|
|
{
|
|
|
|
pn_dlg = (PasteNamedDlg *) client_data;
|
|
|
|
nb = (NamedBuffer *) gtk_object_get_user_data (GTK_OBJECT (w));
|
1999-07-07 18:55:48 +08:00
|
|
|
switch (pn_dlg->action)
|
|
|
|
{
|
|
|
|
case PASTE:
|
|
|
|
edit_paste (pn_dlg->gdisp->gimage,
|
|
|
|
gimage_active_drawable (pn_dlg->gdisp->gimage),
|
|
|
|
nb->buf, FALSE);
|
|
|
|
break;
|
|
|
|
case PASTE_INTO:
|
|
|
|
edit_paste (pn_dlg->gdisp->gimage,
|
1999-07-07 04:43:52 +08:00
|
|
|
gimage_active_drawable (pn_dlg->gdisp->gimage),
|
1999-07-07 18:55:48 +08:00
|
|
|
nb->buf, TRUE);
|
|
|
|
break;
|
|
|
|
case PASTE_AS_NEW:
|
|
|
|
edit_paste_as_new (pn_dlg->gdisp->gimage, nb->buf);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
named_buffer_paste_callback (GtkWidget *w,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
PasteNamedDlg *pn_dlg;
|
|
|
|
|
|
|
|
pn_dlg = (PasteNamedDlg *) client_data;
|
|
|
|
|
1999-07-07 18:55:48 +08:00
|
|
|
pn_dlg->action = PASTE_INTO;
|
|
|
|
gtk_container_foreach ((GtkContainer*) pn_dlg->list,
|
|
|
|
named_buffer_paste_foreach, client_data);
|
|
|
|
|
|
|
|
/* Destroy the box */
|
|
|
|
gtk_widget_destroy (pn_dlg->shell);
|
|
|
|
|
|
|
|
g_free (pn_dlg);
|
|
|
|
|
|
|
|
/* flush the display */
|
|
|
|
gdisplays_flush ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
named_buffer_paste_into_callback (GtkWidget *w,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
PasteNamedDlg *pn_dlg;
|
|
|
|
|
|
|
|
pn_dlg = (PasteNamedDlg *) client_data;
|
|
|
|
|
|
|
|
pn_dlg->action = PASTE_INTO;
|
|
|
|
gtk_container_foreach ((GtkContainer*) pn_dlg->list,
|
|
|
|
named_buffer_paste_foreach, client_data);
|
|
|
|
|
|
|
|
/* Destroy the box */
|
|
|
|
gtk_widget_destroy (pn_dlg->shell);
|
|
|
|
|
|
|
|
g_free (pn_dlg);
|
|
|
|
|
|
|
|
/* flush the display */
|
|
|
|
gdisplays_flush ();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
named_buffer_paste_as_new_callback (GtkWidget *w,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
PasteNamedDlg *pn_dlg;
|
|
|
|
|
|
|
|
pn_dlg = (PasteNamedDlg *) client_data;
|
|
|
|
|
|
|
|
pn_dlg->action = PASTE_AS_NEW;
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_container_foreach ((GtkContainer*) pn_dlg->list,
|
|
|
|
named_buffer_paste_foreach, client_data);
|
|
|
|
|
|
|
|
/* Destroy the box */
|
|
|
|
gtk_widget_destroy (pn_dlg->shell);
|
|
|
|
|
|
|
|
g_free (pn_dlg);
|
1998-04-13 21:46:58 +08:00
|
|
|
|
|
|
|
/* flush the display */
|
|
|
|
gdisplays_flush ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
named_buffer_delete_foreach (GtkWidget *w,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
PasteNamedDlg *pn_dlg;
|
|
|
|
NamedBuffer * nb;
|
|
|
|
|
|
|
|
if (w->state == GTK_STATE_SELECTED)
|
|
|
|
{
|
|
|
|
pn_dlg = (PasteNamedDlg *) client_data;
|
|
|
|
nb = (NamedBuffer *) gtk_object_get_user_data (GTK_OBJECT (w));
|
1998-01-29 16:03:27 +08:00
|
|
|
named_buffers = g_slist_remove (named_buffers, (void *) nb);
|
1997-11-25 06:05:25 +08:00
|
|
|
g_free (nb->name);
|
|
|
|
tile_manager_destroy (nb->buf);
|
|
|
|
g_free (nb);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
named_buffer_delete_callback (GtkWidget *w,
|
|
|
|
gpointer client_data)
|
|
|
|
{
|
|
|
|
PasteNamedDlg *pn_dlg;
|
|
|
|
|
|
|
|
pn_dlg = (PasteNamedDlg *) client_data;
|
|
|
|
gtk_container_foreach ((GtkContainer*) pn_dlg->list,
|
|
|
|
named_buffer_delete_foreach, client_data);
|
|
|
|
set_list_of_named_buffers (pn_dlg->list);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-09-28 01:58:10 +08:00
|
|
|
named_buffer_cancel_callback (GtkWidget *widget,
|
|
|
|
gpointer data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PasteNamedDlg *pn_dlg;
|
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
pn_dlg = (PasteNamedDlg *) data;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* Destroy the box */
|
|
|
|
gtk_widget_destroy (pn_dlg->shell);
|
|
|
|
|
|
|
|
g_free (pn_dlg);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
paste_named_buffer (GDisplay *gdisp)
|
|
|
|
{
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
PasteNamedDlg *pn_dlg;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *listbox;
|
|
|
|
GtkWidget *bbox;
|
|
|
|
GtkWidget *button;
|
|
|
|
gint i;
|
|
|
|
|
1999-10-27 02:27:27 +08:00
|
|
|
static gchar *paste_action_labels[] =
|
|
|
|
{
|
|
|
|
N_("Paste"),
|
|
|
|
N_("Paste Into"),
|
|
|
|
N_("Paste As New"),
|
|
|
|
};
|
|
|
|
|
|
|
|
static GtkSignalFunc paste_action_functions[] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
named_buffer_paste_callback,
|
|
|
|
named_buffer_paste_into_callback,
|
|
|
|
named_buffer_paste_as_new_callback,
|
1999-07-07 18:55:48 +08:00
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
pn_dlg = g_new (PasteNamedDlg, 1);
|
1997-11-25 06:05:25 +08:00
|
|
|
pn_dlg->gdisp = gdisp;
|
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
pn_dlg->shell =
|
|
|
|
gimp_dialog_new (_("Paste Named Buffer"), "paste_named_buffer",
|
|
|
|
gimp_standard_help_func,
|
1999-10-03 21:50:19 +08:00
|
|
|
"dialogs/paste_named.html",
|
1999-09-28 01:58:10 +08:00
|
|
|
GTK_WIN_POS_MOUSE,
|
|
|
|
FALSE, TRUE, FALSE,
|
|
|
|
|
|
|
|
_("Delete"), named_buffer_delete_callback,
|
|
|
|
pn_dlg, NULL, FALSE, FALSE,
|
|
|
|
_("Cancel"), named_buffer_cancel_callback,
|
|
|
|
pn_dlg, NULL, TRUE, TRUE,
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
NULL);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
vbox = gtk_vbox_new (FALSE, 1);
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (vbox), 1);
|
1999-09-28 01:58:10 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (GTK_DIALOG (pn_dlg->shell)->vbox), vbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (vbox);
|
|
|
|
|
1998-11-23 22:47:09 +08:00
|
|
|
label = gtk_label_new (_("Select a buffer to paste:"));
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), label, TRUE, FALSE, 0);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
|
|
|
listbox = gtk_scrolled_window_new (NULL, NULL);
|
|
|
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (listbox),
|
|
|
|
GTK_POLICY_AUTOMATIC,
|
|
|
|
GTK_POLICY_AUTOMATIC);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), listbox, TRUE, TRUE, 0);
|
|
|
|
gtk_widget_set_usize (listbox, 125, 150);
|
|
|
|
gtk_widget_show (listbox);
|
|
|
|
|
|
|
|
pn_dlg->list = gtk_list_new ();
|
|
|
|
gtk_list_set_selection_mode (GTK_LIST (pn_dlg->list), GTK_SELECTION_BROWSE);
|
1998-11-23 17:25:10 +08:00
|
|
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (listbox),
|
|
|
|
pn_dlg->list);
|
1997-11-25 06:05:25 +08:00
|
|
|
set_list_of_named_buffers (pn_dlg->list);
|
|
|
|
gtk_widget_show (pn_dlg->list);
|
|
|
|
|
1999-07-07 18:55:48 +08:00
|
|
|
bbox = gtk_hbutton_box_new ();
|
new ui for the "Layer Offset" dialog.
1999-07-22 Michael Natterer <mitschel@cs.tu-berlin.de>
* app/channel_ops.[ch]: new ui for the "Layer Offset" dialog.
* app/channels_dialog.c
* app/layers_dialog.c: major code cleanup: Folded some callbacks
into common ones, "widget" instead of "w", indentation, ...
* app/commands.c
* app/interface.[ch]
* app/global_edit.c: the query boxes must be shown by the caller
now. There's no need to split up the string for the message box
manually as the Gtk 1.2 label widget handles newlines corectly.
Added the "edge_lock" toggle to the "Shrink Selection" dialog.
Nicer spacings for the query and message boxes.
* app/ink.c: tried to grab the pointer in the blob preview but
failed. Left the code there as a reminder (commented out).
* app/menus.c: reordered <Image>/Select.
I was bored and grep-ed the sources for ancient or deprecated stuff:
* app/about_dialog.[ch]
* app/actionarea.[ch]
* app/app_procs.c
* app/brush_edit.c
* app/brush_select.c
* app/color_select.c
* app/convert.c
* app/devices.c
* app/gdisplay.c
* app/gdisplay_ops.c
* app/histogram_tool.[ch]
* app/info_window.c
* app/install.c
* app/ops_buttons.c
* app/palette.c
* app/palette_select.c
* app/paths_dialog.c
* app/pattern_select.c
* app/resize.c
* app/scale_toolc.c
* app/text_tool.c:
s/container_border_width/container_set_border_width/g,
s/sprintf/g_snprintf/g, replaced some constant string lengths with
strlen(x).
* app/bezier_select.c
* app/blend.c
* app/boundary.c
* app/errors.[ch]
* app/free_select.c
* app/gimpbrushlist.c
* app/gimprc.c
* app/iscissors.c
* app/main.c
* app/patterns.[ch]
* app/text_tool.c: namespace fanaticism: prefixed all gimp error
functions with "gimp_" and formated the messages more uniformly.
* app/gradient.c
* app/gradient_select.c: same stuff as above for the ui
code. There are still some sub-dialogs which need cleanup.
Did some cleanup in most of these files: prototypes, removed tons
of #include's, i18n fixes, s/w/widget/ as above, indentation, ...
1999-07-23 00:21:10 +08:00
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (bbox), 6);
|
1999-07-07 18:55:48 +08:00
|
|
|
gtk_button_box_set_spacing (GTK_BUTTON_BOX (bbox), 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), bbox, FALSE, FALSE, 0);
|
1999-10-27 02:27:27 +08:00
|
|
|
for (i = 0; i < 3; i++)
|
1999-07-07 18:55:48 +08:00
|
|
|
{
|
1999-10-27 02:27:27 +08:00
|
|
|
button = gtk_button_new_with_label (gettext (paste_action_labels[i]));
|
1999-07-07 18:55:48 +08:00
|
|
|
gtk_container_add (GTK_CONTAINER (bbox), button);
|
|
|
|
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
1999-10-27 02:27:27 +08:00
|
|
|
(GtkSignalFunc) paste_action_functions[i],
|
1999-07-07 18:55:48 +08:00
|
|
|
pn_dlg);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
}
|
|
|
|
gtk_widget_show (bbox);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gtk_widget_show (pn_dlg->shell);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1998-04-14 16:19:17 +08:00
|
|
|
new_named_buffer (TileManager *tiles,
|
|
|
|
char *name)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
|
|
|
PixelRegion srcPR, destPR;
|
|
|
|
NamedBuffer *nb;
|
|
|
|
|
1998-04-14 16:19:17 +08:00
|
|
|
if (! tiles) return;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
nb = (NamedBuffer *) g_malloc (sizeof (NamedBuffer));
|
|
|
|
|
1998-08-16 03:17:36 +08:00
|
|
|
nb->buf = tile_manager_new (tiles->width, tiles->height, tiles->bpp);
|
|
|
|
pixel_region_init (&srcPR, tiles, 0, 0, tiles->width, tiles->height, FALSE);
|
|
|
|
pixel_region_init (&destPR, nb->buf, 0, 0, tiles->width, tiles->height, TRUE);
|
1997-11-25 06:05:25 +08:00
|
|
|
copy_region (&srcPR, &destPR);
|
|
|
|
|
1998-04-14 16:19:17 +08:00
|
|
|
nb->name = g_strdup ((char *) name);
|
1998-01-29 16:03:27 +08:00
|
|
|
named_buffers = g_slist_append (named_buffers, (void *) nb);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
1999-09-28 01:58:10 +08:00
|
|
|
cut_named_buffer_callback (GtkWidget *widget,
|
1998-04-14 16:19:17 +08:00
|
|
|
gpointer client_data,
|
|
|
|
gpointer call_data)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
1998-04-14 16:19:17 +08:00
|
|
|
TileManager *new_tiles;
|
|
|
|
GDisplay *gdisp;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
gdisp = (GDisplay *) client_data;
|
|
|
|
name = g_strdup ((char *) call_data);
|
|
|
|
|
|
|
|
new_tiles = edit_cut (gdisp->gimage, gimage_active_drawable (gdisp->gimage));
|
|
|
|
if (new_tiles)
|
|
|
|
new_named_buffer (new_tiles, name);
|
|
|
|
gdisplays_flush ();
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
named_edit_cut (void *gdisp_ptr)
|
|
|
|
{
|
1999-09-28 01:58:10 +08:00
|
|
|
GtkWidget *qbox;
|
|
|
|
GDisplay *gdisp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
/* stop any active tool */
|
|
|
|
gdisp = (GDisplay *) gdisp_ptr;
|
|
|
|
active_tool_control (HALT, gdisp_ptr);
|
|
|
|
|
1999-09-28 01:58:10 +08:00
|
|
|
qbox = gimp_query_string_box (_("Cut Named"),
|
|
|
|
gimp_standard_help_func,
|
1999-10-03 21:50:19 +08:00
|
|
|
"dialogs/cut_named.html",
|
1999-09-28 01:58:10 +08:00
|
|
|
_("Enter a name for this buffer"),
|
|
|
|
NULL,
|
|
|
|
GTK_OBJECT (gdisp->gimage), "destroy",
|
|
|
|
cut_named_buffer_callback, gdisp);
|
|
|
|
gtk_widget_show (qbox);
|
|
|
|
|
1998-04-14 16:19:17 +08:00
|
|
|
return TRUE;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-04-14 16:19:17 +08:00
|
|
|
static void
|
1999-09-28 01:58:10 +08:00
|
|
|
copy_named_buffer_callback (GtkWidget *widget,
|
1998-04-14 16:19:17 +08:00
|
|
|
gpointer client_data,
|
|
|
|
gpointer call_data)
|
|
|
|
{
|
|
|
|
TileManager *new_tiles;
|
|
|
|
GDisplay *gdisp;
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
gdisp = (GDisplay *) client_data;
|
|
|
|
name = g_strdup ((char *) call_data);
|
|
|
|
|
|
|
|
new_tiles = edit_copy (gdisp->gimage, gimage_active_drawable (gdisp->gimage));
|
|
|
|
if (new_tiles)
|
|
|
|
new_named_buffer (new_tiles, name);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
named_edit_copy (void *gdisp_ptr)
|
|
|
|
{
|
1999-09-28 01:58:10 +08:00
|
|
|
GtkWidget *qbox;
|
|
|
|
GDisplay *gdisp;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gdisp = (GDisplay *) gdisp_ptr;
|
1999-09-28 01:58:10 +08:00
|
|
|
|
|
|
|
qbox = gimp_query_string_box (_("Copy Named"),
|
|
|
|
gimp_standard_help_func,
|
1999-10-03 21:50:19 +08:00
|
|
|
"dialogs/copy_named.html",
|
1999-09-28 01:58:10 +08:00
|
|
|
_("Enter a name for this buffer"),
|
|
|
|
NULL,
|
|
|
|
GTK_OBJECT (gdisp->gimage), "destroy",
|
|
|
|
copy_named_buffer_callback, gdisp);
|
|
|
|
gtk_widget_show (qbox);
|
|
|
|
|
1998-04-14 16:19:17 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
named_edit_paste (void *gdisp_ptr)
|
|
|
|
{
|
|
|
|
paste_named_buffer ((GDisplay *) gdisp_ptr);
|
|
|
|
|
|
|
|
gdisplays_flush();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
named_buffers_free ()
|
|
|
|
{
|
1998-01-29 16:03:27 +08:00
|
|
|
GSList *list;
|
1997-11-25 06:05:25 +08:00
|
|
|
NamedBuffer * nb;
|
|
|
|
|
|
|
|
list = named_buffers;
|
|
|
|
|
|
|
|
while (list)
|
|
|
|
{
|
|
|
|
nb = (NamedBuffer *) list->data;
|
|
|
|
tile_manager_destroy (nb->buf);
|
|
|
|
g_free (nb->name);
|
|
|
|
g_free (nb);
|
1998-01-29 16:03:27 +08:00
|
|
|
list = g_slist_next (list);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-01-29 16:03:27 +08:00
|
|
|
g_slist_free (named_buffers);
|
1997-11-25 06:05:25 +08:00
|
|
|
named_buffers = NULL;
|
|
|
|
}
|