~ubuntu-branches/ubuntu/quantal/gimp/quantal-updates

« back to all changes in this revision

Viewing changes to app/tools/gimpmovetool.c

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2012-05-20 19:21:01 UTC
  • mfrom: (1.1.26) (0.4.16 sid)
  • Revision ID: package-import@ubuntu.com-20120520192101-bs7zetx8ffoq2nfv
Tags: 2.8.0-2ubuntu1
* Merge from Debian unstable (LP: #908472). Remaining Changes:
  - debian/patches/02_help-message.patch,
    debian/patches/03_gimp.desktop.in.in.patch:
    + Update some strings for Ubuntu
  - debian/control:
    + Update description
  - debian/rules:
    + Set gettext domain and update translation templates
* Drop the following patches that were applied upstream:
  - debian/patches/ghost-cursor.patch: fix Wacom tablet cursor events
  - debian/patches/embed-page-setup-dialog.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
 
 * This program is free software; you can redistribute it and/or modify
 
4
 * This program is free software: you can redistribute it and/or modify
5
5
 * it under the terms of the GNU General Public License as published by
6
 
 * the Free Software Foundation; either version 2 of the License, or
 
6
 * the Free Software Foundation; either version 3 of the License, or
7
7
 * (at your option) any later version.
8
8
 *
9
9
 * This program is distributed in the hope that it will be useful,
12
12
 * GNU General Public License for more details.
13
13
 *
14
14
 * You should have received a copy of the GNU General Public License
15
 
 * along with this program; if not, write to the Free Software
16
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
16
 */
18
17
 
19
18
#include "config.h"
20
19
 
21
20
#include <string.h>
22
21
 
 
22
#include <gegl.h>
23
23
#include <gtk/gtk.h>
24
 
#include <gdk/gdkkeysyms.h>
25
24
 
26
25
#include "libgimpmath/gimpmath.h"
27
26
#include "libgimpwidgets/gimpwidgets.h"
35
34
#include "core/gimpguide.h"
36
35
#include "core/gimpimage.h"
37
36
#include "core/gimpimage-guides.h"
 
37
#include "core/gimpimage-pick-layer.h"
38
38
#include "core/gimplayer.h"
39
39
#include "core/gimpimage-undo.h"
40
40
#include "core/gimplayermask.h"
41
41
#include "core/gimplayer-floating-sel.h"
42
 
#include "core/gimpitem.h"
43
42
#include "core/gimpundostack.h"
44
43
 
45
44
#include "widgets/gimphelp-ids.h"
 
45
#include "widgets/gimpwidgets-utils.h"
46
46
 
 
47
#include "display/gimpcanvasitem.h"
47
48
#include "display/gimpdisplay.h"
48
49
#include "display/gimpdisplayshell.h"
49
50
#include "display/gimpdisplayshell-appearance.h"
50
 
#include "display/gimpdisplayshell-draw.h"
51
51
#include "display/gimpdisplayshell-selection.h"
52
52
#include "display/gimpdisplayshell-transform.h"
53
53
 
59
59
#include "gimp-intl.h"
60
60
 
61
61
 
 
62
#define GUIDE_POSITION_INVALID G_MININT
 
63
 
62
64
#define SWAP_ORIENT(orient) ((orient) == GIMP_ORIENTATION_HORIZONTAL ? \
63
65
                             GIMP_ORIENTATION_VERTICAL : \
64
66
                             GIMP_ORIENTATION_HORIZONTAL)
66
68
 
67
69
/*  local function prototypes  */
68
70
 
69
 
static void   gimp_move_tool_control        (GimpTool              *tool,
70
 
                                             GimpToolAction         action,
71
 
                                             GimpDisplay           *display);
72
71
static void   gimp_move_tool_button_press   (GimpTool              *tool,
73
 
                                             GimpCoords            *coords,
 
72
                                             const GimpCoords      *coords,
74
73
                                             guint32                time,
75
74
                                             GdkModifierType        state,
 
75
                                             GimpButtonPressType    press_type,
76
76
                                             GimpDisplay           *display);
