app: in GimpFilterTool, consolidate drawable-filter option setup
In GimpFilterTool, move all the drawable-filter option setup to a new gimp_filter_tool_update_filter() function, and call it whenever the drawable-filter's options need to be updated. This avoids duplicating logic in various places.
This commit is contained in:
@ -188,6 +188,8 @@ static void gimp_filter_tool_response (GimpToolGui *gui,
|
|||||||
gint response_id,
|
gint response_id,
|
||||||
GimpFilterTool *filter_tool);
|
GimpFilterTool *filter_tool);
|
||||||
|
|
||||||
|
static void gimp_filter_tool_update_filter (GimpFilterTool *filter_tool);
|
||||||
|
|
||||||
static void gimp_filter_tool_set_has_settings (GimpFilterTool *filter_tool,
|
static void gimp_filter_tool_set_has_settings (GimpFilterTool *filter_tool,
|
||||||
gboolean has_settings);
|
gboolean has_settings);
|
||||||
|
|
||||||
@ -778,37 +780,27 @@ gimp_filter_tool_options_notify (GimpTool *tool,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_drawable_filter_set_preview (filter_tool->filter,
|
gimp_filter_tool_update_filter (filter_tool);
|
||||||
filter_options->preview_split,
|
|
||||||
filter_options->preview_alignment,
|
|
||||||
filter_options->preview_position);
|
|
||||||
|
|
||||||
if (filter_options->preview_split)
|
if (filter_options->preview_split)
|
||||||
gimp_filter_tool_add_guide (filter_tool);
|
gimp_filter_tool_add_guide (filter_tool);
|
||||||
else
|
else
|
||||||
gimp_filter_tool_remove_guide (filter_tool);
|
gimp_filter_tool_remove_guide (filter_tool);
|
||||||
}
|
}
|
||||||
else if (! strcmp (pspec->name, "preview-alignment") &&
|
else if (! strcmp (pspec->name, "preview-alignment") ||
|
||||||
filter_tool->filter)
|
! strcmp (pspec->name, "preview-position"))
|
||||||
{
|
{
|
||||||
gimp_drawable_filter_set_preview (filter_tool->filter,
|
gimp_filter_tool_update_filter (filter_tool);
|
||||||
filter_options->preview_split,
|
|
||||||
filter_options->preview_alignment,
|
|
||||||
filter_options->preview_position);
|
|
||||||
|
|
||||||
if (filter_options->preview_split)
|
if (filter_options->preview_split)
|
||||||
gimp_filter_tool_move_guide (filter_tool);
|
gimp_filter_tool_move_guide (filter_tool);
|
||||||
}
|
}
|
||||||
else if (! strcmp (pspec->name, "preview-position") &&
|
else if (! strcmp (pspec->name, "clip") ||
|
||||||
filter_tool->filter)
|
! strcmp (pspec->name, "region") ||
|
||||||
|
! strcmp (pspec->name, "color-managed") ||
|
||||||
|
! strcmp (pspec->name, "gamma-hack"))
|
||||||
{
|
{
|
||||||
gimp_drawable_filter_set_preview (filter_tool->filter,
|
gimp_filter_tool_update_filter (filter_tool);
|
||||||
filter_options->preview_split,
|
|
||||||
filter_options->preview_alignment,
|
|
||||||
filter_options->preview_position);
|
|
||||||
|
|
||||||
if (filter_options->preview_split)
|
|
||||||
gimp_filter_tool_move_guide (filter_tool);
|
|
||||||
}
|
}
|
||||||
else if (! strcmp (pspec->name, "controller") &&
|
else if (! strcmp (pspec->name, "controller") &&
|
||||||
filter_tool->widget)
|
filter_tool->widget)
|
||||||
@ -816,35 +808,6 @@ gimp_filter_tool_options_notify (GimpTool *tool,
|
|||||||
gimp_tool_widget_set_visible (filter_tool->widget,
|
gimp_tool_widget_set_visible (filter_tool->widget,
|
||||||
filter_options->controller);
|
filter_options->controller);
|
||||||
}
|
}
|
||||||
else if (! strcmp (pspec->name, "clip") &&
|
|
||||||
filter_tool->filter)
|
|
||||||
{
|
|
||||||
gimp_drawable_filter_set_clip (filter_tool->filter,
|
|
||||||
filter_options->clip ==
|
|
||||||
GIMP_TRANSFORM_RESIZE_CLIP ||
|
|
||||||
! gimp_drawable_has_alpha (
|
|
||||||
tool->drawable));
|
|
||||||
}
|
|
||||||
else if (! strcmp (pspec->name, "region") &&
|
|
||||||
filter_tool->filter)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
gimp_drawable_filter_set_color_managed (filter_tool->filter,
|
|
||||||
filter_options->color_managed);
|
|
||||||
}
|
|
||||||
else if (! strcmp (pspec->name, "gamma-hack") &&
|
|
||||||
filter_tool->filter)
|
|
||||||
{
|
|
||||||
gimp_drawable_filter_set_gamma_hack (filter_tool->filter,
|
|
||||||
filter_options->gamma_hack);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
@ -1137,17 +1100,7 @@ gimp_filter_tool_create_filter (GimpFilterTool *filter_tool)
|
|||||||
filter_tool->operation,
|
filter_tool->operation,
|
||||||
gimp_tool_get_icon_name (tool));
|
gimp_tool_get_icon_name (tool));
|
||||||
|
|
||||||
gimp_drawable_filter_set_clip (filter_tool->filter,
|
gimp_filter_tool_update_filter (filter_tool);
|
||||||
options->clip ==
|
|
||||||
GIMP_TRANSFORM_RESIZE_CLIP ||
|
|
||||||
! gimp_drawable_has_alpha (
|
|
||||||
tool->drawable));
|
|
||||||
gimp_drawable_filter_set_region (filter_tool->filter,
|
|
||||||
options->region);
|
|
||||||
gimp_drawable_filter_set_color_managed (filter_tool->filter,
|
|
||||||
options->color_managed);
|
|
||||||
gimp_drawable_filter_set_gamma_hack (filter_tool->filter,
|
|
||||||
options->gamma_hack);
|
|
||||||
|
|
||||||
g_signal_connect (filter_tool->filter, "flush",
|
g_signal_connect (filter_tool->filter, "flush",
|
||||||
G_CALLBACK (gimp_filter_tool_flush),
|
G_CALLBACK (gimp_filter_tool_flush),
|
||||||
@ -1438,6 +1391,32 @@ 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);
|
||||||
|
|
||||||
|
if (! filter_tool->filter)
|
||||||
|
return;
|
||||||
|
|
||||||
|
gimp_drawable_filter_set_clip (filter_tool->filter,
|
||||||
|
options->clip ==
|
||||||
|
GIMP_TRANSFORM_RESIZE_CLIP ||
|
||||||
|
! gimp_drawable_has_alpha (
|
||||||
|
tool->drawable));
|
||||||
|
gimp_drawable_filter_set_region (filter_tool->filter,
|
||||||
|
options->region);
|
||||||
|
gimp_drawable_filter_set_preview (filter_tool->filter,
|
||||||
|
options->preview_split,
|
||||||
|
options->preview_alignment,
|
||||||
|
options->preview_position);
|
||||||
|
gimp_drawable_filter_set_color_managed (filter_tool->filter,
|
||||||
|
options->color_managed);
|
||||||
|
gimp_drawable_filter_set_gamma_hack (filter_tool->filter,
|
||||||
|
options->gamma_hack);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gimp_filter_tool_set_has_settings (GimpFilterTool *filter_tool,
|
gimp_filter_tool_set_has_settings (GimpFilterTool *filter_tool,
|
||||||
gboolean has_settings)
|
gboolean has_settings)
|
||||||
|
Reference in New Issue
Block a user