resize-dialog.c 40.6 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* 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
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
17
 */
Sven Neumann's avatar
Sven Neumann committed
18

19
#include "config.h"
20

Sven Neumann's avatar
Sven Neumann committed
21
22
#include <gtk/gtk.h>

23
#include "libgimpmath/gimpmath.h"
24
#include "libgimpwidgets/gimpwidgets.h"
25

Sven Neumann's avatar
Sven Neumann committed
26
27
#include "apptypes.h"

28
#include "gdisplay.h"
29
#include "gimpimage.h"
30
#include "gimplayer.h"
31
#include "gimplist.h"
32
#include "gimprc.h"
Elliot Lee's avatar
Elliot Lee committed
33
#include "resize.h"
34
#include "undo.h"
Elliot Lee's avatar
Elliot Lee committed
35

36
#include "libgimp/gimplimits.h"
37

38
39
#include "libgimp/gimpintl.h"

40

Elliot Lee's avatar
Elliot Lee committed
41
42
43
44
typedef struct _ResizePrivate ResizePrivate;

struct _ResizePrivate
{
45
46
47
48
49
50
51
52
53
54
55
56
  /*  size frame  */
  GtkWidget *orig_width_label;
  GtkWidget *orig_height_label;

  GtkWidget *size_se;

  GtkObject *ratio_x_adj;
  GtkObject *ratio_y_adj;
  GtkWidget *constrain;

  /*  offset frame  */
  GtkWidget *offset_se;
57
  GtkWidget *offset_area;
Elliot Lee's avatar
Elliot Lee committed
58

59
60
61
62
63
  /*  resolution frame  */
  GtkWidget *printsize_se;
  GtkWidget *resolution_se;
  GtkWidget *equal_res;

Sven Neumann's avatar
Sven Neumann committed
64
65
  gint       old_width, old_height;
  gdouble    old_res_x, old_res_y;
Elliot Lee's avatar
Elliot Lee committed
66
67
};

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
static void  unit_update                 (GtkWidget *widget,
					  gpointer   data);
static gint  resize_bound_off_x          (Resize    *resize,
					  gint       off_x);
static gint  resize_bound_off_y          (Resize    *resize,
					  gint       off_y);
static void  orig_labels_update          (GtkWidget *widget,
					  gpointer   data);
static void  reset_callback              (GtkWidget *widget,
					  gpointer   data);
static void  size_callback               (GtkWidget *widget,
					  gpointer   data);
static void  ratio_callback              (GtkWidget *widget,
					  gpointer   data);
static void  size_update                 (Resize    *widget,
					  gdouble    width,
					  gdouble    height,
					  gdouble    ratio_x,
					  gdouble    ratio_y);
87
88
89
90
static void offset_area_offsets_changed  (GtkWidget *offset_area,
                                          gint       offset_x,
                                          gint       offset_y,
                                          gpointer   data);
91
92
93
94
95
96
97
98
99
100
101
102
103
static void  offset_update               (GtkWidget *widget,
					  gpointer   data);
static void  printsize_update            (GtkWidget *widget,
					  gpointer   data);
static void  resolution_callback         (GtkWidget *widget,
					  gpointer   data);
static void  resolution_update           (Resize    *resize,
					  gdouble    res_x,
					  gdouble    res_y);
static void  resize_scale_warn_callback  (GtkWidget *widget,
					  gboolean   do_scale,
					  gpointer   data);

Elliot Lee's avatar
Elliot Lee committed
104
105

Resize *
106
107
108
resize_widget_new (ResizeType    type,
		   ResizeTarget  target,
		   GtkObject    *object,
109
		   gchar        *signal,
110
111
112
113
		   gint          width,
		   gint          height,
		   gdouble       resolution_x,
		   gdouble       resolution_y,
114
		   GimpUnit      unit,
115
		   gboolean      dot_for_dot,
116
117
118
		   GtkSignalFunc ok_cb,
		   GtkSignalFunc cancel_cb,
		   gpointer      user_data)