77
77
static void   gimp_move_tool_button_release (GimpTool              *tool,
78
 
                                             GimpCoords            *coords,
 
78
                                             const GimpCoords      *coords,
79
79
                                             guint32                time,
80
80
                                             GdkModifierType        state,
81
81
                                             GimpButtonReleaseType  release_type,
82
82
                                             GimpDisplay           *display);
83
83
static void   gimp_move_tool_motion         (GimpTool              *tool,
84
 
                                             GimpCoords            *coords,
 
84
                                             const GimpCoords      *coords,
85
85
                                             guint32                time,
86
86
                                             GdkModifierType        state,
87
87
                                             GimpDisplay           *display);
94
94
                                             GdkModifierType        state,
95
95
                                             GimpDisplay           *display);
96
96
static void   gimp_move_tool_oper_update    (GimpTool              *tool,
97
 
                                             GimpCoords            *coords,
 
97
                                             const GimpCoords      *coords,
98
98
                                             GdkModifierType        state,
99
99
                                             gboolean               proximity,
100
100
                                             GimpDisplay           *display);
101
101
static void   gimp_move_tool_cursor_update  (GimpTool              *tool,
102
 
                                             GimpCoords            *coords,
 
102
                                             const GimpCoords      *coords,
103
103
                                             GdkModifierType        state,
104
104
                                             GimpDisplay           *display);
105
105
 
138
138
  GimpToolClass     *tool_class      = GIMP_TOOL_CLASS (klass);
139
139
  GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
140
140
 
141
 
  tool_class->control        = gimp_move_tool_control;
142
141
  tool_class->button_press   = gimp_move_tool_button_press;
143
142
  tool_class->button_release = gimp_move_tool_button_release;
144
143
  tool_class->motion         = gimp_move_tool_motion;
155
154
{
156
155
  GimpTool *tool = GIMP_TOOL (move_tool);
157
156
 
 
157
  gimp_tool_control_set_motion_mode        (tool->control,
 
158
                                            GIMP_MOTION_MODE_COMPRESS);
 
159
  gimp_tool_control_set_snap_to            (tool->control, FALSE);
 
160
  gimp_tool_control_set_handle_empty_image (tool->control, TRUE);
 
161
  gimp_tool_control_set_tool_cursor        (tool->control,
 
162
                                            GIMP_TOOL_CURSOR_MOVE);
 
163
 
158
164
  move_tool->floating_layer     = NULL;
159
165
  move_tool->guide              = NULL;
160
166
 
161
167
  move_tool->moving_guide       = FALSE;
162
 
  move_tool->guide_position     = -1;
 
168
  move_tool->guide_position     = GUIDE_POSITION_INVALID;
163
169
  move_tool->guide_orientation  = GIMP_ORIENTATION_UNKNOWN;
164
170
 
165
171
  move_tool->saved_type         = GIMP_TRANSFORM_TYPE_LAYER;
166
172
 
167
173
  move_tool->old_active_layer   = NULL;
168
174
  move_tool->old_active_vectors = NULL;
169
 
 
170
 
  gimp_tool_control_set_snap_to            (tool->control, FALSE);
171
 
  gimp_tool_control_set_handle_empty_image (tool->control, TRUE);
172
 
  gimp_tool_control_set_tool_cursor        (tool->control,
173
 
                                            GIMP_TOOL_CURSOR_MOVE);
174
 
}
175
 
 
176
 
static void
177
 
gimp_move_tool_control (GimpTool       *tool,
178
 
                        GimpToolAction  action,
179
 
                        GimpDisplay    *display)
180
 
{
181
 
  GimpMoveTool     *move  = GIMP_MOVE_TOOL (tool);
182
 
  GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
183
 
 
184
 
  switch (action)
185
 
    {
186
 
    case GIMP_TOOL_ACTION_PAUSE:
187
 
      break;
188
 
 
189
 
    case GIMP_TOOL_ACTION_RESUME:
190
 
      if (move->guide && gimp_display_shell_get_show_guides (shell))
191
 
        gimp_display_shell_draw_guide (shell, move->guide, TRUE);
192
 
      break;
193
 
 
194
 
    case GIMP_TOOL_ACTION_HALT:
195
 
      if (move->guide && gimp_display_shell_get_show_guides (shell))
196
 
        gimp_display_shell_draw_guide (shell, move->guide, FALSE);
197
 
      break;
198
 
    }
199
 
 
200
 
  GIMP_TOOL_CLASS (parent_class)->control (tool, action, display);
201
 
}
202
 
 
203
 
