app_procs.c 17.5 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 18 19 20 21 22 23 24
 */
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
#include <unistd.h>

25 26
#include <gtk/gtk.h>

Elliot Lee's avatar
Elliot Lee committed
27 28 29 30 31 32
#include "appenv.h"
#include "app_procs.h"
#include "batch.h"
#include "brushes.h"
#include "color_transfer.h"
#include "curves.h"
33
#include "devices.h"
Elliot Lee's avatar
Elliot Lee committed
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
#include "gdisplay.h"
#include "colormaps.h"
#include "fileops.h"
#include "gimprc.h"
#include "global_edit.h"
#include "gradient.h"
#include "gximage.h"
#include "hue_saturation.h"
#include "image_render.h"
#include "interface.h"
#include "internal_procs.h"
#include "layers_dialog.h"
#include "levels.h"
#include "menus.h"
#include "paint_funcs.h"
#include "palette.h"
#include "patterns.h"
#include "plug_in.h"
#include "procedural_db.h"
#include "temp_buf.h"
#include "tile_swap.h"
#include "tips_dialog.h"
#include "tools.h"
#include "undo.h"
#include "xcf.h"
59
#include "errors.h"
Elliot Lee's avatar
Elliot Lee committed
60

61 62
#include "config.h"

63 64 65
#define LOGO_WIDTH_MIN 350
#define LOGO_HEIGHT_MIN 110 
#define NAME "The GIMP"
66 67
#define BROUGHT "brought to you by"
#define AUTHORS "Spencer Kimball and Peter Mattis" 
68 69 70 71 72
 
#define SHOW_NEVER 0
#define SHOW_LATER 1
#define SHOW_NOW 2
 
Elliot Lee's avatar
Elliot Lee committed
73 74 75
/*  Function prototype for affirmation dialog when exiting application  */
static void      really_quit_dialog (void);
static Argument* quit_invoker       (Argument *args);
76 77
static void make_initialization_status_window(void);
static void destroy_initialization_status_window(void);
78 79 80 81 82
static int splash_logo_load (GtkWidget *window);
static int splash_logo_load_size (GtkWidget *window);
static void splash_logo_draw (GtkWidget *widget);
static void splash_text_draw (GtkWidget *widget);
static void splash_logo_expose (GtkWidget *widget);
Elliot Lee's avatar
Elliot Lee committed
83 84


85 86
static gint is_app_exit_finish_done = FALSE;

Elliot Lee's avatar
Elliot Lee committed
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
static ProcArg quit_args[] =
{
  { PDB_INT32,
    "kill",
    "Flag specifying whether to kill the gimp process or exit normally" },
};

static ProcRecord quit_proc =
{
  "gimp_quit",
  "Causes the gimp to exit gracefully",
  "The internal procedure which can either be used to make the gimp quit normally, or to have the gimp clean up its resources and exit immediately. The normaly shutdown process allows for querying the user to save any dirty images.",
  "Spencer Kimball & Peter Mattis",
  "Spencer Kimball & Peter Mattis",
  "1995-1996",
  PDB_INTERNAL,
  1,
  quit_args,
  0,
  NULL,
  { { quit_invoker } },
};


void
gimp_init (int    gimp_argc,
	   char **gimp_argv)
{
  /* Initialize the application */
  app_init ();

  /* Parse the rest of the command line arguments as images to load */
  if (gimp_argc > 0)
    while (gimp_argc--)
      {
	if (*gimp_argv)
123
	  file_open (*gimp_argv, *gimp_argv);
Elliot Lee's avatar
Elliot Lee committed
124 125 126 127
	gimp_argv++;
      }

  batch_init ();
128 129 130 131

  /* Handle showing dialogs with gdk_quit_adds here  */
  if (!no_interface && show_tips)
    tips_dialog_create ();
Elliot Lee's avatar
Elliot Lee committed
132 133
}

134 135 136 137 138 139 140 141

static GtkWidget *logo_area = NULL;
static GdkPixmap *logo_pixmap = NULL;
static int logo_width = 0;
static int logo_height = 0;
static int logo_area_width = 0;
static int logo_area_height = 0;
static int show_logo = SHOW_NEVER;
142
static int max_label_length = MAXPATHLEN;
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177