Elliot Lee's avatar
Elliot Lee committed
119
120
121
{
  Resize *resize;
  ResizePrivate *private;
122
  GtkWidget *main_vbox;
Elliot Lee's avatar
Elliot Lee committed
123
  GtkWidget *vbox;
124
125
  GtkWidget *table;
  GtkWidget *table2;
Elliot Lee's avatar
Elliot Lee committed
126
127
  GtkWidget *label;
  GtkWidget *frame;
128
  GtkWidget *spinbutton;
129
  GtkWidget *abox;
130
  GtkObject *adjustment;
Elliot Lee's avatar
Elliot Lee committed
131

132
  abox = NULL;
133
  frame = NULL;
Elliot Lee's avatar
Elliot Lee committed
134

135
  private = g_new0 (ResizePrivate, 1);
136
137
138
139
140
141
142
143
  private->old_width  = width;
  private->old_height = height;
  private->old_res_x  = resolution_x;
  private->old_res_y  = resolution_y;

  resize = g_new (Resize, 1);
  resize->type         = type;
  resize->target       = target;
Elliot Lee's avatar
Elliot Lee committed
144
  resize->private_part = private;
145
146
  resize->width        = width;
  resize->height       = height;
147
148
  resize->resolution_x = resolution_x;
  resize->resolution_y = resolution_y;
149
150
151
152
153
  resize->unit         = unit;
  resize->ratio_x      = 1.0;
  resize->ratio_y      = 1.0;
  resize->offset_x     = 0;
  resize->offset_y     = 0;
Elliot Lee's avatar
Elliot Lee committed
154

155
  /*  dialog box  */
156
  {
157
158
159
160
161
162
163
164
165
166
    const gchar *wmclass = NULL;
    const gchar *window_title = NULL;
    gchar *help_page = NULL;

    switch (type)
      {
      case ScaleWidget:
	switch (target)
	  {
	  case ResizeLayer:
167
168
	    wmclass = "scale_layer";
	    window_title = _("Scale Layer");
Michael Natterer's avatar
Michael Natterer committed
169
	    help_page = "layers/dialogs/scale_layer.html";
170
	    frame = gtk_frame_new (_("Size"));
171
	    break;
172
	  case ResizeImage:
173
174
	    wmclass = "scale_image";
	    window_title = _("Scale Image");
175
	    help_page = "dialogs/scale_image.html";
176
	    frame = gtk_frame_new (_("Pixel Dimensions"));
177
	    break;
178
	  }
179
180
	break;

181
182
183
184
      case ResizeWidget:
	switch (target)
	  {
	  case ResizeLayer:
185
	    wmclass = "resize_layer";
186
	    window_title = _("Set Layer Boundary Size");
187
	    help_page = "layers/dialogs/layer_boundary_size.html";
188
	    break;
189
	  case ResizeImage:
190
191
	    wmclass = "resize_image";
	    window_title = _("Set Canvas Size");
192
	    help_page = "dialogs/set_canvas_size.html";
193
	    break;
194
	  }
195
	frame = gtk_frame_new (_("Size"));
196
	break;
197
198
199
200
201
202
203
204
205
      }	

    resize->resize_shell =
      gimp_dialog_new (window_title, wmclass,
		       gimp_standard_help_func, help_page,
		       GTK_WIN_POS_MOUSE,
		       FALSE, FALSE, TRUE,

		       _("OK"), ok_cb,
206
		       user_data, NULL, NULL, TRUE, FALSE,
207
208

		       _("Reset"), reset_callback,
209
		       resize, NULL, NULL, FALSE, FALSE,
210

211
212
213
214
215
		       _("Cancel"), cancel_cb ? cancel_cb : gtk_widget_destroy,
		       cancel_cb ? user_data : NULL,
		       cancel_cb ? NULL : (gpointer) 1,
		       NULL, FALSE, TRUE,

216
		       NULL);
217
218
219
220
221
222
223

    gtk_signal_connect_object (GTK_OBJECT (resize->resize_shell), "destroy",
			       GTK_SIGNAL_FUNC (g_free),
			       (GtkObject *) private);
    gtk_signal_connect_object (GTK_OBJECT (resize->resize_shell), "destroy",
			       GTK_SIGNAL_FUNC (g_free),
			       (GtkObject *) resize);
224
225
  }

226
  /*  handle the image disappearing under our feet  */
227
  if (object && signal)
228
    {
229
230
231
232
233
234
235
236
237
      if (cancel_cb)
	gtk_signal_connect (GTK_OBJECT (object), signal,
			    cancel_cb,
			    user_data);
      else
	gtk_signal_connect_object_while_alive
	  (GTK_OBJECT (object), signal,
	   GTK_SIGNAL_FUNC (gtk_widget_destroy),
	   GTK_OBJECT (resize->resize_shell));
238
    }
239

240
  /*  the main vbox  */
241
242
  main_vbox = gtk_vbox_new (FALSE, 4);
  gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 4);
243
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (resize->resize_shell)->vbox),
244
		     main_vbox);
245

246
  /*  the pixel dimensions frame  */
247
  gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
248
  gtk_widget_show (frame);
Elliot Lee's avatar
Elliot Lee committed
249

250
251
252
  vbox = gtk_vbox_new (FALSE, 2);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
  gtk_container_add (GTK_CONTAINER (frame), vbox);
Elliot Lee's avatar
Elliot Lee committed
253

254
  table = gtk_table_new (6, 2, FALSE);
255
  gtk_container_set_border_width (GTK_CONTAINER (table), 2);
256
257
258
259
260
  gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
  gtk_table_set_row_spacing (GTK_TABLE (table), 0, 4);
  gtk_table_set_row_spacing (GTK_TABLE (table), 1, 4);
  gtk_table_set_row_spacing (GTK_TABLE (table), 3, 4);
  gtk_table_set_row_spacing (GTK_TABLE (table), 4, 2);
261
  gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
