[gimp/gimp-2-10] app: in GimpFilterTool, store common settings in GimpOperationSettings
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: in GimpFilterTool, store common settings in GimpOperationSettings
- Date: Tue, 7 Apr 2020 16:46:46 +0000 (UTC)
commit bdbce2d23502efbd1334b1838c66e1aac3e0423d
Author: Ell <ell_se yahoo com>
Date: Tue Apr 7 18:23:21 2020 +0300
app: in GimpFilterTool, store common settings in GimpOperationSettings
Remove the common operation settings from GimpFilterOptions, and
instead, in GimpFilterTool, store these settings in the operation's
config object, which is now a GimpOperationSettings subclass, as
per last commit.
app/tools/gimpfilteroptions.c | 70 +------------
app/tools/gimpfilteroptions.h | 16 ++-
app/tools/gimpfiltertool.c | 236 +++++++++++++++++++++++++-----------------
app/tools/gimpfiltertool.h | 1 +
4 files changed, 148 insertions(+), 175 deletions(-)
---
diff --git a/app/tools/gimpfilteroptions.c b/app/tools/gimpfilteroptions.c
index fc491f4d7b..e2c4a48d91 100644
--- a/app/tools/gimpfilteroptions.c
+++ b/app/tools/gimpfilteroptions.c
@@ -36,11 +36,7 @@ enum
PROP_PREVIEW_SPLIT,
PROP_PREVIEW_SPLIT_ALIGNMENT,
PROP_PREVIEW_SPLIT_POSITION,
- PROP_CONTROLLER,
- PROP_CLIP,
- PROP_REGION,
- PROP_COLOR_MANAGED,
- PROP_GAMMA_HACK
+ PROP_CONTROLLER
};
@@ -104,38 +100,6 @@ gimp_filter_options_class_init (GimpFilterOptionsClass *klass)
_("Show on-canvas filter controls"),
TRUE,
GIMP_PARAM_STATIC_STRINGS);
-
- GIMP_CONFIG_PROP_ENUM (object_class, PROP_CLIP,
- "clip",
- _("Clipping"),
- _("How to clip"),
- GIMP_TYPE_TRANSFORM_RESIZE,
- GIMP_TRANSFORM_RESIZE_ADJUST,
- GIMP_PARAM_STATIC_STRINGS);
-
- g_object_class_install_property (object_class, PROP_REGION,
- g_param_spec_enum ("region",
- NULL, NULL,
- GIMP_TYPE_FILTER_REGION,
- GIMP_FILTER_REGION_SELECTION,
- GIMP_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class, PROP_COLOR_MANAGED,
- g_param_spec_boolean ("color-managed",
- _("Color _managed"),
- NULL,
- FALSE,
- GIMP_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
-
- g_object_class_install_property (object_class, PROP_GAMMA_HACK,
- g_param_spec_boolean ("gamma-hack",
- "Gamma hack (temp hack, please ignore)",
- NULL,
- FALSE,
- GIMP_PARAM_READWRITE |
- G_PARAM_CONSTRUCT));
}
static void
@@ -173,22 +137,6 @@ gimp_filter_options_set_property (GObject *object,
options->controller = g_value_get_boolean (value);
break;
- case PROP_CLIP:
- options->clip = g_value_get_enum (value);
- break;
-
- case PROP_REGION:
- options->region = g_value_get_enum (value);
- break;
-
- case PROP_COLOR_MANAGED:
- options->color_managed = g_value_get_boolean (value);
- break;
-
- case PROP_GAMMA_HACK:
- options->gamma_hack = g_value_get_boolean (value);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@@ -225,22 +173,6 @@ gimp_filter_options_get_property (GObject *object,
g_value_set_boolean (value, options->controller);
break;
- case PROP_CLIP:
- g_value_set_enum (value, options->clip);
- break;
-
- case PROP_REGION:
- g_value_set_enum (value, options->region);
- break;
-
- case PROP_COLOR_MANAGED:
- g_value_set_boolean (value, options->color_managed);
- break;
-
- case PROP_GAMMA_HACK:
- g_value_set_boolean (value, options->gamma_hack);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
diff --git a/app/tools/gimpfilteroptions.h b/app/tools/gimpfilteroptions.h
index 6518aefa2d..9cda679d8d 100644
--- a/app/tools/gimpfilteroptions.h
+++ b/app/tools/gimpfilteroptions.h
@@ -34,17 +34,13 @@ typedef struct _GimpFilterOptionsClass GimpFilterOptionsClass;
struct _GimpFilterOptions
{
- GimpColorOptions parent_instance;
+ GimpColorOptions parent_instance;
- gboolean preview;
- gboolean preview_split;
- GimpAlignmentType preview_split_alignment;
- gdouble preview_split_position;
- gboolean controller;
- GimpTransformResize clip;
- GimpFilterRegion region;
- gboolean color_managed;
- gboolean gamma_hack;
+ gboolean preview;
+ gboolean preview_split;
+ GimpAlignmentType preview_split_alignment;
+ gdouble preview_split_position;
+ gboolean controller;
};
struct _GimpFilterOptionsClass
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index aeffe31333..435bec9ffd 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -159,6 +159,9 @@ static void gimp_filter_tool_reset (GimpFilterTool *filter_to
static void gimp_filter_tool_create_filter (GimpFilterTool *filter_tool);
static void gimp_filter_tool_update_dialog (GimpFilterTool *filter_tool);
+static void gimp_filter_tool_update_dialog_operation_settings
+ (GimpFilterTool *filter_tool);
+
static void gimp_filter_tool_region_changed (GimpFilterTool *filter_tool);
@@ -323,10 +326,6 @@ gimp_filter_tool_initialize (GimpTool *tool,
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *toggle;
- GtkWidget *expander;
- GtkWidget *frame;
- GtkWidget *vbox2;
- GtkWidget *combo;
/* disabled for at least GIMP 2.8 */
filter_tool->overlay = FALSE;
@@ -400,56 +399,14 @@ gimp_filter_tool_initialize (GimpTool *tool,
if (filter_tool->widget)
gtk_widget_show (filter_tool->controller_toggle);
- /* The Color Options expander */
- expander = gtk_expander_new (_("Advanced Color Options"));
- gtk_box_pack_end (GTK_BOX (vbox), expander, FALSE, FALSE, 0);
-
- g_object_bind_property (G_OBJECT (image->gimp->config),
- "filter-tool-show-color-options",
- G_OBJECT (expander), "visible",
- G_BINDING_SYNC_CREATE);
-
- frame = gimp_frame_new (NULL);
- gtk_container_add (GTK_CONTAINER (expander), frame);
- gtk_widget_show (frame);
-
- vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
- gtk_container_add (GTK_CONTAINER (frame), vbox2);
- gtk_widget_show (vbox2);
-
- /* The color managed combo */
- combo = gimp_prop_boolean_combo_box_new
- (G_OBJECT (tool_info->tool_options), "color-managed",
- _("Convert pixels to built-in sRGB to apply filter (slow)"),
- _("Assume pixels are built-in sRGB (ignore actual image color space)"));
- g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
- gtk_box_pack_start (GTK_BOX (vbox2), combo, FALSE, FALSE, 0);
- gtk_widget_show (combo);
-
- /* The gamma hack toggle */
- toggle = gimp_prop_check_button_new (G_OBJECT (tool_info->tool_options),
- "gamma-hack", NULL);
- gtk_box_pack_start (GTK_BOX (vbox2), toggle, FALSE, FALSE, 0);
- gtk_widget_show (toggle);
-
- /* The area combo */
- filter_tool->region_combo =
- gimp_prop_enum_combo_box_new (G_OBJECT (tool_info->tool_options),
- "region",
- 0, 0);
- gtk_box_pack_end (GTK_BOX (vbox), filter_tool->region_combo,
+ /* The operation-settings box */
+ filter_tool->operation_settings_box = gtk_box_new (
+ GTK_ORIENTATION_VERTICAL, 2);
+ gtk_box_pack_end (GTK_BOX (vbox), filter_tool->operation_settings_box,
FALSE, FALSE, 0);
+ gtk_widget_show (filter_tool->operation_settings_box);
- /* The clipping combo */
- filter_tool->clip_combo =
- gimp_prop_enum_combo_box_new (G_OBJECT (tool_info->tool_options),
- "clip",
- GIMP_TRANSFORM_RESIZE_ADJUST,
- GIMP_TRANSFORM_RESIZE_CLIP);
- gimp_int_combo_box_set_label (
- GIMP_INT_COMBO_BOX (filter_tool->clip_combo), _("Clipping"));
- gtk_box_pack_end (GTK_BOX (vbox), filter_tool->clip_combo,
- FALSE, FALSE, 0);
+ gimp_filter_tool_update_dialog_operation_settings (filter_tool);
/* Fill in subclass widgets */
gimp_filter_tool_dialog (filter_tool);
@@ -797,13 +754,6 @@ gimp_filter_tool_options_notify (GimpTool *tool,
if (filter_options->preview_split)
gimp_filter_tool_move_guide (filter_tool);
}
- else if (! strcmp (pspec->name, "clip") ||
- ! strcmp (pspec->name, "region") ||
- ! strcmp (pspec->name, "color-managed") ||
- ! strcmp (pspec->name, "gamma-hack"))
- {
- gimp_filter_tool_update_filter (filter_tool);
- }
else if (! strcmp (pspec->name, "controller") &&
filter_tool->widget)
{
@@ -928,6 +878,18 @@ static void
gimp_filter_tool_real_set_config (GimpFilterTool *filter_tool,
GimpConfig *config)
{
+ GimpFilterRegion region;
+
+ /* copy the "gimp-region" property first, to avoid incorrectly adjusting the
+ * copied operation properties in gimp_operation_tool_region_changed().
+ */
+ g_object_get (config,
+ "gimp-region", ®ion,
+ NULL);
+ g_object_set (filter_tool->config,
+ "gimp-region", region,
+ NULL);
+
gimp_config_copy (GIMP_CONFIG (config),
GIMP_CONFIG (filter_tool->config), 0);
@@ -948,8 +910,25 @@ gimp_filter_tool_real_config_notify (GimpFilterTool *filter_tool,
{
GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
- if (filter_tool->filter && options->preview)
- gimp_drawable_filter_apply (filter_tool->filter, NULL);
+ if (filter_tool->filter)
+ {
+ if (! strcmp (pspec->name, "gimp-clip") ||
+ ! strcmp (pspec->name, "gimp-color-managed") ||
+ ! strcmp (pspec->name, "gimp-gamma-hack"))
+ {
+ gimp_filter_tool_update_filter (filter_tool);
+ }
+ else if (! strcmp (pspec->name, "gimp-region"))
+ {
+ gimp_filter_tool_update_filter (filter_tool);
+
+ gimp_filter_tool_region_changed (filter_tool);
+ }
+ else if (options->preview)
+ {
+ gimp_drawable_filter_apply (filter_tool->filter, NULL);
+ }
+ }
}
static void
@@ -1068,6 +1047,85 @@ gimp_filter_tool_dialog (GimpFilterTool *filter_tool)
GIMP_FILTER_TOOL_GET_CLASS (filter_tool)->dialog (filter_tool);
}
+static void
+gimp_filter_tool_update_dialog_operation_settings (GimpFilterTool *filter_tool)
+{
+ GimpTool *tool = GIMP_TOOL (filter_tool);
+ GimpImage *image = gimp_display_get_image (tool->display);
+
+ if (filter_tool->operation_settings_box)
+ {
+ gimp_gtk_container_clear (
+ GTK_CONTAINER (filter_tool->operation_settings_box));
+
+ if (filter_tool->config)
+ {
+ GtkWidget *vbox;
+ GtkWidget *expander;
+ GtkWidget *frame;
+ GtkWidget *vbox2;
+ GtkWidget *combo;
+ GtkWidget *toggle;
+
+ vbox = filter_tool->operation_settings_box;
+
+ /* The clipping combo */
+ filter_tool->clip_combo =
+ gimp_prop_enum_combo_box_new (filter_tool->config,
+ "gimp-clip",
+ GIMP_TRANSFORM_RESIZE_ADJUST,
+ GIMP_TRANSFORM_RESIZE_CLIP);
+ gimp_int_combo_box_set_label (
+ GIMP_INT_COMBO_BOX (filter_tool->clip_combo), _("Clipping"));
+ gtk_box_pack_start (GTK_BOX (vbox), filter_tool->clip_combo,
+ FALSE, FALSE, 0);
+
+ /* The region combo */
+ filter_tool->region_combo =
+ gimp_prop_enum_combo_box_new (filter_tool->config,
+ "gimp-region",
+ 0, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), filter_tool->region_combo,
+ FALSE, FALSE, 0);
+
+ /* The Color Options expander */
+ expander = gtk_expander_new (_("Advanced Color Options"));
+ gtk_box_pack_start (GTK_BOX (vbox), expander,
+ FALSE, FALSE, 0);
+
+ g_object_bind_property (image->gimp->config,
+ "filter-tool-show-color-options",
+ expander, "visible",
+ G_BINDING_SYNC_CREATE);
+
+ frame = gimp_frame_new (NULL);
+ gtk_container_add (GTK_CONTAINER (expander), frame);
+ gtk_widget_show (frame);
+
+ vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
+ gtk_container_add (GTK_CONTAINER (frame), vbox2);
+ gtk_widget_show (vbox2);
+
+ /* The color managed combo */
+ combo = gimp_prop_boolean_combo_box_new (
+ filter_tool->config, "gimp-color-managed",
+ _("Convert pixels to built-in sRGB to apply filter (slow)"),
+ _("Assume pixels are built-in sRGB (ignore actual image color space)"));
+ g_object_set (combo, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
+ gtk_box_pack_start (GTK_BOX (vbox2), combo,
+ FALSE, FALSE, 0);
+ gtk_widget_show (combo);
+
+ /* The gamma hack toggle */
+ toggle = gimp_prop_check_button_new (filter_tool->config,
+ "gimp-gamma-hack", NULL);
+ gtk_box_pack_start (GTK_BOX (vbox2), toggle,
+ FALSE, FALSE, 0);
+ gtk_widget_show (toggle);
+ }
+ }
+}
+
static void
gimp_filter_tool_reset (GimpFilterTool *filter_tool)
{
@@ -1208,11 +1266,13 @@ static void
gimp_filter_tool_mask_changed (GimpImage *image,
GimpFilterTool *filter_tool)
{
- GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
+ GimpOperationSettings *settings;
+
+ settings = GIMP_OPERATION_SETTINGS (filter_tool->config);
gimp_filter_tool_update_dialog (filter_tool);
- if (options->region == GIMP_FILTER_REGION_SELECTION)
+ if (settings && settings->region == GIMP_FILTER_REGION_SELECTION)
gimp_filter_tool_region_changed (filter_tool);
}
@@ -1395,24 +1455,14 @@ gimp_filter_tool_response (GimpToolGui *gui,
static void
gimp_filter_tool_update_filter (GimpFilterTool *filter_tool)
{
- GimpTool *tool = GIMP_TOOL (filter_tool);
- GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
- gboolean add_alpha;
- gboolean clip;
+ GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
+ GimpOperationSettings *settings;
if (! filter_tool->filter)
return;
- add_alpha = gimp_drawable_supports_alpha (tool->drawable) &&
- gimp_gegl_node_has_key (filter_tool->operation, "needs-alpha");
- clip = options->clip == GIMP_TRANSFORM_RESIZE_CLIP ||
- ! (gimp_drawable_has_alpha (tool->drawable) ||
- add_alpha);
+ settings = GIMP_OPERATION_SETTINGS (filter_tool->config);
- gimp_drawable_filter_set_clip (filter_tool->filter,
- clip);
- gimp_drawable_filter_set_region (filter_tool->filter,
- options->region);
gimp_drawable_filter_set_preview (filter_tool->filter,
options->preview);
gimp_drawable_filter_set_preview_split (filter_tool->filter,
@@ -1420,11 +1470,11 @@ gimp_filter_tool_update_filter (GimpFilterTool *filter_tool)
options->preview_split_alignment,
options->preview_split_position);
gimp_drawable_filter_set_add_alpha (filter_tool->filter,
- add_alpha);
- gimp_drawable_filter_set_color_managed (filter_tool->filter,
- options->color_managed);
- gimp_drawable_filter_set_gamma_hack (filter_tool->filter,
- options->gamma_hack);
+ gimp_gegl_node_has_key (
+ filter_tool->operation,
+ "needs-alpha"));
+
+ gimp_operation_settings_sync_drawable_filter (settings, filter_tool->filter);
}
static void
@@ -1573,14 +1623,8 @@ gimp_filter_tool_get_operation (GimpFilterTool *filter_tool)
gimp_tool_get_icon_name (tool));
gimp_tool_gui_set_help_id (filter_tool->gui,
gimp_tool_get_help_id (tool));
- }
- if (gimp_gegl_node_is_point_operation (filter_tool->operation) &&
- ! gimp_gegl_node_has_key (filter_tool->operation, "position-dependent"))
- {
- g_object_set (GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool),
- "region", GIMP_FILTER_REGION_SELECTION,
- NULL);
+ gimp_filter_tool_update_dialog_operation_settings (filter_tool);
}
gimp_filter_tool_update_dialog (filter_tool);
@@ -1605,7 +1649,7 @@ gimp_filter_tool_set_config (GimpFilterTool *filter_tool,
GimpConfig *config)
{
g_return_if_fail (GIMP_IS_FILTER_TOOL (filter_tool));
- g_return_if_fail (GIMP_IS_SETTINGS (config));
+ g_return_if_fail (GIMP_IS_OPERATION_SETTINGS (config));
/* if the user didn't change a setting since the last set_config(),
* this handler is still connected
@@ -1890,15 +1934,17 @@ gimp_filter_tool_get_drawable_area (GimpFilterTool *filter_tool,
gint *drawable_offset_y,
GeglRectangle *drawable_area)
{
- GimpTool *tool;
- GimpDrawable *drawable;
+ GimpTool *tool;
+ GimpOperationSettings *settings;
+ GimpDrawable *drawable;
g_return_val_if_fail (GIMP_IS_FILTER_TOOL (filter_tool), FALSE);
g_return_val_if_fail (drawable_offset_x != NULL, FALSE);
g_return_val_if_fail (drawable_offset_y != NULL, FALSE);
g_return_val_if_fail (drawable_area != NULL, FALSE);
- tool = GIMP_TOOL (filter_tool);
+ tool = GIMP_TOOL (filter_tool);
+ settings = GIMP_OPERATION_SETTINGS (filter_tool->config);
*drawable_offset_x = 0;
*drawable_offset_y = 0;
@@ -1910,14 +1956,12 @@ gimp_filter_tool_get_drawable_area (GimpFilterTool *filter_tool,
drawable = tool->drawable;
- if (drawable)
+ if (drawable && settings)
{
- GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
-
gimp_item_get_offset (GIMP_ITEM (drawable),
drawable_offset_x, drawable_offset_y);
- switch (options->region)
+ switch (settings->region)
{
case GIMP_FILTER_REGION_SELECTION:
if (! gimp_item_mask_intersect (GIMP_ITEM (drawable),
diff --git a/app/tools/gimpfiltertool.h b/app/tools/gimpfiltertool.h
index 559f0288ac..b1c91cbae0 100644
--- a/app/tools/gimpfiltertool.h
+++ b/app/tools/gimpfiltertool.h
@@ -59,6 +59,7 @@ struct _GimpFilterTool
GimpToolGui *gui;
GtkWidget *settings_box;
GtkWidget *controller_toggle;
+ GtkWidget *operation_settings_box;
GtkWidget *clip_combo;
GtkWidget *region_combo;
GtkWidget *active_picker;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]