static void
204
 
gimp_move_tool_button_press (GimpTool        *tool,
205
 
                             GimpCoords      *coords,
206
 
                             guint32          time,
207
 
                             GdkModifierType  state,
208
 
                             GimpDisplay     *display)
 
175
}
 
176
 
 
177
static void
 
178
gimp_move_tool_button_press (GimpTool            *tool,
 
179
                             const GimpCoords    *coords,
 
180
                             guint32              time,
 
181
                             GdkModifierType      state,
 
182
                             GimpButtonPressType  press_type,
 
183
                             GimpDisplay         *display)
209
184
{
210
185
  GimpMoveTool     *move    = GIMP_MOVE_TOOL (tool);
211
 
  GimpDisplayShell *shell   = GIMP_DISPLAY_SHELL (display->shell);
212
186
  GimpMoveOptions  *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool);
 
187
  GimpDisplayShell *shell   = gimp_display_get_shell (display);
 
188
  GimpImage        *image   = gimp_display_get_image (display);
213
189
 
214
190
  tool->display = display;
215
191
 
231
207
                                         &vectors))
232
208
            {
233
209
              move->old_active_vectors =
234
 
                gimp_image_get_active_vectors (display->image);
 
210
                gimp_image_get_active_vectors (image);
235
211
 
236
 
              gimp_image_set_active_vectors (display->image, vectors);
 
212
              gimp_image_set_active_vectors (image, vectors);
237
213
            }
238
214
          else
239
215
            {
243
219
        }
244
220
      else if (options->move_type == GIMP_TRANSFORM_TYPE_LAYER)