262
263
264
265

  /*  the original width & height labels  */
  label = gtk_label_new (_("Original Width:"));
  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
Elliot Lee's avatar
Elliot Lee committed
266
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
267
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
Elliot Lee's avatar
Elliot Lee committed
268
269
  gtk_widget_show (label);

270
271
  label = gtk_label_new (_("Height:"));
  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
Elliot Lee's avatar
Elliot Lee committed
272
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
273
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
Elliot Lee's avatar
Elliot Lee committed
274
275
  gtk_widget_show (label);

276
277
278
279
280
281
282
283
284
285
286
287
  private->orig_width_label = gtk_label_new ("");
  gtk_misc_set_alignment (GTK_MISC ( private->orig_width_label), 0.0, 0.5);
  gtk_table_attach (GTK_TABLE (table),  private->orig_width_label, 1, 2, 0, 1,
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  gtk_widget_show ( private->orig_width_label);

  private->orig_height_label = gtk_label_new ("");
  gtk_misc_set_alignment (GTK_MISC (private->orig_height_label), 0.0, 0.5);
  gtk_table_attach (GTK_TABLE (table), private->orig_height_label, 1, 2, 1, 2,
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  gtk_widget_show (private->orig_height_label);

288
  /*  the new size labels  */
289
290
  label = gtk_label_new (_("New Width:"));
  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
291
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
292
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
293
294
  gtk_widget_show (label);

295
296
  label = gtk_label_new (_("Height:"));
  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
297
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
298
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
299
  gtk_widget_show (label);
300

301
  /*  the new size sizeentry  */
302
303
304
305
306
307
308
309
  adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
  spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
  gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
                                   GTK_SHADOW_NONE);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
  gtk_widget_set_usize (spinbutton, 75, 0);

  private->size_se =
310
    gimp_size_entry_new (1, unit, "%a", TRUE, TRUE, FALSE, 75,
311
312
313
314
315
316
317
318
319
320
			 GIMP_SIZE_ENTRY_UPDATE_SIZE);
  gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->size_se),
			     GTK_SPIN_BUTTON (spinbutton), NULL);
  gtk_table_attach_defaults (GTK_TABLE (private->size_se), spinbutton,
			     1, 2, 0, 1);
  gtk_widget_show (spinbutton);
  gtk_table_attach (GTK_TABLE (table), private->size_se, 1, 2, 2, 4,
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  gtk_widget_show (private->size_se);

321
  if (dot_for_dot)
322
323
    gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->size_se),
			      GIMP_UNIT_PIXEL);
324

325
326
327
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0,
				  resolution_x, FALSE);
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 1,
328
329
				  resolution_y, FALSE);

330
331
332
333
334
335
  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se), 0,
					 GIMP_MIN_IMAGE_SIZE,
					 GIMP_MAX_IMAGE_SIZE);
  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (private->size_se), 1,
					 GIMP_MIN_IMAGE_SIZE,
					 GIMP_MAX_IMAGE_SIZE);
336
337
338
339
340
341

  gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->size_se), 0, 0, width);
  gimp_size_entry_set_size (GIMP_SIZE_ENTRY (private->size_se), 1, 0, height);

  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->size_se), 0, width);
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->size_se), 1, height);
342
343

  gtk_signal_connect (GTK_OBJECT (private->size_se), "value_changed",
344
		      GTK_SIGNAL_FUNC (size_callback),
345
346
		      resize);
  gtk_signal_connect (GTK_OBJECT (private->size_se), "unit_changed",
347
		      GTK_SIGNAL_FUNC (orig_labels_update),
348
349
		      resize);

350
  /*  initialize the original width & height labels  */
351
  orig_labels_update (private->size_se, resize);
352

353
  /*  the scale ratio labels  */
354
355
356
357
358
359
360
361
362
363
364
365
  label = gtk_label_new (_("Ratio X:"));
  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 4, 5,
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  gtk_widget_show (label);

  label = gtk_label_new (_("Y:"));
  gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 5, 6,
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  gtk_widget_show (label);

366
  /*  a table for the spinbuttons and the chainbutton  */
367
  abox = gtk_alignment_new (0.0, 0.5, 0.0, 1.0);
368
369
  table2 = gtk_table_new (2, 2, FALSE);
  gtk_table_set_col_spacing (GTK_TABLE (table2), 0, 2);
370
  gtk_table_set_row_spacing (GTK_TABLE (table2), 0, 2);
