image-commands.c 19 KB
Newer Older
Michael Natterer's avatar
Michael Natterer committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include "config.h"

#include <gtk/gtk.h>

23
#include "libgimpbase/gimpbase.h"
Michael Natterer's avatar
Michael Natterer committed
24 25
#include "libgimpwidgets/gimpwidgets.h"

Michael Natterer's avatar
Michael Natterer committed
26
#include "actions-types.h"
Michael Natterer's avatar
Michael Natterer committed
27

28 29 30
#include "config/gimpguiconfig.h"

#include "core/core-enums.h"
31
#include "core/gimp.h"
32
#include "core/gimpchannel.h"
33
#include "core/gimpcontext.h"
Michael Natterer's avatar
Michael Natterer committed
34
#include "core/gimpimage.h"
35
#include "core/gimpimage-convert.h"
36
#include "core/gimpimage-crop.h"
Michael Natterer's avatar
Michael Natterer committed
37
#include "core/gimpimage-duplicate.h"
38
#include "core/gimpimage-flip.h"
39
#include "core/gimpimage-merge.h"
40
#include "core/gimpimage-resize.h"
41
#include "core/gimpimage-rotate.h"
42
#include "core/gimpimage-scale.h"
43
#include "core/gimpimage-undo.h"
44
#include "core/gimpprogress.h"
Michael Natterer's avatar
Michael Natterer committed
45

46
#include "widgets/gimpdialogfactory.h"
47
#include "widgets/gimpdock.h"
48
#include "widgets/gimphelp-ids.h"
49 50
#include "widgets/gimpmessagebox.h"
#include "widgets/gimpmessagedialog.h"
51

52
#include "display/gimpdisplay.h"
53
#include "display/gimpdisplayshell.h"
54

55 56 57
#include "dialogs/convert-dialog.h"
#include "dialogs/dialogs.h"
#include "dialogs/grid-dialog.h"
58
#include "dialogs/image-merge-layers-dialog.h"
59 60
#include "dialogs/image-new-dialog.h"
#include "dialogs/resize-dialog.h"
Michael Natterer's avatar
Michael Natterer committed
61

62
#include "actions.h"
63
#include "image-commands.h"
Michael Natterer's avatar
Michael Natterer committed
64

65
#include "gimp-intl.h"
Michael Natterer's avatar
Michael Natterer committed
66 67


68 69 70
typedef struct _ImageResizeOptions ImageResizeOptions;

struct _ImageResizeOptions
Michael Natterer's avatar
Michael Natterer committed
71
{
72
  ResizeDialog *dialog;
73 74

  GimpContext  *context;
75 76
  GimpDisplay  *gdisp;
  GimpImage    *gimage;
77 78 79
};


80
/*  local function prototypes  */
Michael Natterer's avatar
Michael Natterer committed
81

82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
static void   image_resize_callback        (GtkWidget              *widget,
                                            gpointer                data);
static void   image_scale_callback         (GtkWidget              *widget,
                                            gpointer                data);
static void   image_scale_confirm_large    (ImageResizeOptions     *options,
                                            gint64                  new_memsize,
                                            gint64                  max_memsize);
static void   image_scale_confirm_small    (ImageResizeOptions     *options);
static void   image_scale_confirm_response (GtkWidget              *widget,
                                            gint                    response_id,
                                            ImageResizeOptions     *options);
static void   image_scale_implement        (ImageResizeOptions     *options);
static void   image_merge_layers_response  (GtkWidget              *widget,
                                            gint                    response_id,
                                            ImageMergeLayersDialog *dialog);
Michael Natterer's avatar
Michael Natterer committed
97 98


99 100 101 102 103
/*  private variables  */

static GimpMergeType image_merge_layers_type = GIMP_EXPAND_AS_NECESSARY;


Michael Natterer's avatar
Michael Natterer committed
104 105
/*  public functions  */

