diff --git a/app/actions/config-commands.c b/app/actions/config-commands.c index ebacbc1a70..d11b0b42fb 100644 --- a/app/actions/config-commands.c +++ b/app/actions/config-commands.c @@ -34,7 +34,8 @@ config_use_gegl_cmd_callback (GtkAction *action, gpointer data) { GtkToggleAction *toggle_action = GTK_TOGGLE_ACTION (action); - Gimp *gimp = action_data_get_gimp (data); + Gimp *gimp = NULL; + return_if_no_gimp (gimp, data); g_object_set (gimp->config, "use-gegl", gtk_toggle_action_get_active (toggle_action), diff --git a/app/display/gimpdisplay-handlers.c b/app/display/gimpdisplay-handlers.c index 738dcb053d..4539f07297 100644 --- a/app/display/gimpdisplay-handlers.c +++ b/app/display/gimpdisplay-handlers.c @@ -30,36 +30,30 @@ /* local function prototypes */ -static void gimp_display_update_handler (GimpProjection *projection, - gboolean now, - gint x, - gint y, - gint w, - gint h, - GimpDisplay *display); -static void gimp_display_flush_handler (GimpImage *image, - gboolean invalidate_preview, - GimpDisplay *display); +static void gimp_display_update_handler (GimpProjection *projection, + gboolean now, + gint x, + gint y, + gint w, + gint h, + GimpDisplay *display); +static void gimp_display_flush_handler (GimpImage *image, + gboolean invalidate_preview, + GimpDisplay *display); /* public functions */ void -gimp_display_connect (GimpDisplay *display, - GimpImage *image) +gimp_display_connect (GimpDisplay *display) { + GimpImage *image; + g_return_if_fail (GIMP_IS_DISPLAY (display)); + + image = gimp_display_get_image (display); + g_return_if_fail (GIMP_IS_IMAGE (image)); - g_return_if_fail (display->image == NULL); - -#if 0 - g_print ("%s: image->ref_count before refing: %d\n", - G_STRFUNC, G_OBJECT (display->image)->ref_count); -#endif - - display->image = g_object_ref (image); - - image->disp_count++; g_signal_connect (gimp_image_get_projection (image), "update", G_CALLBACK (gimp_display_update_handler), @@ -76,9 +70,10 @@ gimp_display_disconnect (GimpDisplay *display) GimpImage *image; g_return_if_fail (GIMP_IS_DISPLAY (display)); - g_return_if_fail (GIMP_IS_IMAGE (display->image)); - image = display->image; + image = gimp_display_get_image (display); + + g_return_if_fail (GIMP_IS_IMAGE (image)); g_signal_handlers_disconnect_by_func (image, gimp_display_flush_handler, @@ -87,21 +82,6 @@ gimp_display_disconnect (GimpDisplay *display) g_signal_handlers_disconnect_by_func (gimp_image_get_projection (image), gimp_display_update_handler, display); - - image->disp_count--; - -#if 0 - g_print ("%s: image->ref_count before unrefing: %d\n", - G_STRFUNC, G_OBJECT (display->image)->ref_count); -#endif - - /* set display->image to NULL before unrefing because there may be code - * that listens for image removals and then iterates the display list - * to find a valid display. - */ - display->image = NULL; - - g_object_unref (image); } diff --git a/app/display/gimpdisplay-handlers.h b/app/display/gimpdisplay-handlers.h index 5ed3b3d63a..9b03c34939 100644 --- a/app/display/gimpdisplay-handlers.h +++ b/app/display/gimpdisplay-handlers.h @@ -19,8 +19,7 @@ #define __GIMP_DISPLAY_HANDLERS_H__ -void gimp_display_connect (GimpDisplay *display, - GimpImage *image); +void gimp_display_connect (GimpDisplay *display); void gimp_display_disconnect (GimpDisplay *display); diff --git a/app/display/gimpdisplay.c b/app/display/gimpdisplay.c index e13cc1f493..e1be80191c 100644 --- a/app/display/gimpdisplay.c +++ b/app/display/gimpdisplay.c @@ -406,11 +406,7 @@ gimp_display_new (Gimp *gimp, /* refs the image */ if (image) - { - private->instance = image->instance_count++; - - gimp_display_connect (display, image); - } + gimp_display_set_image (display, image); /* get an image window */ if (GIMP_GUI_CONFIG (display->config)->single_window_mode) @@ -614,39 +610,70 @@ gimp_display_set_image (GimpDisplay *display, { GimpDisplayPrivate *private; GimpImage *old_image = NULL; + GimpDisplayShell *shell; g_return_if_fail (GIMP_IS_DISPLAY (display)); g_return_if_fail (image == NULL || GIMP_IS_IMAGE (image)); private = GIMP_DISPLAY_GET_PRIVATE (display); + shell = gimp_display_get_shell (display); + if (display->image) { /* stop any active tool */ tool_manager_control_active (display->gimp, GIMP_TOOL_ACTION_HALT, display); - gimp_display_shell_disconnect (gimp_display_get_shell (display)); - - old_image = g_object_ref (display->image); + gimp_display_shell_disconnect (shell); gimp_display_disconnect (display); + + display->image->disp_count--; + + /* set display->image before unrefing because there may be code + * that listens for image removals and then iterates the + * display list to find a valid display. + */ + old_image = display->image; + +#if 0 + g_print ("%s: image->ref_count before unrefing: %d\n", + G_STRFUNC, G_OBJECT (old_image)->ref_count); +#endif } + display->image = image; + if (image) { +#if 0 + g_print ("%s: image->ref_count before refing: %d\n", + G_STRFUNC, G_OBJECT (image)->ref_count); +#endif + + g_object_ref (image); + private->instance = image->instance_count++; - gimp_display_connect (display, image); + image->disp_count++; + + gimp_display_connect (display); + + if (shell) + gimp_display_shell_connect (shell); } if (old_image) g_object_unref (old_image); - if (image) - gimp_display_shell_reconnect (gimp_display_get_shell (display)); - else - gimp_display_shell_icon_update (gimp_display_get_shell (display)); + if (shell) + { + if (image) + gimp_display_shell_reconnect (shell); + else + gimp_display_shell_icon_update (shell); + } if (old_image != image) g_object_notify (G_OBJECT (display), "image"); diff --git a/app/display/gimpdisplayshell-appearance.c b/app/display/gimpdisplayshell-appearance.c index 59ba2e168b..7d8356761e 100644 --- a/app/display/gimpdisplayshell-appearance.c +++ b/app/display/gimpdisplayshell-appearance.c @@ -299,7 +299,7 @@ gimp_display_shell_set_show_layer (GimpDisplayShell *shell, g_object_set (options, "show-layer-boundary", show, NULL); - gimp_display_shell_selection_layer_set_hidden (shell, ! show); + gimp_display_shell_selection_set_layer_hidden (shell, ! show); appearance_set_action_active (shell, "view-show-layer-boundary", show); } diff --git a/app/display/gimpdisplayshell-callbacks.c b/app/display/gimpdisplayshell-callbacks.c index bd86d6b380..18359ec639 100644 --- a/app/display/gimpdisplayshell-callbacks.c +++ b/app/display/gimpdisplayshell-callbacks.c @@ -2007,9 +2007,11 @@ gimp_display_shell_hscrollbar_update_range (GtkRange *range, (scroll == GTK_SCROLL_PAGE_FORWARD)) return FALSE; + g_object_freeze_notify (G_OBJECT (shell->hsbdata)); + gimp_display_shell_scroll_setup_hscrollbar (shell, value); - gtk_adjustment_changed (shell->hsbdata); + g_object_thaw_notify (G_OBJECT (shell->hsbdata)); /* emits "changed" */ return FALSE; } @@ -2028,9 +2030,11 @@ gimp_display_shell_vscrollbar_update_range (GtkRange *range, (scroll == GTK_SCROLL_PAGE_FORWARD)) return FALSE; + g_object_freeze_notify (G_OBJECT (shell->vsbdata)); + gimp_display_shell_scroll_setup_vscrollbar (shell, value); - gtk_adjustment_changed (shell->vsbdata); + g_object_thaw_notify (G_OBJECT (shell->vsbdata)); /* emits "changed" */ return FALSE; } diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c index 5cec9eb30e..79e77d4ced 100644 --- a/app/display/gimpdisplayshell-handlers.c +++ b/app/display/gimpdisplayshell-handlers.c @@ -295,7 +295,7 @@ gimp_display_shell_disconnect (GimpDisplayShell *shell) g_return_if_fail (GIMP_IS_IMAGE (image)); - gimp_display_shell_icon_idle_stop (shell); + gimp_display_shell_icon_update_stop (shell); if (shell->grid_gc) { @@ -572,7 +572,7 @@ static void gimp_display_shell_invalidate_preview_handler (GimpImage *image, GimpDisplayShell *shell) { - gimp_display_shell_icon_idle_update (shell); + gimp_display_shell_icon_update (shell); } static void diff --git a/app/display/gimpdisplayshell-icon.c b/app/display/gimpdisplayshell-icon.c index c046a508c4..a0675e41f6 100644 --- a/app/display/gimpdisplayshell-icon.c +++ b/app/display/gimpdisplayshell-icon.c @@ -24,7 +24,6 @@ #include "core/gimp.h" #include "core/gimpimage.h" -#include "core/gimpviewable.h" #include "gimpdisplay.h" #include "gimpdisplayshell.h" @@ -33,18 +32,51 @@ #define GIMP_DISPLAY_UPDATE_ICON_TIMEOUT 1000 -static gboolean gimp_display_shell_idle_update_icon (gpointer data); +static gboolean gimp_display_shell_icon_update_idle (gpointer data); +/* public functions */ + void gimp_display_shell_icon_update (GimpDisplayShell *shell) { - GimpImage *image; - GdkPixbuf *pixbuf = NULL; - g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); - image = gimp_display_get_image (shell->display); + gimp_display_shell_icon_update_stop (shell); + + if (gimp_display_get_image (shell->display)) + shell->icon_idle_id = g_timeout_add_full (G_PRIORITY_LOW, + GIMP_DISPLAY_UPDATE_ICON_TIMEOUT, + gimp_display_shell_icon_update_idle, + shell, + NULL); + else + gimp_display_shell_icon_update_idle (shell); +} + +void +gimp_display_shell_icon_update_stop (GimpDisplayShell *shell) +{ + g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); + + if (shell->icon_idle_id) + { + g_source_remove (shell->icon_idle_id); + shell->icon_idle_id = 0; + } +} + + +/* private functions */ + +static gboolean +gimp_display_shell_icon_update_idle (gpointer data) +{ + GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data); + GimpImage *image = gimp_display_get_image (shell->display); + GdkPixbuf *pixbuf = NULL; + + shell->icon_idle_id = 0; if (image) { @@ -71,43 +103,6 @@ gimp_display_shell_icon_update (GimpDisplayShell *shell) } g_object_set (shell, "icon", pixbuf, NULL); -} - -void -gimp_display_shell_icon_idle_update (GimpDisplayShell *shell) -{ - g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); - - if (shell->icon_idle_id) - g_source_remove (shell->icon_idle_id); - - shell->icon_idle_id = g_timeout_add_full (G_PRIORITY_LOW, - GIMP_DISPLAY_UPDATE_ICON_TIMEOUT, - gimp_display_shell_idle_update_icon, - shell, - NULL); -} - -void -gimp_display_shell_icon_idle_stop (GimpDisplayShell *shell) -{ - g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); - - if (shell->icon_idle_id) - { - g_source_remove (shell->icon_idle_id); - shell->icon_idle_id = 0; - } -} - -static gboolean -gimp_display_shell_idle_update_icon (gpointer data) -{ - GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data); - - shell->icon_idle_id = 0; - - gimp_display_shell_icon_update (shell); return FALSE; } diff --git a/app/display/gimpdisplayshell-icon.h b/app/display/gimpdisplayshell-icon.h index ba45f0fe1c..a94e72bd74 100644 --- a/app/display/gimpdisplayshell-icon.h +++ b/app/display/gimpdisplayshell-icon.h @@ -20,8 +20,7 @@ void gimp_display_shell_icon_update (GimpDisplayShell *shell); -void gimp_display_shell_icon_idle_update (GimpDisplayShell *shell); -void gimp_display_shell_icon_idle_stop (GimpDisplayShell *shell); +void gimp_display_shell_icon_update_stop (GimpDisplayShell *shell); #endif /* __GIMP_DISPLAY_SHELL_ICON_H__ */ diff --git a/app/display/gimpdisplayshell-scale.c b/app/display/gimpdisplayshell-scale.c index 816b9a075d..8522919466 100644 --- a/app/display/gimpdisplayshell-scale.c +++ b/app/display/gimpdisplayshell-scale.c @@ -134,24 +134,32 @@ gimp_display_shell_scale_update_scrollbars (GimpDisplayShell *shell) /* Horizontal scrollbar */ - shell->hsbdata->value = shell->offset_x; - shell->hsbdata->page_size = shell->disp_width; - shell->hsbdata->page_increment = shell->disp_width / 2; + g_object_freeze_notify (G_OBJECT (shell->hsbdata)); + + g_object_set (shell->hsbdata, + "value", (gdouble) shell->offset_x, + "page-size", (gdouble) shell->disp_width, + "page-increment", (gdouble) shell->disp_width / 2, + NULL); gimp_display_shell_scroll_setup_hscrollbar (shell, shell->offset_x); - gtk_adjustment_changed (shell->hsbdata); + g_object_thaw_notify (G_OBJECT (shell->hsbdata)); /* emits "changed" */ /* Vertcal scrollbar */ - shell->vsbdata->value = shell->offset_y; - shell->vsbdata->page_size = shell->disp_height; - shell->vsbdata->page_increment = shell->disp_height / 2; + g_object_freeze_notify (G_OBJECT (shell->vsbdata)); + + g_object_set (shell->vsbdata, + "value", (gdouble) shell->offset_y, + "page-size", (gdouble) shell->disp_height, + "page-increment", (gdouble) shell->disp_height / 2, + NULL); gimp_display_shell_scroll_setup_vscrollbar (shell, shell->offset_y); - gtk_adjustment_changed (shell->vsbdata); + g_object_thaw_notify (G_OBJECT (shell->vsbdata)); /* emits "changed" */ } /** diff --git a/app/display/gimpdisplayshell-scroll.c b/app/display/gimpdisplayshell-scroll.c index 3429fb5ec1..7cc4869158 100644 --- a/app/display/gimpdisplayshell-scroll.c +++ b/app/display/gimpdisplayshell-scroll.c @@ -546,7 +546,9 @@ void gimp_display_shell_scroll_setup_hscrollbar (GimpDisplayShell *shell, gdouble value) { - gint sw; + gint sw; + gdouble lower; + gdouble upper; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); @@ -558,22 +560,22 @@ gimp_display_shell_scroll_setup_hscrollbar (GimpDisplayShell *shell, if (shell->disp_width < sw) { - shell->hsbdata->lower = MIN (value, - 0); - - shell->hsbdata->upper = MAX (value + shell->disp_width, - sw); + lower = MIN (value, 0); + upper = MAX (value + shell->disp_width, sw); } else { - shell->hsbdata->lower = MIN (value, - -(shell->disp_width - sw) / 2); - - shell->hsbdata->upper = MAX (value + shell->disp_width, - sw + (shell->disp_width - sw) / 2); + lower = MIN (value, -(shell->disp_width - sw) / 2); + upper = MAX (value + shell->disp_width, + sw + (shell->disp_width - sw) / 2); } - shell->hsbdata->step_increment = MAX (shell->scale_x, MINIMUM_STEP_AMOUNT); + g_object_set (shell->hsbdata, + "lower", lower, + "upper", upper, + "step-increment", (gdouble) MAX (shell->scale_x, + MINIMUM_STEP_AMOUNT), + NULL); } /** @@ -588,7 +590,9 @@ void gimp_display_shell_scroll_setup_vscrollbar (GimpDisplayShell *shell, gdouble value) { - gint sh; + gint sh; + gdouble lower; + gdouble upper; g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); @@ -600,20 +604,20 @@ gimp_display_shell_scroll_setup_vscrollbar (GimpDisplayShell *shell, if (shell->disp_height < sh) { - shell->vsbdata->lower = MIN (value, - 0); - - shell->vsbdata->upper = MAX (value + shell->disp_height, - sh); + lower = MIN (value, 0); + upper = MAX (value + shell->disp_height, sh); } else { - shell->vsbdata->lower = MIN (value, - -(shell->disp_height - sh) / 2); - - shell->vsbdata->upper = MAX (value + shell->disp_height, - sh + (shell->disp_height - sh) / 2); + lower = MIN (value, -(shell->disp_height - sh) / 2); + upper = MAX (value + shell->disp_height, + sh + (shell->disp_height - sh) / 2); } - shell->vsbdata->step_increment = MAX (shell->scale_y, MINIMUM_STEP_AMOUNT); + g_object_set (shell->vsbdata, + "lower", lower, + "upper", upper, + "step-increment", (gdouble) MAX (shell->scale_y, + MINIMUM_STEP_AMOUNT), + NULL); } diff --git a/app/display/gimpdisplayshell-selection.c b/app/display/gimpdisplayshell-selection.c index 847f6d325e..89be8c94cd 100644 --- a/app/display/gimpdisplayshell-selection.c +++ b/app/display/gimpdisplayshell-selection.c @@ -225,7 +225,7 @@ gimp_display_shell_selection_set_hidden (GimpDisplayShell *shell, } void -gimp_display_shell_selection_layer_set_hidden (GimpDisplayShell *shell, +gimp_display_shell_selection_set_layer_hidden (GimpDisplayShell *shell, gboolean hidden) { g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell)); diff --git a/app/display/gimpdisplayshell-selection.h b/app/display/gimpdisplayshell-selection.h index 3411aec8b4..10bb1d171f 100644 --- a/app/display/gimpdisplayshell-selection.h +++ b/app/display/gimpdisplayshell-selection.h @@ -27,7 +27,7 @@ void gimp_display_shell_selection_control (GimpDisplayShell *shell, void gimp_display_shell_selection_set_hidden (GimpDisplayShell *shell, gboolean hidden); -void gimp_display_shell_selection_layer_set_hidden (GimpDisplayShell *shell, +void gimp_display_shell_selection_set_layer_hidden (GimpDisplayShell *shell, gboolean hidden); diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c index af930b08b7..e7fbb41762 100644 --- a/app/display/gimpdisplayshell.c +++ b/app/display/gimpdisplayshell.c @@ -1215,8 +1215,6 @@ gimp_display_shell_reconnect (GimpDisplayShell *shell) shell->fill_idle_id = 0; } - gimp_display_shell_connect (shell); - g_signal_emit (shell, display_shell_signals[RECONNECT], 0); gimp_color_managed_profile_changed (GIMP_COLOR_MANAGED (shell)); diff --git a/app/display/gimpnavigationeditor.c b/app/display/gimpnavigationeditor.c index 1ac816073f..176ea974ac 100644 --- a/app/display/gimpnavigationeditor.c +++ b/app/display/gimpnavigationeditor.c @@ -573,16 +573,19 @@ gimp_navigation_editor_scroll (GimpNavigationView *view, { case GDK_SCROLL_LEFT: case GDK_SCROLL_UP: - value -= adj->page_increment / 2; + value -= gtk_adjustment_get_page_increment (adj) / 2; break; case GDK_SCROLL_RIGHT: case GDK_SCROLL_DOWN: - value += adj->page_increment / 2; + value += gtk_adjustment_get_page_increment (adj) / 2; break; } - value = CLAMP (value, adj->lower, adj->upper - adj->page_size); + value = CLAMP (value, + gtk_adjustment_get_lower (adj), + gtk_adjustment_get_upper (adj) - + gtk_adjustment_get_page_size (adj)); gtk_adjustment_set_value (adj, value); } diff --git a/app/tools/gimpaligntool.c b/app/tools/gimpaligntool.c index 968ab004ed..9bb85aa83b 100644 --- a/app/tools/gimpaligntool.c +++ b/app/tools/gimpaligntool.c @@ -324,7 +324,7 @@ gimp_align_tool_button_release (GimpTool *tool, GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool); GimpDisplayShell *shell = gimp_display_get_shell (display); GObject *object = NULL; - GimpImage *image = display->image; + GimpImage *image = gimp_display_get_image (display); gint i; gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); @@ -361,7 +361,7 @@ gimp_align_tool_button_release (GimpTool *tool, object = G_OBJECT (vectors); } else if (gimp_display_shell_get_show_guides (shell) && - (guide = gimp_image_find_guide (display->image, + (guide = gimp_image_find_guide (image, coords->x, coords->y, FUNSCALEX (shell, snap_distance), FUNSCALEY (shell, snap_distance)))) @@ -370,7 +370,7 @@ gimp_align_tool_button_release (GimpTool *tool, } else { - if ((layer = select_layer_by_coords (display->image, + if ((layer = select_layer_by_coords (image, coords->x, coords->y))) { object = G_OBJECT (layer); @@ -475,9 +475,10 @@ gimp_align_tool_oper_update (GimpTool *tool, gboolean proximity, GimpDisplay *display) { - GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool); - GimpDisplayShell *shell = gimp_display_get_shell (display); - gint snap_distance = display->config->snap_distance; + GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool); + GimpDisplayShell *shell = gimp_display_get_shell (display); + GimpImage *image = gimp_display_get_image (display); + gint snap_distance = display->config->snap_distance; if (gimp_draw_tool_on_vectors (GIMP_DRAW_TOOL (tool), display, coords, snap_distance, snap_distance, @@ -489,7 +490,7 @@ gimp_align_tool_oper_update (GimpTool *tool, align_tool->function = ALIGN_TOOL_PICK_PATH; } else if (gimp_display_shell_get_show_guides (shell) && - (NULL != gimp_image_find_guide (display->image, + (NULL != gimp_image_find_guide (image, coords->x, coords->y, FUNSCALEX (shell, snap_distance), FUNSCALEY (shell, snap_distance)))) @@ -501,7 +502,7 @@ gimp_align_tool_oper_update (GimpTool *tool, } else { - GimpLayer *layer = select_layer_by_coords (display->image, + GimpLayer *layer = select_layer_by_coords (image, coords->x, coords->y); if (layer) @@ -714,7 +715,7 @@ gimp_align_tool_draw (GimpDrawTool *draw_tool) else if (GIMP_IS_GUIDE (list->data)) { GimpGuide *guide = GIMP_GUIDE (list->data); - GimpImage *image = GIMP_TOOL (draw_tool)->display->image; + GimpImage *image = gimp_display_get_image (GIMP_TOOL (draw_tool)->display); gint x, y; gint w, h; @@ -916,13 +917,13 @@ do_alignment (GtkWidget *widget, gpointer data) { GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (data); - GimpAlignmentType action; GimpImage *image; + GimpAlignmentType action; GObject *reference_object = NULL; GList *list; gint offset; - image = GIMP_TOOL (align_tool)->display->image; + image = gimp_display_get_image (GIMP_TOOL (align_tool)->display); action = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "action")); offset = align_tool->horz_offset; diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c index dab8b7fa7f..a4736b5e2d 100644 --- a/app/tools/gimpblendtool.c +++ b/app/tools/gimpblendtool.c @@ -153,7 +153,8 @@ gimp_blend_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { - GimpDrawable *drawable = gimp_image_get_active_drawable (display->image); + GimpImage *image = gimp_display_get_image (display); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error)) { @@ -221,7 +222,7 @@ gimp_blend_tool_button_release (GimpTool *tool, GimpBlendOptions *options = GIMP_BLEND_TOOL_GET_OPTIONS (tool); GimpPaintOptions *paint_options = GIMP_PAINT_OPTIONS (options); GimpContext *context = GIMP_CONTEXT (options); - GimpImage *image = display->image; + GimpImage *image = gimp_display_get_image (display); gimp_tool_pop_status (tool, display); @@ -357,11 +358,10 @@ gimp_blend_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *display) { - GimpDrawable *drawable; + GimpImage *image = gimp_display_get_image (display); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE; - drawable = gimp_image_get_active_drawable (display->image); - if (gimp_drawable_is_indexed (drawable) || gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) || gimp_item_is_content_locked (GIMP_ITEM (drawable))) diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c index fe956ec6d8..c8737508f0 100644 --- a/app/tools/gimpbucketfilltool.c +++ b/app/tools/gimpbucketfilltool.c @@ -121,7 +121,8 @@ gimp_bucket_fill_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { - GimpDrawable *drawable = gimp_image_get_active_drawable (display->image); + GimpImage *image = gimp_display_get_image (display); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error)) { @@ -154,13 +155,14 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool, GimpDisplay *display) { GimpBucketFillOptions *options = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool); + GimpImage *image = gimp_display_get_image (display); if ((release_type == GIMP_BUTTON_RELEASE_CLICK || release_type == GIMP_BUTTON_RELEASE_NO_MOTION) && - gimp_image_coords_in_active_pickable (display->image, coords, + gimp_image_coords_in_active_pickable (image, coords, options->sample_merged, TRUE)) { - GimpDrawable *drawable = gimp_image_get_active_drawable (display->image); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); GimpContext *context = GIMP_CONTEXT (options); gint x, y; GError *error = NULL; @@ -196,7 +198,7 @@ gimp_bucket_fill_tool_button_release (GimpTool *tool, } else { - gimp_image_flush (display->image); + gimp_image_flush (image); } } @@ -246,11 +248,12 @@ gimp_bucket_fill_tool_cursor_update (GimpTool *tool, { GimpBucketFillOptions *options = GIMP_BUCKET_FILL_TOOL_GET_OPTIONS (tool); GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_BAD; + GimpImage *image = gimp_display_get_image (display); - if (gimp_image_coords_in_active_pickable (display->image, coords, + if (gimp_image_coords_in_active_pickable (image, coords, options->sample_merged, TRUE)) { - GimpDrawable *drawable = gimp_image_get_active_drawable (display->image); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (! gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) && ! gimp_item_is_content_locked (GIMP_ITEM (drawable))) diff --git a/app/tools/gimpcolortool.c b/app/tools/gimpcolortool.c index feae8012c7..4f1b15a7ab 100644 --- a/app/tools/gimpcolortool.c +++ b/app/tools/gimpcolortool.c @@ -290,6 +290,7 @@ gimp_color_tool_button_release (GimpTool *tool, { GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool); GimpDisplayShell *shell = gimp_display_get_shell (display); + GimpImage *image = gimp_display_get_image (display); /* Chain up to halt the tool */ GIMP_TOOL_CLASS (parent_class)->button_release (tool, coords, time, state, @@ -326,7 +327,7 @@ gimp_color_tool_button_release (GimpTool *tool, { if (color_tool->sample_point) { - gimp_image_remove_sample_point (display->image, + gimp_image_remove_sample_point (image, color_tool->sample_point, TRUE); color_tool->sample_point = NULL; } @@ -335,7 +336,7 @@ gimp_color_tool_button_release (GimpTool *tool, { if (color_tool->sample_point) { - gimp_image_move_sample_point (display->image, + gimp_image_move_sample_point (image, color_tool->sample_point, color_tool->sample_point_x, color_tool->sample_point_y, @@ -344,7 +345,7 @@ gimp_color_tool_button_release (GimpTool *tool, else { color_tool->sample_point = - gimp_image_add_sample_point_at_pos (display->image, + gimp_image_add_sample_point_at_pos (image, color_tool->sample_point_x, color_tool->sample_point_y, TRUE); @@ -352,7 +353,7 @@ gimp_color_tool_button_release (GimpTool *tool, } gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME); - gimp_image_flush (display->image); + gimp_image_flush (image); if (color_tool->sample_point) gimp_display_shell_draw_sample_point (shell, color_tool->sample_point, @@ -471,6 +472,7 @@ gimp_color_tool_oper_update (GimpTool *tool, { GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool); GimpDisplayShell *shell = gimp_display_get_shell (display); + GimpImage *image = gimp_display_get_image (display); GimpSamplePoint *sample_point = NULL; if (color_tool->enabled && @@ -481,15 +483,15 @@ gimp_color_tool_oper_update (GimpTool *tool, snap_distance = GIMP_DISPLAY_CONFIG (display->gimp->config)->snap_distance; sample_point = - gimp_image_find_sample_point (display->image, + gimp_image_find_sample_point (image, coords->x, coords->y, FUNSCALEX (shell, snap_distance), FUNSCALEY (shell, snap_distance)); } - if (color_tool->sample_point && color_tool->sample_point != sample_point) - gimp_image_update_sample_point (shell->display->image, - color_tool->sample_point); + if (color_tool->sample_point && + color_tool->sample_point != sample_point) + gimp_image_update_sample_point (image, color_tool->sample_point); color_tool->sample_point = sample_point; @@ -505,6 +507,7 @@ gimp_color_tool_cursor_update (GimpTool *tool, GimpDisplay *display) { GimpColorTool *color_tool = GIMP_COLOR_TOOL (tool); + GimpImage *image = gimp_display_get_image (display); if (color_tool->enabled) { @@ -519,7 +522,7 @@ gimp_color_tool_cursor_update (GimpTool *tool, { GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_BAD; - if (gimp_image_coords_in_active_pickable (display->image, coords, + if (gimp_image_coords_in_active_pickable (image, coords, color_tool->options->sample_merged, FALSE)) { @@ -564,7 +567,7 @@ gimp_color_tool_draw (GimpDrawTool *draw_tool) if (color_tool->sample_point_x != -1 && color_tool->sample_point_y != -1) { - GimpImage *image = draw_tool->display->image; + GimpImage *image = gimp_display_get_image (draw_tool->display); gimp_draw_tool_draw_line (draw_tool, 0, color_tool->sample_point_y + 0.5, @@ -606,12 +609,13 @@ gimp_color_tool_real_pick (GimpColorTool *color_tool, GimpRGB *color, gint *color_index) { - GimpTool *tool = GIMP_TOOL (color_tool); + GimpTool *tool = GIMP_TOOL (color_tool); + GimpImage *image = gimp_display_get_image (tool->display); g_return_val_if_fail (tool->display != NULL, FALSE); g_return_val_if_fail (tool->drawable != NULL, FALSE); - return gimp_image_pick_color (tool->display->image, tool->drawable, x, y, + return gimp_image_pick_color (image, tool->drawable, x, y, color_tool->options->sample_merged, color_tool->options->sample_average, color_tool->options->average_radius, diff --git a/app/tools/gimpforegroundselecttool.c b/app/tools/gimpforegroundselecttool.c index ce605b0d00..99ebbfd006 100644 --- a/app/tools/gimpforegroundselecttool.c +++ b/app/tools/gimpforegroundselecttool.c @@ -624,7 +624,7 @@ gimp_foreground_select_tool_select (GimpFreeSelectTool *free_sel, { GimpForegroundSelectTool *fg_select; GimpForegroundSelectOptions *options; - GimpImage *image = display->image; + GimpImage *image = gimp_display_get_image (display); GimpDrawable *drawable; GimpScanConvert *scan_convert; GimpChannel *mask; @@ -761,10 +761,11 @@ gimp_foreground_select_tool_apply (GimpForegroundSelectTool *fg_select, { GimpTool *tool = GIMP_TOOL (fg_select); GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool); + GimpImage *image = gimp_display_get_image (display); g_return_if_fail (fg_select->mask != NULL); - gimp_channel_select_channel (gimp_image_get_mask (display->image), + gimp_channel_select_channel (gimp_image_get_mask (image), C_("command", "Foreground Select"), fg_select->mask, 0, 0, options->operation, @@ -774,7 +775,7 @@ gimp_foreground_select_tool_apply (GimpForegroundSelectTool *fg_select, gimp_tool_control (tool, GIMP_TOOL_ACTION_HALT, display); - gimp_image_flush (display->image); + gimp_image_flush (image); } static void diff --git a/app/tools/gimpfreeselecttool.c b/app/tools/gimpfreeselecttool.c index 9e4031223d..34e319eddc 100644 --- a/app/tools/gimpfreeselecttool.c +++ b/app/tools/gimpfreeselecttool.c @@ -789,7 +789,7 @@ gimp_free_select_tool_commit (GimpFreeSelectTool *fst, gimp_free_select_tool_select (fst, display); } - gimp_image_flush (display->image); + gimp_image_flush (gimp_display_get_image (display)); } static void @@ -846,12 +846,13 @@ gimp_free_select_tool_handle_click (GimpFreeSelectTool *fst, guint32 time, GimpDisplay *display) { - GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst); + GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst); + GimpImage *image = gimp_display_get_image (display); /* If there is a floating selection, anchor it */ - if (gimp_image_get_floating_selection (display->image)) + if (gimp_image_get_floating_selection (image)) { - floating_sel_anchor (gimp_image_get_floating_selection (display->image)); + floating_sel_anchor (gimp_image_get_floating_selection (image)); gimp_free_select_tool_halt (fst); } else @@ -1578,8 +1579,9 @@ gimp_free_select_tool_real_select (GimpFreeSelectTool *fst, { GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (fst); GimpFreeSelectToolPrivate *priv = GET_PRIVATE (fst); + GimpImage *image = gimp_display_get_image (display); - gimp_channel_select_polygon (gimp_image_get_mask (display->image), + gimp_channel_select_polygon (gimp_image_get_mask (image), C_("command", "Free Select"), priv->n_points, priv->points, diff --git a/app/tools/gimpiscissorstool.c b/app/tools/gimpiscissorstool.c index 1cedd8d871..31e0024308 100644 --- a/app/tools/gimpiscissorstool.c +++ b/app/tools/gimpiscissorstool.c @@ -408,6 +408,7 @@ gimp_iscissors_tool_button_press (GimpTool *tool, { GimpIscissorsTool *iscissors = GIMP_ISCISSORS_TOOL (tool); GimpIscissorsOptions *options = GIMP_ISCISSORS_TOOL_GET_OPTIONS (tool); + GimpImage *image = gimp_display_get_image (display); iscissors->x = RINT (coords->x); iscissors->y = RINT (coords->y); @@ -437,15 +438,12 @@ gimp_iscissors_tool_button_press (GimpTool *tool, iscissors->draw = DRAW_CURRENT_SEED; if (! (state & GDK_SHIFT_MASK)) - find_max_gradient (iscissors, - display->image, + find_max_gradient (iscissors, image, &iscissors->x, &iscissors->y); - iscissors->x = CLAMP (iscissors->x, - 0, gimp_image_get_width (display->image) - 1); - iscissors->y = CLAMP (iscissors->y, - 0, gimp_image_get_height (display->image) - 1); + iscissors->x = CLAMP (iscissors->x, 0, gimp_image_get_width (image) - 1); + iscissors->y = CLAMP (iscissors->y, 0, gimp_image_get_height (image) - 1); iscissors->ix = iscissors->x; iscissors->iy = iscissors->y; @@ -499,6 +497,7 @@ iscissors_convert (GimpIscissorsTool *iscissors, GimpDisplay *display) { GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (iscissors); + GimpImage *image = gimp_display_get_image (display); GimpScanConvert *sc; GList *list; GimpVector2 *points = NULL; @@ -547,9 +546,9 @@ iscissors_convert (GimpIscissorsTool *iscissors, if (iscissors->mask) g_object_unref (iscissors->mask); - iscissors->mask = gimp_channel_new_mask (display->image, - gimp_image_get_width (display->image), - gimp_image_get_height (display->image)); + iscissors->mask = gimp_channel_new_mask (image, + gimp_image_get_width (image), + gimp_image_get_height (image)); gimp_scan_convert_render (sc, gimp_drawable_get_tiles (GIMP_DRAWABLE (iscissors->mask)), 0, 0, options->antialias); @@ -682,6 +681,7 @@ gimp_iscissors_tool_motion (GimpTool *tool, { GimpIscissorsTool *iscissors = GIMP_ISCISSORS_TOOL (tool); GimpIscissorsOptions *options = GIMP_ISCISSORS_TOOL_GET_OPTIONS (tool); + GimpImage *image = gimp_display_get_image (display); if (iscissors->state == NO_ACTION) return; @@ -708,13 +708,11 @@ gimp_iscissors_tool_motion (GimpTool *tool, case SEED_PLACEMENT: /* Hold the shift key down to disable the auto-edge snap feature */ if (! (state & GDK_SHIFT_MASK)) - find_max_gradient (iscissors, display->image, + find_max_gradient (iscissors, image, &iscissors->x, &iscissors->y); - iscissors->x = CLAMP (iscissors->x, - 0, gimp_image_get_width (display->image) - 1); - iscissors->y = CLAMP (iscissors->y, - 0, gimp_image_get_height (display->image) - 1); + iscissors->x = CLAMP (iscissors->x, 0, gimp_image_get_width (image) - 1); + iscissors->y = CLAMP (iscissors->y, 0, gimp_image_get_height (image) - 1); if (iscissors->first_point) { @@ -726,13 +724,11 @@ gimp_iscissors_tool_motion (GimpTool *tool, case SEED_ADJUSTMENT: /* Move the current seed to the location of the cursor */ if (! (state & GDK_SHIFT_MASK)) - find_max_gradient (iscissors, display->image, + find_max_gradient (iscissors, image, &iscissors->x, &iscissors->y); - iscissors->x = CLAMP (iscissors->x, - 0, gimp_image_get_width (display->image) - 1); - iscissors->y = CLAMP (iscissors->y, - 0, gimp_image_get_height (display->image) - 1); + iscissors->x = CLAMP (iscissors->x, 0, gimp_image_get_width (image) - 1); + iscissors->y = CLAMP (iscissors->y, 0, gimp_image_get_height (image) - 1); iscissors->nx = iscissors->x; iscissors->ny = iscissors->y; @@ -1118,6 +1114,7 @@ gimp_iscissors_tool_apply (GimpIscissorsTool *iscissors, { GimpTool *tool = GIMP_TOOL (iscissors); GimpSelectionOptions *options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool); + GimpImage *image = gimp_display_get_image (display); /* Undraw the curve */ gimp_tool_control_halt (tool->control); @@ -1125,7 +1122,7 @@ gimp_iscissors_tool_apply (GimpIscissorsTool *iscissors, iscissors->draw = DRAW_CURVE; gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool)); - gimp_channel_select_channel (gimp_image_get_mask (display->image), + gimp_channel_select_channel (gimp_image_get_mask (image), tool->tool_info->blurb, iscissors->mask, 0, 0, @@ -1136,7 +1133,7 @@ gimp_iscissors_tool_apply (GimpIscissorsTool *iscissors, gimp_iscissors_tool_reset (iscissors); - gimp_image_flush (display->image); + gimp_image_flush (image); } static void @@ -1375,8 +1372,9 @@ static void calculate_curve (GimpTool *tool, ICurve *curve) { - GimpIscissorsTool *iscissors; - GimpDisplay *display; + GimpIscissorsTool *iscissors = GIMP_ISCISSORS_TOOL (tool); + GimpDisplay *display = tool->display; + GimpImage *image = gimp_display_get_image (display); gint x, y, dir; gint xs, ys, xe, ye; gint x1, y1, x2, y2; @@ -1393,15 +1391,11 @@ calculate_curve (GimpTool *tool, * structure. */ - iscissors = GIMP_ISCISSORS_TOOL (tool); - - display = tool->display; - /* Get the bounding box */ - xs = CLAMP (curve->x1, 0, gimp_image_get_width (display->image) - 1); - ys = CLAMP (curve->y1, 0, gimp_image_get_height (display->image) - 1); - xe = CLAMP (curve->x2, 0, gimp_image_get_width (display->image) - 1); - ye = CLAMP (curve->y2, 0, gimp_image_get_height (display->image) - 1); + xs = CLAMP (curve->x1, 0, gimp_image_get_width (image) - 1); + ys = CLAMP (curve->y1, 0, gimp_image_get_height (image) - 1); + xe = CLAMP (curve->x2, 0, gimp_image_get_width (image) - 1); + ye = CLAMP (curve->y2, 0, gimp_image_get_height (image) - 1); x1 = MIN (xs, xe); y1 = MIN (ys, ye); x2 = MAX (xs, xe) + 1; /* +1 because if xe = 199 & xs = 0, x2 - x1, width = 200 */ @@ -1418,12 +1412,12 @@ calculate_curve (GimpTool *tool, eheight = (y2 - y1) * EXTEND_BY + FIXED; if (xe >= xs) - x2 += CLAMP (ewidth, 0, gimp_image_get_width (display->image) - x2); + x2 += CLAMP (ewidth, 0, gimp_image_get_width (image) - x2); else x1 -= CLAMP (ewidth, 0, x1); if (ye >= ys) - y2 += CLAMP (eheight, 0, gimp_image_get_height (display->image) - y2); + y2 += CLAMP (eheight, 0, gimp_image_get_height (image) - y2); else y1 -= CLAMP (eheight, 0, y1); @@ -1443,7 +1437,7 @@ calculate_curve (GimpTool *tool, /* Initialise the gradient map tile manager for this image if we * don't already have one. */ if (!iscissors->gradient_map) - iscissors->gradient_map = gradient_map_new (display->image); + iscissors->gradient_map = gradient_map_new (image); /* allocate the dynamic programming array */ iscissors->dp_buf = diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c index 2ba02c883d..7b9c4bbe43 100644 --- a/app/tools/gimpmeasuretool.c +++ b/app/tools/gimpmeasuretool.c @@ -190,6 +190,7 @@ gimp_measure_tool_button_press (GimpTool *tool, GimpMeasureTool *measure = GIMP_MEASURE_TOOL (tool); GimpMeasureOptions *options = GIMP_MEASURE_TOOL_GET_OPTIONS (tool); GimpDisplayShell *shell = gimp_display_get_shell (display); + GimpImage *image = gimp_display_get_image (display); gint i; /* if we are changing displays, pop the statusbar of the old one */ @@ -230,40 +231,40 @@ gimp_measure_tool_button_press (GimpTool *tool, (measure->y[i] == CLAMP (measure->y[i], 0, - gimp_image_get_height (display->image)))); + gimp_image_get_height (image)))); create_vguide = ((state & GDK_MOD1_MASK) && (measure->x[i] == CLAMP (measure->x[i], 0, - gimp_image_get_width (display->image)))); + gimp_image_get_width (image)))); if (create_hguide && create_vguide) - gimp_image_undo_group_start (display->image, + gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_GUIDE, _("Add Guides")); if (create_hguide) { - guide = gimp_image_add_hguide (display->image, + guide = gimp_image_add_hguide (image, measure->y[i], TRUE); - gimp_image_update_guide (display->image, guide); + gimp_image_update_guide (image, guide); } if (create_vguide) { - guide = gimp_image_add_vguide (display->image, + guide = gimp_image_add_vguide (image, measure->x[i], TRUE); - gimp_image_update_guide (display->image, guide); + gimp_image_update_guide (image, guide); } if (create_hguide && create_vguide) - gimp_image_undo_group_end (display->image); + gimp_image_undo_group_end (image); if (create_hguide || create_vguide) - gimp_image_flush (display->image); + gimp_image_flush (image); measure->function = GUIDING; break; @@ -344,7 +345,7 @@ gimp_measure_tool_button_press (GimpTool *tool, if (measure->dialog) gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (measure->dialog), - GIMP_VIEWABLE (tool->display->image), + GIMP_VIEWABLE (image), GIMP_CONTEXT (options)); } @@ -812,7 +813,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure, GimpDisplay *display) { GimpDisplayShell *shell = gimp_display_get_shell (display); - GimpImage *image = display->image; + GimpImage *image = gimp_display_get_image (display); gint ax, ay; gint bx, by; gint pixel_width; diff --git a/app/tools/gimpmovetool.c b/app/tools/gimpmovetool.c index 4bc7463b0a..75d2ddf4e2 100644 --- a/app/tools/gimpmovetool.c +++ b/app/tools/gimpmovetool.c @@ -210,8 +210,9 @@ gimp_move_tool_button_press (GimpTool *tool, GimpDisplay *display) { GimpMoveTool *move = GIMP_MOVE_TOOL (tool); - GimpDisplayShell *shell = gimp_display_get_shell (display); GimpMoveOptions *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool); + GimpDisplayShell *shell = gimp_display_get_shell (display); + GimpImage *image = gimp_display_get_image (display); tool->display = display; @@ -233,9 +234,9 @@ gimp_move_tool_button_press (GimpTool *tool, &vectors)) { move->old_active_vectors = - gimp_image_get_active_vectors (display->image); + gimp_image_get_active_vectors (image); - gimp_image_set_active_vectors (display->image, vectors); + gimp_image_set_active_vectors (image, vectors); } else { @@ -250,7 +251,7 @@ gimp_move_tool_button_press (GimpTool *tool, gint snap_distance = display->config->snap_distance; if (gimp_display_shell_get_show_guides (shell) && - (guide = gimp_image_find_guide (display->image, + (guide = gimp_image_find_guide (image, coords->x, coords->y, FUNSCALEX (shell, snap_distance), FUNSCALEY (shell, snap_distance)))) @@ -279,18 +280,18 @@ gimp_move_tool_button_press (GimpTool *tool, return; } - else if ((layer = gimp_image_pick_layer (display->image, + else if ((layer = gimp_image_pick_layer (image, coords->x, coords->y))) { - if (gimp_image_get_floating_selection (display->image) && + if (gimp_image_get_floating_selection (image) && ! gimp_layer_is_floating_sel (layer)) { /* If there is a floating selection, and this aint it, * use the move tool to anchor it. */ move->floating_layer = - gimp_image_get_floating_selection (display->image); + gimp_image_get_floating_selection (image); gimp_tool_control_activate (tool->control); @@ -298,10 +299,9 @@ gimp_move_tool_button_press (GimpTool *tool, } else { - move->old_active_layer = - gimp_image_get_active_layer (display->image); + move->old_active_layer = gimp_image_get_active_layer (image); - gimp_image_set_active_layer (display->image, layer); + gimp_image_set_active_layer (image, layer); } } else @@ -316,22 +316,20 @@ gimp_move_tool_button_press (GimpTool *tool, switch (options->move_type) { case GIMP_TRANSFORM_TYPE_PATH: - if (gimp_image_get_active_vectors (display->image)) + if (gimp_image_get_active_vectors (image)) gimp_edit_selection_tool_start (tool, display, coords, GIMP_TRANSLATE_MODE_VECTORS, TRUE); break; case GIMP_TRANSFORM_TYPE_SELECTION: - if (! gimp_channel_is_empty (gimp_image_get_mask (display->image))) + if (! gimp_channel_is_empty (gimp_image_get_mask (image))) gimp_edit_selection_tool_start (tool, display, coords, GIMP_TRANSLATE_MODE_MASK, TRUE); break; case GIMP_TRANSFORM_TYPE_LAYER: { - GimpDrawable *drawable; - - drawable = gimp_image_get_active_drawable (display->image); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (GIMP_IS_LAYER_MASK (drawable)) gimp_edit_selection_tool_start (tool, display, coords, @@ -356,8 +354,9 @@ gimp_move_tool_button_release (GimpTool *tool, GimpDisplay *display) { GimpMoveTool *move = GIMP_MOVE_TOOL (tool); - GimpDisplayShell *shell = gimp_display_get_shell (display); GimpGuiConfig *config = GIMP_GUI_CONFIG (display->gimp->config); + GimpDisplayShell *shell = gimp_display_get_shell (display); + GimpImage *image = gimp_display_get_image (display); if (gimp_tool_control_is_active (tool->control)) gimp_tool_control_halt (tool->control); @@ -409,7 +408,7 @@ gimp_move_tool_button_release (GimpTool *tool, { if (move->guide) { - gimp_image_remove_guide (display->image, move->guide, TRUE); + gimp_image_remove_guide (image, move->guide, TRUE); move->guide = NULL; } } @@ -417,7 +416,7 @@ gimp_move_tool_button_release (GimpTool *tool, { if (move->guide) { - gimp_image_move_guide (display->image, move->guide, + gimp_image_move_guide (image, move->guide, move->guide_position, TRUE); } else @@ -425,13 +424,13 @@ gimp_move_tool_button_release (GimpTool *tool, switch (move->guide_orientation) { case GIMP_ORIENTATION_HORIZONTAL: - move->guide = gimp_image_add_hguide (display->image, + move->guide = gimp_image_add_hguide (image, move->guide_position, TRUE); break; case GIMP_ORIENTATION_VERTICAL: - move->guide = gimp_image_add_vguide (display->image, + move->guide = gimp_image_add_vguide (image, move->guide_position, TRUE); break; @@ -443,7 +442,7 @@ gimp_move_tool_button_release (GimpTool *tool, } gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME); - gimp_image_flush (display->image); + gimp_image_flush (image); if (move->guide) gimp_display_shell_draw_guide (shell, move->guide, TRUE); @@ -461,8 +460,7 @@ gimp_move_tool_button_release (GimpTool *tool, { if (move->old_active_layer) { - gimp_image_set_active_layer (display->image, - move->old_active_layer); + gimp_image_set_active_layer (image, move->old_active_layer); move->old_active_layer = NULL; flush = TRUE; @@ -470,8 +468,7 @@ gimp_move_tool_button_release (GimpTool *tool, if (move->old_active_vectors) { - gimp_image_set_active_vectors (display->image, - move->old_active_vectors); + gimp_image_set_active_vectors (image, move->old_active_vectors); move->old_active_vectors = NULL; flush = TRUE; @@ -489,7 +486,7 @@ gimp_move_tool_button_release (GimpTool *tool, } if (flush) - gimp_image_flush (display->image); + gimp_image_flush (image); } } @@ -653,6 +650,7 @@ gimp_move_tool_oper_update (GimpTool *tool, GimpMoveTool *move = GIMP_MOVE_TOOL (tool); GimpMoveOptions *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool); GimpDisplayShell *shell = gimp_display_get_shell (display); + GimpImage *image = gimp_display_get_image (display); GimpGuide *guide = NULL; if (options->move_type == GIMP_TRANSFORM_TYPE_LAYER && @@ -662,7 +660,7 @@ gimp_move_tool_oper_update (GimpTool *tool, { gint snap_distance = display->config->snap_distance; - guide = gimp_image_find_guide (display->image, coords->x, coords->y, + guide = gimp_image_find_guide (image, coords->x, coords->y, FUNSCALEX (shell, snap_distance), FUNSCALEY (shell, snap_distance)); } @@ -682,8 +680,9 @@ gimp_move_tool_cursor_update (GimpTool *tool, GdkModifierType state, GimpDisplay *display) { - GimpDisplayShell *shell = gimp_display_get_shell (display); GimpMoveOptions *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool); + GimpDisplayShell *shell = gimp_display_get_shell (display); + GimpImage *image = gimp_display_get_image (display); GimpCursorType cursor = GIMP_CURSOR_MOUSE; GimpToolCursorType tool_cursor = GIMP_TOOL_CURSOR_MOVE; GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE; @@ -695,7 +694,7 @@ gimp_move_tool_cursor_update (GimpTool *tool, if (options->move_current) { - if (! gimp_image_get_active_vectors (display->image)) + if (! gimp_image_get_active_vectors (image)) modifier = GIMP_CURSOR_MODIFIER_BAD; } else @@ -717,12 +716,12 @@ gimp_move_tool_cursor_update (GimpTool *tool, tool_cursor = GIMP_TOOL_CURSOR_RECT_SELECT; modifier = GIMP_CURSOR_MODIFIER_MOVE; - if (gimp_channel_is_empty (gimp_image_get_mask (display->image))) + if (gimp_channel_is_empty (gimp_image_get_mask (image))) modifier = GIMP_CURSOR_MODIFIER_BAD; } else if (options->move_current) { - if (! gimp_image_get_active_drawable (display->image)) + if (! gimp_image_get_active_drawable (image)) modifier = GIMP_CURSOR_MODIFIER_BAD; } else @@ -732,24 +731,24 @@ gimp_move_tool_cursor_update (GimpTool *tool, gint snap_distance = display->config->snap_distance; if (gimp_display_shell_get_show_guides (shell) && - (guide = gimp_image_find_guide (display->image, coords->x, coords->y, + (guide = gimp_image_find_guide (image, coords->x, coords->y, FUNSCALEX (shell, snap_distance), FUNSCALEY (shell, snap_distance)))) { tool_cursor = GIMP_TOOL_CURSOR_HAND; modifier = GIMP_CURSOR_MODIFIER_MOVE; } - else if ((layer = gimp_image_pick_layer (display->image, + else if ((layer = gimp_image_pick_layer (image, coords->x, coords->y))) { /* if there is a floating selection, and this aint it... */ - if (gimp_image_get_floating_selection (display->image) && + if (gimp_image_get_floating_selection (image) && ! gimp_layer_is_floating_sel (layer)) { tool_cursor = GIMP_TOOL_CURSOR_MOVE; modifier = GIMP_CURSOR_MODIFIER_ANCHOR; } - else if (layer != gimp_image_get_active_layer (display->image)) + else if (layer != gimp_image_get_active_layer (image)) { tool_cursor = GIMP_TOOL_CURSOR_HAND; modifier = GIMP_CURSOR_MODIFIER_MOVE; diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c index b89918ebe3..d2a9637dbb 100644 --- a/app/tools/gimppainttool.c +++ b/app/tools/gimppainttool.c @@ -228,7 +228,8 @@ gimp_paint_tool_control (GimpTool *tool, GimpDisplay *display) { GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); - GimpDrawable *drawable = gimp_image_get_active_drawable (display->image); + GimpImage *image = gimp_display_get_image (display); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); switch (action) { @@ -260,7 +261,8 @@ gimp_paint_tool_button_press (GimpTool *tool, GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool); GimpPaintCore *core = paint_tool->core; - GimpDrawable *drawable; + GimpImage *image = gimp_display_get_image (display); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); GimpCoords curr_coords; gint off_x, off_y; GError *error = NULL; @@ -272,8 +274,6 @@ gimp_paint_tool_button_press (GimpTool *tool, return; } - drawable = gimp_image_get_active_drawable (display->image); - if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable))) { gimp_tool_message_literal (tool, display, @@ -298,9 +298,9 @@ gimp_paint_tool_button_press (GimpTool *tool, if (gimp_draw_tool_is_active (draw_tool)) gimp_draw_tool_stop (draw_tool); - if (tool->display && + if (tool->display && tool->display != display && - tool->display->image == display->image) + gimp_display_get_image (tool->display) == image) { /* if this is a different display, but the same image, HACK around * in tool internals AFTER stopping the current draw_tool, so @@ -345,7 +345,7 @@ gimp_paint_tool_button_press (GimpTool *tool, press_type, display); /* pause the current selection */ - gimp_image_selection_control (display->image, GIMP_SELECTION_PAUSE); + gimp_image_selection_control (image, GIMP_SELECTION_PAUSE); /* Let the specific painting function initialize itself */ gimp_paint_core_paint (core, drawable, paint_options, @@ -363,7 +363,7 @@ gimp_paint_tool_button_press (GimpTool *tool, GIMP_PAINT_STATE_MOTION, time); } - gimp_projection_flush_now (gimp_image_get_projection (display->image)); + gimp_projection_flush_now (gimp_image_get_projection (image)); gimp_display_flush_now (display); gimp_draw_tool_start (draw_tool, display); @@ -380,7 +380,8 @@ gimp_paint_tool_button_release (GimpTool *tool, GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool); GimpPaintCore *core = paint_tool->core; - GimpDrawable *drawable; + GimpImage *image = gimp_display_get_image (display); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool))) { @@ -390,8 +391,6 @@ gimp_paint_tool_button_release (GimpTool *tool, return; } - drawable = gimp_image_get_active_drawable (display->image); - gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool)); /* Let the specific painting function finish up */ @@ -399,7 +398,7 @@ gimp_paint_tool_button_release (GimpTool *tool, GIMP_PAINT_STATE_FINISH, time); /* resume the current selection */ - gimp_image_selection_control (display->image, GIMP_SELECTION_RESUME); + gimp_image_selection_control (image, GIMP_SELECTION_RESUME); /* chain up to halt the tool */ GIMP_TOOL_CLASS (parent_class)->button_release (tool, coords, time, state, @@ -410,7 +409,7 @@ gimp_paint_tool_button_release (GimpTool *tool, else gimp_paint_core_finish (core, drawable, TRUE); - gimp_image_flush (display->image); + gimp_image_flush (image); gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); } @@ -425,7 +424,8 @@ gimp_paint_tool_motion (GimpTool *tool, GimpPaintTool *paint_tool = GIMP_PAINT_TOOL (tool); GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool); GimpPaintCore *core = paint_tool->core; - GimpDrawable *drawable; + GimpImage *image = gimp_display_get_image (display); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); GimpCoords curr_coords; gint off_x, off_y; @@ -436,8 +436,6 @@ gimp_paint_tool_motion (GimpTool *tool, curr_coords = *coords; - drawable = gimp_image_get_active_drawable (display->image); - gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y); curr_coords.x -= off_x; @@ -455,7 +453,7 @@ gimp_paint_tool_motion (GimpTool *tool, gimp_paint_core_interpolate (core, drawable, paint_options, &curr_coords, time); - gimp_projection_flush_now (gimp_image_get_projection (display->image)); + gimp_projection_flush_now (gimp_image_get_projection (image)); gimp_display_flush_now (display); gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool)); @@ -538,7 +536,8 @@ gimp_paint_tool_cursor_update (GimpTool *tool, if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool))) { - GimpDrawable *drawable = gimp_image_get_active_drawable (display->image); + GimpImage *image = gimp_display_get_image (display); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable)) || gimp_item_is_content_locked (GIMP_ITEM (drawable))) @@ -577,7 +576,8 @@ gimp_paint_tool_oper_update (GimpTool *tool, GimpPaintOptions *paint_options = GIMP_PAINT_TOOL_GET_OPTIONS (tool); GimpPaintCore *core = paint_tool->core; GimpDisplayShell *shell = gimp_display_get_shell (display); - GimpDrawable *drawable; + GimpImage *image = gimp_display_get_image (display); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool))) { @@ -593,7 +593,7 @@ gimp_paint_tool_oper_update (GimpTool *tool, if (tool->display && tool->display != display && - tool->display->image == display->image) + gimp_display_get_image (tool->display) == image) { /* if this is a different display, but the same image, HACK around * in tool internals AFTER stopping the current draw_tool, so @@ -604,8 +604,6 @@ gimp_paint_tool_oper_update (GimpTool *tool, tool->display = display; } - drawable = gimp_image_get_active_drawable (display->image); - if (drawable && proximity) { if (display == tool->display && (state & GDK_SHIFT_MASK)) @@ -647,10 +645,9 @@ gimp_paint_tool_oper_update (GimpTool *tool, } else { - GimpImage *image = display->image; - gdouble xres; - gdouble yres; - gchar format_str[64]; + gdouble xres; + gdouble yres; + gchar format_str[64]; gimp_image_get_resolution (image, &xres, &yres); diff --git a/app/tools/gimprectangletool.c b/app/tools/gimprectangletool.c index 1271fe94ba..9f1102fcbd 100644 --- a/app/tools/gimprectangletool.c +++ b/app/tools/gimprectangletool.c @@ -710,16 +710,21 @@ void gimp_rectangle_tool_frame_item (GimpRectangleTool *rect_tool, GimpItem *item) { - GimpDisplay *display = GIMP_TOOL (rect_tool)->display; + GimpDisplay *display; gint offset_x; gint offset_y; gint width; gint height; + g_return_if_fail (GIMP_IS_RECTANGLE_TOOL (rect_tool)); g_return_if_fail (GIMP_IS_ITEM (item)); g_return_if_fail (gimp_item_is_attached (item)); - g_return_if_fail (display != NULL); - g_return_if_fail (display->image == gimp_item_get_image (item)); + + display = GIMP_TOOL (rect_tool)->display; + + g_return_if_fail (GIMP_IS_DISPLAY (display)); + g_return_if_fail (gimp_display_get_image (display) == + gimp_item_get_image (item)); width = gimp_item_get_width (item); height = gimp_item_get_height (item); @@ -2068,6 +2073,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool, GimpTool *tool = GIMP_TOOL (rect_tool); GimpRectangleOptionsPrivate *options_private; GimpRectangleToolPrivate *private; + GimpImage *image; gdouble xres; gdouble yres; @@ -2076,6 +2082,8 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool, private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (rect_tool); + image = gimp_display_get_image (display); + tool->display = display; g_signal_connect_object (gimp_display_get_shell (tool->display), "scrolled", @@ -2092,7 +2100,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool, gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), tool->display); - gimp_image_get_resolution (display->image, &xres, &yres); + gimp_image_get_resolution (image, &xres, &yres); if (options_private->fixed_width_entry) { @@ -2100,7 +2108,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool, gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, xres, FALSE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0, - 0, gimp_image_get_width (display->image)); + 0, gimp_image_get_width (image)); } if (options_private->fixed_height_entry) @@ -2109,7 +2117,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool, gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, yres, FALSE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0, - 0, gimp_image_get_height (display->image)); + 0, gimp_image_get_height (image)); } if (options_private->x_entry) @@ -2118,7 +2126,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool, gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, xres, FALSE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0, - 0, gimp_image_get_width (display->image)); + 0, gimp_image_get_width (image)); } if (options_private->y_entry) @@ -2127,7 +2135,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool, gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, yres, FALSE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0, - 0, gimp_image_get_height (display->image)); + 0, gimp_image_get_height (image)); } if (options_private->width_entry) @@ -2136,7 +2144,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool, gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, xres, FALSE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0, - 0, gimp_image_get_width (display->image)); + 0, gimp_image_get_width (image)); } if (options_private->height_entry) @@ -2145,7 +2153,7 @@ gimp_rectangle_tool_start (GimpRectangleTool *rect_tool, gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (entry), 0, yres, FALSE); gimp_size_entry_set_size (GIMP_SIZE_ENTRY (entry), 0, - 0, gimp_image_get_height (display->image)); + 0, gimp_image_get_height (image)); } if (options_private->auto_shrink_button) @@ -2578,6 +2586,7 @@ gimp_rectangle_tool_auto_shrink (GimpRectangleTool *rect_tool) GimpTool *tool = GIMP_TOOL (rect_tool); GimpRectangleToolPrivate *private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); GimpDisplay *display = tool->display; + GimpImage *image; gint width; gint height; gint offset_x = 0; @@ -2593,8 +2602,10 @@ gimp_rectangle_tool_auto_shrink (GimpRectangleTool *rect_tool) if (! display) return; - width = gimp_image_get_width (display->image); - height = gimp_image_get_height (display->image); + image = gimp_display_get_image (display); + + width = gimp_image_get_width (image); + height = gimp_image_get_height (image); g_object_get (gimp_tool_get_options (tool), "shrink-merged", &shrink_merged, @@ -2605,7 +2616,7 @@ gimp_rectangle_tool_auto_shrink (GimpRectangleTool *rect_tool) y1 = private->y1 - offset_y > 0 ? private->y1 - offset_y : 0; y2 = private->y2 - offset_y < height ? private->y2 - offset_y : height; - if (gimp_image_crop_auto_shrink (display->image, + if (gimp_image_crop_auto_shrink (image, x1, y1, x2, y2, ! shrink_merged, &shrunk_x1, @@ -4006,11 +4017,13 @@ gimp_rectangle_tool_apply_fixed_rule (GimpRectangleTool *rect_tool) GimpRectangleOptions *options; GimpRectangleOptionsPrivate *options_private; GimpRectangleConstraint constraint_to_use; + GimpImage *image; tool = GIMP_TOOL (rect_tool); private = GIMP_RECTANGLE_TOOL_GET_PRIVATE (tool); options = GIMP_RECTANGLE_TOOL_GET_OPTIONS (tool); options_private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options); + image = gimp_display_get_image (tool->display); /* Calculate what constraint to use when needed. */ constraint_to_use = gimp_rectangle_tool_get_constraint (rect_tool); @@ -4022,8 +4035,8 @@ gimp_rectangle_tool_apply_fixed_rule (GimpRectangleTool *rect_tool) aspect = CLAMP (options_private->aspect_numerator / options_private->aspect_denominator, - 1.0 / gimp_image_get_height (tool->display->image), - gimp_image_get_width (tool->display->image)); + 1.0 / gimp_image_get_height (image), + gimp_image_get_width (image)); if (constraint_to_use == GIMP_RECTANGLE_CONSTRAIN_NONE) { @@ -4111,11 +4124,12 @@ gimp_rectangle_tool_get_constraints (GimpRectangleTool *rect_tool, gint *max_y, GimpRectangleConstraint constraint) { - GimpTool *tool = GIMP_TOOL (rect_tool); - gint min_x_dummy; - gint min_y_dummy; - gint max_x_dummy; - gint max_y_dummy; + GimpTool *tool = GIMP_TOOL (rect_tool); + GimpImage *image; + gint min_x_dummy; + gint min_y_dummy; + gint max_x_dummy; + gint max_y_dummy; if (! min_x) min_x = &min_x_dummy; if (! min_y) min_y = &min_y_dummy; @@ -4130,13 +4144,15 @@ gimp_rectangle_tool_get_constraints (GimpRectangleTool *rect_tool, if (! tool->display) return; + image = gimp_display_get_image (tool->display); + switch (constraint) { case GIMP_RECTANGLE_CONSTRAIN_IMAGE: *min_x = 0; *min_y = 0; - *max_x = gimp_image_get_width (tool->display->image); - *max_y = gimp_image_get_height (tool->display->image); + *max_x = gimp_image_get_width (image); + *max_y = gimp_image_get_height (image); break; case GIMP_RECTANGLE_CONSTRAIN_DRAWABLE: diff --git a/app/tools/gimpregionselecttool.c b/app/tools/gimpregionselecttool.c index cc444aae23..44b141badd 100644 --- a/app/tools/gimpregionselecttool.c +++ b/app/tools/gimpregionselecttool.c @@ -181,6 +181,7 @@ gimp_region_select_tool_button_release (GimpTool *tool, GimpRegionSelectTool *region_sel = GIMP_REGION_SELECT_TOOL (tool); GimpSelectionOptions *sel_options = GIMP_SELECTION_TOOL_GET_OPTIONS (tool); GimpRegionSelectOptions *options = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool); + GimpImage *image = gimp_display_get_image (display); gimp_tool_pop_status (tool, display); @@ -192,19 +193,18 @@ gimp_region_select_tool_button_release (GimpTool *tool, { if (GIMP_SELECTION_TOOL (tool)->function == SELECTION_ANCHOR) { - if (gimp_image_get_floating_selection (display->image)) + if (gimp_image_get_floating_selection (image)) { /* If there is a floating selection, anchor it */ - floating_sel_anchor (gimp_image_get_floating_selection (display->image)); + floating_sel_anchor (gimp_image_get_floating_selection (image)); } else { /* Otherwise, clear the selection mask */ - gimp_channel_clear (gimp_image_get_mask (display->image), NULL, - TRUE); + gimp_channel_clear (gimp_image_get_mask (image), NULL, TRUE); } - gimp_image_flush (display->image); + gimp_image_flush (image); } else if (region_sel->region_mask) { @@ -213,14 +213,12 @@ gimp_region_select_tool_button_release (GimpTool *tool, if (! options->sample_merged) { - GimpDrawable *drawable; - - drawable = gimp_image_get_active_drawable (display->image); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); gimp_item_get_offset (GIMP_ITEM (drawable), &off_x, &off_y); } - gimp_channel_select_channel (gimp_image_get_mask (display->image), + gimp_channel_select_channel (gimp_image_get_mask (image), GIMP_REGION_SELECT_TOOL_GET_CLASS (tool)->undo_desc, region_sel->region_mask, off_x, @@ -231,7 +229,7 @@ gimp_region_select_tool_button_release (GimpTool *tool, sel_options->feather_radius); - gimp_image_flush (display->image); + gimp_image_flush (image); } } @@ -309,8 +307,9 @@ gimp_region_select_tool_cursor_update (GimpTool *tool, { GimpRegionSelectOptions *options = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool); GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE; + GimpImage *image = gimp_display_get_image (display); - if (! gimp_image_coords_in_active_pickable (display->image, coords, + if (! gimp_image_coords_in_active_pickable (image, coords, options->sample_merged, FALSE)) modifier = GIMP_CURSOR_MODIFIER_BAD; @@ -344,13 +343,10 @@ gimp_region_select_tool_calculate (GimpRegionSelectTool *region_sel, GimpTool *tool = GIMP_TOOL (region_sel); GimpRegionSelectOptions *options = GIMP_REGION_SELECT_TOOL_GET_OPTIONS (tool); GimpDisplayShell *shell = gimp_display_get_shell (display); - GimpDrawable *drawable; GdkSegment *segs; BoundSeg *bsegs; PixelRegion maskPR; - drawable = gimp_image_get_active_drawable (display->image); - gimp_display_shell_set_override_cursor (shell, GDK_WATCH); if (region_sel->region_mask) diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c index 336be26423..3c61d78d7a 100644 --- a/app/tools/gimptransformtool.c +++ b/app/tools/gimptransformtool.c @@ -334,10 +334,9 @@ gimp_transform_tool_initialize (GimpTool *tool, GimpDisplay *display, GError **error) { - GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool); - GimpDrawable *drawable; - - drawable = gimp_image_get_active_drawable (display->image); + GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (tool); + GimpImage *image = gimp_display_get_image (display); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); if (! GIMP_TOOL_CLASS (parent_class)->initialize (tool, display, error)) { @@ -704,6 +703,7 @@ gimp_transform_tool_cursor_update (GimpTool *tool, GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tool); GimpCursorType cursor; GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE; + GimpImage *image = gimp_display_get_image (display); cursor = gimp_tool_control_get_cursor (tool->control); @@ -759,7 +759,7 @@ gimp_transform_tool_cursor_update (GimpTool *tool, GimpDrawable *drawable; case GIMP_TRANSFORM_TYPE_LAYER: - drawable = gimp_image_get_active_drawable (display->image); + drawable = gimp_image_get_active_drawable (image); if (gimp_item_is_content_locked (GIMP_ITEM (drawable))) modifier = GIMP_CURSOR_MODIFIER_BAD; break; @@ -768,7 +768,7 @@ gimp_transform_tool_cursor_update (GimpTool *tool, break; case GIMP_TRANSFORM_TYPE_PATH: - if (! gimp_image_get_active_vectors (display->image)) + if (! gimp_image_get_active_vectors (image)) modifier = GIMP_CURSOR_MODIFIER_BAD; break; } @@ -784,6 +784,7 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool) { GimpTool *tool = GIMP_TOOL (draw_tool); GimpTransformTool *tr_tool = GIMP_TRANSFORM_TOOL (draw_tool); + GimpImage *image = gimp_display_get_image (tool->display); gdouble z1, z2, z3, z4; if (tr_tool->use_grid) @@ -948,7 +949,7 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool) gint num_groups; gint i; - gimp_channel_boundary (gimp_image_get_mask (tool->display->image), + gimp_channel_boundary (gimp_image_get_mask (image), &orig_in, &orig_out, &num_segs_in, &num_segs_out, 0, 0, 0, 0); @@ -1029,7 +1030,7 @@ gimp_transform_tool_draw (GimpDrawTool *draw_tool) GimpStroke *stroke = NULL; GimpMatrix3 matrix = tr_tool->transform; - vectors = gimp_image_get_active_vectors (tool->display->image); + vectors = gimp_image_get_active_vectors (image); if (vectors) { @@ -1176,6 +1177,7 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool, GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tool); GimpContext *context = GIMP_CONTEXT (options); GimpDisplayShell *shell = gimp_display_get_shell (display); + GimpImage *image = gimp_display_get_image (display); GimpItem *active_item = NULL; TileManager *new_tiles; const gchar *null_message = NULL; @@ -1186,20 +1188,20 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool, switch (options->type) { case GIMP_TRANSFORM_TYPE_LAYER: - active_item = GIMP_ITEM (gimp_image_get_active_drawable (display->image)); + active_item = GIMP_ITEM (gimp_image_get_active_drawable (image)); null_message = _("There is no layer to transform."); locked_message = _("The active layer's pixels are locked."); break; case GIMP_TRANSFORM_TYPE_SELECTION: - active_item = GIMP_ITEM (gimp_image_get_mask (display->image)); + active_item = GIMP_ITEM (gimp_image_get_mask (image)); /* cannot happen, so don't translate these messages */ null_message = "There is no selection to transform."; locked_message = "The selection's pixels are locked."; break; case GIMP_TRANSFORM_TYPE_PATH: - active_item = GIMP_ITEM (gimp_image_get_active_vectors (display->image)); + active_item = GIMP_ITEM (gimp_image_get_active_vectors (image)); null_message = _("There is no path to transform."); locked_message = _("The active path's strokes are locked."); break; @@ -1221,7 +1223,7 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool, gimp_dialog_factory_hide_dialog (tr_tool->dialog); - mask_empty = gimp_channel_is_empty (gimp_image_get_mask (display->image)); + mask_empty = gimp_channel_is_empty (gimp_image_get_mask (image)); gimp_set_busy (display->gimp); @@ -1232,7 +1234,7 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool, gimp_tool_control_set_preserve (tool->control, TRUE); /* Start a transform undo group */ - gimp_image_undo_group_start (display->image, GIMP_UNDO_GROUP_TRANSFORM, + gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_TRANSFORM, tr_tool->undo_desc); /* With the old UI, if original is NULL, then this is the @@ -1244,7 +1246,7 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool, * selection pointer, so that the original source can be repeatedly * modified. */ - tool->drawable = gimp_image_get_active_drawable (display->image); + tool->drawable = gimp_image_get_active_drawable (image); switch (options->type) { @@ -1313,16 +1315,16 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool, /* Make a note of the new current drawable (since we may have * a floating selection, etc now. */ - tool->drawable = gimp_image_get_active_drawable (display->image); + tool->drawable = gimp_image_get_active_drawable (image); - gimp_image_undo_push (display->image, GIMP_TYPE_TRANSFORM_TOOL_UNDO, + gimp_image_undo_push (image, GIMP_TYPE_TRANSFORM_TOOL_UNDO, GIMP_UNDO_TRANSFORM, NULL, 0, "transform-tool", tr_tool, NULL); /* push the undo group end */ - gimp_image_undo_group_end (display->image); + gimp_image_undo_group_end (image); /* We're done dirtying the image, and would like to be restarted * if the image gets dirty while the tool exists @@ -1339,7 +1341,7 @@ gimp_transform_tool_doit (GimpTransformTool *tr_tool, gimp_unset_busy (display->gimp); - gimp_image_flush (display->image); + gimp_image_flush (image); gimp_transform_tool_halt (tr_tool); } @@ -1513,8 +1515,7 @@ gimp_transform_tool_bounds (GimpTransformTool *tr_tool, GimpDisplay *display) { GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool); - - g_return_if_fail (GIMP_IS_DISPLAY (display)); + GimpImage *image = gimp_display_get_image (display); /* find the boundaries */ if (tr_tool->original) @@ -1534,7 +1535,7 @@ gimp_transform_tool_bounds (GimpTransformTool *tr_tool, gint offset_x; gint offset_y; - drawable = gimp_image_get_active_drawable (display->image); + drawable = gimp_image_get_active_drawable (image); gimp_item_get_offset (GIMP_ITEM (drawable), &offset_x, &offset_y); @@ -1550,7 +1551,7 @@ gimp_transform_tool_bounds (GimpTransformTool *tr_tool, case GIMP_TRANSFORM_TYPE_SELECTION: case GIMP_TRANSFORM_TYPE_PATH: - gimp_channel_bounds (gimp_image_get_mask (display->image), + gimp_channel_bounds (gimp_image_get_mask (image), &tr_tool->x1, &tr_tool->y1, &tr_tool->x2, &tr_tool->y2); break; @@ -1737,6 +1738,7 @@ gimp_transform_tool_prepare (GimpTransformTool *tr_tool, GimpDisplay *display) { GimpTransformOptions *options = GIMP_TRANSFORM_TOOL_GET_OPTIONS (tr_tool); + GimpImage *image = gimp_display_get_image (display); gboolean show_transform; show_transform = @@ -1750,7 +1752,7 @@ gimp_transform_tool_prepare (GimpTransformTool *tr_tool, if (tr_tool->dialog) { - GimpDrawable *drawable = gimp_image_get_active_drawable (display->image); + GimpDrawable *drawable = gimp_image_get_active_drawable (image); gimp_viewable_dialog_set_viewable (GIMP_VIEWABLE_DIALOG (tr_tool->dialog), GIMP_VIEWABLE (drawable), diff --git a/devel-docs/app/app-sections.txt b/devel-docs/app/app-sections.txt index 624d0afd3b..706d609698 100644 --- a/devel-docs/app/app-sections.txt +++ b/devel-docs/app/app-sections.txt @@ -3722,8 +3722,6 @@ GimpDynamicOptions GimpFadeOptions GimpGradientOptions GimpJitterOptions -GIMP_PAINT_PRESSURE_SCALE -GIMP_PAINT_VELOCITY_SCALE GimpPaintOptions GimpPaintOptions gimp_paint_options_new diff --git a/tools/gimptool.c b/tools/gimptool.c index b6ce242607..fb173818e3 100644 --- a/tools/gimptool.c +++ b/tools/gimptool.c @@ -631,7 +631,7 @@ maybe_append_exe (const gchar *what) gchar *p = strrchr (what, '.'); if (p == NULL || g_ascii_strcasecmp (p, ".exe") != 0) - return g_strconcat (what, ".exe"); + return g_strconcat (what, ".exe", NULL); #endif return what;