file-new-dialog.c 21.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995-1999 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.
 */
18 19 20

#include "config.h"

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

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

Michael Natterer's avatar
Michael Natterer committed
27
#include "core/core-types.h"
28

29
#include "file-new-dialog.h"
30
#include "gdisplay.h"
31

32 33
#include "image_new.h"
#include "gimprc.h"
34

35
#include "libgimp/gimpintl.h"
36

37

38 39
typedef struct
{
40
  GtkWidget *dlg;
41

42 43 44 45 46
  GtkWidget *confirm_dlg;

  GtkWidget *size_frame;
  GtkWidget *size_se;
  GtkWidget *resolution_se;
47
  GtkWidget *couple_resolutions;
48

49
  /* this should be a list */
50 51 52
  GtkWidget *type_w[2];
  GtkWidget *fill_type_w[4];

53 54 55
  GimpImageNewValues *values;
  gdouble size;
} NewImageInfo;
56 57

/*  new image local functions  */
Michael Natterer's avatar
Michael Natterer committed
58
static void file_new_confirm_dialog      (NewImageInfo *);
59

Michael Natterer's avatar
Michael Natterer committed
60 61 62
static void file_new_ok_callback         (GtkWidget *, gpointer);
static void file_new_reset_callback      (GtkWidget *, gpointer);
static void file_new_cancel_callback     (GtkWidget *, gpointer);
63
static void file_new_resolution_callback (GtkWidget *, gpointer);
64
static void file_new_image_size_callback (GtkWidget *, gpointer);
65

66 67 68 69
static void
file_new_ok_callback (GtkWidget *widget,
		      gpointer   data)
{
70 71
  NewImageInfo *info;
  GimpImageNewValues *values;
72

73 74
  info = (NewImageInfo*) data;
  values = info->values;
75 76

  /* get the image size in pixels */
77 78 79 80
  values->width = 
    RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0));
  values->height = 
    RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1));
81 82

  /* get the resolution in dpi */
83 84 85 86
  values->xresolution =
    gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->resolution_se), 0);
  values->yresolution =
    gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->resolution_se), 1);
87 88

  /* get the units */
89 90 91 92
  values->unit =
    gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (info->size_se));
  values->res_unit =
    gimp_size_entry_get_unit (GIMP_SIZE_ENTRY (info->resolution_se));
93

94
  if (info->size > max_new_image_size)
95
    {
96
      file_new_confirm_dialog (info);
97 98 99
    }
  else
    {
100 101 102
      gtk_widget_destroy (info->dlg);
      image_new_create_image (values);
      image_new_values_free (values);
Sven Neumann's avatar
Sven Neumann committed
103
      g_free (info);
104 105 106 107 108 109 110
    }
}

static void
file_new_reset_callback (GtkWidget *widget,
			 gpointer   data)
{
111
  NewImageInfo *info;
112

113
  info = (NewImageInfo*) data;
114

115
  gtk_signal_handler_block_by_data (GTK_OBJECT (info->resolution_se), info);
116 117

  gimp_chain_button_set_active
118
    (GIMP_CHAIN_BUTTON (info->couple_resolutions),
119 120
     ABS (default_xresolution - default_yresolution) < GIMP_MIN_RESOLUTION);

121
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->resolution_se),
122
			      0, default_xresolution);
123
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->resolution_se),
124
			      1, default_yresolution);
125
  gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (info->resolution_se),
126 127
			    default_resolution_units);

128
  gtk_signal_handler_unblock_by_data (GTK_OBJECT (info->resolution_se), info);
129

130
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se),
131
				  0, default_xresolution, TRUE);
132
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se),
133
				  1, default_yresolution, TRUE);
134
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se),
135
			      0, default_width);
136
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se),
137
			      1, default_height);
138
  gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (info->size_se),
139 140
			    default_units);

141
  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (info->type_w[default_type]),
142 143
				TRUE);
  gtk_toggle_button_set_active
144
    (GTK_TOGGLE_BUTTON (info->fill_type_w[BACKGROUND_FILL]), TRUE);
145 146
}

147 148 149 150
static void
file_new_cancel_callback (GtkWidget *widget,
			  gpointer   data)
{
151
  NewImageInfo *info;
152

153
  info = (NewImageInfo*) data;
154

155 156 157
  gtk_widget_destroy (info->dlg);
  image_new_values_free(info->values);
  g_free (info);
158 159
}

160
/*  local callback of file_new_confirm_dialog()  */
161
static void
162 163 164
file_new_confirm_dialog_callback (GtkWidget *widget,
				  gboolean   create,
				  gpointer   data)