371
372
  gtk_container_add (GTK_CONTAINER (abox), table2);
  gtk_table_attach (GTK_TABLE (table), abox, 1, 2, 4, 6,
373
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
374
  gtk_widget_show (abox);
375
  
376
  /*  the scale ratio spinbuttons  */
377
  private->ratio_x_adj =
378
    gtk_adjustment_new (resize->ratio_x, 
379
380
			(double) GIMP_MIN_IMAGE_SIZE / (double) resize->width,
			(double) GIMP_MAX_IMAGE_SIZE / (double) resize->width,
381
			0.01, 0.1, 1);
382
383
384
385
386
387
388
  spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (private->ratio_x_adj), 1, 4);
  gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
                                   GTK_SHADOW_NONE);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
  gtk_widget_set_usize (spinbutton, 75, 0);
  gtk_table_attach_defaults (GTK_TABLE (table2), spinbutton, 0, 1, 0, 1);
  gtk_signal_connect (GTK_OBJECT ( private->ratio_x_adj), "value_changed",
389
		      (GtkSignalFunc) ratio_callback,
390
391
392
393
		      resize);
  gtk_widget_show (spinbutton);

  private->ratio_y_adj =
394
    gtk_adjustment_new (resize->ratio_y,
395
396
			(double) GIMP_MIN_IMAGE_SIZE / (double) resize->height,
			(double) GIMP_MAX_IMAGE_SIZE / (double) resize->height,
397
			0.01, 0.1, 1);
398
399
400
401
402
403
404
  spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (private->ratio_y_adj), 1, 4);
  gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
                                   GTK_SHADOW_NONE);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
  gtk_widget_set_usize (spinbutton, 75, 0);
  gtk_table_attach_defaults (GTK_TABLE (table2), spinbutton, 0, 1, 1, 2);
  gtk_signal_connect (GTK_OBJECT ( private->ratio_y_adj), "value_changed",
405
		      (GtkSignalFunc) ratio_callback,
406
407
408
		      resize);
  gtk_widget_show (spinbutton);

409
  /*  the constrain ratio chainbutton  */
410
411
412
413
414
415
416
  private->constrain = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
  gimp_chain_button_set_active (GIMP_CHAIN_BUTTON (private->constrain), TRUE);
  gtk_table_attach_defaults (GTK_TABLE (table2), private->constrain, 1, 2, 0, 2);
  gtk_widget_show (private->constrain);

  gtk_widget_show (table2);
  gtk_widget_show (table);
417
  gtk_widget_show (vbox);
418
419

  /*  the offset frame  */
Elliot Lee's avatar
Elliot Lee committed
420
421
  if (type == ResizeWidget)
    {
422
      frame = gtk_frame_new (_("Offset"));
423
      gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
424
425
      gtk_widget_show (frame);

426
427
428
      vbox = gtk_vbox_new (FALSE, 4);
      gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
      gtk_container_add (GTK_CONTAINER (frame), vbox);
429

430
431
      abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
      gtk_box_pack_start (GTK_BOX (vbox), abox, FALSE, FALSE, 0);
432
 
433
      /*  the offset sizeentry  */
434
435
436
437
438
439
440
441
      adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
      spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
      gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
				       GTK_SHADOW_NONE);
      gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
      gtk_widget_set_usize (spinbutton, 75, 0);

      private->offset_se =
442
	gimp_size_entry_new (1, unit, "%a", TRUE, FALSE, FALSE, 75,
443
444
445
446
447
			     GIMP_SIZE_ENTRY_UPDATE_SIZE);
      gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->offset_se),
				 GTK_SPIN_BUTTON (spinbutton), NULL);
      gtk_table_attach_defaults (GTK_TABLE (private->offset_se), spinbutton,
				 1, 2, 0, 1);
448
449
450
451
452
      gtk_table_set_col_spacing (GTK_TABLE (private->offset_se), 0, 4);
      gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (private->offset_se),
				    _("X:"), 0, 0, 1.0);
      gimp_size_entry_attach_label (GIMP_SIZE_ENTRY (private->offset_se),
				    _("Y:"), 1, 0, 1.0);
453
      gtk_widget_show (spinbutton);
454
      gtk_container_add (GTK_CONTAINER (abox), private->offset_se);
455
456
      gtk_widget_show (private->offset_se);

457
458
      if (dot_for_dot)
	gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->offset_se),
459
				  GIMP_UNIT_PIXEL);
460

461
462
      gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 0,
				      resolution_x, FALSE);
463
464
      gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 1,
				      resolution_y, FALSE);
465

466
467
      gimp_size_entry_set_refval_boundaries
	(GIMP_SIZE_ENTRY (private->offset_se), 0, 0, 0);
468
469
      gimp_size_entry_set_refval_boundaries
	(GIMP_SIZE_ENTRY (private->offset_se), 1, 0, 0);
470
471

      gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->offset_se), 0, 0);
472
473
      gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->offset_se), 1, 0);

474
      gtk_signal_connect (GTK_OBJECT (private->offset_se), "value_changed",
475
476
			  GTK_SIGNAL_FUNC (offset_update),
			  resize);
Elliot Lee's avatar
Elliot Lee committed
477

478
      gtk_widget_show (abox);
Elliot Lee's avatar
Elliot Lee committed
479

480
      /*  frame to hold GimpOffsetArea  */
481
482
      abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
      gtk_box_pack_start (GTK_BOX (vbox), abox, FALSE, FALSE, 0);
483