static int
splash_logo_load_size (GtkWidget *window)
{
  char buf[1024];
  FILE *fp;

  if (logo_pixmap)
    return TRUE;

  sprintf (buf, "%s/gimp_splash.ppm", DATADIR);

  fp = fopen (buf, "r");
  if (!fp)
    return 0;

  fgets (buf, 1024, fp);
  if (strcmp (buf, "P6\n") != 0)
    {
      fclose (fp);
      return 0;
    }

  fgets (buf, 1024, fp);
  fgets (buf, 1024, fp);
  sscanf (buf, "%d %d", &logo_width, &logo_height);

  fclose (fp);
  return TRUE;
}

static int
splash_logo_load (GtkWidget *window)
{
  GtkWidget *preview;
178
  GdkGC *gc;
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
  char buf[1024];
  unsigned char *pixelrow;
  FILE *fp;
  int count;
  int i;

  if (logo_pixmap)
    return TRUE;

  sprintf (buf, "%s/gimp_splash.ppm", DATADIR);

  fp = fopen (buf, "r");
  if (!fp)
    return 0;

  fgets (buf, 1024, fp);
  if (strcmp (buf, "P6\n") != 0)
    {
      fclose (fp);
      return 0;
    }

  fgets (buf, 1024, fp);
  fgets (buf, 1024, fp);
  sscanf (buf, "%d %d", &logo_width, &logo_height);

  fgets (buf, 1024, fp);
  if (strcmp (buf, "255\n") != 0)
    {
      fclose (fp);
      return 0;
    }

  preview = gtk_preview_new (GTK_PREVIEW_COLOR);
  gtk_preview_size (GTK_PREVIEW (preview), logo_width, logo_height);
  pixelrow = g_new (guchar, logo_width * 3);

  for (i = 0; i < logo_height; i++)
    {
      count = fread (pixelrow, sizeof (unsigned char), logo_width * 3, fp);
      if (count != (logo_width * 3))
	{
	  gtk_widget_destroy (preview);
	  g_free (pixelrow);
	  fclose (fp);
	  return 0;
	}
      gtk_preview_draw_row (GTK_PREVIEW (preview), pixelrow, 0, i, logo_width);
    }

  gtk_widget_realize (window);
230 231 232
  logo_pixmap = gdk_pixmap_new (window->window, logo_width, logo_height,
				gtk_preview_get_visual ()->depth);
  gc = gdk_gc_new (logo_pixmap);
233
  gtk_preview_put (GTK_PREVIEW (preview),
234
		   logo_pixmap, gc,
235
		   0, 0, 0, 0, logo_width, logo_height);
236
  gdk_gc_destroy (gc);
237

238
  gtk_widget_unref (preview);
239 240 241 242 243 244 245 246 247 248 249 250 251 252
  g_free (pixelrow);

  fclose (fp);
  return TRUE;
}

static void
splash_text_draw (GtkWidget *widget)
{
  GdkFont *font = NULL;

  font = gdk_font_load ("-Adobe-Helvetica-Bold-R-Normal--*-140-*-*-*-*-*-*");
  gdk_draw_string (widget->window,
		   font,
253
		   widget->style->fg_gc[GTK_STATE_NORMAL],
254
		   ((logo_area_width - gdk_string_width (font, NAME)) / 2), 
255
		   (0.25 * logo_area_height),
256 257 258 259 260
		   NAME);

  font = gdk_font_load ("-Adobe-Helvetica-Bold-R-Normal--*-120-*-*-*-*-*-*");
  gdk_draw_string (widget->window,
		   font,
261
		   widget->style->fg_gc[GTK_STATE_NORMAL],
262
		   ((logo_area_width - gdk_string_width (font, GIMP_VERSION)) / 2), 
263
		   (0.45 * logo_area_height),
264
		   GIMP_VERSION);
265 266
  gdk_draw_string (widget->window,
		   font,
267
		   widget->style->fg_gc[GTK_STATE_NORMAL],
268 269 270
		   ((logo_area_width - gdk_string_width (font, BROUGHT)) / 2), 
		   (0.65 * logo_area_height),
		   BROUGHT);
271 272
  gdk_draw_string (widget->window,
		   font,
273
		   widget->style->fg_gc[GTK_STATE_NORMAL],
274
		   ((logo_area_width - gdk_string_width (font, AUTHORS)) / 2), 
275
		   (0.80 * logo_area_height),
276
		   AUTHORS);
277 278 279 280 281 282
  /*  
   *  This is a hack: we try to compute a good guess for the maximum number
   *  of charcters that will fit into the splash-screen using the given font 
   */
  max_label_length = (float)strlen (AUTHORS) * 
        ( (float)logo_area_width / (float)gdk_string_width (font, AUTHORS) ); 
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308
}