165
{
166 167 168 169 170
  NewImageInfo *info;

  info = (NewImageInfo*) data;

  info->confirm_dlg = NULL;
171 172 173 174 175 176 177 178 179 180 181 182

  if (create)
    {
      gtk_widget_destroy (info->dlg);
      image_new_create_image (info->values);
      image_new_values_free (info->values);
      g_free (info);
    }
  else
    {
      gtk_widget_set_sensitive (info->dlg, TRUE);
    }
183 184 185
}

static void
186
file_new_confirm_dialog (NewImageInfo *info)
187 188 189 190 191
{
  gchar *size;
  gchar *max_size;
  gchar *text;

192
  gtk_widget_set_sensitive (info->dlg, FALSE);
193

194 195
  size = image_new_get_size_string (info->size);
  max_size = image_new_get_size_string (max_new_image_size);
196

197 198
  /* xgettext:no-c-format */
	    
199 200 201 202 203 204 205 206 207
  text = g_strdup_printf (_("You are trying to create an image which\n"
			    "has an initial size of %s.\n\n"
			    "Choose OK to create this image anyway.\n"
			    "Choose Cancel if you didn't mean to\n"
			    "create such a large image.\n\n"
			    "To prevent this dialog from appearing,\n"
			    "increase the \"Maximum Image Size\"\n"
			    "setting (currently %s) in the\n"
			    "preferences dialog."),
208
                          size, max_size);
209 210 211 212 213 214 215 216 217 218 219

  info->confirm_dlg =
    gimp_query_boolean_box (_("Confirm Image Size"),
			    gimp_standard_help_func,
			    "dialogs/file_new.html#confirm_size",
			    FALSE,
			    text,
			    _("OK"), _("Cancel"),
			    NULL, NULL,
			    file_new_confirm_dialog_callback,
			    info);
220 221 222 223 224

  g_free (text);
  g_free (max_size);
  g_free (size);

225
  gtk_widget_show (info->confirm_dlg);
226 227
}

228 229
static void
file_new_resolution_callback (GtkWidget *widget,
230
			      gpointer   data)
231
{
232
  NewImageInfo *info;
233

234 235 236 237
  static gdouble xres = 0.0;
  static gdouble yres = 0.0;
  gdouble new_xres;
  gdouble new_yres;
238

239
  info = (NewImageInfo*) data;
240

241
  new_xres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 0);
242
  new_yres = gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (widget), 1);
243

244
  if (gimp_chain_button_get_active
245
      (GIMP_CHAIN_BUTTON (info->couple_resolutions)))
246
    {
247
      gtk_signal_handler_block_by_data
248
	(GTK_OBJECT (info->resolution_se), info);
249

250 251
      if (new_xres != xres)
	{
252
	  yres = new_yres = xres = new_xres;
253
	  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 1, yres);
254
	}
255 256

      if (new_yres != yres)
257
	{
258 259
	  xres = new_xres = yres = new_yres;
	  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (widget), 0, xres);
260
	}
261

262
      gtk_signal_handler_unblock_by_data
263
	(GTK_OBJECT (info->resolution_se), info);
264 265 266 267 268 269 270 271
    }
  else
    {
      if (new_xres != xres)
	xres = new_xres;
      if (new_yres != yres)
	yres = new_yres;
    }
272

273
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
274
				  xres, FALSE);
275
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
276
				  yres, FALSE);
277 278 279 280 281 282 283 284

  file_new_image_size_callback (widget, data);
}

static void
file_new_image_size_callback (GtkWidget *widget,
			      gpointer   data)
{
285
  NewImageInfo *info;
286 287 288
  gchar *text;
  gchar *label;

289
  info = (NewImageInfo*) data;
290

291 292 293 294
  info->values->width = 
    RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 0));
  info->values->height =
    RINT (gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (info->size_se), 1));
295

296
  info->size = image_new_calculate_size (info->values);
297

298
  label = g_strdup_printf (_("Image Size: %s"),
299 300
			   text = image_new_get_size_string (info->size));
  gtk_frame_set_label (GTK_FRAME (info->size_frame), label);
301

302 303
  g_free (label);
  g_free (text);
304
}
305

306
void
307 308 309
file_new_cmd_callback (GtkWidget *widget,
		       gpointer   callback_data,
		       guint      callback_action)
310
{
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332
  GDisplay *gdisp;
  GimpImage *image = NULL;

  /*  Before we try to determine the responsible gdisplay,
   *  make sure this wasn't called from the toolbox
   */
  if (callback_action)
    {
      gdisp = gdisplay_active ();

      if (gdisp)
        image = gdisp->gimage;
    }

  image_new_create_window (NULL, image);
}