106 107 108 109 110 111 112 113 114 115
void
image_new_cmd_callback (GtkAction *action,
                        gpointer   data)
{
  GtkWidget *widget;
  GtkWidget *dialog;
  return_if_no_widget (widget, data);

  dialog = gimp_dialog_factory_dialog_new (global_dialog_factory,
                                           gtk_widget_get_screen (widget),
116
                                           "gimp-image-new-dialog", -1, FALSE);
117

118
  if (dialog)
119
    {
120
      image_new_dialog_set (dialog, NULL, NULL);
121 122 123

      gtk_window_present (GTK_WINDOW (dialog));
    }
124 125 126 127 128 129 130 131 132 133 134 135
}

void
image_new_from_image_cmd_callback (GtkAction *action,
                                   gpointer   data)
{
  GtkWidget *widget;
  GtkWidget *dialog;
  return_if_no_widget (widget, data);

  dialog = gimp_dialog_factory_dialog_new (global_dialog_factory,
                                           gtk_widget_get_screen (widget),
136
                                           "gimp-image-new-dialog", -1, FALSE);
137 138 139 140 141 142

  if (dialog)
    {
      GimpImage *gimage = action_data_get_image (data);

      if (gimage)
143
        image_new_dialog_set (dialog, gimage, NULL);
144 145

      gtk_window_present (GTK_WINDOW (dialog));
146 147 148
    }
}

Michael Natterer's avatar
Michael Natterer committed
149
void
150 151 152
image_convert_cmd_callback (GtkAction *action,
                            gint       value,
                            gpointer   data)
Michael Natterer's avatar
Michael Natterer committed
153
{
154 155 156
  GimpImage   *gimage;
  GtkWidget   *widget;
  GimpDisplay *gdisp;
157 158
  return_if_no_image (gimage, data);
  return_if_no_widget (widget, data);
159
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
160

161 162 163 164 165
  switch ((GimpImageBaseType) value)
    {
    case GIMP_RGB:
    case GIMP_GRAY:
      gimp_image_convert (gimage, (GimpImageBaseType) value,
166
                          0, 0, FALSE, FALSE, 0, NULL, NULL);
167 168 169 170
      gimp_image_flush (gimage);
      break;

    case GIMP_INDEXED:
171 172
      gtk_widget_show (convert_dialog_new (gimage, widget,
                                           GIMP_PROGRESS (gdisp)));
173 174
      break;
    }
Michael Natterer's avatar
Michael Natterer committed
175 176 177
}

void
178
image_resize_cmd_callback (GtkAction *action,
Michael Natterer's avatar
Michael Natterer committed
179 180
			   gpointer   data)
{
181 182 183
  ImageResizeOptions *options;
  GimpDisplay        *gdisp;
  GimpImage          *gimage;
Michael Natterer's avatar
Michael Natterer committed
184
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
185 186 187

  gimage = gdisp->gimage;

188
  options = g_new0 (ImageResizeOptions, 1);
Michael Natterer's avatar
Michael Natterer committed
189

190 191 192
  options->context = action_data_get_context (data);
  options->gdisp   = gdisp;
  options->gimage  = gimage;
193

194
  options->dialog =
195 196
    resize_dialog_new (GIMP_VIEWABLE (gimage), gdisp->shell,
                       RESIZE_DIALOG,
197 198 199 200
                       gimage->width,
                       gimage->height,
                       gimage->xresolution,
                       gimage->yresolution,
201
                       GIMP_DISPLAY_SHELL (gdisp->shell)->unit,
202
                       G_CALLBACK (image_resize_callback),
203
                       options);
Michael Natterer's avatar
Michael Natterer committed
204

205
  g_signal_connect_object (gdisp, "disconnect",
206
                           G_CALLBACK (gtk_widget_destroy),
207
                           options->dialog->shell,
208 209
                           G_CONNECT_SWAPPED);

210
  g_object_weak_ref (G_OBJECT (options->dialog->shell),
211
		     (GWeakNotify) g_free,
212
		     options);
Michael Natterer's avatar
Michael Natterer committed
213

214
  gtk_widget_show (options->dialog->shell);
Michael Natterer's avatar
Michael Natterer committed
215 216
}