Elliot Lee's avatar
Elliot Lee committed
484
485
      frame = gtk_frame_new (NULL);
      gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
486
487
      gtk_container_add (GTK_CONTAINER (abox), frame);

488
489
490
491
492
493
494
      private->offset_area = gimp_offset_area_new (private->old_width,
                                                   private->old_height);
      gtk_signal_connect (GTK_OBJECT (private->offset_area), "offsets_changed",
			  GTK_SIGNAL_FUNC (offset_area_offsets_changed),
			  resize);
      gtk_container_add (GTK_CONTAINER (frame), private->offset_area);
      gtk_widget_show (private->offset_area);
Elliot Lee's avatar
Elliot Lee committed
495
      gtk_widget_show (frame);
496
497
      gtk_widget_show (abox);
      gtk_widget_show (vbox);
Elliot Lee's avatar
Elliot Lee committed
498
499
    }

500
501
502
  /*  the resolution stuff  */
  if ((type == ScaleWidget) && (target == ResizeImage))
    {
503
      frame = gtk_frame_new (_("Print Size & Display Unit"));
504
      gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
505
506
      gtk_widget_show (frame);

507
508
509
      vbox = gtk_vbox_new (FALSE, 2);
      gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
      gtk_container_add (GTK_CONTAINER (frame), vbox);
510
511
512
513

      table = gtk_table_new (4, 2, FALSE);
      gtk_table_set_col_spacing (GTK_TABLE (table), 0, 4);
      gtk_table_set_row_spacing (GTK_TABLE (table), 1, 4);
514
      gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
515

516
      /*  the print size labels  */
517
518
519
520
521
522
523
524
525
526
527
528
      label = gtk_label_new (_("New Width:"));
      gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
			GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
      gtk_widget_show (label);

      label = gtk_label_new (_("Height:"));
      gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 1, 2,
			GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
      gtk_widget_show (label);

529
      /*  the print size sizeentry  */
530
      abox = gtk_alignment_new (0.0, 0.5, 0.0, 1.0);
531
532
533
534
535
536
      adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
      spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
      gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
				       GTK_SHADOW_NONE);
      gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
      gtk_widget_set_usize (spinbutton, 75, 0);
537
      gtk_container_add (GTK_CONTAINER (abox), spinbutton);
538
      gtk_widget_show (spinbutton);
539
      gtk_table_attach (GTK_TABLE (table), abox, 1, 2, 0, 1,
540
			GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
541
      gtk_widget_show (abox);
542

543
      abox = gtk_alignment_new (0.0, 0.5, 0.0, 1.0);
544
545
546
547
548
      private->printsize_se =
	gimp_size_entry_new (1, unit, "%a", FALSE, FALSE, FALSE, 75,
			     GIMP_SIZE_ENTRY_UPDATE_SIZE);
      gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->printsize_se),
				 GTK_SPIN_BUTTON (spinbutton), NULL);
549
550
      gtk_container_add (GTK_CONTAINER (abox), private->printsize_se);
      gtk_table_attach (GTK_TABLE (table), abox, 1, 2, 1, 2,
551
552
			GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
      gtk_widget_show (private->printsize_se);
553
      gtk_widget_show (abox);
554
555
556

      gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->printsize_se),
				      0, resolution_x, FALSE);
557
558
559
560
561
      gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->printsize_se),
				      1, resolution_y, FALSE);

      gimp_size_entry_set_refval_boundaries
	(GIMP_SIZE_ENTRY (private->printsize_se),
562
	 0, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
563
564
      gimp_size_entry_set_refval_boundaries
	(GIMP_SIZE_ENTRY (private->printsize_se),
565
	 1, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
566

567
568
569
570
571
      gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->printsize_se),
				  0, resize->width);
      gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->printsize_se),
				  1, resize->height);

572
      gtk_signal_connect (GTK_OBJECT (private->printsize_se), "value_changed",
573
			  GTK_SIGNAL_FUNC (printsize_update),
574
			  resize);
575
      gtk_signal_connect (GTK_OBJECT (private->printsize_se), "unit_changed",
576
			  GTK_SIGNAL_FUNC (unit_update),
577
578
			  resize);
      
579
      /*  the resolution labels  */
580
581
582
583
584
585
586
587
588
589
590
591
      label = gtk_label_new (_("Resolution X:"));
      gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 2, 3,
			GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
      gtk_widget_show (label);

      label = gtk_label_new (_("Y:"));
      gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
      gtk_table_attach (GTK_TABLE (table), label, 0, 1, 3, 4,
			GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
      gtk_widget_show (label);

592
      /*  the resolution sizeentry  */
593
594
595
596
597
598
599
600
      adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
      spinbutton = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 2);
      gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton),
				       GTK_SHADOW_NONE);
      gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
      gtk_widget_set_usize (spinbutton, 75, 0);

      private->resolution_se =