void
ui_new_image_window_create (const GimpImageNewValues *values_orig)
{
  NewImageInfo       *info;
  GimpImageNewValues *values;
333

334 335 336 337 338 339 340 341 342 343 344 345 346 347
  GtkWidget *top_vbox;
  GtkWidget *hbox;
  GtkWidget *vbox;
  GtkWidget *abox;
  GtkWidget *frame;
  GtkWidget *table;
  GtkWidget *separator;
  GtkWidget *label;
  GtkWidget *button;
  GtkObject *adjustment;
  GtkWidget *spinbutton;
  GtkWidget *spinbutton2;
  GtkWidget *radio_box;
  GSList *group;
348
  GList *list;
349

350 351
  info = g_new (NewImageInfo, 1);
  info->values = values = image_new_values_new (values_orig);
352

353 354
  info->confirm_dlg = NULL;
  info->size = 0.0;
355

356 357
  info->dlg = gimp_dialog_new (_("New Image"), "new_image",
			       gimp_standard_help_func,
358
			       "dialogs/file_new.html",
359 360 361
			       GTK_WIN_POS_MOUSE,
			       FALSE, FALSE, TRUE,

362
			       _("OK"), file_new_ok_callback,
363
			       info, NULL, NULL, TRUE, FALSE,
364
			       _("Reset"), file_new_reset_callback,
365
			       info, NULL, NULL, FALSE, FALSE,
366
			       _("Cancel"), file_new_cancel_callback,
367
			       info, NULL, NULL, FALSE, TRUE,
368 369

			       NULL);
370

371
  /*  vbox holding the rest of the dialog  */
372
  top_vbox = gtk_vbox_new (FALSE, 4);
373
  gtk_container_set_border_width (GTK_CONTAINER (top_vbox), 4);
374
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (info->dlg)->vbox),
375 376 377
		      top_vbox, TRUE, TRUE, 0);
  gtk_widget_show (top_vbox);

378
  /*  Image size frame  */
379 380 381
  info->size_frame = gtk_frame_new (NULL);
  gtk_box_pack_start (GTK_BOX (top_vbox), info->size_frame, FALSE, FALSE, 0);
  gtk_widget_show (info->size_frame);
382 383 384

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
385
  gtk_container_add (GTK_CONTAINER (info->size_frame), vbox);
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
  gtk_widget_show (vbox);

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

  /*  the pixel size labels  */
  label = gtk_label_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);

  /*  a separator after the pixel section  */
  separator = gtk_hseparator_new ();
  gtk_table_attach_defaults (GTK_TABLE (table), separator, 0, 2, 2, 3);
  gtk_widget_show (separator);

  /*  the unit size labels  */
  label = gtk_label_new (_("Width:"));
  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);

  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, 4, 5,
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  gtk_widget_show (label);

  /*  create the sizeentry which keeps it all together  */
  abox = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
  gtk_table_attach_defaults (GTK_TABLE (table), abox, 1, 2, 3, 5);
431 432
  info->size_se =
    gimp_size_entry_new (0, values->unit, "%a", FALSE, FALSE, TRUE, 75,
433
			 GIMP_SIZE_ENTRY_UPDATE_SIZE);
434 435 436
  gtk_table_set_col_spacing (GTK_TABLE (info->size_se), 1, 2);
  gtk_container_add (GTK_CONTAINER (abox), info->size_se);
  gtk_widget_show (info->size_se);
437 438 439 440 441 442 443 444 445 446
  gtk_widget_show (abox);

  /*  height in units  */
  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);
  /*  add the "height in units" spinbutton to the sizeentry  */
447
  gtk_table_attach_defaults (GTK_TABLE (info->size_se), spinbutton,
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467
			     0, 1, 2, 3);
  gtk_widget_show (spinbutton);

  /*  height in pixels  */
  hbox = gtk_hbox_new (FALSE, 2);
  adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
  spinbutton2 = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 0);
  gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton2),
                                   GTK_SHADOW_NONE);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton2), TRUE);
  gtk_widget_set_usize (spinbutton2, 75, 0);
  gtk_box_pack_start (GTK_BOX (hbox), spinbutton2, FALSE, FALSE, 0);
  gtk_widget_show (spinbutton2);

  label = gtk_label_new (_("Pixels"));
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
  gtk_widget_show (label);

  /*  add the "height in pixels" spinbutton to the main table  */
  gtk_table_attach_defaults (GTK_TABLE (table), hbox, 1, 2, 1, 2);
468
  gtk_widget_show (hbox);
469