217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
void
image_resize_to_layers_cmd_callback (GtkAction *action,
                                     gpointer   data)
{
  GimpDisplay  *gdisp;
  GimpProgress *progress;

  return_if_no_display (gdisp, data);

  progress = gimp_progress_start (GIMP_PROGRESS (gdisp),
                                  _("Resizing..."), FALSE);

  gimp_image_resize_to_layers (gdisp->gimage,
                               action_data_get_context (data),
                               progress);

  if (progress)
    gimp_progress_end (progress);

  gimp_image_flush (gdisp->gimage);
}

Michael Natterer's avatar
Michael Natterer committed
239
void
240
image_scale_cmd_callback (GtkAction *action,
Michael Natterer's avatar
Michael Natterer committed
241 242
			  gpointer   data)
{
243 244 245
  ImageResizeOptions *options;
  GimpDisplay        *gdisp;
  GimpImage          *gimage;
Michael Natterer's avatar
Michael Natterer committed
246
  return_if_no_display (gdisp, data);
Michael Natterer's avatar
Michael Natterer committed
247 248 249

  gimage = gdisp->gimage;

250
  options = g_new0 (ImageResizeOptions, 1);
Michael Natterer's avatar
Michael Natterer committed
251

252 253 254
  options->context = action_data_get_context (data);
  options->gdisp   = gdisp;
  options->gimage  = gimage;
255

256
  options->dialog =
257 258
    resize_dialog_new (GIMP_VIEWABLE (gimage), gdisp->shell,
                       SCALE_DIALOG,
259 260 261 262
                       gimage->width,
                       gimage->height,
                       gimage->xresolution,
                       gimage->yresolution,
263
                       GIMP_DISPLAY_SHELL (gdisp->shell)->unit,
264
                       G_CALLBACK (image_scale_callback),
265
                       options);
Michael Natterer's avatar
Michael Natterer committed
266

267
  g_signal_connect_object (gdisp, "disconnect",
268
                           G_CALLBACK (gtk_widget_destroy),
269
                           options->dialog->shell,
270 271
                           G_CONNECT_SWAPPED);

272
  g_object_weak_ref (G_OBJECT (options->dialog->shell),
273
		     (GWeakNotify) g_free,
274
		     options);
Michael Natterer's avatar
Michael Natterer committed
275

276
  gtk_widget_show (options->dialog->shell);
Michael Natterer's avatar
Michael Natterer committed
277 278
}

279
void
280 281 282
image_flip_cmd_callback (GtkAction *action,
                         gint       value,
                         gpointer   data)
283 284 285 286 287
{
  GimpDisplay  *gdisp;
  GimpProgress *progress;
  return_if_no_display (gdisp, data);

288 289
  progress = gimp_progress_start (GIMP_PROGRESS (gdisp),
                                  _("Flipping..."), FALSE);
290

291
  gimp_image_flip (gdisp->gimage, action_data_get_context (data),
292
                   (GimpOrientationType) value, progress);
293

294 295
  if (progress)
    gimp_progress_end (progress);
296 297 298 299

  gimp_image_flush (gdisp->gimage);
}

300
void
301 302 303
image_rotate_cmd_callback (GtkAction *action,
                           gint       value,
                           gpointer   data)
304 305 306 307 308
{
  GimpDisplay  *gdisp;
  GimpProgress *progress;
  return_if_no_display (gdisp, data);

309 310
  progress = gimp_progress_start (GIMP_PROGRESS (gdisp),
                                  _("Rotating..."), FALSE);
311

312
  gimp_image_rotate (gdisp->gimage, action_data_get_context (data),
313
                     (GimpRotationType) value, progress);
314

315 316
  if (progress)
    gimp_progress_end (progress);
317 318 319 320

  gimp_image_flush (gdisp->gimage);
}

321
void
322
image_crop_cmd_callback (GtkAction *action,
323 324
                         gpointer   data)
{
325 326 327
  GimpImage *gimage;
  gint       x1, y1, x2, y2;
  return_if_no_image (gimage, data);
328

329
  if (! gimp_channel_bounds (gimp_image_get_mask (gimage),
330
                             &x1, &y1, &x2, &y2))
331 332 333 334 335
    {
      g_message (_("Cannot crop because the current selection is empty."));
      return;
    }

336
  gimp_image_crop (gimage, action_data_get_context (data),
337
                   x1, y1, x2, y2, FALSE, TRUE);
338
  gimp_image_flush (gimage);
339 340
}