static void
splash_logo_draw (GtkWidget *widget)
{
  gdk_draw_pixmap (widget->window,
		   widget->style->black_gc,
		   logo_pixmap, 
		   0, 0,
		   ((logo_area_width - logo_width) / 2), ((logo_area_height - logo_height) / 2),
		   logo_width, logo_height);
}

static void
splash_logo_expose (GtkWidget *widget)
{
  switch (show_logo) {
     case SHOW_NEVER: 
     case SHOW_LATER:
       splash_text_draw (widget);
       break;
     case SHOW_NOW:
       splash_logo_draw (widget);
  }
}

309 310 311 312
static GtkWidget *win_initstatus = NULL;
static GtkWidget *label1 = NULL;
static GtkWidget *label2 = NULL;
static GtkWidget *pbar = NULL;
313
static gint idle_tag = -1;
314 315 316 317 318 319 320

static void
destroy_initialization_status_window(void)
{
  if(win_initstatus)
    {
      gtk_widget_destroy(win_initstatus);
321 322
      if (logo_pixmap != NULL)
	gdk_pixmap_unref(logo_pixmap);
323 324 325
      win_initstatus = label1 = label2 = pbar = logo_area = NULL;
      logo_pixmap = NULL;
      gtk_idle_remove(idle_tag);
326 327 328 329 330 331
    }
}

static void
make_initialization_status_window(void)
{
332
  if (no_interface == FALSE)
333
    {
334 335 336
      if (no_splash == FALSE)
	{
	  GtkWidget *vbox;
337

338
	  win_initstatus = gtk_window_new(GTK_WINDOW_DIALOG);
339 340 341
	  gtk_signal_connect (GTK_OBJECT (win_initstatus), "delete_event",
			      GTK_SIGNAL_FUNC (gtk_true),
			      NULL);
342 343 344
	  gtk_window_set_wmclass (GTK_WINDOW(win_initstatus), "gimp_startup", "Gimp");
	  gtk_window_set_title(GTK_WINDOW(win_initstatus),
		               "GIMP Startup");
345

346 347 348 349
	  if (no_splash_image == FALSE && splash_logo_load_size (win_initstatus)) 
	    {
	      show_logo = SHOW_LATER;
	    }
350

351 352
	  vbox = gtk_vbox_new(FALSE, 4);
	  gtk_container_add(GTK_CONTAINER(win_initstatus), vbox);
353

354 355
	  gtk_widget_push_visual (gtk_preview_get_visual ());
	  gtk_widget_push_colormap  (gtk_preview_get_cmap ());
356

357
	  logo_area = gtk_drawing_area_new ();
358

359 360
	  gtk_widget_pop_colormap ();
	  gtk_widget_pop_visual ();
361

362 363 364 365 366 367
	  gtk_signal_connect (GTK_OBJECT (logo_area), "expose_event",
			      (GtkSignalFunc) splash_logo_expose, NULL);
	  logo_area_width = ( logo_width > LOGO_WIDTH_MIN ) ? logo_width : LOGO_WIDTH_MIN;
	  logo_area_height = ( logo_height > LOGO_HEIGHT_MIN ) ? logo_height : LOGO_HEIGHT_MIN;
	  gtk_drawing_area_size (GTK_DRAWING_AREA (logo_area), logo_area_width, logo_area_height);
	  gtk_box_pack_start_defaults(GTK_BOX(vbox), logo_area);
368

369 370 371 372
	  label1 = gtk_label_new("");
	  gtk_box_pack_start_defaults(GTK_BOX(vbox), label1);
	  label2 = gtk_label_new("");
	  gtk_box_pack_start_defaults(GTK_BOX(vbox), label2);
373
      
374 375
	  pbar = gtk_progress_bar_new();
	  gtk_box_pack_start_defaults(GTK_BOX(vbox), pbar);
376
      
377 378 379 380 381
	  gtk_widget_show(vbox);
	  gtk_widget_show (logo_area);
	  gtk_widget_show(label1);
	  gtk_widget_show(label2);
	  gtk_widget_show(pbar);
382
      
383 384
	  gtk_window_position(GTK_WINDOW(win_initstatus),
			      GTK_WIN_POS_CENTER);
385
      
386
	  gtk_widget_show(win_initstatus);
387

388 389
	  gtk_window_set_policy (GTK_WINDOW (win_initstatus), FALSE, TRUE, FALSE);
	}
390 391 392 393 394 395 396 397
    }
}

