[gimp/gimp-2-10] app: add GimpFilterTool::region_changed() virtual function
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add GimpFilterTool::region_changed() virtual function
- Date: Thu, 6 Jun 2019 07:15:29 +0000 (UTC)
commit 0d7a57d7820667bc2c399310dd9d89dbbc4e5008
Author: Ell <ell_se yahoo com>
Date: Thu Jun 6 02:58:48 2019 -0400
app: add GimpFilterTool::region_changed() virtual function
Add a new GimpFilterTool::region_changed() virtual function, which
gets called whenever the filter region changes, either due to a
change to the tool's "region" option, or a change to the image
mask.
Override GimpFilterTool::region_changed() in GimpOperationTool and
GimpOffsetTool, instead of listening to a change to the "region"
option in GimpTool::options_notify(), so that the tools are
properly updated when the image mask changes.
(cherry picked from commit 066827e23c4e72a7483061de1ce28da393f4692a)
app/tools/gimpfiltertool.c | 23 ++++++++++++--
app/tools/gimpfiltertool.h | 1 +
app/tools/gimpoffsettool.c | 47 ++++++++++++-----------------
app/tools/gimpoperationtool.c | 70 ++++++++++++++++++-------------------------
4 files changed, 70 insertions(+), 71 deletions(-)
---
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index 4eb4a12917..1a2dfb65af 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -156,6 +156,8 @@ static void gimp_filter_tool_reset (GimpFilterTool *filter_to
static void gimp_filter_tool_create_filter (GimpFilterTool *filter_tool);
+static void gimp_filter_tool_region_changed (GimpFilterTool *filter_tool);
+
static void gimp_filter_tool_flush (GimpDrawableFilter *filter,
GimpFilterTool *filter_tool);
static void gimp_filter_tool_config_notify (GObject *object,
@@ -456,14 +458,14 @@ gimp_filter_tool_initialize (GimpTool *tool,
gimp_tool_gui_show (filter_tool->gui);
- gimp_filter_tool_create_filter (filter_tool);
-
g_signal_connect_object (image, "mask-changed",
G_CALLBACK (gimp_filter_tool_mask_changed),
filter_tool, 0);
gimp_filter_tool_mask_changed (image, filter_tool);
+ gimp_filter_tool_create_filter (filter_tool);
+
return TRUE;
}
@@ -806,6 +808,8 @@ gimp_filter_tool_options_notify (GimpTool *tool,
{
gimp_drawable_filter_set_region (filter_tool->filter,
filter_options->region);
+
+ gimp_filter_tool_region_changed (filter_tool);
}
else if (! strcmp (pspec->name, "color-managed") &&
filter_tool->filter)
@@ -1122,6 +1126,16 @@ gimp_filter_tool_create_filter (GimpFilterTool *filter_tool)
gimp_drawable_filter_apply (filter_tool->filter, NULL);
}
+static void
+gimp_filter_tool_region_changed (GimpFilterTool *filter_tool)
+{
+ if (filter_tool->filter &&
+ GIMP_FILTER_TOOL_GET_CLASS (filter_tool)->region_changed)
+ {
+ GIMP_FILTER_TOOL_GET_CLASS (filter_tool)->region_changed (filter_tool);
+ }
+}
+
static void
gimp_filter_tool_flush (GimpDrawableFilter *filter,
GimpFilterTool *filter_tool)
@@ -1146,6 +1160,8 @@ static void
gimp_filter_tool_mask_changed (GimpImage *image,
GimpFilterTool *filter_tool)
{
+ GimpFilterOptions *options = GIMP_FILTER_TOOL_GET_OPTIONS (filter_tool);
+
if (filter_tool->gui)
{
GimpChannel *mask = gimp_image_get_mask (image);
@@ -1153,6 +1169,9 @@ gimp_filter_tool_mask_changed (GimpImage *image,
gtk_widget_set_sensitive (filter_tool->region_combo,
! gimp_channel_is_empty (mask));
}
+
+ if (options->region == GIMP_FILTER_REGION_SELECTION)
+ gimp_filter_tool_region_changed (filter_tool);
}
static void
diff --git a/app/tools/gimpfiltertool.h b/app/tools/gimpfiltertool.h
index a3eaa4fc8e..feb6df685d 100644
--- a/app/tools/gimpfiltertool.h
+++ b/app/tools/gimpfiltertool.h
@@ -89,6 +89,7 @@ struct _GimpFilterToolClass
GOutputStream *output,
GError **error);
+ void (* region_changed) (GimpFilterTool *filter_tool);
void (* color_picked) (GimpFilterTool *filter_tool,
gpointer identifier,
gdouble x,
diff --git a/app/tools/gimpoffsettool.c b/app/tools/gimpoffsettool.c
index 45c4565d71..c1d6e3d783 100644
--- a/app/tools/gimpoffsettool.c
+++ b/app/tools/gimpoffsettool.c
@@ -78,9 +78,6 @@ static void gimp_offset_tool_cursor_update (GimpTool
const GimpCoords *coords,
GdkModifierType state,
GimpDisplay *display);
-static void gimp_offset_tool_options_notify (GimpTool *tool,
- GimpToolOptions *options,
- const GParamSpec *pspec);
static gchar * gimp_offset_tool_get_operation (GimpFilterTool *filter_tool,
gchar **description);
@@ -88,6 +85,7 @@ static void gimp_offset_tool_dialog (GimpFilterTool
static void gimp_offset_tool_config_notify (GimpFilterTool *filter_tool,
GimpConfig *config,
const GParamSpec *pspec);
+static void gimp_offset_tool_region_changed (GimpFilterTool *filter_tool);
static void gimp_offset_tool_offset_changed (GimpSizeEntry *se,
GimpOffsetTool *offset_tool);
@@ -142,18 +140,18 @@ gimp_offset_tool_class_init (GimpOffsetToolClass *klass)
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpFilterToolClass *filter_tool_class = GIMP_FILTER_TOOL_CLASS (klass);
- tool_class->initialize = gimp_offset_tool_initialize;
- tool_class->control = gimp_offset_tool_control;
- tool_class->button_press = gimp_offset_tool_button_press;
- tool_class->button_release = gimp_offset_tool_button_release;
- tool_class->motion = gimp_offset_tool_motion;
- tool_class->oper_update = gimp_offset_tool_oper_update;
- tool_class->cursor_update = gimp_offset_tool_cursor_update;
- tool_class->options_notify = gimp_offset_tool_options_notify;
-
- filter_tool_class->get_operation = gimp_offset_tool_get_operation;
- filter_tool_class->dialog = gimp_offset_tool_dialog;
- filter_tool_class->config_notify = gimp_offset_tool_config_notify;
+ tool_class->initialize = gimp_offset_tool_initialize;
+ tool_class->control = gimp_offset_tool_control;
+ tool_class->button_press = gimp_offset_tool_button_press;
+ tool_class->button_release = gimp_offset_tool_button_release;
+ tool_class->motion = gimp_offset_tool_motion;
+ tool_class->oper_update = gimp_offset_tool_oper_update;
+ tool_class->cursor_update = gimp_offset_tool_cursor_update;
+
+ filter_tool_class->get_operation = gimp_offset_tool_get_operation;
+ filter_tool_class->dialog = gimp_offset_tool_dialog;
+ filter_tool_class->config_notify = gimp_offset_tool_config_notify;
+ filter_tool_class->region_changed = gimp_offset_tool_region_changed;
}
static void
@@ -443,19 +441,6 @@ gimp_offset_tool_cursor_update (GimpTool *tool,
}
}
-static void
-gimp_offset_tool_options_notify (GimpTool *tool,
- GimpToolOptions *options,
- const GParamSpec *pspec)
-{
- GimpOffsetTool *offset_tool = GIMP_OFFSET_TOOL (tool);
-
- GIMP_TOOL_CLASS (parent_class)->options_notify (tool, options, pspec);
-
- if (! strcmp (pspec->name, "region"))
- gimp_offset_tool_update (offset_tool);
-}
-
static void
gimp_offset_tool_dialog (GimpFilterTool *filter_tool)
{
@@ -579,6 +564,12 @@ gimp_offset_tool_config_notify (GimpFilterTool *filter_tool,
config, pspec);
}
+static void
+gimp_offset_tool_region_changed (GimpFilterTool *filter_tool)
+{
+ gimp_offset_tool_update (GIMP_OFFSET_TOOL (filter_tool));
+}
+
static void
gimp_offset_tool_offset_changed (GimpSizeEntry *se,
GimpOffsetTool *offset_tool)
diff --git a/app/tools/gimpoperationtool.c b/app/tools/gimpoperationtool.c
index 17ac2f1634..eae2184058 100644
--- a/app/tools/gimpoperationtool.c
+++ b/app/tools/gimpoperationtool.c
@@ -78,9 +78,6 @@ static gboolean gimp_operation_tool_initialize (GimpTool
static void gimp_operation_tool_control (GimpTool *tool,
GimpToolAction action,
GimpDisplay *display);
-static void gimp_operation_tool_options_notify (GimpTool *tool,
- GimpToolOptions *options,
- const GParamSpec *pspec);
static gchar * gimp_operation_tool_get_operation (GimpFilterTool *filter_tool,
gchar **description);
@@ -88,6 +85,7 @@ static void gimp_operation_tool_dialog (GimpFilterTool
static void gimp_operation_tool_reset (GimpFilterTool *filter_tool);
static void gimp_operation_tool_set_config (GimpFilterTool *filter_tool,
GimpConfig *config);
+static void gimp_operation_tool_region_changed (GimpFilterTool *filter_tool);
static void gimp_operation_tool_color_picked (GimpFilterTool *filter_tool,
gpointer identifier,
gdouble x,
@@ -150,17 +148,17 @@ gimp_operation_tool_class_init (GimpOperationToolClass *klass)
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
GimpFilterToolClass *filter_tool_class = GIMP_FILTER_TOOL_CLASS (klass);
- object_class->finalize = gimp_operation_tool_finalize;
+ object_class->finalize = gimp_operation_tool_finalize;
- tool_class->initialize = gimp_operation_tool_initialize;
- tool_class->control = gimp_operation_tool_control;
- tool_class->options_notify = gimp_operation_tool_options_notify;
+ tool_class->initialize = gimp_operation_tool_initialize;
+ tool_class->control = gimp_operation_tool_control;
- filter_tool_class->get_operation = gimp_operation_tool_get_operation;
- filter_tool_class->dialog = gimp_operation_tool_dialog;
- filter_tool_class->reset = gimp_operation_tool_reset;
- filter_tool_class->set_config = gimp_operation_tool_set_config;
- filter_tool_class->color_picked = gimp_operation_tool_color_picked;
+ filter_tool_class->get_operation = gimp_operation_tool_get_operation;
+ filter_tool_class->dialog = gimp_operation_tool_dialog;
+ filter_tool_class->reset = gimp_operation_tool_reset;
+ filter_tool_class->set_config = gimp_operation_tool_set_config;
+ filter_tool_class->region_changed = gimp_operation_tool_region_changed;
+ filter_tool_class->color_picked = gimp_operation_tool_color_picked;
}
static void
@@ -241,35 +239,6 @@ gimp_operation_tool_control (GimpTool *tool,
GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
}
-static void
-gimp_operation_tool_options_notify (GimpTool *tool,
- GimpToolOptions *options,
- const GParamSpec *pspec)
-{
- GimpOperationTool *op_tool = GIMP_OPERATION_TOOL (tool);
-
- GIMP_TOOL_CLASS (parent_class)->options_notify (tool, options, pspec);
-
- if (! strcmp (pspec->name, "region"))
- {
- GimpFilterTool *filter_tool = GIMP_FILTER_TOOL (tool);
-
- /* when the region changes, do we want the operation's on-canvas
- * controller to move to a new position, or the operation to
- * change its properties to match the on-canvas controller?
- *
- * decided to leave the on-canvas controller where it is and
- * pretend it has changed, so the operation is updated
- * accordingly...
- */
- if (filter_tool->widget)
- g_signal_emit_by_name (filter_tool->widget, "changed");
-
- if (filter_tool->config && tool->drawable)
- gimp_operation_tool_sync_op (op_tool, FALSE);
- }
-}
-
static gchar *
gimp_operation_tool_get_operation (GimpFilterTool *filter_tool,
gchar **description)
@@ -358,6 +327,25 @@ gimp_operation_tool_set_config (GimpFilterTool *filter_tool,
gimp_operation_tool_relink_chains (op_tool);
}
+static void
+gimp_operation_tool_region_changed (GimpFilterTool *filter_tool)
+{
+ GimpOperationTool *op_tool = GIMP_OPERATION_TOOL (filter_tool);
+
+ /* when the region changes, do we want the operation's on-canvas
+ * controller to move to a new position, or the operation to
+ * change its properties to match the on-canvas controller?
+ *
+ * decided to leave the on-canvas controller where it is and
+ * pretend it has changed, so the operation is updated
+ * accordingly...
+ */
+ if (filter_tool->widget)
+ g_signal_emit_by_name (filter_tool->widget, "changed");
+
+ gimp_operation_tool_sync_op (op_tool, FALSE);
+}
+
static void
gimp_operation_tool_color_picked (GimpFilterTool *filter_tool,
gpointer identifier,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]