Michael Natterer's avatar
Michael Natterer committed
341
void
342
image_duplicate_cmd_callback (GtkAction *action,
Michael Natterer's avatar
Michael Natterer committed
343 344
			      gpointer   data)
{
345 346 347 348 349
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
  GimpImage        *new_gimage;
  return_if_no_display (gdisp, data);

350
  shell = GIMP_DISPLAY_SHELL (gdisp->shell);
Michael Natterer's avatar
Michael Natterer committed
351

352
  new_gimage = gimp_image_duplicate (gdisp->gimage);
353 354 355 356 357

  gimp_create_display (new_gimage->gimp,
                       new_gimage,
                       shell->unit, shell->scale);

358
  g_object_unref (new_gimage);
Michael Natterer's avatar
Michael Natterer committed
359 360
}

361
void
362
image_merge_layers_cmd_callback (GtkAction *action,
363 364
                                 gpointer   data)
{
365 366 367
  ImageMergeLayersDialog *dialog;
  GimpImage              *gimage;
  GtkWidget              *widget;
368 369
  return_if_no_image (gimage, data);
  return_if_no_widget (widget, data);
370

371 372 373
  dialog = image_merge_layers_dialog_new (gimage,
                                          action_data_get_context (data),
                                          widget,
374
                                          image_merge_layers_type);
375

376
  g_signal_connect (dialog->dialog, "response",
377
                    G_CALLBACK (image_merge_layers_response),
378
                    dialog);
379

380
  gtk_widget_show (dialog->dialog);
381 382 383
}

void
384
image_flatten_image_cmd_callback (GtkAction *action,
385 386 387 388 389
                                  gpointer   data)
{
  GimpImage *gimage;
  return_if_no_image (gimage, data);

390
  gimp_image_flatten (gimage, action_data_get_context (data));
391
  gimp_image_flush (gimage);
392
}
393

394
void
395
image_configure_grid_cmd_callback (GtkAction *action,
396 397 398 399
                                   gpointer   data)
{
  GimpDisplay      *gdisp;
  GimpDisplayShell *shell;
400
  GimpImage        *gimage;
401 402
  return_if_no_display (gdisp, data);

403
  shell  = GIMP_DISPLAY_SHELL (gdisp->shell);
404
  gimage = gdisp->gimage;
405 406 407

  if (! shell->grid_dialog)
    {
408
      shell->grid_dialog = grid_dialog_new (gdisp->gimage, gdisp->shell);
409 410

      gtk_window_set_transient_for (GTK_WINDOW (shell->grid_dialog),
411
                                    GTK_WINDOW (gdisp->shell));
412 413 414 415 416 417 418 419 420 421
      gtk_window_set_destroy_with_parent (GTK_WINDOW (shell->grid_dialog),
                                          TRUE);

      g_object_add_weak_pointer (G_OBJECT (shell->grid_dialog),
                                 (gpointer *) &shell->grid_dialog);
    }

  gtk_window_present (GTK_WINDOW (shell->grid_dialog));
}

422

Michael Natterer's avatar
Michael Natterer committed
423 424 425 426 427 428
/*  private functions  */

static void
image_resize_callback (GtkWidget *widget,
		       gpointer   data)
{
429
  ImageResizeOptions *options = data;
Michael Natterer's avatar
Michael Natterer committed
430

431
  gtk_widget_set_sensitive (options->dialog->shell, FALSE);
Michael Natterer's avatar
Michael Natterer committed
432

433 434
  if (options->dialog->width  > 0 &&
      options->dialog->height > 0)
Michael Natterer's avatar
Michael Natterer committed
435
    {
436 437
      GimpProgress *progress;

438 439
      progress = gimp_progress_start (GIMP_PROGRESS (options->gdisp),
                                      _("Resizing..."), FALSE);
440

441 442 443 444 445 446
      gimp_image_resize (options->gimage,
                         options->context,
			 options->dialog->width,
			 options->dialog->height,
			 options->dialog->offset_x,
			 options->dialog->offset_y,
447
                         progress);
448

449 450
      if (progress)
        gimp_progress_end (progress);
451

452
      gimp_image_flush (options->gimage);
Michael Natterer's avatar
Michael Natterer committed
453
    }
454
  else
Michael Natterer's avatar
Michael Natterer committed
455 456 457 458 459
    {
      g_message (_("Resize Error: Both width and height must be "
		   "greater than zero."));
    }

460
  gtk_widget_destroy (options->dialog->shell);
Michael Natterer's avatar
Michael Natterer committed
461 462 463 464 465 466
}