void
app_init_update_status(char *label1val,
		       char *label2val,
		       float pct_progress)
{
398 399
  char *temp;

400
  if(no_interface == FALSE && no_splash == FALSE && win_initstatus)
401 402 403 404 405 406 407 408 409 410
    {
      GdkRectangle area = {0, 0, -1, -1};
      if(label1val
	 && strcmp(label1val, GTK_LABEL(label1)->label))
	{
	  gtk_label_set(GTK_LABEL(label1), label1val);
	}
      if(label2val
	 && strcmp(label2val, GTK_LABEL(label2)->label))
	{
411 412 413 414 415 416 417 418
	  while ( strlen (label2val) > max_label_length )
	    {
	      temp = strchr (label2val, '/');
	      if (temp == NULL)  /* for sanity */
		break;
	      temp++;
	      label2val = temp;
	    }
419 420 421 422 423 424 425 426
	  gtk_label_set(GTK_LABEL(label2), label2val);
	}
      if(pct_progress >= 0
	 && GTK_PROGRESS_BAR(pbar)->percentage != pct_progress)
	{
	  gtk_progress_bar_update(GTK_PROGRESS_BAR(pbar), pct_progress);
	}
      gtk_widget_draw(win_initstatus, &area);
Manish Singh's avatar
Manish Singh committed
427
      idle_tag = gtk_idle_add((GtkFunction) gtk_true, NULL);
428 429
      gtk_main_iteration();
      gtk_idle_remove(idle_tag);
430 431 432 433 434 435
    }
}

/* #define RESET_BAR() app_init_update_status("", "", 0) */
#define RESET_BAR()