245
221
        {
246
 
          GimpGuide *guide;
247
 
          GimpLayer *layer;
248
 
          gint       snap_distance;
249
 
 
250
 
          snap_distance =
251
 
            GIMP_DISPLAY_CONFIG (display->image->gimp->config)->snap_distance;
 
222
          GimpGuide  *guide;
 
223
          GimpLayer  *layer;
 
224
          const gint  snap_distance = display->config->snap_distance;
252
225
 
253
226
          if (gimp_display_shell_get_show_guides (shell) &&
254
 
              (guide = gimp_image_find_guide (display->image,
 
227
              (guide = gimp_image_find_guide (image,
255
228
                                              coords->x, coords->y,
256
229
                                              FUNSCALEX (shell, snap_distance),
257
230
                                              FUNSCALEY (shell, snap_distance))))
267
240
 
268
241
              gimp_tool_control_activate (tool->control);
269
242
 
270
 
              gimp_display_shell_selection_control (shell,
271
 
                                                    GIMP_SELECTION_PAUSE);
 
243
              gimp_display_shell_selection_pause (shell);
272
244
 
273
 
              gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
 
245
              if (! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tool)))
 
246
                gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
274
247
 
275
248
              gimp_tool_push_status_length (tool, display,
276
249
                                            _("Move Guide: "),
280
253
 
281
254
              return;
282
255
            }
283
 
          else if ((layer = gimp_image_pick_correlate_layer (display->image,
284
 
                                                             coords->x,
285
 
                                                             coords->y)))
 
256
          else if ((layer = gimp_image_pick_layer (image,
 
257
                                                   coords->x,
 
258
                                                   coords->y)))
286
259
            {
287
 
              if (gimp_image_floating_sel (display->image) &&
 
260
              if (gimp_image_get_floating_selection (image) &&
288
261
                  ! gimp_layer_is_floating_sel (layer))
289
262
                {
290
263
                  /*  If there is a floating selection, and this aint it,
291
264
                   *  use the move tool to anchor it.
292
265
                   */
293
 
                  move->floating_layer = gimp_image_floating_sel (display->image);
 
266
                  move->floating_layer =
 
267
                    gimp_image_get_floating_selection (image);
 
268
 
294
269
                  gimp_tool_control_activate (tool->control);
295
270
 
296
271
                  return;
297
272
                }
298
273
              else
299
274
                {
300
 
                  move->old_active_layer =
301
 
                    gimp_image_get_active_layer (display->image);
 
275
                  move->old_active_layer = gimp_image_get_active_layer (image);
302
276
 
303
 
                  gimp_image_set_active_layer (display->image, layer);
 
277
                  gimp_image_set_active_layer (image, layer);
304
278
                }
305
279
            }
306
280
          else
315
289
  switch (options->move_type)
316
290
    {
317
291
    case GIMP_TRANSFORM_TYPE_PATH:
318
 
      if (gimp_image_get_active_vectors (display->image))
319
 
        gimp_edit_selection_tool_start (tool, display, coords,
320
 
                                        GIMP_TRANSLATE_MODE_VECTORS, TRUE);
 
292
      if (gimp_image_get_active_vectors (image))
 
293
        {
 
294
          gimp_tool_control_activate (tool->control);
 
295
          gimp_edit_selection_tool_start (tool, display, coords,
 
296
                                          GIMP_TRANSLATE_MODE_VECTORS, TRUE);
 
297
        }
321
298
      break;
322
299
 
323
300
    case GIMP_TRANSFORM_TYPE_SELECTION:
324
 
      if (! gimp_channel_is_empty (gimp_image_get_mask (display->image)))
325
 
        gimp_edit_selection_tool_start (tool, display, coords,
326
 
                                        GIMP_TRANSLATE_MODE_MASK, TRUE);
 
301
      if (! gimp_channel_is_empty (gimp_image_get_mask (image)))
 
302
        {
 
303
          gimp_tool_control_activate (tool->control);
 
304
          gimp_edit_selection_tool_start (tool, display, coords,
 
305
                                          GIMP_TRANSLATE_MODE_MASK, TRUE);
 
306
        }
327
307
      break;
328
308
 
329
309
    case GIMP_TRANSFORM_TYPE_LAYER:
330
310
      {
331
 
        GimpDrawable *drawable;
332
 
 
333
 
        drawable = gimp_image_get_active_drawable (display->image);
 
311
        GimpDrawable *drawable = gimp_image_get_active_drawable (image);
334
312
 
335
313
        if (GIMP_IS_LAYER_MASK (drawable))
336
 
          gimp_edit_selection_tool_start (tool, display, coords,
337
 
                                          GIMP_TRANSLATE_MODE_LAYER_MASK, TRUE);
 
314
          {
 
315
            gimp_tool_control_activate (tool->control);
 
316
            gimp_edit_selection_tool_start (tool, display, coords,
 
317
                                            GIMP_TRANSLATE_MODE_LAYER_MASK, TRUE);
 
318
          }
338
319
        else if (GIMP_IS_CHANNEL (drawable))
339
 
          gimp_edit_selection_tool_start (tool, display, coords,
340
 
                                          GIMP_TRANSLATE_MODE_CHANNEL, TRUE);
 
320
          {
 
321
            gimp_tool_control_activate (tool->control);
 
322
            gimp_edit_selection_tool_start (tool, display, coords,
 
323
                                            GIMP_TRANSLATE_MODE_CHANNEL, TRUE);
 
324
          }
341
325
        else if (GIMP_IS_LAYER (drawable))
342
 
          gimp_edit_selection_tool_start (tool, display, coords,
343
 
                                          GIMP_TRANSLATE_MODE_LAYER, TRUE);
 
326
          {
 
327
            gimp_tool_control_activate (tool->control);
 
328
            gimp_edit_selection_tool_start (tool, display, coords,
 
329
                                            GIMP_TRANSLATE_MODE_LAYER, TRUE);
 
330
          }
344
331
      }
345
332
      break;
346
333
    }
348
335
 
349
336
static void
350
337
gimp_move_tool_button_release (GimpTool              *tool,
351
 
                               GimpCoords            *coords,
 
338
                               const GimpCoords      *coords,
352
339
                               guint32                time,
353
340
                               GdkModifierType        state,
354
341
                               GimpButtonReleaseType  release_type,
355
342
                               GimpDisplay           *display)
356
343
{
357
344
  GimpMoveTool     *move   = GIMP_MOVE_TOOL (tool);
358
 
  GimpDisplayShell *shell  = GIMP_DISPLAY_SHELL (display->shell);
359
 
  GimpGuiConfig    *config = GIMP_GUI_CONFIG (display->image->gimp->config);
 
345
  GimpGuiConfig    *config = GIMP_GUI_CONFIG (display->gimp->config);
 
346
  GimpDisplayShell *shell  = gimp_display_get_shell (display);
 
347
  GimpImage        *image  = gimp_display_get_image (display);
360
348
 
361
 
  if (gimp_tool_control_is_active (tool->control))
362
 
    gimp_tool_control_halt (tool->control);
 
349
  gimp_tool_control_halt (tool->control);
363
350
 
364
351
  if (move->moving_guide)
365
352
    {
377
364
      if (release_type == GIMP_BUTTON_RELEASE_CANCEL)
378
365
        {
379
366
          move->moving_guide      = FALSE;
380
 
          move->guide_position    = -1;
 
367
          move->guide_position    = GUIDE_POSITION_INVALID;
381
368
          move->guide_orientation = GIMP_ORIENTATION_UNKNOWN;
382
369
 
383
 
          gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME);
 
370
          gimp_display_shell_selection_resume (shell);
384
371
          return;
385
372
        }
386
373
 
408
395
        {
409
396
          if (move->guide)
410
397
            {
411
 
              gimp_image_remove_guide (display->image, move->guide, TRUE);
 
398
              gimp_image_remove_guide (image, move->guide, TRUE);
412
399
              move->guide = NULL;
413
400
            }
414
401
        }
416
403
        {
417
404
          if (move->guide)
418
405
            {
419
 
              gimp_image_move_guide (display->image, move->guide,
 
406
              gimp_image_move_guide (image, move->guide,
420
407
                                     move->guide_position, TRUE);
421
408
            }
422
409
          else
424
411
              switch (move->guide_orientation)
425
412
                {
426
413
                case GIMP_ORIENTATION_HORIZONTAL:
427
 
                  move->guide = gimp_image_add_hguide (display->image,
 
414
                  move->guide = gimp_image_add_hguide (image,
428
415
                                                       move->guide_position,
429
416
                                                       TRUE);
430
417
                  break;
431
418
 
432
419
                case GIMP_ORIENTATION_VERTICAL:
433
 
                  move->guide = gimp_image_add_vguide (display->image,
 
420
                  move->guide = gimp_image_add_vguide (image,
434
421
                                                       move->guide_position,
435
422
                                                       TRUE);
436
423
                  break;
441
428
            }
442
429
        }
443
430
 
444
 
      gimp_display_shell_selection_control (shell, GIMP_SELECTION_RESUME);
445
 
      gimp_image_flush (display->image);
446
 
 
447
 
      if (move->guide)
448
 
        gimp_display_shell_draw_guide (shell, move->guide, TRUE);
 
431
      gimp_display_shell_selection_resume (shell);
 
432
      gimp_image_flush (image);
449
433
 
450
434
      move->moving_guide      = FALSE;
451
 
      move->guide_position    = -1;
 
435
      move->guide_position    = GUIDE_POSITION_INVALID;
452
436
      move->guide_orientation = GIMP_ORIENTATION_UNKNOWN;
 
437
 
 
438
      if (move->guide)
 
439
        gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), display);
453
440
    }
454
441
  else
455
442
    {
460
447
        {
461
448
          if (move->old_active_layer)
462
449
            {
463
 
              gimp_image_set_active_layer (display->image,
464
 
                                           move->old_active_layer);
 
450
              gimp_image_set_active_layer (image, move->old_active_layer);
465
451
              move->old_active_layer = NULL;
466
452
 
467
453
              flush = TRUE;
469
455
 
470
456
          if (move->old_active_vectors)
471
457
            {
472
 
              gimp_image_set_active_vectors (display->image,
473
 
                                             move->old_active_vectors);
 
458
              gimp_image_set_active_vectors (image, move->old_active_vectors);
474
459
              move->old_active_vectors = NULL;
475
460
 
476
461
              flush = TRUE;
488
473
        }
489
474
 
490
475
      if (flush)
491
 
        gimp_image_flush (display->image);
 
476
        gimp_image_flush (image);
492
477
    }
493
478
}
494
479
 
495
480
static void
496
 
gimp_move_tool_motion (GimpTool        *tool,
497
 
                       GimpCoords      *coords,
498
 
                       guint32          time,
499
 
                       GdkModifierType  state,
500
 
                       GimpDisplay     *display)
 
481
gimp_move_tool_motion (GimpTool         *tool,
 
482
                       const GimpCoords *coords,
 
483
                       guint32           time,
 
484
                       GdkModifierType   state,
 
485
                       GimpDisplay      *display)
501
486
 
502
487
{
503
488
  GimpMoveTool     *move  = GIMP_MOVE_TOOL (tool);
504
 
  GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (display->shell);
 
489
  GimpDisplayShell *shell = gimp_display_get_shell (display);
505
490
 
506
491
  if (move->moving_guide)
507
492
    {
512
497
 
513
498
      gimp_display_shell_transform_xy (shell,
514
499
                                       coords->x, coords->y,
515
 
                                       &tx, &ty,
516
 
                                       FALSE);
 
500
                                       &tx, &ty);
517
501
 
518
502
      if (tx < 0 || tx >= shell->disp_width ||
519
503
          ty < 0 || ty >= shell->disp_height)
520
504
        {
521
 
          move->guide_position = -1;
 
505
          move->guide_position = GUIDE_POSITION_INVALID;
522
506
 
523
507
          delete_guide = TRUE;
524
508
        }
601
585
    {
602
586
      g_object_set (options, "move-current", ! options->move_current, NULL);
603
587
    }
604
 
  else if (key == GDK_MOD1_MASK || key == GDK_CONTROL_MASK)
 
588
  else if (key == GDK_MOD1_MASK ||
 
589
           key == gimp_get_toggle_behavior_mask ())
605
590
    {
606
591
      GimpTransformType button_type;
607
592
 
609
594
 
610
595
      if (press)
611
596
        {
612
 
          if (key == (state & (GDK_MOD1_MASK | GDK_CONTROL_MASK)))
 
597
          if (key == (state & (GDK_MOD1_MASK |
 
598
                               gimp_get_toggle_behavior_mask ())))
613
599
            {
614
600
              /*  first modifier pressed  */
615
601
 
618
604
        }
619
605
      else
620
606
        {
621
 
          if (! (state & (GDK_MOD1_MASK | GDK_CONTROL_MASK)))
 
607
          if (! (state & (GDK_MOD1_MASK |
 
608
                          gimp_get_toggle_behavior_mask ())))
622
609
            {
623
610
              /*  last modifier released  */
624
611
 
630
617
        {
631
618
          button_type = GIMP_TRANSFORM_TYPE_SELECTION;
632
619
        }
633
 
      else if (state & GDK_CONTROL_MASK)
 
620
      else if (state & gimp_get_toggle_behavior_mask ())
634
621
        {
635
622
          button_type = GIMP_TRANSFORM_TYPE_PATH;
636
623
        }
643
630
}
644
631
 
645
632
static void
646
 
gimp_move_tool_oper_update (GimpTool        *tool,
647
 
                            GimpCoords      *coords,
648
 
                            GdkModifierType  state,
649
 
                            gboolean         proximity,
650
 
                            GimpDisplay     *display)
 
633
gimp_move_tool_oper_update (GimpTool         *tool,
 
634
                            const GimpCoords *coords,
 
635
                            GdkModifierType   state,
 
636
                            gboolean          proximity,
 
637
                            GimpDisplay      *display)
651
638
{
652
639
  GimpMoveTool     *move    = GIMP_MOVE_TOOL (tool);
653
640
  GimpMoveOptions  *options = GIMP_MOVE_TOOL_GET_OPTIONS (tool);
654
 
  GimpDisplayShell *shell   = GIMP_DISPLAY_SHELL (display->shell);
 
641
  GimpDisplayShell *shell   = gimp_display_get_shell (display);
 
642
  GimpImage        *image   = gimp_display_get_image (display);
655
643
  GimpGuide        *guide   = NULL;
656
644
 
657
645
  if (options->move_type == GIMP_TRANSFORM_TYPE_LAYER &&
659
647
      gimp_display_shell_get_show_guides (shell)      &&
660
648
      proximity)
661
649
    {
662
 
      gint snap_distance;
663
 
 
664
 
      snap_distance =
665
 
        GIMP_DISPLAY_CONFIG (display->image->gimp->config)->snap_distance;
666
 
 
667
 
      guide = gimp_image_find_guide (display->image, coords->x, coords->y,
 
650
      gint snap_distance = display->config->snap_distance;
 
651
 
 
652
      guide = gimp_image_find_guide (image, coords->x, coords->y,
668
653
                                     FUNSCALEX (shell, snap_distance),
669
654
                                     FUNSCALEY (shell, snap_distance));
670
655
    }
671
656
 
672
 
  if (move->guide && move->guide != guide)
673
 
    gimp_display_shell_draw_guide (shell, move->guide, FALSE);
674
 
 
675
 
  move->guide = guide;
676
 
 
677
 
  if (move->guide)
678
 
    gimp_display_shell_draw_guide (shell, move->guide, TRUE);
 
657
  if (move->guide != guide)
 
658
    {
 
659
      GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
 
660
 
 
661
      gimp_draw_tool_pause (draw_tool);
 
662
 
 
663
      if (gimp_draw_tool_is_active (draw_tool) &&
 
664
          draw_tool->display != display)
 
665
        gimp_draw_tool_stop (draw_tool);
 
666
 
 
667
      move->guide = guide;
 
668
 
 
669
      if (! gimp_draw_tool_is_active (draw_tool))
 
670
        gimp_draw_tool_start (draw_tool, display);
 
671
 
 
672
      gimp_draw_tool_resume (draw_tool);
 
673
    }
679
674
}
680
675
 
681
676
static void
682
 
gimp_move_tool_cursor_update (GimpTool        *tool,
683
 
                              GimpCoords      *coords,
684
 
                              GdkModifierType  state,
685
 
                              GimpDisplay     *display)
 
677
gimp_move_tool_cursor_update (GimpTool         *tool,
 
678
                              const GimpCoords *coords,
 
679
                              GdkModifierType   state,
 
680
                              GimpDisplay      *display)
686
681
{
687
 
  GimpDisplayShell   *shell       = GIMP_DISPLAY_SHELL (display->shell);
688
682
  GimpMoveOptions    *options     = GIMP_MOVE_TOOL_GET_OPTIONS (tool);
 
683
  GimpDisplayShell   *shell       = gimp_display_get_shell (display);
 
684
  GimpImage          *image       = gimp_display_get_image (display);
689
685
  GimpCursorType      cursor      = GIMP_CURSOR_MOUSE;
690
686
  GimpToolCursorType  tool_cursor = GIMP_TOOL_CURSOR_MOVE;
691
687
  GimpCursorModifier  modifier    = GIMP_CURSOR_MODIFIER_NONE;
697
693
 
698
694
      if (options->move_current)
699
695
        {
700
 
          if (! gimp_image_get_active_vectors (display->image))
 
696
          if (! gimp_image_get_active_vectors (image))
701
697
            modifier = GIMP_CURSOR_MODIFIER_BAD;
702
698
        }
703
699
      else
719
715
      tool_cursor = GIMP_TOOL_CURSOR_RECT_SELECT;
720
716
      modifier    = GIMP_CURSOR_MODIFIER_MOVE;
721
717
 
722
 
      if (gimp_channel_is_empty (gimp_image_get_mask (display->image)))
 
718
      if (gimp_channel_is_empty (gimp_image_get_mask (image)))
723
719
        modifier = GIMP_CURSOR_MODIFIER_BAD;
724
720
    }
725
721
  else if (options->move_current)
726
722
    {
727
 
      if (! gimp_image_get_active_drawable (display->image))
 
723
      if (! gimp_image_get_active_drawable (image))
728
724
        modifier = GIMP_CURSOR_MODIFIER_BAD;
729
725
    }
730
726
  else
731
727
    {
732
 
      GimpGuide *guide;
733
 
      GimpLayer *layer;
734
 
      gint       snap_distance;
735
 
 
736
 
      snap_distance =
737
 
        GIMP_DISPLAY_CONFIG (display->image->gimp->config)->snap_distance;
 
728
      GimpGuide  *guide;
 
729
      GimpLayer  *layer;
 
730
      const gint  snap_distance = display->config->snap_distance;
738
731
 
739
732
      if (gimp_display_shell_get_show_guides (shell) &&
740
 
          (guide = gimp_image_find_guide (display->image, coords->x, coords->y,
 
733
          (guide = gimp_image_find_guide (image, coords->x, coords->y,
741
734
                                          FUNSCALEX (shell, snap_distance),
742
735
                                          FUNSCALEY (shell, snap_distance))))
743
736
        {
744
737
          tool_cursor = GIMP_TOOL_CURSOR_HAND;
745
738
          modifier    = GIMP_CURSOR_MODIFIER_MOVE;
746
739
        }
747
 
      else if ((layer = gimp_image_pick_correlate_layer (display->image,
748
 
                                                         coords->x, coords->y)))
 
740
      else if ((layer = gimp_image_pick_layer (image,
 
741
                                               coords->x, coords->y)))
749
742
        {
750
743
          /*  if there is a floating selection, and this aint it...  */
751
 
          if (gimp_image_floating_sel (display->image) &&
 
744
          if (gimp_image_get_floating_selection (image) &&
752
745
              ! gimp_layer_is_floating_sel (layer))
753
746
            {
754
747
              tool_cursor = GIMP_TOOL_CURSOR_MOVE;
755
748
              modifier    = GIMP_CURSOR_MODIFIER_ANCHOR;
756
749
            }
757
 
          else if (layer != gimp_image_get_active_layer (display->image))
 
750
          else if (layer != gimp_image_get_active_layer (image))
758
751
            {
759
752
              tool_cursor = GIMP_TOOL_CURSOR_HAND;
760
753
              modifier    = GIMP_CURSOR_MODIFIER_MOVE;
778
771
{
779
772
  GimpMoveTool *move = GIMP_MOVE_TOOL (draw_tool);
780
773
 
781
 
  if (move->moving_guide && move->guide_position != -1)
782
 
    {
783
 
      gimp_draw_tool_draw_guide_line (draw_tool,
784
 
                                      move->guide_orientation,
785
 
                                      move->guide_position);
 
774
  if (move->guide)
 
775
    {
 
776
      GimpCanvasItem *item;
 
777
 
 
778
      item = gimp_draw_tool_add_guide (draw_tool,
 
779
                                       gimp_guide_get_orientation (move->guide),
 
780
                                       gimp_guide_get_position (move->guide),
 
781
                                       TRUE);
 
782
      gimp_canvas_item_set_highlight (item, TRUE);
 
783
    }
 
784
 
 
785
  if (move->moving_guide && move->guide_position != GUIDE_POSITION_INVALID)
 
786
    {
 
787
      gimp_draw_tool_add_guide (draw_tool,
 
788
                                move->guide_orientation,
 
789
                                move->guide_position,
 
790
                                FALSE);
786
791
    }
787
792
}
788
793
 
815
820
{
816
821
  GimpTool *tool = GIMP_TOOL (move);
817
822
 
818
 
  gimp_display_shell_selection_control (GIMP_DISPLAY_SHELL (display->shell),
819
 
                                        GIMP_SELECTION_PAUSE);
 
823
  gimp_display_shell_selection_pause (gimp_display_get_shell (display));
820
824
 
821
825
  tool->display = display;
822
826
  gimp_tool_control_activate (tool->control);
823
827
  gimp_tool_control_set_scroll_lock (tool->control, TRUE);
824
828
 
825
 
  if (move->guide)
826
 
    gimp_display_shell_draw_guide (GIMP_DISPLAY_SHELL (display->shell),
827
 
                                   move->guide, FALSE);
 
829
  if (gimp_draw_tool_is_active  (GIMP_DRAW_TOOL (tool)))
 
830
    gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
828
831
 
829
832
  move->guide             = NULL;
830
833
  move->moving_guide      = TRUE;
831
 
  move->guide_position    = -1;
 
834
  move->guide_position    = GUIDE_POSITION_INVALID;
832
835
  move->guide_orientation = orientation;
833
836
 
834
837
  gimp_tool_set_cursor (tool, display,