601
	gimp_size_entry_new (1, default_resolution_units, _("pixels/%a"),
602
603
604
605
606
607
608
609
610
611
612
613
614
615
			     FALSE, FALSE, FALSE, 75,
			     GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
      gtk_table_set_col_spacing (GTK_TABLE (private->resolution_se), 1, 2);
      gtk_table_set_col_spacing (GTK_TABLE (private->resolution_se), 2, 2);
      gimp_size_entry_add_field (GIMP_SIZE_ENTRY (private->resolution_se),
				 GTK_SPIN_BUTTON (spinbutton), NULL);
      gtk_table_attach_defaults (GTK_TABLE (private->resolution_se), spinbutton,
				 1, 2, 0, 1);
      gtk_widget_show (spinbutton);
      gtk_table_attach (GTK_TABLE (table), private->resolution_se, 1, 2, 2, 4,
			GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
      gtk_widget_show (private->resolution_se);

      gimp_size_entry_set_refval_boundaries
616
	(GIMP_SIZE_ENTRY (private->resolution_se),
617
	 0, GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
618
619
      gimp_size_entry_set_refval_boundaries
	(GIMP_SIZE_ENTRY (private->resolution_se),
620
	 1, GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION);
621

622
623
624
625
626
      gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->resolution_se),
				  0, resize->resolution_x);
      gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->resolution_se),
				  1, resize->resolution_y);

627
      gtk_signal_connect (GTK_OBJECT (private->resolution_se), "value_changed",
628
			  GTK_SIGNAL_FUNC (resolution_callback),
629
630
			  resize);

631
      /*  the resolution chainbutton  */
632
633
634
635
636
637
638
639
640
      private->equal_res = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
      gimp_chain_button_set_active
	(GIMP_CHAIN_BUTTON (private->equal_res),
	 ABS (resize->resolution_x - resize->resolution_y) < 1e-5);
      gtk_table_attach_defaults (GTK_TABLE (private->resolution_se),
				 private->equal_res, 2, 3, 0, 2);
      gtk_widget_show (private->equal_res);

      gtk_widget_show (table);
641
      gtk_widget_show (vbox);
642
643
    }

644
  gtk_widget_show (main_vbox);
Elliot Lee's avatar
Elliot Lee committed
645

646
647
  /*  finally, activate the first entry  */
  gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (private->size_se));
648

Elliot Lee's avatar
Elliot Lee committed
649
650
651
  return resize;
}

652
static gint
Elliot Lee's avatar
Elliot Lee committed
653
resize_bound_off_x (Resize *resize,
654
		    gint    off_x)
Elliot Lee's avatar
Elliot Lee committed
655
656
657
658
659
660
{
  ResizePrivate *private;

  private = (ResizePrivate *) resize->private_part;

  if (private->old_width <= resize->width)
661
    off_x = CLAMP (off_x, 0, (resize->width - private->old_width));
Elliot Lee's avatar
Elliot Lee committed
662
  else
663
    off_x = CLAMP (off_x, (resize->width - private->old_width), 0);
Elliot Lee's avatar
Elliot Lee committed
664
665
666
667

  return off_x;
}

668
static gint
Elliot Lee's avatar
Elliot Lee committed
669
resize_bound_off_y (Resize *resize,
670
		    gint    off_y)
Elliot Lee's avatar
Elliot Lee committed
671
672
673
674
675
676
{
  ResizePrivate *private;

  private = (ResizePrivate *) resize->private_part;

  if (private->old_height <= resize->height)
677
    off_y = CLAMP (off_y, 0, (resize->height - private->old_height));
Elliot Lee's avatar
Elliot Lee committed
678
  else
679
    off_y = CLAMP (off_y, (resize->height - private->old_height), 0);
Elliot Lee's avatar
Elliot Lee committed
680
681
682
683
684

  return off_y;
}

static void
685
orig_labels_update (GtkWidget *widget,
686
		    gpointer   data)
Elliot Lee's avatar
Elliot Lee committed
687
{
688
  Resize        *resize;
Elliot Lee's avatar
Elliot Lee committed
689
  ResizePrivate *private;
690
691
692
  GimpUnit       unit;
  gchar          format_buf[16];
  gchar          buf[32];
693

694
  static GimpUnit label_unit = GIMP_UNIT_PIXEL;
Elliot Lee's avatar
Elliot Lee committed
695
696
697
698

  resize = (Resize *) data;
  private = (ResizePrivate *) resize->private_part;

699
  unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget));
Elliot Lee's avatar
Elliot Lee committed
700

701
  if (unit != GIMP_UNIT_PERCENT)
702
    label_unit = unit;
Elliot Lee's avatar
Elliot Lee committed
703

704
  if (label_unit) /* unit != GIMP_UNIT_PIXEL */
