app: more code in paint and brightness-contrast tool to port.

These 2 tools only work on single drawable at once. Yet slowly getting
rid of all usage of gimp_image_get_active_drawable().
This commit is contained in:
Jehan 2020-08-01 18:24:15 +02:00
parent ac0287e2f3
commit 1fa951127e
2 changed files with 16 additions and 5 deletions

View File

@ -127,16 +127,20 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool,
GimpDisplay *display,
GError **error)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
GimpImage *image = gimp_display_get_image (display);
GimpDrawable *drawable = gimp_image_get_active_drawable (image);
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (tool);
GimpImage *image = gimp_display_get_image (display);
GList *drawables;
if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error))
{
return FALSE;
}
if (gimp_drawable_get_component_type (drawable) == GIMP_COMPONENT_TYPE_U8)
drawables = gimp_image_get_selected_drawables (image);
/* Single drawable selection has been checked in parent initialize(). */
g_return_val_if_fail (g_list_length (drawables) == 1, FALSE);
if (gimp_drawable_get_component_type (drawables->data) == GIMP_COMPONENT_TYPE_U8)
{
gimp_prop_widget_set_factor (bc_tool->brightness_scale,
127.0, 1.0, 8.0, 0);
@ -151,6 +155,8 @@ gimp_brightness_contrast_tool_initialize (GimpTool *tool,
0.5, 0.01, 0.1, 3);
}
g_list_free (drawables);
return TRUE;
}

View File

@ -231,6 +231,7 @@ gimp_paint_tool_paint_start (GimpPaintTool *paint_tool,
GimpDisplayShell *shell;
GimpImage *image;
GimpDrawable *drawable;
GList *drawables;
GimpCoords curr_coords;
gint off_x, off_y;
@ -246,10 +247,14 @@ gimp_paint_tool_paint_start (GimpPaintTool *paint_tool,
core = paint_tool->core;
shell = gimp_display_get_shell (display);
image = gimp_display_get_image (display);
drawable = gimp_image_get_active_drawable (image);
drawables = gimp_image_get_selected_drawables (image);
g_return_val_if_fail (g_list_length (drawables) == 1, FALSE);
curr_coords = *coords;
drawable = drawables->data;
g_list_free (drawables);
gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y);
curr_coords.x -= off_x;