static void
image_scale_callback (GtkWidget *widget,
		      gpointer   data)
{
467
  ImageResizeOptions      *options = data;
Michael Natterer's avatar
Michael Natterer committed
468
  GimpImageScaleCheckType  scale_check;
Michael Natterer's avatar
Michael Natterer committed
469
  gint64                   max_memsize;
Michael Natterer's avatar
Michael Natterer committed
470
  gint64                   new_memsize;
Michael Natterer's avatar
Michael Natterer committed
471

472
  gtk_widget_set_sensitive (options->dialog->shell, FALSE);
Michael Natterer's avatar
Michael Natterer committed
473

Michael Natterer's avatar
Michael Natterer committed
474 475 476
  max_memsize =
    GIMP_GUI_CONFIG (options->gimage->gimp->config)->max_new_image_size;

477 478 479
  scale_check = gimp_image_scale_check (options->gimage,
                                        options->dialog->width,
                                        options->dialog->height,
Michael Natterer's avatar
Michael Natterer committed
480
                                        max_memsize,
Michael Natterer's avatar
Michael Natterer committed
481
                                        &new_memsize);
482
  switch (scale_check)
Michael Natterer's avatar
Michael Natterer committed
483
    {
484
    case GIMP_IMAGE_SCALE_TOO_BIG:
485
      image_scale_confirm_large (options, new_memsize, max_memsize);
486 487 488
      break;

    case GIMP_IMAGE_SCALE_TOO_SMALL:
489
      image_scale_confirm_small (options);
490 491 492 493
      break;

    case GIMP_IMAGE_SCALE_OK:
      /* If all is well, return directly after scaling image. */
494 495
      image_scale_implement (options);
      gtk_widget_destroy (options->dialog->shell);
496
      break;
Michael Natterer's avatar
Michael Natterer committed
497
    }
498 499
}

500 501
static GtkWidget *
image_scale_confirm_dialog (ImageResizeOptions *options)
502 503 504
{
  GtkWidget *dialog;

505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
  dialog = gimp_message_dialog_new (_("Confirm Scaling"),
                                    GIMP_STOCK_WARNING,
                                    options->dialog->shell,
                                    GTK_DIALOG_DESTROY_WITH_PARENT,
                                    gimp_standard_help_func,
                                    GIMP_HELP_IMAGE_SCALE_WARNING,

                                    GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                    GIMP_STOCK_SCALE, GTK_RESPONSE_OK,

                                    NULL);

  g_signal_connect (dialog, "response",
                    G_CALLBACK (image_scale_confirm_response),
                    options);

  return dialog;
}

static void
image_scale_confirm_large (ImageResizeOptions *options,
                           gint64              new_memsize,
                           gint64              max_memsize)
{
  GtkWidget *dialog = image_scale_confirm_dialog (options);
  gchar     *size;

  size = gimp_memsize_to_string (new_memsize);
  gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                                     _("You are trying to create an image "
                                       "with a size of %s."), size);
  g_free (size);

  size = gimp_memsize_to_string (max_memsize);
  gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                             _("Scaling the image to the choosen size will "
                               "make it use more memory than what is "
                               "configured as \"Maximum Image Size\" in the "
                               "Preferences dialog (currently %s)."), size);
  g_free (size);

546
  gtk_widget_show (dialog);
Michael Natterer's avatar
Michael Natterer committed
547 548 549
}

