[gimp] app: make deletion of cropped pixels in crop tool optional
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: make deletion of cropped pixels in crop tool optional
- Date: Wed, 1 Apr 2020 18:57:47 +0000 (UTC)
commit ee97c25b87df2dd7f25e36eb52a7edf0dfb0b647
Author: woob <thetoastcaper gmail com>
Date: Sun Mar 29 02:22:56 2020 -0400
app: make deletion of cropped pixels in crop tool optional
Adds a new "Delete cropped pixels" toggle to the crop tool options,
to allow turning off the deletion of layer data that falls out of the
crop region.
app/tools/gimpcropoptions.c | 28 +++++++++++++++++++++++++++-
app/tools/gimpcropoptions.h | 3 +++
app/tools/gimpcroptool.c | 2 +-
3 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/app/tools/gimpcropoptions.c b/app/tools/gimpcropoptions.c
index 5e7155dd0e..560cd21cbd 100644
--- a/app/tools/gimpcropoptions.c
+++ b/app/tools/gimpcropoptions.c
@@ -40,7 +40,8 @@ enum
{
PROP_LAYER_ONLY = GIMP_RECTANGLE_OPTIONS_PROP_LAST + 1,
PROP_ALLOW_GROWING,
- PROP_FILL_TYPE
+ PROP_FILL_TYPE,
+ PROP_DELETE_PIXELS
};
@@ -96,6 +97,13 @@ gimp_crop_options_class_init (GimpCropOptionsClass *klass)
FALSE,
GIMP_PARAM_STATIC_STRINGS);
+ GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_DELETE_PIXELS,
+ "delete-pixels",
+ _("Delete cropped pixels"),
+ _("Discard layer data that falls out of the crop region"),
+ TRUE,
+ GIMP_PARAM_STATIC_STRINGS);
+
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_ALLOW_GROWING,
"allow-growing",
_("Allow growing"),
@@ -139,6 +147,10 @@ gimp_crop_options_set_property (GObject *object,
options->layer_only = g_value_get_boolean (value);
break;
+ case PROP_DELETE_PIXELS:
+ options->delete_pixels = g_value_get_boolean (value);
+ break;
+
case PROP_ALLOW_GROWING:
options->allow_growing = g_value_get_boolean (value);
break;
@@ -167,6 +179,10 @@ gimp_crop_options_get_property (GObject *object,
g_value_set_boolean (value, options->layer_only);
break;
+ case PROP_DELETE_PIXELS:
+ g_value_set_boolean (value, options->delete_pixels);
+ break;
+
case PROP_ALLOW_GROWING:
g_value_set_boolean (value, options->allow_growing);
break;
@@ -188,6 +204,7 @@ gimp_crop_options_gui (GimpToolOptions *tool_options)
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
GtkWidget *vbox_rectangle;
GtkWidget *button;
+ GtkWidget *button2;
GtkWidget *combo;
GtkWidget *frame;
@@ -195,6 +212,15 @@ gimp_crop_options_gui (GimpToolOptions *tool_options)
button = gimp_prop_check_button_new (config, "layer-only", NULL);
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ /* delete pixels toggle */
+ button2 = gimp_prop_check_button_new (config, "delete-pixels", NULL);
+ gtk_box_pack_start (GTK_BOX (vbox), button2, FALSE, FALSE, 0);
+
+ g_object_bind_property (G_OBJECT (config), "layer-only",
+ G_OBJECT (button2), "sensitive",
+ G_BINDING_SYNC_CREATE |
+ G_BINDING_INVERT_BOOLEAN);
+
/* fill type combo */
combo = gimp_prop_enum_combo_box_new (config, "fill-type", 0, 0);
gimp_int_combo_box_set_label (GIMP_INT_COMBO_BOX (combo), _("Fill with"));
diff --git a/app/tools/gimpcropoptions.h b/app/tools/gimpcropoptions.h
index ca4b5d3ef6..e123dca789 100644
--- a/app/tools/gimpcropoptions.h
+++ b/app/tools/gimpcropoptions.h
@@ -47,6 +47,9 @@ struct _GimpCropOptions
/* How to fill new areas created by 'allow_growing. */
GimpFillType fill_type;
+
+ /* Whether to discard layer data that falls out of the crop region */
+ gboolean delete_pixels;
};
diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c
index 40863f22f1..9e103a86b4 100644
--- a/app/tools/gimpcroptool.c
+++ b/app/tools/gimpcroptool.c
@@ -477,7 +477,7 @@ gimp_crop_tool_commit (GimpCropTool *crop_tool)
{
gimp_image_crop (image,
GIMP_CONTEXT (options), GIMP_FILL_TRANSPARENT,
- x, y, w, h, TRUE);
+ x, y, w, h, options->delete_pixels);
}
gimp_image_flush (image);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]