Elliot Lee's avatar
Elliot Lee committed
436
void
437
app_init (void)
Elliot Lee's avatar
Elliot Lee committed
438 439 440 441 442
{
  char filename[MAXPATHLEN];
  char *gimp_dir;
  char *path;

443 444 445 446 447 448 449 450 451 452 453
  gimp_dir = gimp_directory ();
  if (gimp_dir[0] != '\000')
    {
      sprintf (filename, "%s/gtkrc", gimp_dir);

      if ((be_verbose == TRUE) || (no_splash == TRUE))
	g_print ("parsing \"%s\"\n", filename);

      gtk_rc_parse (filename);
    }

454
  make_initialization_status_window();
455 456 457 458
  if (no_interface == FALSE && no_splash == FALSE && win_initstatus) {
    splash_text_draw (logo_area);
  }
    
Elliot Lee's avatar
Elliot Lee committed
459 460 461 462 463 464
  /*
   *  Initialize the procedural database
   *    We need to do this first because any of the init
   *    procedures might install or query it as needed.
   */
  procedural_db_init ();
465
  RESET_BAR();
Elliot Lee's avatar
Elliot Lee committed
466
  internal_procs_init ();
467
  RESET_BAR();
Elliot Lee's avatar
Elliot Lee committed
468 469
  procedural_db_register (&quit_proc);

470 471 472 473 474 475 476 477 478 479 480 481
  RESET_BAR();
  parse_gimprc ();         /*  parse the local GIMP configuration file  */

  /* Now we are ready to draw the splash-screen-image to the start-up window */
  if (no_interface == FALSE)
    {
      if (no_splash_image == FALSE && show_logo && splash_logo_load (win_initstatus)) {
	show_logo = SHOW_NOW;
	splash_logo_draw (logo_area);
      }
    }

482
  RESET_BAR();
Elliot Lee's avatar
Elliot Lee committed
483
  file_ops_pre_init ();    /*  pre-initialize the file types  */
484
  RESET_BAR();
Elliot Lee's avatar
Elliot Lee committed
485
  xcf_init ();             /*  initialize the xcf file format routines */
486

487
  app_init_update_status ("Looking for data files", "Brushes", 0.00);
488
  brushes_init (no_data);         /*  initialize the list of gimp brushes  */
489
  app_init_update_status (NULL, "Patterns", 0.25);
490
  patterns_init (no_data);        /*  initialize the list of gimp patterns  */
491
  app_init_update_status (NULL, "Palettes", 0.50);
492
  palettes_init (no_data);        /*  initialize the list of gimp palettes  */
493
  app_init_update_status (NULL, "Gradients", 0.75);
494
  gradients_init (no_data);       /*  initialize the list of gimp gradients  */
495
  app_init_update_status (NULL, NULL, 1.00);
496

Elliot Lee's avatar
Elliot Lee committed
497
  plug_in_init ();         /*  initialize the plug in structures  */
498
  RESET_BAR();
Elliot Lee's avatar
Elliot Lee committed
499 500 501 502 503 504 505 506 507 508
  file_ops_post_init ();   /*  post-initialize the file types  */

  /* Add the swap file  */
  if (swap_path == NULL)
    swap_path = "/tmp";
  path = g_new (gchar, strlen (swap_path) + 32);
  sprintf (path, "%s/gimpswap.%ld", swap_path, (long)getpid ());
  tile_swap_add (path, NULL, NULL);
  g_free (path);

509 510
  destroy_initialization_status_window();

Elliot Lee's avatar
Elliot Lee committed
511 512 513
  /*  Things to do only if there is an interface  */
  if (no_interface == FALSE)
    {
514
      get_standard_colormaps ();
515
      devices_init ();
Elliot Lee's avatar
Elliot Lee committed
516 517 518 519 520
      create_toolbox ();
      gximage_init ();
      render_setup (transparency_type, transparency_size);
      tools_options_dialog_new ();
      tools_select (RECT_SELECT);
Manish Singh's avatar
Manish Singh committed
521 522
      if (console_messages == FALSE)
        g_set_message_handler (&message_box_func);
Elliot Lee's avatar
Elliot Lee committed
523 524 525 526 527 528
    }

  color_transfer_init ();
  get_active_brush ();
  get_active_pattern ();
  paint_funcs_setup ();
529

Elliot Lee's avatar
Elliot Lee committed
530 531
}

Elliot Lee's avatar
Elliot Lee committed
532
int
533 534 535 536 537
app_exit_finish_done (void)
{
  return is_app_exit_finish_done;
}

538
void
539
app_exit_finish (void)
Elliot Lee's avatar
Elliot Lee committed
540
{
541 542 543
  if (app_exit_finish_done ())
    return;
  is_app_exit_finish_done = TRUE;
544

Manish Singh's avatar
Manish Singh committed
545 546
  g_set_message_handler (&message_console_func);

Elliot Lee's avatar
Elliot Lee committed
547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
  lc_dialog_free ();
  gdisplays_delete ();
  global_edit_free ();
  named_buffers_free ();
  swapping_free ();
  brushes_free ();
  patterns_free ();
  palettes_free ();
  gradients_free ();
  hue_saturation_free ();
  curves_free ();
  levels_free ();
  brush_select_dialog_free ();
  pattern_select_dialog_free ();
  palette_free ();
  paint_funcs_free ();
  procedural_db_free ();
  plug_in_kill ();
  menus_quit ();
  tile_swap_exit ();

  /*  Things to do only if there is an interface  */
  if (no_interface == FALSE)
    {
      gximage_free ();
      render_free ();
      tools_options_dialog_free ();
    }
575 576
  /*  gtk_exit (0); */
  gtk_main_quit();
Elliot Lee's avatar
Elliot Lee committed
577 578 579 580 581 582 583 584
}