470
  /*  register the height spinbuttons with the sizeentry  */
471
  gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->size_se),
472 473 474 475 476 477 478 479 480 481 482
                             GTK_SPIN_BUTTON (spinbutton),
			     GTK_SPIN_BUTTON (spinbutton2));

  /*  width in units  */
  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);
  /*  add the "width in units" spinbutton to the sizeentry  */
483
  gtk_table_attach_defaults (GTK_TABLE (info->size_se), spinbutton,
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
			     0, 1, 1, 2);
  gtk_widget_show (spinbutton);

  /*  width in pixels  */
  abox = gtk_alignment_new (0.0, 0.5, 0.0, 0.0);
  gtk_table_attach_defaults (GTK_TABLE (table), abox, 1, 2, 0, 1);
  adjustment = gtk_adjustment_new (1, 1, 1, 1, 10, 1);
  spinbutton2 = gtk_spin_button_new (GTK_ADJUSTMENT (adjustment), 1, 0);
  gtk_spin_button_set_shadow_type (GTK_SPIN_BUTTON (spinbutton2),
                                   GTK_SHADOW_NONE);
  gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton2), TRUE);
  gtk_widget_set_usize (spinbutton2, 75, 0);
  /*  add the "width in pixels" spinbutton to the main table  */
  gtk_container_add (GTK_CONTAINER (abox), spinbutton2);
  gtk_widget_show (spinbutton2);
  gtk_widget_show (abox);

  /*  register the width spinbuttons with the sizeentry  */
502
  gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->size_se),
503 504 505 506
                             GTK_SPIN_BUTTON (spinbutton),
			     GTK_SPIN_BUTTON (spinbutton2));

  /*  initialize the sizeentry  */
507 508 509 510
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 0,
				  values->xresolution, FALSE);
  gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (info->size_se), 1,
				  values->yresolution, FALSE);
511

512
  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (info->size_se), 0,
513 514
					 GIMP_MIN_IMAGE_SIZE,
					 GIMP_MAX_IMAGE_SIZE);
515
  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (info->size_se), 1,
516 517 518
					 GIMP_MIN_IMAGE_SIZE,
					 GIMP_MAX_IMAGE_SIZE);

519 520
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se), 0, values->width);
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->size_se), 1, values->height);
521

522
  gtk_signal_connect (GTK_OBJECT (info->size_se), "refval_changed",
Michael Natterer's avatar
Michael Natterer committed
523 524
		      GTK_SIGNAL_FUNC (file_new_image_size_callback),
		      info);
525
  gtk_signal_connect (GTK_OBJECT (info->size_se), "value_changed",
Michael Natterer's avatar
Michael Natterer committed
526 527
		      GTK_SIGNAL_FUNC (file_new_image_size_callback),
		      info);
528 529

  /*  initialize the size label  */
530
  file_new_image_size_callback (info->size_se, info);
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552

  /*  the resolution labels  */
  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, 5, 6,
		    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, 6, 7,
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
  gtk_widget_show (label);

  /*  the resolution sizeentry  */
  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);

553 554 555 556 557 558 559
  info->resolution_se =
    gimp_size_entry_new (1, default_resolution_units, _("pixels/%a"),
		         FALSE, FALSE, FALSE, 75,
		         GIMP_SIZE_ENTRY_UPDATE_RESOLUTION);
  gtk_table_set_col_spacing (GTK_TABLE (info->resolution_se), 1, 2);
  gtk_table_set_col_spacing (GTK_TABLE (info->resolution_se), 2, 2);
  gimp_size_entry_add_field (GIMP_SIZE_ENTRY (info->resolution_se),
560
			     GTK_SPIN_BUTTON (spinbutton), NULL);
561
  gtk_table_attach_defaults (GTK_TABLE (info->resolution_se), spinbutton,
562 563
			     1, 2, 0, 1);
  gtk_widget_show (spinbutton);
564
  gtk_table_attach (GTK_TABLE (table), info->resolution_se, 1, 2, 5, 7,
565
		    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
566
  gtk_widget_show (info->resolution_se);
567

568
  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (info->resolution_se),
569 570
					 0, GIMP_MIN_RESOLUTION,
					 GIMP_MAX_RESOLUTION);
571
  gimp_size_entry_set_refval_boundaries (GIMP_SIZE_ENTRY (info->resolution_se),
572 573 574
					 1, GIMP_MIN_RESOLUTION,
					 GIMP_MAX_RESOLUTION);

575 576 577 578
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->resolution_se),
			      0, values->xresolution);
  gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (info->resolution_se),
			      1, values->yresolution);
579

