2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
1997-11-25 06:05:25 +08:00
|
|
|
* 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"
|
|
|
|
|
2008-10-10 04:24:04 +08:00
|
|
|
#include <gegl.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"
|
|
|
|
|
2007-08-18 02:29:09 +08:00
|
|
|
#include "core/gimp.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"
|
2007-08-18 02:29:09 +08:00
|
|
|
#include "core/gimpitem.h"
|
|
|
|
#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
|
|
|
|
2008-05-11 21:23:35 +08:00
|
|
|
struct _GimpCropTool
|
|
|
|
{
|
|
|
|
GimpDrawTool parent_instance;
|
|
|
|
|
|
|
|
GimpImage *current_image;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GimpCropToolClass
|
|
|
|
{
|
|
|
|
GimpDrawToolClass parent_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-05-01 02:55:49 +08:00
|
|
|
static void gimp_crop_tool_rectangle_tool_iface_init (GimpRectangleToolInterface *iface);
|
|
|
|
|
|
|
|
static GObject * gimp_crop_tool_constructor (GType type,
|
|
|
|
guint n_params,
|
|
|
|
GObjectConstructParam *params);
|
|
|
|
static void gimp_crop_tool_control (GimpTool *tool,
|
|
|
|
GimpToolAction action,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_crop_tool_button_press (GimpTool *tool,
|
2008-11-01 23:17:36 +08:00
|
|
|
const GimpCoords *coords,
|
2008-05-01 02:55:49 +08:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_crop_tool_button_release (GimpTool *tool,
|
2008-11-01 23:17:36 +08:00
|
|
|
const GimpCoords *coords,
|
2008-05-01 02:55:49 +08:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_crop_tool_active_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static void gimp_crop_tool_cursor_update (GimpTool *tool,
|
2008-11-01 23:17:36 +08:00
|
|
|
const GimpCoords *coords,
|
2008-05-01 02:55:49 +08:00
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display);
|
|
|
|
static gboolean gimp_crop_tool_execute (GimpRectangleTool *rectangle,
|
|
|
|
gint x,
|
|
|
|
gint y,
|
|
|
|
gint w,
|
|
|
|
gint h);
|
|
|
|
static void gimp_crop_tool_update_option_defaults (GimpCropTool *crop_tool,
|
|
|
|
gboolean ignore_pending);
|
|
|
|
static GimpRectangleConstraint
|
|
|
|
gimp_crop_tool_get_constraint (GimpCropTool *crop_tool);
|
|
|
|
|
|
|
|
static void gimp_crop_tool_options_notify (GimpCropOptions *options,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpCropTool *crop_tool);
|
2008-05-08 01:55:39 +08:00
|
|
|
static void gimp_crop_tool_image_changed (GimpCropTool *crop_tool,
|
2008-05-01 02:55:49 +08:00
|
|
|
GimpImage *image,
|
2008-05-08 01:55:39 +08:00
|
|
|
GimpContext *context);
|
2008-05-09 20:46:28 +08:00
|
|
|
static void gimp_crop_tool_image_size_changed (GimpCropTool *crop_tool);
|
2008-05-10 15:34:22 +08:00
|
|
|
static void gimp_crop_tool_cancel (GimpRectangleTool *rect_tool);
|
2008-05-11 21:01:24 +08:00
|
|
|
static gboolean gimp_crop_tool_rectangle_change_complete (GimpRectangleTool *rect_tool);
|
2007-08-18 02:29:09 +08:00
|
|
|
|
2005-12-13 17:13:50 +08:00
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpCropTool, gimp_crop_tool, GIMP_TYPE_DRAW_TOOL,
|
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_RECTANGLE_TOOL,
|
|
|
|
gimp_crop_tool_rectangle_tool_iface_init));
|
|
|
|
|
|
|
|
#define parent_class gimp_crop_tool_parent_class
|
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",
|
2006-09-14 00:03:24 +08:00
|
|
|
_("Crop"),
|
2006-09-19 02:00:22 +08:00
|
|
|
_("Crop Tool: Remove edge areas from image or layer"),
|
2006-09-14 00:03:24 +08:00
|
|
|
N_("_Crop"), "<shift>C",
|
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
|
|
|
|
|
|
|
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
|
|
|
|
2006-11-05 20:35:59 +08:00
|
|
|
object_class->constructor = gimp_crop_tool_constructor;
|
|
|
|
object_class->set_property = gimp_rectangle_tool_set_property;
|
|
|
|
object_class->get_property = gimp_rectangle_tool_get_property;
|
|
|
|
|
2005-09-04 03:48:22 +08:00
|
|
|
gimp_rectangle_tool_install_properties (object_class);
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2006-09-13 02:41:09 +08:00
|
|
|
tool_class->control = gimp_crop_tool_control;
|
|
|
|
tool_class->button_press = gimp_crop_tool_button_press;
|
|
|
|
tool_class->button_release = gimp_crop_tool_button_release;
|
|
|
|
tool_class->motion = gimp_rectangle_tool_motion;
|
|
|
|
tool_class->key_press = gimp_rectangle_tool_key_press;
|
2006-09-24 06:32:35 +08:00
|
|
|
tool_class->active_modifier_key = gimp_crop_tool_active_modifier_key;
|
2006-09-13 02:41:09 +08:00
|
|
|
tool_class->oper_update = gimp_rectangle_tool_oper_update;
|
|
|
|
tool_class->cursor_update = gimp_crop_tool_cursor_update;
|
|
|
|
|
|
|
|
draw_tool_class->draw = gimp_rectangle_tool_draw;
|
1999-04-09 06:25:54 +08:00
|
|
|
}
|
|
|
|
|
2006-11-05 20:35:59 +08:00
|
|
|
static void
|
|
|
|
gimp_crop_tool_rectangle_tool_iface_init (GimpRectangleToolInterface *iface)
|
|
|
|
{
|
2008-05-11 21:01:24 +08:00
|
|
|
iface->execute = gimp_crop_tool_execute;
|
|
|
|
iface->cancel = gimp_crop_tool_cancel;
|
|
|
|
iface->rectangle_change_complete = gimp_crop_tool_rectangle_change_complete;
|
2006-11-05 20:35:59 +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
|
|
|
{
|
2007-04-01 00:07:05 +08:00
|
|
|
GimpTool *tool = GIMP_TOOL (crop_tool);
|
2001-04-01 04:41:39 +08:00
|
|
|
|
2007-12-09 17:38:34 +08:00
|
|
|
gimp_rectangle_tool_init (GIMP_RECTANGLE_TOOL (crop_tool));
|
|
|
|
|
2007-02-28 05:11:35 +08:00
|
|
|
gimp_tool_control_set_wants_click (tool->control, TRUE);
|
2008-08-21 00:22:09 +08:00
|
|
|
gimp_tool_control_set_precision (tool->control,
|
|
|
|
GIMP_CURSOR_PRECISION_PIXEL_BORDER);
|
2004-06-05 07:08:29 +08:00
|
|
|
gimp_tool_control_set_tool_cursor (tool->control, GIMP_TOOL_CURSOR_CROP);
|
2008-05-09 20:46:28 +08:00
|
|
|
|
|
|
|
crop_tool->current_image = NULL;
|
2001-07-07 22:53:42 +08:00
|
|
|
}
|
1998-12-04 14:46:52 +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
|
|
|
{
|
2007-04-01 00:07:05 +08:00
|
|
|
GObject *object;
|
2007-09-23 02:55:14 +08:00
|
|
|
GimpCropTool *crop_tool;
|
2007-04-01 00:07:05 +08:00
|
|
|
GimpCropOptions *options;
|
2007-08-18 02:29:09 +08:00
|
|
|
GimpContext *gimp_context;
|
|
|
|
GimpToolInfo *tool_info;
|
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
|
|
|
|
2007-08-18 02:29:09 +08:00
|
|
|
|
|
|
|
g_object_get (object,
|
|
|
|
"tool-info", &tool_info,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
gimp_context = gimp_get_user_context (tool_info->gimp);
|
|
|
|
|
2007-09-23 02:55:14 +08:00
|
|
|
crop_tool = GIMP_CROP_TOOL (object);
|
|
|
|
|
2007-08-18 02:29:09 +08:00
|
|
|
g_signal_connect_object (gimp_context, "image-changed",
|
|
|
|
G_CALLBACK (gimp_crop_tool_image_changed),
|
2008-05-08 01:55:39 +08:00
|
|
|
crop_tool,
|
|
|
|
G_CONNECT_SWAPPED);
|
2007-08-18 02:29:09 +08:00
|
|
|
|
2008-05-09 20:46:28 +08:00
|
|
|
/* Make sure we are connected to "size-changed" for the initial
|
|
|
|
* image.
|
|
|
|
*/
|
|
|
|
gimp_crop_tool_image_changed (crop_tool,
|
|
|
|
gimp_context_get_image (gimp_context),
|
|
|
|
gimp_context);
|
|
|
|
|
2007-08-18 02:29:09 +08:00
|
|
|
|
2007-04-01 00:07:05 +08:00
|
|
|
options = GIMP_CROP_TOOL_GET_OPTIONS (object);
|
1998-12-04 14:46:52 +08:00
|
|
|
|
2006-11-05 22:11:34 +08:00
|
|
|
g_signal_connect_object (options, "notify::layer-only",
|
2007-09-23 02:55:14 +08:00
|
|
|
G_CALLBACK (gimp_crop_tool_options_notify),
|
|
|
|
object, 0);
|
|
|
|
|
|
|
|
g_signal_connect_object (options, "notify::allow-growing",
|
|
|
|
G_CALLBACK (gimp_crop_tool_options_notify),
|
2006-11-05 22:11:34 +08:00
|
|
|
object, 0);
|
2006-09-07 06:51:54 +08:00
|
|
|
|
2007-04-01 00:07:05 +08:00
|
|
|
gimp_rectangle_tool_set_constraint (GIMP_RECTANGLE_TOOL (object),
|
2007-09-23 02:55:14 +08:00
|
|
|
gimp_crop_tool_get_constraint (crop_tool));
|
2006-09-07 06:51:54 +08:00
|
|
|
|
2007-09-23 02:55:14 +08:00
|
|
|
gimp_crop_tool_update_option_defaults (crop_tool,
|
2007-09-02 12:39:17 +08:00
|
|
|
FALSE);
|
2007-08-18 02:29:09 +08:00
|
|
|
|
2006-11-05 22:11:34 +08:00
|
|
|
return object;
|
2006-09-07 06:51:54 +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,
|
2006-03-29 01:55:52 +08:00
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-24 01:37:18 +08:00
|
|
|
gimp_rectangle_tool_control (tool, action, display);
|
1998-07-27 05:49:42 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
2005-10-20 05:13:25 +08:00
|
|
|
static void
|
2008-11-01 23:17:36 +08:00
|
|
|
gimp_crop_tool_button_press (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
2005-10-20 05:13:25 +08:00
|
|
|
{
|
2007-12-15 01:22:46 +08:00
|
|
|
if (tool->display && display != tool->display)
|
2006-06-06 01:14:16 +08:00
|
|
|
gimp_rectangle_tool_cancel (GIMP_RECTANGLE_TOOL (tool));
|
2005-10-20 05:13:25 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_rectangle_tool_button_press (tool, coords, time, state, display);
|
2005-10-20 05:13:25 +08:00
|
|
|
}
|
|
|
|
|
2005-10-09 03:20:31 +08:00
|
|
|
static void
|
2007-02-28 02:55:12 +08:00
|
|
|
gimp_crop_tool_button_release (GimpTool *tool,
|
2008-11-01 23:17:36 +08:00
|
|
|
const GimpCoords *coords,
|
2007-02-28 02:55:12 +08:00
|
|
|
guint32 time,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpButtonReleaseType release_type,
|
|
|
|
GimpDisplay *display)
|
2005-10-09 03:20:31 +08:00
|
|
|
{
|
2007-03-01 06:35:37 +08:00
|
|
|
gimp_tool_push_status (tool, display, _("Click or press Enter to crop"));
|
2005-10-09 03:20:31 +08:00
|
|
|
|
2007-08-18 14:39:18 +08:00
|
|
|
gimp_rectangle_tool_button_release (tool,
|
|
|
|
coords,
|
|
|
|
time,
|
|
|
|
state,
|
|
|
|
release_type,
|
|
|
|
display);
|
2005-10-09 03:20:31 +08:00
|
|
|
}
|
|
|
|
|
2006-09-24 06:32:35 +08:00
|
|
|
static void
|
|
|
|
gimp_crop_tool_active_modifier_key (GimpTool *tool,
|
|
|
|
GdkModifierType key,
|
|
|
|
gboolean press,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
|
|
|
{
|
|
|
|
GIMP_TOOL_CLASS (parent_class)->active_modifier_key (tool, key, press, state,
|
|
|
|
display);
|
|
|
|
|
|
|
|
gimp_rectangle_tool_active_modifier_key (tool, key, press, state, display);
|
|
|
|
}
|
|
|
|
|
1998-03-19 06:35:31 +08:00
|
|
|
static void
|
2008-11-01 23:17:36 +08:00
|
|
|
gimp_crop_tool_cursor_update (GimpTool *tool,
|
|
|
|
const GimpCoords *coords,
|
|
|
|
GdkModifierType state,
|
|
|
|
GimpDisplay *display)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-03-29 01:55:52 +08:00
|
|
|
gimp_rectangle_tool_cursor_update (tool, coords, state, display);
|
2001-07-07 22:53:42 +08:00
|
|
|
|
2006-03-29 01:55:52 +08:00
|
|
|
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
|
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
|
|
|
{
|
2007-09-23 02:55:14 +08:00
|
|
|
GimpTool *tool;
|
|
|
|
GimpCropOptions *options;
|
|
|
|
GimpImage *image;
|
2004-10-01 23:15:14 +08:00
|
|
|
|
2007-09-23 02:55:14 +08:00
|
|
|
tool = GIMP_TOOL (rectangle);
|
|
|
|
options = GIMP_CROP_TOOL_GET_OPTIONS (tool);
|
2007-08-11 00:41:30 +08:00
|
|
|
|
2007-12-15 01:22:46 +08:00
|
|
|
gimp_tool_pop_status (tool, tool->display);
|
2007-08-12 00:13:14 +08:00
|
|
|
|
2007-12-15 01:22:46 +08:00
|
|
|
image = tool->display->image;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
/* if rectangle exists, crop it */
|
2007-09-23 02:55:14 +08:00
|
|
|
if (w > 0 && h > 0)
|
2003-08-17 06:15:36 +08:00
|
|
|
{
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_crop (image, GIMP_CONTEXT (options),
|
2005-08-15 22:23:28 +08:00
|
|
|
x, y, w + x, h + y,
|
|
|
|
options->layer_only,
|
2006-09-06 23:38:28 +08:00
|
|
|
TRUE);
|
2005-08-23 08:18:08 +08:00
|
|
|
|
2006-03-29 01:08:36 +08:00
|
|
|
gimp_image_flush (image);
|
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
|
|
|
}
|
|
|
|
|
2008-05-11 21:01:24 +08:00
|
|
|
/**
|
|
|
|
* gimp_crop_tool_rectangle_change_complete:
|
|
|
|
* @rectangle:
|
|
|
|
*
|
2008-09-04 16:37:32 +08:00
|
|
|
* Returns:
|
2008-05-11 21:01:24 +08:00
|
|
|
**/
|
|
|
|
static gboolean
|
|
|
|
gimp_crop_tool_rectangle_change_complete (GimpRectangleTool *rectangle)
|
|
|
|
{
|
|
|
|
gimp_crop_tool_update_option_defaults (GIMP_CROP_TOOL (rectangle), FALSE);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2007-08-18 02:29:09 +08:00
|
|
|
/**
|
2007-09-02 12:39:17 +08:00
|
|
|
* gimp_crop_tool_update_option_defaults:
|
2007-08-18 02:29:09 +08:00
|
|
|
* @crop_tool:
|
2007-08-18 14:31:15 +08:00
|
|
|
* @ignore_pending: %TRUE to ignore any pending crop rectangle.
|
2007-08-18 02:29:09 +08:00
|
|
|
*
|
2007-09-02 12:39:17 +08:00
|
|
|
* Sets the default Fixed: Aspect ratio and Fixed: Size option
|
|
|
|
* properties.
|
2007-08-18 02:29:09 +08:00
|
|
|
*/
|
2007-09-02 04:01:38 +08:00
|
|
|
static void
|
2007-09-02 12:39:17 +08:00
|
|
|
gimp_crop_tool_update_option_defaults (GimpCropTool *crop_tool,
|
|
|
|
gboolean ignore_pending)
|
2007-08-18 02:29:09 +08:00
|
|
|
{
|
|
|
|
GimpTool *tool;
|
|
|
|
GimpRectangleTool *rectangle_tool;
|
|
|
|
GimpRectangleOptions *rectangle_options;
|
|
|
|
|
|
|
|
tool = GIMP_TOOL (crop_tool);
|
|
|
|
rectangle_tool = GIMP_RECTANGLE_TOOL (tool);
|
|
|
|
rectangle_options = GIMP_RECTANGLE_TOOL_GET_OPTIONS (rectangle_tool);
|
|
|
|
|
2007-08-18 14:31:15 +08:00
|
|
|
if (tool->display != NULL && !ignore_pending)
|
2007-08-18 02:29:09 +08:00
|
|
|
{
|
2007-09-02 12:39:17 +08:00
|
|
|
/* There is a pending rectangle and we should not ignore it, so
|
2007-10-10 04:54:07 +08:00
|
|
|
* set default Fixed: Aspect ratio to the same as the current
|
|
|
|
* pending rectangle width/height.
|
2007-09-02 12:39:17 +08:00
|
|
|
*/
|
|
|
|
|
2007-09-02 04:01:38 +08:00
|
|
|
gimp_rectangle_tool_pending_size_set (rectangle_tool,
|
|
|
|
G_OBJECT (rectangle_options),
|
|
|
|
"default-aspect-numerator",
|
|
|
|
"default-aspect-denominator");
|
2007-09-02 12:39:17 +08:00
|
|
|
|
2007-10-10 04:54:07 +08:00
|
|
|
g_object_set (G_OBJECT (rectangle_options),
|
|
|
|
"use-string-current", TRUE,
|
|
|
|
NULL);
|
2007-08-18 02:29:09 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-02 12:39:17 +08:00
|
|
|
/* There is no pending rectangle, set default Fixed: Aspect
|
2007-10-10 04:54:07 +08:00
|
|
|
* ratio to that of the current image/layer.
|
2007-09-02 12:39:17 +08:00
|
|
|
*/
|
|
|
|
|
2007-09-02 04:01:38 +08:00
|
|
|
gimp_rectangle_tool_constraint_size_set (rectangle_tool,
|
|
|
|
G_OBJECT (rectangle_options),
|
|
|
|
"default-aspect-numerator",
|
|
|
|
"default-aspect-denominator");
|
2007-09-02 12:39:17 +08:00
|
|
|
|
|
|
|
g_object_set (G_OBJECT (rectangle_options),
|
2007-10-10 04:54:07 +08:00
|
|
|
"use-string-current", FALSE,
|
2007-09-02 12:39:17 +08:00
|
|
|
NULL);
|
2007-08-18 02:29:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-23 02:55:14 +08:00
|
|
|
static GimpRectangleConstraint
|
|
|
|
gimp_crop_tool_get_constraint (GimpCropTool *crop_tool)
|
|
|
|
{
|
|
|
|
GimpCropOptions *crop_options = GIMP_CROP_TOOL_GET_OPTIONS (crop_tool);
|
|
|
|
|
|
|
|
if (crop_options->allow_growing)
|
|
|
|
{
|
|
|
|
return GIMP_RECTANGLE_CONSTRAIN_NONE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return crop_options->layer_only ? GIMP_RECTANGLE_CONSTRAIN_DRAWABLE :
|
|
|
|
GIMP_RECTANGLE_CONSTRAIN_IMAGE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-09-07 06:51:54 +08:00
|
|
|
static void
|
2007-09-23 02:55:14 +08:00
|
|
|
gimp_crop_tool_options_notify (GimpCropOptions *options,
|
|
|
|
GParamSpec *pspec,
|
|
|
|
GimpCropTool *crop_tool)
|
2006-09-07 06:51:54 +08:00
|
|
|
{
|
2007-09-23 02:55:14 +08:00
|
|
|
gimp_rectangle_tool_set_constraint (GIMP_RECTANGLE_TOOL (crop_tool),
|
|
|
|
gimp_crop_tool_get_constraint (crop_tool));
|
2007-08-18 02:29:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-05-08 01:55:39 +08:00
|
|
|
gimp_crop_tool_image_changed (GimpCropTool *crop_tool,
|
2007-08-18 02:29:09 +08:00
|
|
|
GimpImage *image,
|
2008-05-08 01:55:39 +08:00
|
|
|
GimpContext *context)
|
2007-08-18 02:29:09 +08:00
|
|
|
{
|
2008-05-09 20:46:28 +08:00
|
|
|
if (crop_tool->current_image)
|
|
|
|
{
|
|
|
|
g_signal_handlers_disconnect_by_func (crop_tool->current_image,
|
|
|
|
gimp_crop_tool_image_size_changed,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (image)
|
|
|
|
{
|
|
|
|
g_signal_connect_object (image, "size-changed",
|
|
|
|
G_CALLBACK (gimp_crop_tool_image_size_changed),
|
|
|
|
crop_tool,
|
|
|
|
G_CONNECT_SWAPPED);
|
|
|
|
}
|
|
|
|
|
|
|
|
crop_tool->current_image = image;
|
|
|
|
|
2007-09-02 12:39:17 +08:00
|
|
|
gimp_crop_tool_update_option_defaults (GIMP_CROP_TOOL (crop_tool),
|
|
|
|
FALSE);
|
2006-09-07 06:51:54 +08:00
|
|
|
}
|
2008-05-09 20:46:28 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_crop_tool_image_size_changed (GimpCropTool *crop_tool)
|
|
|
|
{
|
|
|
|
gimp_crop_tool_update_option_defaults (crop_tool,
|
|
|
|
FALSE);
|
|
|
|
}
|
2008-05-10 15:34:22 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_crop_tool_cancel (GimpRectangleTool *rect_tool)
|
|
|
|
{
|
|
|
|
gimp_crop_tool_update_option_defaults (GIMP_CROP_TOOL (rect_tool),
|
|
|
|
TRUE);
|
|
|
|
}
|