void
app_exit (int kill_it)
{
  /*  If it's the user's perogative, and there are dirty images  */
  if (kill_it == 0 && gdisplays_dirty () && no_interface == FALSE)
    really_quit_dialog ();
585
  else if (no_interface == FALSE)
586
    toolbox_free ();
587 588
  else
    app_exit_finish ();
Elliot Lee's avatar
Elliot Lee committed
589 590 591 592 593 594 595 596 597 598 599
}

/********************************************************
 *   Routines to query exiting the application          *
 ********************************************************/

static void
really_quit_callback (GtkButton *button,
		      GtkWidget *dialog)
{
  gtk_widget_destroy (dialog);
600
  toolbox_free ();
Elliot Lee's avatar
Elliot Lee committed
601 602 603
}

static void
604
really_quit_cancel_callback (GtkWidget *widget,
Elliot Lee's avatar
Elliot Lee committed
605 606 607 608 609 610 611 612 613 614 615 616
			     GtkWidget *dialog)
{
  menus_set_sensitive ("<Toolbox>/File/Quit", TRUE);
  menus_set_sensitive ("<Image>/File/Quit", TRUE);
  gtk_widget_destroy (dialog);
}

static gint
really_quit_delete_callback (GtkWidget *widget,
			     GdkEvent  *event,
			     gpointer client_data) 
{
617
  really_quit_cancel_callback (widget, (GtkWidget *) client_data);
Elliot Lee's avatar
Elliot Lee committed
618

619
  return TRUE;
Elliot Lee's avatar
Elliot Lee committed
620 621 622 623 624 625 626 627 628 629 630 631 632
}

static void
really_quit_dialog ()
{
  GtkWidget *dialog;
  GtkWidget *button;
  GtkWidget *label;

  menus_set_sensitive ("<Toolbox>/File/Quit", FALSE);
  menus_set_sensitive ("<Image>/File/Quit", FALSE);

  dialog = gtk_dialog_new ();
633
  gtk_window_set_wmclass (GTK_WINDOW (dialog), "really_quit", "Gimp");
Elliot Lee's avatar
Elliot Lee committed
634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679
  gtk_window_set_title (GTK_WINDOW (dialog), "Really Quit?");
  gtk_window_position (GTK_WINDOW (dialog), GTK_WIN_POS_MOUSE);
  gtk_container_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 2);

  gtk_signal_connect (GTK_OBJECT (dialog), "delete_event",
		      (GtkSignalFunc) really_quit_delete_callback,
		      dialog);
 
  button = gtk_button_new_with_label ("Yes");
  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
  gtk_signal_connect (GTK_OBJECT (button), "clicked",
		      (GtkSignalFunc) really_quit_callback,
		      dialog);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE, TRUE, 0);
  gtk_widget_grab_default (button);
  gtk_widget_show (button);

  button = gtk_button_new_with_label ("No");
  GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
  gtk_signal_connect (GTK_OBJECT (button), "clicked",
		      (GtkSignalFunc) really_quit_cancel_callback,
		      dialog);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), button, TRUE, TRUE, 0);
  gtk_widget_show (button);

  label = gtk_label_new ("Some files unsaved.  Quit the GIMP?");
  gtk_misc_set_padding (GTK_MISC (label), 10, 1);
  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, TRUE, TRUE, 0);
  gtk_widget_show (label);

  gtk_widget_show (dialog);
}

static Argument*
quit_invoker (Argument *args)
{
  Argument *return_args;
  int kill_it;

  kill_it = args[0].value.pdb_int;
  app_exit (kill_it);

  return_args = procedural_db_return_args (&quit_proc, TRUE);

  return return_args;
}