Elliot Lee's avatar
Elliot Lee committed
705
    {
706
      gdouble unit_factor = gimp_unit_get_factor (label_unit);
707
  
708
      g_snprintf (format_buf, sizeof (format_buf), "%%.%df %s",
709
710
                  gimp_unit_get_digits (label_unit) + 1,
                  gimp_unit_get_symbol (label_unit));
711
      g_snprintf (buf, sizeof (buf), format_buf,
712
713
                  private->old_width * unit_factor / private->old_res_x);
      gtk_label_set_text (GTK_LABEL (private->orig_width_label), buf);
714
      g_snprintf (buf, sizeof (buf), format_buf,
715
716
717
                  private->old_height * unit_factor / private->old_res_y);
      gtk_label_set_text (GTK_LABEL (private->orig_height_label), buf);
    }
718
  else /* unit == GIMP_UNIT_PIXEL */
719
    {
720
      g_snprintf (buf, sizeof (buf), "%d", private->old_width);
721
      gtk_label_set_text (GTK_LABEL (private->orig_width_label), buf);
722
      g_snprintf (buf, sizeof (buf), "%d", private->old_height);
723
      gtk_label_set_text (GTK_LABEL (private->orig_height_label), buf);
Elliot Lee's avatar
Elliot Lee committed
724
725
726
    }
}

727
static void
728
unit_update (GtkWidget *widget,
729
730
731
732
733
	     gpointer   data)
{
  Resize *resize;

  resize = (Resize *) data;
734
  resize->unit = gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (widget));
735
736
}

Elliot Lee's avatar
Elliot Lee committed
737
static void
738
offset_update (GtkWidget *widget,
739
	       gpointer   data)
Elliot Lee's avatar
Elliot Lee committed
740
741
742
743
744
745
746
{
  Resize *resize;
  ResizePrivate *private;

  resize = (Resize *) data;
  private = (ResizePrivate *) resize->private_part;

747
748
  resize->offset_x = resize_bound_off_x (resize, 
                                         RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->offset_se), 0)));
Elliot Lee's avatar
Elliot Lee committed
749

750
751
  resize->offset_y = resize_bound_off_y (resize, 
                                         RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->offset_se), 1)));  
752

753
754
  gimp_offset_area_set_offsets (GIMP_OFFSET_AREA (private->offset_area),
                                resize->offset_x, resize->offset_y); 
Elliot Lee's avatar
Elliot Lee committed
755
756
}

757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
/*
 * Callback function for "Reset" button.
 * Data must be a pointer pointer to a Resize structure.
 */
static void
reset_callback (GtkWidget *widget,
                gpointer data)
{
  Resize *resize;
  ResizePrivate *private;

  resize = (Resize *)data;
  private = (ResizePrivate *)resize->private_part;

  /* restore size and ratio settings */
  size_update (resize, private->old_width, private->old_height, 1.0, 1.0);

  if ((resize->type == ScaleWidget) && (resize->target == ResizeImage))
    {
      /* restore resolution settings */
      resolution_update (resize, private->old_res_x, private->old_res_y);
    }

}
  
Elliot Lee's avatar
Elliot Lee committed
782
static void
783
size_callback (GtkWidget *widget,
784
	       gpointer   data)
Elliot Lee's avatar
Elliot Lee committed
785
786
787
{
  Resize *resize;
  ResizePrivate *private;
788
789
790
791
  gdouble width;
  gdouble height;
  gdouble ratio_x;
  gdouble ratio_y;
Elliot Lee's avatar
Elliot Lee committed
792

793
  resize  = (Resize *) data;
Elliot Lee's avatar
Elliot Lee committed
794
795
  private = (ResizePrivate *) resize->private_part;

796
  width  = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 0);
797
  height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 1);
Elliot Lee's avatar
Elliot Lee committed
798

799
800
  ratio_x = width  / (gdouble) private->old_width;
  ratio_y = height / (gdouble) private->old_height;
801
802
803

  if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (private->constrain)))
    {
804
      if (ratio_x != resize->ratio_x)
805
806
	{
	  ratio_y = ratio_x;
807
	  height = (gdouble) private->old_height * ratio_y;
808
	  height = CLAMP (height, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
809
810
811
812
	}
      else
	{
	  ratio_x = ratio_y;
813
	  width = (gdouble) private->old_width * ratio_x;
814
	  width = CLAMP (width, GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
815
816
	}
    }
Elliot Lee's avatar
Elliot Lee committed
817

818
  size_update (resize, width, height, ratio_x, ratio_y);
Elliot Lee's avatar
Elliot Lee committed
819
820
821
}

static void
822
ratio_callback (GtkWidget *widget,
823
		gpointer   data)
Elliot Lee's avatar
Elliot Lee committed
824
825
826
{
  Resize *resize;
  ResizePrivate *private;
827
828
829
830
  gdouble width;
  gdouble height;
  gdouble ratio_x;
  gdouble ratio_y;
831

832
  resize  = (Resize *) data;
Elliot Lee's avatar
Elliot Lee committed
833
834
  private = (ResizePrivate *) resize->private_part;

835
  width  = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 0);
836
837
  height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 1);

838
839
  ratio_x = GTK_ADJUSTMENT (private->ratio_x_adj)->value;
  ratio_y = GTK_ADJUSTMENT (private->ratio_y_adj)->value;