580
  gtk_signal_connect (GTK_OBJECT (info->resolution_se), "value_changed",
Michael Natterer's avatar
Michael Natterer committed
581 582
		      GTK_SIGNAL_FUNC (file_new_resolution_callback),
		      info);
583

584
  /*  the resolution chainbutton  */
585
  info->couple_resolutions = gimp_chain_button_new (GIMP_CHAIN_RIGHT);
586
  gimp_chain_button_set_active
587 588 589 590 591
    (GIMP_CHAIN_BUTTON (info->couple_resolutions),
     ABS (values->xresolution - values->yresolution) < GIMP_MIN_RESOLUTION);
  gtk_table_attach_defaults (GTK_TABLE (info->resolution_se),
			     info->couple_resolutions, 2, 3, 0, 2);
  gtk_widget_show (info->couple_resolutions);
592

593 594
  /*  hbox containing the Image type and fill type frames  */
  hbox = gtk_hbox_new (FALSE, 2);
595
  gtk_box_pack_start (GTK_BOX (top_vbox), hbox, FALSE, FALSE, 0);
596
  gtk_widget_show (hbox);
597

598
  /*  frame for Image Type  */
599
  frame = gtk_frame_new (_("Image Type"));
600 601 602
  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
  gtk_widget_show (frame);

603
  /*  radio buttons and box  */
604
  radio_box = gtk_vbox_new (FALSE, 1);
605
  gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2);
606 607 608
  gtk_container_add (GTK_CONTAINER (frame), radio_box);
  gtk_widget_show (radio_box);

609
  group = NULL;
610 611
  list = g_list_first (image_new_get_image_base_type_names ());
  while (list)
612
    {
613 614 615 616 617
      GimpImageBaseTypeName *name_info;

      name_info = (GimpImageBaseTypeName*) list->data;

      button = gtk_radio_button_new_with_label (group, name_info->name);
618 619
      group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
      gtk_box_pack_start (GTK_BOX (radio_box), button, FALSE, TRUE, 0);
620
      gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) name_info->type);
621
      gtk_signal_connect (GTK_OBJECT (button), "toggled",
Michael Natterer's avatar
Michael Natterer committed
622
			  GTK_SIGNAL_FUNC (gimp_radio_button_update),
623
			  &values->type);
624
      gtk_signal_connect (GTK_OBJECT (button), "toggled",
Michael Natterer's avatar
Michael Natterer committed
625 626
			  GTK_SIGNAL_FUNC (file_new_image_size_callback),
			  info);
627
      if (values->type == name_info->type)
628 629 630
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
      gtk_widget_show (button);

631 632 633
      info->type_w[name_info->type] = button;

      list = g_list_next (list);
634 635 636
    }

  /* frame for Fill Type */
637
  frame = gtk_frame_new (_("Fill Type"));
638 639 640 641
  gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 0);
  gtk_widget_show (frame);

  radio_box = gtk_vbox_new (FALSE, 1);
642
  gtk_container_set_border_width (GTK_CONTAINER (radio_box), 2);
643 644 645
  gtk_container_add (GTK_CONTAINER (frame), radio_box);
  gtk_widget_show (radio_box);

646
  group = NULL;
647 648
  list = g_list_first (image_new_get_fill_type_names ());
  while (list)
649
    {
650 651 652 653
      GimpFillTypeName *name_info;

      name_info = (GimpFillTypeName*) list->data;

654
      button =
655
	gtk_radio_button_new_with_label (group, name_info->name);
656 657
      group = gtk_radio_button_group (GTK_RADIO_BUTTON (button));
      gtk_box_pack_start (GTK_BOX (radio_box), button, TRUE, TRUE, 0);
658
      gtk_object_set_user_data (GTK_OBJECT (button), (gpointer) name_info->type);
659
      gtk_signal_connect (GTK_OBJECT (button), "toggled",
Michael Natterer's avatar
Michael Natterer committed
660
			  GTK_SIGNAL_FUNC (gimp_radio_button_update),
661
			  &values->fill_type);
662
      gtk_signal_connect (GTK_OBJECT (button), "toggled",
Michael Natterer's avatar
Michael Natterer committed
663 664
			  GTK_SIGNAL_FUNC (file_new_image_size_callback),
			  info);
665
      if (values->fill_type == name_info->type)
666 667 668
	gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
      gtk_widget_show (button);

669
      info->fill_type_w[name_info->type] = button;
670

671 672
      list = g_list_next (list);
    }
673

674
  gimp_size_entry_grab_focus (GIMP_SIZE_ENTRY (info->size_se));
675

676
  gtk_widget_show (info->dlg);
677
}