static void
550
image_scale_confirm_small (ImageResizeOptions *options)
Michael Natterer's avatar
Michael Natterer committed
551
{
552 553 554 555 556 557 558 559 560 561 562
  GtkWidget *dialog = image_scale_confirm_dialog (options);

  gimp_message_box_set_primary_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                                     _("Scaling the image to the choosen size "
                                       "will shrink some layers completely "
                                       "away."));
  gimp_message_box_set_text (GIMP_MESSAGE_DIALOG (dialog)->box,
                             _("Is this what you want to do?"));

  gtk_widget_show (dialog);
}
Michael Natterer's avatar
Michael Natterer committed
563

564 565 566 567 568 569 570 571
static void
image_scale_confirm_response (GtkWidget          *dialog,
                              gint                response_id,
                              ImageResizeOptions *options)
{
  gtk_widget_destroy (dialog);

  if (response_id == GTK_RESPONSE_OK)
Michael Natterer's avatar
Michael Natterer committed
572
    {
573 574
      image_scale_implement (options);
      gtk_widget_destroy (options->dialog->shell);
Michael Natterer's avatar
Michael Natterer committed
575 576 577
    }
  else
    {
578
      gtk_widget_set_sensitive (options->dialog->shell, TRUE);
Michael Natterer's avatar
Michael Natterer committed
579 580 581 582
    }
}

static void
583
image_scale_implement (ImageResizeOptions *options)
Michael Natterer's avatar
Michael Natterer committed
584
{
585
  GimpImage *gimage = options->gimage;
Michael Natterer's avatar
Michael Natterer committed
586

587 588 589 590
  if (options->dialog->resolution_x == gimage->xresolution     &&
      options->dialog->resolution_y == gimage->yresolution     &&
      options->dialog->unit         == gimage->resolution_unit &&
      options->dialog->width        == gimage->width           &&
591
      options->dialog->height       == gimage->height)
592
    return;
Michael Natterer's avatar
Michael Natterer committed
593

594 595
  gimp_image_undo_group_start (gimage, GIMP_UNDO_GROUP_IMAGE_SCALE,
                               _("Scale Image"));
Michael Natterer's avatar
Michael Natterer committed
596

597
  gimp_image_set_resolution (gimage,
598 599 600
                             options->dialog->resolution_x,
                             options->dialog->resolution_y);
  gimp_image_set_unit (gimage, options->dialog->unit);
Michael Natterer's avatar
Michael Natterer committed
601

602 603
  if (options->dialog->width  != gimage->width ||
      options->dialog->height != gimage->height)
Michael Natterer's avatar
Michael Natterer committed
604
    {
605 606
      if (options->dialog->width  > 0 &&
	  options->dialog->height > 0)
Michael Natterer's avatar
Michael Natterer committed
607
	{
Michael Natterer's avatar
Michael Natterer committed
608 609
          GimpProgress *progress;

610 611
          progress = gimp_progress_start (GIMP_PROGRESS (options->gdisp),
                                          _("Scaling..."), FALSE);
Michael Natterer's avatar
Michael Natterer committed
612

Michael Natterer's avatar
Michael Natterer committed
613
	  gimp_image_scale (gimage,
614 615 616
			    options->dialog->width,
			    options->dialog->height,
                            options->dialog->interpolation,
617
                            progress);
Michael Natterer's avatar
Michael Natterer committed
618

619 620
          if (progress)
            gimp_progress_end (progress);
Michael Natterer's avatar
Michael Natterer committed
621 622 623 624 625 626 627 628 629
	}
      else
	{
	  g_message (_("Scale Error: Both width and height must be "
		       "greater than zero."));
	  return;
	}
    }

630 631 632
  gimp_image_undo_group_end (gimage);

  gimp_image_flush (gimage);
Michael Natterer's avatar
Michael Natterer committed
633
}
634 635

static void
636 637 638
image_merge_layers_response (GtkWidget              *widget,
                             gint                    response_id,
                             ImageMergeLayersDialog *dialog)
639 640 641
{
  if (response_id == GTK_RESPONSE_OK)
    {
642 643
      image_merge_layers_type = dialog->merge_type;

644 645
      gimp_image_merge_visible_layers (dialog->gimage,
                                       dialog->context,
646
                                       image_merge_layers_type);
647
      gimp_image_flush (dialog->gimage);
648 649
    }

650
  gtk_widget_destroy (dialog->dialog);
651
}