Elliot Lee's avatar
Elliot Lee committed
840

841
842
843
844
845
846
847
848
849
850
851
852
  if (gimp_chain_button_get_active (GIMP_CHAIN_BUTTON (private->constrain)))
    {
      if (ratio_x != resize->ratio_x)
	{
	  ratio_y = ratio_x;
	}
      else
	{
	  ratio_x = ratio_y;
	}
    }

853
854
  width  = CLAMP (private->old_width * ratio_x,
		  GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
855
  height = CLAMP (private->old_height * ratio_y,
856
		  GIMP_MIN_IMAGE_SIZE, GIMP_MAX_IMAGE_SIZE);
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871

  size_update (resize, width, height, ratio_x, ratio_y);
}

static void
size_update (Resize *resize,
	     double  width,
	     double  height,
	     double  ratio_x,
	     double  ratio_y)
{
  ResizePrivate *private;

  private = (ResizePrivate *) resize->private_part;

872
  resize->width  = (gint) (width  + 0.5);
873
  resize->height = (gint) (height + 0.5);
874
875
876
877

  resize->ratio_x = ratio_x;
  resize->ratio_y = ratio_y;

878
879
880
  gimp_offset_area_set_size  (GIMP_OFFSET_AREA (private->offset_area), 
                              resize->width, resize->height);

881
  gtk_signal_handler_block_by_data (GTK_OBJECT (private->size_se), resize);
882
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->size_se),
883
			      0, width);
884
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->size_se),
885
886
			      1, height);
  gtk_signal_handler_unblock_by_data (GTK_OBJECT (private->size_se), resize);
887

888
889
  gtk_signal_handler_block_by_data (GTK_OBJECT (private->ratio_x_adj), resize);
  gtk_signal_handler_block_by_data (GTK_OBJECT (private->ratio_y_adj), resize);
890
891
  gtk_adjustment_set_value (GTK_ADJUSTMENT (private->ratio_x_adj), ratio_x);
  gtk_adjustment_set_value (GTK_ADJUSTMENT (private->ratio_y_adj), ratio_y);
892
893
  gtk_signal_handler_unblock_by_data (GTK_OBJECT (private->ratio_x_adj), resize);
  gtk_signal_handler_unblock_by_data (GTK_OBJECT (private->ratio_y_adj), resize);
894
  
Elliot Lee's avatar
Elliot Lee committed
895
896
  if (resize->type == ResizeWidget)
    {
897
      gimp_size_entry_set_refval_boundaries
898
899
900
        (GIMP_SIZE_ENTRY (private->offset_se), 0,
         MIN (0, resize->width - private->old_width),
         MAX (0, resize->width - private->old_width));
901
      gimp_size_entry_set_refval_boundaries
902
903
904
        (GIMP_SIZE_ENTRY (private->offset_se), 1,
         MIN (0, resize->height - private->old_height),
         MAX (0, resize->height - private->old_height));
Elliot Lee's avatar
Elliot Lee committed
905
906
    }

907
  if ((resize->type == ScaleWidget) && (resize->target == ResizeImage))
Elliot Lee's avatar
Elliot Lee committed
908
    {
909
910
      gtk_signal_handler_block_by_data (GTK_OBJECT (private->printsize_se),
					resize);
911
      gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->printsize_se),
912
				  0, width);
913
      gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->printsize_se),
914
915
916
				  1, height);
      gtk_signal_handler_unblock_by_data (GTK_OBJECT (private->printsize_se),
					  resize);
917
    }
918
}
919

920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
static void
offset_area_offsets_changed (GtkWidget *offset_area,
                             gint       offset_x,
                             gint       offset_y,
                             gpointer   data)
{
  Resize        *resize;
  ResizePrivate *private;

  resize  = (Resize *) data;
  private = (ResizePrivate *) resize->private_part;

  resize->offset_x = offset_x;
  resize->offset_y = offset_y;
  
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->offset_se),
                              0, resize->offset_x);
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (private->offset_se),
                              1, resize->offset_y);
939
940
}

941

942
static void
943
printsize_update (GtkWidget *widget,
944
		  gpointer   data)
945
946
947
{
  Resize *resize;
  ResizePrivate *private;
948
949
950
951
952
953
954
955
  gdouble width;
  gdouble height;
  gdouble print_width;
  gdouble print_height;
  gdouble res_x;
  gdouble res_y;

  resize  = (Resize *) data;
956
957
  private = (ResizePrivate *) resize->private_part;

958
  width  = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 0);
959
  height = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->size_se), 1);
960

961
962
963
964
  print_width =
    gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->printsize_se), 0);
  print_height =
    gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (private->printsize_se), 1);
965

966
967
968
969
  /*  this is tricky: we use the sizes in pixels (which is otherwise
   *  meaningless for the "print size" widgets) to calculate the new
   *  resolution.
   */
Michael Natterer's avatar