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
|
|
|
*/
|
2000-10-27 06:02:44 +08:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2000-12-17 05:37:03 +08:00
|
|
|
#include <gtk/gtk.h>
|
2000-01-14 20:41:00 +08:00
|
|
|
|
2001-01-25 06:36:18 +08:00
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
2001-01-24 07:56:18 +08:00
|
|
|
|
2002-05-03 20:45:22 +08:00
|
|
|
#include "tools-types.h"
|
|
|
|
|
2001-05-09 10:32:03 +08:00
|
|
|
#include "core/gimpimage.h"
|
2001-07-07 22:53:42 +08:00
|
|
|
#include "core/gimpimage-crop.h"
|
2001-11-20 21:53:21 +08:00
|
|
|
#include "core/gimptoolinfo.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "widgets/gimphelp-ids.h"
|
2002-03-20 03:17:31 +08:00
|
|
|
|
2003-08-22 09:42:57 +08:00
|
|
|
#include "display/gimpdisplay.h"
|
2003-05-03 02:43:15 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
#include "gimprectangleoptions.h"
|
|
|
|
#include "gimprectangletool.h"
|
2003-02-05 22:39:40 +08:00
|
|
|
#include "gimpcropoptions.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
#include "gimpcroptool.h"
|
2003-04-16 00:05:52 +08:00
|
|
|
#include "gimptoolcontrol.h"
|
2001-04-18 05:43:29 +08:00
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
#include "gimp-intl.h"
|
Lots of ii8n stuff here and some additions to the de.po. Applied
Wed Oct 14 17:46:15 EDT 1998 Adrian Likins <adrian@gimp.org>
* app/*, po/de.po, de/POTFILES.in, libgimp/gimpintl.h:
Lots of ii8n stuff here and some additions to the de.po.
Applied gimp-egger-981005-1 ,gimp-egger-981006-1,
gimp-egger-981007-1, gimp-egger-981008-1,
gimp-egger-981009-1.patch, gimp-egger-981010-1.patch
* plug-in/guillotine/guillotine.c: added the coordinates
of the split images from the original image to the title.
ie foo.jpg (0,0) for the image in the topleft.
* plug-in/script-fu/scripts/neon-logo.scm,
perspective-shadow.scm, predator.scm,rendermap.scm,
ripply-anim.scm, select_to_image.scm,swirltile.scm,
xach-effect.scm: updated scripts to use new script-fu stuff
wooo boy! a big un!
in testing this, it looks like some of the po files are busted.
but the code stuff seems okay.
-adrian
1998-10-15 07:23:52 +08:00
|
|
|
|
2000-12-29 23:22:01 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
static void gimp_crop_tool_class_init (GimpCropToolClass *klass);
|
|
|
|
static void gimp_crop_tool_init (GimpCropTool *crop_tool);
|
|
|
|
static void gimp_crop_tool_rectangle_tool_iface_init (GimpRectangleToolInterface *rectangle_iface);
|
|
|
|
|
|
|
|
static GObject * gimp_crop_tool_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
|
|
|
static void gimp_crop_tool_finalize (GObject *object);
|
|
|
|
static void gimp_crop_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *gdisp);
|
|
|
|
|
2005-10-20 05:13:25 +08:00
|
|
|
static void gimp_crop_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
2005-10-09 03:20:31 +08:00
|
|
|
static void gimp_crop_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
2005-10-20 05:13:25 +08:00
|
|
|
static void gimp_crop_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp);
|
2005-08-15 22:23:28 +08:00
|
|
|
|
2005-10-20 05:13:25 +08:00
|
|
|
static gboolean gimp_crop_tool_execute (GimpRectangleTool *rectangle,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
2005-08-15 22:23:28 +08:00
|
|
|
|
2001-03-02 00:57:16 +08:00
|
|
|
static GimpDrawToolClass *parent_class = NULL;
|
2001-02-28 11:29:03 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-11-21 07:00:47 +08:00
|
|
|
/* public functions */
|
2001-07-07 22:53:42 +08:00
|
|
|
|
|
|
|
void
|
2002-03-29 11:50:29 +08:00
|
|
|
gimp_crop_tool_register (GimpToolRegisterCallback callback,
|
2002-05-03 19:31:08 +08:00
|
|
|
gpointer data)
|
1999-10-27 02:27:27 +08:00
|
|
|
{
|
2002-03-29 11:50:29 +08:00
|
|
|
(* callback) (GIMP_TYPE_CROP_TOOL,
|
2003-02-05 22:39:40 +08:00
|
|
|
GIMP_TYPE_CROP_OPTIONS,
|
|
|
|
gimp_crop_options_gui,
|
2003-06-28 19:20:37 +08:00
|
|
|
0,
|
2002-03-21 20:17:17 +08:00
|
|
|
"gimp-crop-tool",
|
GimpViewableDialogs everywhere, cleanup:
2002-09-01 Michael Natterer <mitch@gimp.org>
GimpViewableDialogs everywhere, cleanup:
* libgimpwidgets/gimpstock.c: added texts for the RESIZE, SCALE
and CROP stock items.
* app/widgets/gimpviewabledialog.c: update the title when the
viewable's name changes.
* app/gui/color-notebook.[ch]: added color_notebook_viewable_new()
which creates a GimpViewableDialog.
* app/widgets/gimpgradienteditor.[ch]
* app/gui/colormap-editor-commands.c
* app/gui/file-new-dialog.c
* app/gui/gradient-editor-commands.c
* app/gui/palette-editor-commands.c
* app/undo_history.c: use GimpViewableDialogs and the new
color_notebook constructor.
* app/gui/convert-dialog.c: #include "widgets/gimpviewabledialog.h"
* app/gui/image-commands.c
* app/gui/info-dialog.c
* app/gui/resize-dialog.c: minor cleanups.
* app/gui/info-window.c: cleaned up the whole thing, esp. the
"Extended" page. Added HSV color display to the color picker
frame. Set the icons as frame titles, stuff...
* app/tools/gimpimagemaptool.[ch]: removed "shell_title",
"shell_name" and "stock_id" from the GimpImageMapTool struct
because they can be obtained from the tool's GimpToolInfo object.
* app/tools/gimpbrightnesscontrasttool.c
* app/tools/gimpcolorbalancetool.c
* app/tools/gimpcurvestool.c
* app/tools/gimphuesaturationtool.c
* app/tools/gimplevelstool.c
* app/tools/gimpposterizetool.c
* app/tools/gimpthresholdtool.c: changed accordingly.
* app/tools/gimphistogramtool.c: same here: take values from
tool->tool_info instead of hardcoding them.
* app/tools/gimpcroptool.[ch]: removed the static crop dialog
variables and added them to the GimpCropTool struct. Feels safer
and makes the callback code much simpler. Use stock items for the
dialog's "Resize" and "Crop" buttons.
* app/tools/gimpmeasuretool.c
* app/tools/gimprotatetool.c: for consistency don't name the tools
"Blah Tool", also the dialog titles need to match the menu
entries.
Unrelated:
* libgimpwidgets/gimpwidgets.c: the recently changed, gtk-doc
comment was correct, as gtk-doc takes the parameter names from
the header, not the .c file.
* app/tools/gimptransformtool.c: set the transform tool's state to
TRANSFORM_CREATING after changing displays, so the initial matrix
components are saved correctly for the "Reset" function.
2002-09-01 16:44:57 +08:00
|
|
|
_("Crop & Resize"),
|
2001-11-21 07:00:47 +08:00
|
|
|
_("Crop or Resize an image"),
|
2005-08-15 22:23:28 +08:00
|
|
|
N_("_Crop & Resize"), NULL,
|
2003-08-22 09:42:57 +08:00
|
|
|
NULL, GIMP_HELP_TOOL_CROP,
|
2002-03-29 11:50:29 +08:00
|
|
|
GIMP_STOCK_TOOL_CROP,
|
2002-05-03 19:31:08 +08:00
|
|
|
data);
|
2001-07-07 22:53:42 +08:00
|
|
|
}
|
1998-12-04 14:46:52 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
GType
|
2001-07-07 22:53:42 +08:00
|
|
|
gimp_crop_tool_get_type (void)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static GType tool_type = 0;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
if (! tool_type)
|
|
|
|
{
|
2001-08-14 22:53:55 +08:00
|
|
|
static const GTypeInfo tool_info =
|
|
|
|
{
|
|
|
|
sizeof (GimpCropToolClass),
|
2004-06-15 23:30:36 +08:00
|
|
|
(GBaseInitFunc) NULL,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
|
|
|
(GClassInitFunc) gimp_crop_tool_class_init,
|
|
|
|
NULL, /* class_finalize */
|
|
|
|
NULL, /* class_data */
|
|
|
|
sizeof (GimpCropTool),
|
|
|
|
0, /* n_preallocs */
|
|
|
|
(GInstanceInitFunc) gimp_crop_tool_init,
|
2001-08-14 22:53:55 +08:00
|
|
|
};
|
2005-08-15 22:23:28 +08:00
|
|
|
static const GInterfaceInfo rectangle_info =
|
|
|
|
{
|
|
|
|
(GInterfaceInitFunc) gimp_crop_tool_rectangle_tool_iface_init, /* interface_init */
|
|
|
|
NULL, /* interface_finalize */
|
|
|
|
NULL /* interface_data */
|
|
|
|
};
|
2005-08-23 08:18:08 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
tool_type = g_type_register_static (GIMP_TYPE_DRAW_TOOL,
|
2004-06-15 23:30:36 +08:00
|
|
|
"GimpCropTool",
|
2001-08-14 22:53:55 +08:00
|
|
|
&tool_info, 0);
|
2005-08-15 22:23:28 +08:00
|
|
|
g_type_add_interface_static (tool_type,
|
|
|
|
GIMP_TYPE_RECTANGLE_TOOL,
|
|
|
|
&rectangle_info);
|
2001-07-07 22:53:42 +08:00
|
|
|
}
|
2001-08-14 22:53:55 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
return tool_type;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
1998-12-04 14:46:52 +08:00
|
|
|
static void
|
2001-07-07 22:53:42 +08:00
|
|
|
gimp_crop_tool_class_init (GimpCropToolClass *klass)
|
1999-04-09 06:25:54 +08:00
|
|
|
{
|
2004-06-02 06:04:20 +08:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
|
|
|
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
1999-04-09 06:25:54 +08:00
|
|
|
|
2001-08-14 22:53:55 +08:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
object_class->constructor = gimp_crop_tool_constructor;
|
2005-09-04 03:48:22 +08:00
|
|
|
object_class->dispose = gimp_rectangle_tool_dispose;
|
2001-08-14 22:53:55 +08:00
|
|
|
object_class->finalize = gimp_crop_tool_finalize;
|
2005-09-04 03:48:22 +08:00
|
|
|
object_class->set_property = gimp_rectangle_tool_set_property;
|
|
|
|
object_class->get_property = gimp_rectangle_tool_get_property;
|
|
|
|
gimp_rectangle_tool_install_properties (object_class);
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
tool_class->initialize = gimp_rectangle_tool_initialize;
|
2001-07-07 22:53:42 +08:00
|
|
|
tool_class->control = gimp_crop_tool_control;
|
2005-10-20 05:13:25 +08:00
|
|
|
tool_class->button_press = gimp_crop_tool_button_press;
|
2005-10-09 03:20:31 +08:00
|
|
|
tool_class->button_release = gimp_crop_tool_button_release;
|
2005-08-15 22:23:28 +08:00
|
|
|
tool_class->motion = gimp_rectangle_tool_motion;
|
|
|
|
tool_class->key_press = gimp_rectangle_tool_key_press;
|
|
|
|
tool_class->modifier_key = gimp_rectangle_tool_modifier_key;
|
|
|
|
tool_class->oper_update = gimp_rectangle_tool_oper_update;
|
2001-11-09 03:14:51 +08:00
|
|
|
tool_class->cursor_update = gimp_crop_tool_cursor_update;
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
draw_tool_class->draw = gimp_rectangle_tool_draw;
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
static void
|
|
|
|
gimp_crop_tool_init (GimpCropTool *crop_tool)
|
1998-12-04 14:46:52 +08:00
|
|
|
{
|
2005-08-15 22:23:28 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (crop_tool);
|
2001-04-01 04:41:39 +08:00
|
|
|
|
2004-06-05 07:08:29 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_CROP);
|
2001-07-07 22:53:42 +08:00
|
|
|
}
|
1998-12-04 14:46:52 +08:00
|
|
|
|
2001-07-07 22:53:42 +08:00
|
|
|
static void
|
2005-08-15 22:23:28 +08:00
|
|
|
gimp_crop_tool_rectangle_tool_iface_init (GimpRectangleToolInterface *rectangle_iface)
|
2001-07-07 22:53:42 +08:00
|
|
|
{
|
2005-08-15 22:23:28 +08:00
|
|
|
rectangle_iface->execute = gimp_crop_tool_execute;
|
2001-08-14 22:53:55 +08:00
|
|
|
}
|
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
static GObject *
|
|
|
|
gimp_crop_tool_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params)
|
2001-08-14 22:53:55 +08:00
|
|
|
{
|
2005-08-15 22:23:28 +08:00
|
|
|
GObject *object;
|
2004-11-02 19:26:05 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
2001-08-14 22:53:55 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
gimp_rectangle_tool_constructor (object);
|
2001-08-14 22:53:55 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
return object;
|
1998-12-04 14:46:52 +08:00
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2005-08-15 22:23:28 +08:00
|
|
|
gimp_crop_tool_finalize (GObject *object)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-08-15 22:23:28 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2005-08-15 22:23:28 +08:00
|
|
|
gimp_crop_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-10-20 05:13:25 +08:00
|
|
|
GimpRectangleTool *rectangle = GIMP_RECTANGLE_TOOL (tool);
|
|
|
|
|
|
|
|
switch (action)
|
|
|
|
{
|
|
|
|
case PAUSE:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RESUME:
|
|
|
|
gimp_rectangle_tool_configure (rectangle);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case HALT:
|
|
|
|
gimp_rectangle_tool_response (NULL, GTK_RESPONSE_CANCEL,
|
|
|
|
rectangle);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
1998-07-27 05:49:42 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2005-10-20 05:13:25 +08:00
|
|
|
static void
|
|
|
|
gimp_crop_tool_button_press (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
if (tool->gdisp && gdisp != tool->gdisp)
|
|
|
|
gimp_rectangle_tool_response (NULL, GTK_RESPONSE_CANCEL,
|
|
|
|
GIMP_RECTANGLE_TOOL (tool));
|
|
|
|
|
|
|
|
gimp_rectangle_tool_button_press (tool, coords, time, state, gdisp);
|
|
|
|
}
|
|
|
|
|
2005-10-09 03:20:31 +08:00
|
|
|
static void
|
|
|
|
gimp_crop_tool_button_release (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
|
|
|
{
|
|
|
|
GimpCropOptions *options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options);
|
|
|
|
|
|
|
|
if (options->crop_mode == GIMP_CROP_MODE_CROP)
|
|
|
|
gimp_tool_push_status (tool, gdisp,
|
|
|
|
_("Click or press enter to crop."));
|
|
|
|
else
|
|
|
|
gimp_tool_push_status (tool, gdisp,
|
|
|
|
_("Click or press enter to resize."));
|
|
|
|
|
|
|
|
gimp_rectangle_tool_button_release (tool, coords, time, state, gdisp);
|
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2005-08-15 22:23:28 +08:00
|
|
|
gimp_crop_tool_cursor_update (GimpTool *tool,
|
|
|
|
GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *gdisp)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-08-15 22:23:28 +08:00
|
|
|
gimp_rectangle_tool_cursor_update (tool, coords, state, gdisp);
|
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_CROP);
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2004-06-24 18:16:08 +08:00
|
|
|
static gboolean
|
2005-08-15 22:23:28 +08:00
|
|
|
gimp_crop_tool_execute (GimpRectangleTool *rectangle,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-08-15 22:23:28 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (rectangle);
|
|
|
|
GimpCropOptions *options;
|
|
|
|
GimpImage *gimage;
|
2005-09-16 04:31:49 +08:00
|
|
|
gint max_x, max_y;
|
2005-08-15 22:23:28 +08:00
|
|
|
gboolean rectangle_exists;
|
2004-10-01 23:15:14 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
options = GIMP_CROP_OPTIONS (tool->tool_info->tool_options);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-10-09 03:20:31 +08:00
|
|
|
gimp_tool_pop_status (tool, tool->gdisp);
|
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
gimage = tool->gdisp->gimage;
|
2005-09-16 04:31:49 +08:00
|
|
|
max_x = gimage->width;
|
|
|
|
max_y = gimage->height;
|
1999-04-08 13:20:37 +08:00
|
|
|
|
2005-09-25 23:27:11 +08:00
|
|
|
rectangle_exists = (x <= max_x && y <= max_y &&
|
|
|
|
x + w >= 0 && y + h >= 0 &&
|
|
|
|
w > 0 && h > 0);
|
|
|
|
|
2005-09-16 04:31:49 +08:00
|
|
|
if (x < 0)
|
|
|
|
{
|
|
|
|
w += x;
|
|
|
|
x = 0;
|
|
|
|
}
|
2005-09-25 23:27:11 +08:00
|
|
|
|
2005-09-16 04:31:49 +08:00
|
|
|
if (y < 0)
|
|
|
|
{
|
|
|
|
h += y;
|
|
|
|
y = 0;
|
|
|
|
}
|
2005-09-25 23:27:11 +08:00
|
|
|
|
2005-09-16 04:31:49 +08:00
|
|
|
if (x + w > max_x)
|
|
|
|
w = max_x - x;
|
2005-09-25 23:27:11 +08:00
|
|
|
|
2005-09-16 04:31:49 +08:00
|
|
|
if (y + h > max_y)
|
|
|
|
h = max_y - y;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
/* if rectangle exists, crop it */
|
|
|
|
if (rectangle_exists)
|
2003-08-17 06:15:36 +08:00
|
|
|
{
|
2005-08-15 22:23:28 +08:00
|
|
|
gimp_image_crop (gimage, GIMP_CONTEXT (options),
|
|
|
|
x, y, w + x, h + y,
|
|
|
|
options->layer_only,
|
|
|
|
options->crop_mode == GIMP_CROP_MODE_CROP);
|
2005-08-23 08:18:08 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
gimp_image_flush (gimage);
|
2001-03-02 00:57:16 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
return TRUE;
|
2003-08-17 06:15:36 +08:00
|
|
|
}
|
|
|
|
|
2004-06-24 18:16:08 +08:00
|
|
|
return TRUE;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|