user-install-dialog.c 40.1 KB
Newer Older
Elliot Lee's avatar
Elliot Lee committed
1
2
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
 * Copyright (C) 2000 Michael Natterer and Sven Neumann
Elliot Lee's avatar
Elliot Lee committed
4
5
6
7
8
9
10
11
12
13
14
15
16
 *
 * 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
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Elliot Lee's avatar
Elliot Lee committed
18
 */
Sven Neumann's avatar
Sven Neumann committed
19

Tor Lillqvist's avatar
Tor Lillqvist committed
20
21
#include "config.h"

22
#include <errno.h>
Elliot Lee's avatar
Elliot Lee committed
23
24
#include <stdio.h>
#include <stdlib.h>
25
#include <string.h>
Elliot Lee's avatar
Elliot Lee committed
26
#include <sys/stat.h>
27
#include <sys/types.h>
Tor Lillqvist's avatar
Tor Lillqvist committed
28
#ifdef HAVE_UNISTD_H
Elliot Lee's avatar
Elliot Lee committed
29
#include <unistd.h>
Tor Lillqvist's avatar
Tor Lillqvist committed
30
#endif
Elliot Lee's avatar
Elliot Lee committed
31

32
33
#include <gtk/gtk.h>

34
#include "libgimpmath/gimpmath.h"
35
#include "libgimpbase/gimpbase.h"
36
#include "libgimpwidgets/gimpwidgets.h"
37

Michael Natterer's avatar
Michael Natterer committed
38
#include "gui-types.h"
Sven Neumann's avatar
Sven Neumann committed
39

40
#include "config/gimprc.h"
Michael Natterer's avatar
Michael Natterer committed
41

42
#include "widgets/gimppropwidgets.h"
43

Michael Natterer's avatar
Michael Natterer committed
44
45
46
#include "gui.h"
#include "resolution-calibrate-dialog.h"
#include "user-install-dialog.h"
Michael Natterer's avatar
Michael Natterer committed
47

Sven Neumann's avatar
Sven Neumann committed
48
49
#include "libgimp/gimpintl.h"

50
#ifdef G_OS_WIN32
51
52
#  include <io.h>
#  define mkdir(path, mode) _mkdir(path)
Tor Lillqvist's avatar
Tor Lillqvist committed
53
#endif
Elliot Lee's avatar
Elliot Lee committed
54

55

56
57
#define PAGE_STYLE(widget)  gtk_widget_modify_style (widget, page_style)
#define TITLE_STYLE(widget) gtk_widget_modify_style (widget, title_style)
58

59
60
61
62
63
64
65
66
67
68
enum
{
  GPL_PAGE,
  TREE_PAGE,
  LOG_PAGE,
  TUNING_PAGE,
  RESOLUTION_PAGE,
  EEK_PAGE,
  NUM_PAGES
};
69
70
71

enum
{
Manish Singh's avatar
Manish Singh committed
72
73
74
75
76
77
  DIRENT_COLUMN,
  PIXBUF_COLUMN,
  DESC_COLUMN,
  NUM_COLUMNS
};

78
79

static void     user_install_continue_callback (GtkWidget *widget,
80
                                                GimpRc    *gimprc);
81
static void     user_install_cancel_callback   (GtkWidget *widget,
82
                                                gpointer   data);
Sven Neumann's avatar
Sven Neumann committed
83

84
static gboolean user_install_run               (void);
85
86
static void     user_install_tuning            (GimpRc    *gimprc);
static void     user_install_resolution        (GimpRc    *gimprc);
Elliot Lee's avatar
Elliot Lee committed
87
88


Sven Neumann's avatar
Sven Neumann committed
89
90
/*  private stuff  */

91
static GtkWidget  *user_install_dialog = NULL;
Sven Neumann's avatar
Sven Neumann committed
92

93
static GtkWidget  *notebook        = NULL;
94

95
static GtkWidget  *title_image     = NULL;
96

97
98
static GtkWidget  *title_label     = NULL;
static GtkWidget  *footer_label    = NULL;
Sven Neumann's avatar
Sven Neumann committed
99

100
101
102
static GtkWidget  *log_page        = NULL;
static GtkWidget  *tuning_page     = NULL;
static GtkWidget  *resolution_page = NULL;
Sven Neumann's avatar
Sven Neumann committed
103

104
105
static GtkWidget  *continue_button = NULL;
static GtkWidget  *cancel_button   = NULL;
Sven Neumann's avatar
Sven Neumann committed
106

107
108
static GtkRcStyle *title_style     = NULL;
static GtkRcStyle *page_style      = NULL;
Sven Neumann's avatar
Sven Neumann committed
109

110
111
112
static GdkColor    black_color;
static GdkColor    white_color;
static GdkColor    title_color;
Sven Neumann's avatar
Sven Neumann committed
113

114
typedef enum
115
{
116
117
118
119
  TREE_ITEM_DONT,              /* Don't pre-create            */
  TREE_ITEM_MKDIR_ONLY,        /* Just mkdir                  */
  TREE_ITEM_FROM_SYSCONF_DIR,  /* Copy from sysconf directory */
  TREE_ITEM_FROM_DATA_DIR      /* ... from data directory     */
120
} TreeItemType;
Sven Neumann's avatar
Sven Neumann committed
121
122
123

static struct
{
124
125
126
127
128
  gboolean      directory;
  gchar        *text;
  gchar        *description;
  TreeItemType  type;
  gchar        *source_filename;  /* If NULL, use text */
Sven Neumann's avatar
Sven Neumann committed
129
130
131
132
133
134
135
136
}
tree_items[] =
{
  {
    FALSE, "gimprc",
    N_("The gimprc is used to store personal preferences\n"
       "that affect GIMP's default behavior.\n"
       "Paths to search for brushes, palettes, gradients,\n"
137
       "patterns, plug-ins and modules can also configured\n"
138
       "here."),
139
    TREE_ITEM_DONT, NULL
Sven Neumann's avatar
Sven Neumann committed
140
141
142
143
  },
  {
    FALSE, "gtkrc",
    N_("GIMP uses an additional gtkrc file so you can\n"
144
145
       "configure it to look differently than other GTK apps."),
    TREE_ITEM_FROM_SYSCONF_DIR, "gtkrc_user"
Sven Neumann's avatar
Sven Neumann committed
146
147
148
  },
  {
    FALSE, "pluginrc",
149
150
    N_("Plug-ins and extensions are external programs run\n"
       "by the GIMP which provide additional functionality.\n"
Sven Neumann's avatar
Sven Neumann committed
151
152
153
       "These programs are searched for at run-time and\n"
       "information about their functionality and mod-times\n"
       "is cached in this file.  This file is intended to\n"
154
155
       "be GIMP-readable only, and should not be edited."),
    TREE_ITEM_DONT, NULL
Sven Neumann's avatar
Sven Neumann committed
156
157
158
159
160
  },
  {
    FALSE, "menurc",
    N_("Key shortcuts can be dynamically redefined in The GIMP.\n"
       "The menurc is a dump of your configuration so it can.\n"
161
       "be remembered for the next session.  You may edit this\n"
Sven Neumann's avatar
Sven Neumann committed
162
       "file if you wish, but it is much easier to define the\n"
163
       "keys from within The GIMP.  Deleting this file will\n"
164
165
       "restore the default shortcuts."),
    TREE_ITEM_DONT, NULL
Sven Neumann's avatar
Sven Neumann committed
166
167
168
169
  },
  {
    FALSE, "sessionrc",
    N_("The sessionrc is used to store what dialog windows were\n"
170
       "open the last time you quit The GIMP.  You can configure\n"
171
172
       "The GIMP to reopen these dialogs at the saved position."),
    TREE_ITEM_DONT, NULL
Sven Neumann's avatar
Sven Neumann committed
173
174
175
176
177
178
  },
  {
    FALSE, "unitrc",
    N_("The unitrc is used to store your user units database.\n"
       "You can define additional units and use them just\n"
       "like you use the built-in units inches, millimeters,\n"
179
       "points and picas.  This file is overwritten each time\n"
180
181
       "you quit the GIMP."),
    TREE_ITEM_FROM_SYSCONF_DIR, NULL
Sven Neumann's avatar
Sven Neumann committed
182
  },
183
184
185
186
187
  {
    TRUE, "themes",
    N_("This folder is searched for user-installed themes."),
    TREE_ITEM_MKDIR_ONLY, NULL
  },
Sven Neumann's avatar
Sven Neumann committed
188
189
  {
    TRUE, "brushes",
190
191
    N_("This folder is used to store user defined brushes.\n"
       "The GIMP checks this folder in addition to the system-\n"
192
       "wide GIMP brushes installation when searching for\n"
193
194
       "brushes."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
195
196
197
  },
  {
    TRUE, "gradients",
198
199
200
    N_("This folder is used to store user defined gradients\n"
       "The GIMP checks this folder in addition to the system-\n"
       "wide GIMP gradients installation when searching for\n"
201
202
       "gradients."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
203
204
205
  },
  {
    TRUE, "palettes",
206
207
208
    N_("This folder is used to store user defined palettes.\n"
       "The GIMP checks this folder in addition to the system-\n"
       "wide GIMP palettes installation when searching for\n"
209
210
       "palettes."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
211
212
213
  },
  {
    TRUE, "patterns",
214
215
    N_("This folder is used to store user defined patterns.\n"
       "The GIMP checks this folder in addition to the system-\n"
216
       "wide GIMP patterns installation when searching for\n"
217
218
       "patterns."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
219
220
221
  },
  {
    TRUE, "plug-ins",
222
223
224
    N_("This folder is used to store user created, temporary,\n"
       "or otherwise non-system-supported plug-ins.  The GIMP\n"
       "checks this folder in addition to the system-wide\n"
225
226
       "GIMP plug-in folder when searching for plug-ins."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
227
228
229
  },
  {
    TRUE, "modules",
230
231
232
233
    N_("This folder is used to store user created, temporary,\n"
       "or otherwise non-system-supported DLL modules.  The\n"
       "GIMP checks this folder in addition to the system-wide\n"
       "GIMP module folder when searching for modules to load\n"
234
235
       "during initialization."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
236
  },
237
238
239
240
241
242
243
  {
    TRUE, "environ",
    N_("This folder is used to store user created, temporary,\n"
       "or otherwise non-system-supported additions to the\n"
       "plug-in environment.  The GIMP checks this folder in\n"
       "addition to the system-wide GIMP environment folder\n"
       "when searching for plug-in environment modification\n"
244
245
       "files."),
    TREE_ITEM_MKDIR_ONLY, NULL
246
  },
Sven Neumann's avatar
Sven Neumann committed
247
248
  {
    TRUE, "scripts",
249
250
251
    N_("This folder is used to store user created and installed\n"
       "scripts.  The GIMP checks this folder in addition to\n"
       "the systemwide GIMP scripts folder when searching for\n"
252
253
       "scripts."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
254
255
256
  },
  {
    TRUE, "tmp",
257
258
259
260
    N_("This folder is used to temporarily store undo buffers\n"
       "to reduce memory usage.  If The GIMP is unceremoniously\n"
       "killed, files of the form: gimp<#>.<#> may persist in\n"
       "this folder.  These files are useless across GIMP\n"
261
262
       "sessions and can be destroyed with impunity."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
263
264
265
  },
  {
    TRUE, "curves",
266
    N_("This folder is used to store parameter files for the\n"
267
268
       "Curves tool."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
269
270
271
  },
  {
    TRUE, "levels",
272
    N_("This folder is used to store parameter files for the\n"
273
274
       "Levels tool."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
275
276
277
  },
  {
    TRUE, "fractalexplorer",
278
279
280
    N_("This is folder used to store user defined fractals to\n"
       "be used by the FractalExplorer plug-in.  The GIMP\n"
       "checks this folder in addition to the systemwide\n"
281
282
       "FractalExplorer installation when searching for fractals."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
283
284
285
  },  
  {
    TRUE, "gfig",
286
287
288
    N_("This folder is used to store user defined figures to\n"
       "be used by the GFig plug-in.  The GIMP checks this\n"
       "folder in addition to the systemwide GFig installation\n"
289
290
       "when searching for gfig figures."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
291
292
293
  },
  {
    TRUE, "gflare",
294
295
296
    N_("This folder is used to store user defined gflares to\n"
       "be used by the GFlare plug-in.  The GIMP checks this\n"
       "folder in addition to the systemwide GFlares\n"
297
298
       "installation when searching for gflares."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
299
300
301
  },
  {
    TRUE, "gimpressionist",
302
303
304
    N_("This folder is used to store user defined data to be\n"
       "used by the Gimpressionist plug-in.  The GIMP checks\n"
       "this folder in addition to the systemwide Gimpressionist\n"
305
306
       "installation when searching for data."),
    TREE_ITEM_MKDIR_ONLY, NULL
Sven Neumann's avatar
Sven Neumann committed
307
308
  }  
};
309

Sven Neumann's avatar
Sven Neumann committed
310

311
static void
312
user_install_notebook_set_page (GtkNotebook *notebook,
313
				gint         index)
314
315
{
  GtkWidget *page;
316
317
318
  gchar     *title;
  gchar     *footer;

319
  page = gtk_notebook_get_nth_page (notebook, index);
320

321
322
  title  = g_object_get_data (G_OBJECT (page), "title");
  footer = g_object_get_data (G_OBJECT (page), "footer");
323
324
325
326

  gtk_label_set_text (GTK_LABEL (title_label), title);
  gtk_label_set_text (GTK_LABEL (footer_label), footer);

327
  if (index == EEK_PAGE && title_image)
328
    {
329
330
331
332
333
334
335
336
337
338
339
340
341
      GdkPixbuf *wilber;
      gchar     *filename;

      filename = g_build_filename (gimp_data_directory(),
                                   "images", "wilber-eek.png", NULL);
      wilber = gdk_pixbuf_new_from_file (filename, NULL);
      g_free (filename);

      if (wilber)
        {
          gtk_image_set_from_pixbuf (GTK_IMAGE (title_image), wilber);
          g_object_unref (wilber);
        }
342
343
    }
  
344
  gtk_notebook_set_current_page (notebook, index);
345
}
Sven Neumann's avatar
Sven Neumann committed
346
347

static void
348
user_install_continue_callback (GtkWidget *widget,
349
				GimpRc    *gimprc)
Sven Neumann's avatar
Sven Neumann committed
350
{
351
  static gint notebook_index = GPL_PAGE;
Sven Neumann's avatar
Sven Neumann committed
352
353
354

  switch (notebook_index)
    {
355
356
    case GPL_PAGE:
      user_install_notebook_set_page (GTK_NOTEBOOK (notebook), ++notebook_index);
Sven Neumann's avatar
Sven Neumann committed
357
      break;
358
359
360
361
362

    case TREE_PAGE:
      user_install_notebook_set_page (GTK_NOTEBOOK (notebook), ++notebook_index);

      /*  Creating the directories can take some time on NFS, so inform
363
364
365
366
367
368
       *  the user and set the buttons insensitive
       */
      gtk_widget_set_sensitive (continue_button, FALSE);
      gtk_widget_set_sensitive (cancel_button, FALSE);

      if (user_install_run ())
369
370
371
372
373
374
375
376
377
378
379
380
        {
          gtk_widget_set_sensitive (continue_button, TRUE);
          gtk_label_set_text (GTK_LABEL (footer_label),
                              _("Installation successful.\n"
                                "Click \"Continue\" to proceed."));
        }
      else
        {
          gtk_label_set_text (GTK_LABEL (footer_label),
                              _("Installation failed.\n"
                                "Contact system administrator."));
        }
381
382

      gtk_widget_set_sensitive (cancel_button, TRUE);
Sven Neumann's avatar
Sven Neumann committed
383
384
      break;

385
386
    case LOG_PAGE:
      user_install_notebook_set_page (GTK_NOTEBOOK (notebook), ++notebook_index);
387
      user_install_tuning (gimprc);
Sven Neumann's avatar
Sven Neumann committed
388
389
      break;

390
391
    case TUNING_PAGE:
      user_install_notebook_set_page (GTK_NOTEBOOK (notebook), ++notebook_index);
392
      user_install_resolution (gimprc);
Sven Neumann's avatar
Sven Neumann committed
393
394
      break;

395
    case RESOLUTION_PAGE:
396
397
      gimp_rc_save (gimprc);
      
398
399
400
      g_object_unref (G_OBJECT (title_style));
      g_object_unref (G_OBJECT (page_style));

401
      gtk_widget_destroy (user_install_dialog);
Sven Neumann's avatar
Sven Neumann committed
402

403
      gtk_main_quit ();
404
      return;
Sven Neumann's avatar
Sven Neumann committed
405
      break;
406
407
408

    default:
      g_assert_not_reached ();
Sven Neumann's avatar
Sven Neumann committed
409
410
    }
}
Elliot Lee's avatar
Elliot Lee committed
411
412

static void
413
user_install_cancel_callback (GtkWidget *widget,
414
			      gpointer   data)
Elliot Lee's avatar
Elliot Lee committed
415
{
416
  static guint timeout_id = 0;
417

418
  if (timeout_id)
419
    exit (0);
420
421

  gtk_widget_destroy (continue_button);
422
  user_install_notebook_set_page (GTK_NOTEBOOK (notebook), EEK_PAGE);
423
  timeout_id = g_timeout_add (1024, (GSourceFunc) exit, NULL);
Sven Neumann's avatar
Sven Neumann committed
424
425
}

426
static gboolean
427
user_install_corner_expose (GtkWidget      *widget,
428
429
			    GdkEventExpose *eevent,
			    gpointer        data)
Sven Neumann's avatar
Sven Neumann committed
430
{
431
432
433
434
435
  GtkCornerType corner;

  /* call default handler explicitly, then draw the corners */
  if (GTK_WIDGET_GET_CLASS (widget)->expose_event)
    GTK_WIDGET_GET_CLASS (widget)->expose_event (widget, eevent);
436

437
438
439
  corner = GPOINTER_TO_INT (data);

  switch (corner)
440
441
442
    {
    case GTK_CORNER_TOP_LEFT:
      gdk_draw_arc (widget->window,
443
		    widget->style->white_gc,
444
445
446
447
448
449
450
		    TRUE,
		    0, 0,
		    widget->allocation.width * 2,
		    widget->allocation.height * 2,
		    90 * 64,
		    180 * 64);
      break;
451

452
453
    case GTK_CORNER_BOTTOM_LEFT:
      gdk_draw_arc (widget->window,
454
		    widget->style->white_gc,
455
456
457
458
459
460
461
		    TRUE,
		    0, -widget->allocation.height,
		    widget->allocation.width * 2,
		    widget->allocation.height * 2,
		    180 * 64,
		    270 * 64);
      break;
462

463
464
    case GTK_CORNER_TOP_RIGHT:
      gdk_draw_arc (widget->window,
465
		    widget->style->white_gc,
466
467
468
469
470
471
472
		    TRUE,
		    -widget->allocation.width, 0,
		    widget->allocation.width * 2,
		    widget->allocation.height * 2,
		    0 * 64,
		    90 * 64);
      break;
473

474
475
    case GTK_CORNER_BOTTOM_RIGHT:
      gdk_draw_arc (widget->window,
476
		    widget->style->white_gc,
477
478
479
480
481
482
483
		    TRUE,
		    -widget->allocation.width, -widget->allocation.height,
		    widget->allocation.width * 2,
		    widget->allocation.height * 2,
		    270 * 64,
		    360 * 64);
      break;
484

485
    default:
486
      break;
487
    }
Sven Neumann's avatar
Sven Neumann committed
488
489
490
491
492

  return TRUE;
}

static GtkWidget *
493
user_install_notebook_append_page (GtkNotebook *notebook,
494
495
				   gchar       *title,
				   gchar       *footer)
Sven Neumann's avatar
Sven Neumann committed
496
497
{
  GtkWidget *page;
498

499
  page = gtk_vbox_new (FALSE, 6);
500
501
  g_object_set_data (G_OBJECT (page), "title", title);
  g_object_set_data (G_OBJECT (page), "footer", footer);
502
  gtk_notebook_append_page (notebook, page, NULL);
Sven Neumann's avatar
Sven Neumann committed
503
504
  gtk_widget_show (page);

505
  return page;
Elliot Lee's avatar
Elliot Lee committed
506
507
508
}

static void
Sven Neumann's avatar
Sven Neumann committed
509
510
add_label (GtkBox   *box,
	   gchar    *text)
Elliot Lee's avatar
Elliot Lee committed
511
{
Sven Neumann's avatar
Sven Neumann committed
512
513
514
  GtkWidget *label;

  label = gtk_label_new (text);
515
  PAGE_STYLE (label);
Sven Neumann's avatar
Sven Neumann committed
516
  gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
Elliot Lee's avatar
Elliot Lee committed
517

518
519
  gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
  gtk_box_pack_start (box, label, FALSE, FALSE, 0);
520

Sven Neumann's avatar
Sven Neumann committed
521
  gtk_widget_show (label);
Elliot Lee's avatar
Elliot Lee committed
522
523
524
}

static void
Manish Singh's avatar
Manish Singh committed
525
526
user_install_sel_changed (GtkTreeSelection *sel,
			  gpointer          data)
Elliot Lee's avatar
Elliot Lee committed
527
{
Manish Singh's avatar
Manish Singh committed
528
529
530
531
532
533
534
  GtkNotebook  *notebook = GTK_NOTEBOOK (data);
  GtkTreeModel *model;
  GtkTreeIter   iter;
  gint          index = 0;

  if (gtk_tree_selection_get_selected (sel, &model, &iter))
    gtk_tree_model_get (model, &iter, DESC_COLUMN, &index, -1);
Sven Neumann's avatar
Sven Neumann committed
535

Manish Singh's avatar
Manish Singh committed
536
537
  gtk_notebook_set_current_page (notebook, index);
}
Elliot Lee's avatar
Elliot Lee committed
538

Manish Singh's avatar
Manish Singh committed
539
540
541
542
543
544
545
546
static void
user_install_tv_fix_size_request (GtkWidget     *widget,
				  GtkAllocation *allocation)
{
  gtk_widget_set_size_request (widget, allocation->width, allocation->height);
  g_signal_handlers_disconnect_by_func (widget,
					user_install_tv_fix_size_request,
					NULL);
Elliot Lee's avatar
Elliot Lee committed
547
548
}

Sven Neumann's avatar
Sven Neumann committed
549
void
550
user_install_dialog_create (const gchar *alternate_system_gimprc,
551
552
                            const gchar *alternate_gimprc,
                            gboolean     verbose)
Elliot Lee's avatar
Elliot Lee committed
553
{
554
  GimpRc    *gimprc;
Sven Neumann's avatar
Sven Neumann committed
555
  GtkWidget *dialog;
556
557
558
559
560
  GtkWidget *vbox;
  GtkWidget *hbox;
  GtkWidget *ebox;
  GtkWidget *table;
  GtkWidget *darea;
Sven Neumann's avatar
Sven Neumann committed
561
562
  GtkWidget *page;
  GtkWidget *sep;
563
  GtkWidget *eek_box;
564
565
  GdkPixbuf *wilber;
  gchar     *filename;
566

567
  gimprc = gimp_rc_new (alternate_system_gimprc, alternate_gimprc, verbose);
568

569
  dialog = user_install_dialog =
Sven Neumann's avatar
Sven Neumann committed
570
571
572
573
574
    gimp_dialog_new (_("GIMP User Installation"), "user_installation",
		     NULL, NULL,
		     GTK_WIN_POS_CENTER,
		     FALSE, FALSE, FALSE,

575
		     GTK_STOCK_CANCEL, user_install_cancel_callback,
576
		     NULL, 1, &cancel_button, FALSE, TRUE,
Sven Neumann's avatar
Sven Neumann committed
577

578
		     _("Continue"), user_install_continue_callback,
579
		     gimprc, NULL, &continue_button, TRUE, FALSE,
580

Sven Neumann's avatar
Sven Neumann committed
581
582
		     NULL);

583
584
585
  g_object_weak_ref (G_OBJECT (dialog),
                     (GWeakNotify) g_object_unref, gimprc);

586
587
  gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area), 8);

588
589
  gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE);

590
591
  eek_box = gtk_hbox_new (FALSE, 8);

Manish Singh's avatar
Manish Singh committed
592
  g_object_ref (GTK_DIALOG (dialog)->action_area);
593
594
595
596
597
598
599
600
601
602
  gtk_container_remove (GTK_CONTAINER (GTK_DIALOG (dialog)->action_area->parent),
                        GTK_DIALOG (dialog)->action_area);
  gtk_box_pack_end (GTK_BOX (eek_box), GTK_DIALOG (dialog)->action_area,
                    FALSE, FALSE, 0);
  g_object_unref (GTK_DIALOG (dialog)->action_area);

  gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->vbox), eek_box,
                    FALSE, FALSE, 0);
  gtk_widget_show (eek_box);

603
604
  gdk_color_parse ("black",       &black_color);
  gdk_color_parse ("white",       &white_color);
605
  gdk_color_parse ("dark orange", &title_color);
606

Sven Neumann's avatar
Sven Neumann committed
607
608
609
  gtk_widget_realize (dialog);

  /*  B/W Style for the page contents  */
610
  page_style = gtk_widget_get_modifier_style (dialog);
Manish Singh's avatar
Manish Singh committed
611
  g_object_ref (page_style);
Sven Neumann's avatar
Sven Neumann committed
612
613
614
615

  page_style->fg[GTK_STATE_NORMAL]   = black_color;
  page_style->bg[GTK_STATE_NORMAL]   = white_color;

616
617
618
619
620
621
622
623
624
625
626
  page_style->text[GTK_STATE_NORMAL] = black_color;
  page_style->base[GTK_STATE_NORMAL] = white_color;

  page_style->color_flags[GTK_STATE_NORMAL] |= (GTK_RC_FG   | GTK_RC_BG   |
						GTK_RC_TEXT | GTK_RC_BASE);

  page_style->fg[GTK_STATE_ACTIVE]   = black_color;
  page_style->bg[GTK_STATE_ACTIVE]   = white_color;

  page_style->color_flags[GTK_STATE_ACTIVE] |= (GTK_RC_FG | GTK_RC_BG);

Sven Neumann's avatar
Sven Neumann committed
627

628
629
  /*  B/Colored Style for the page title  */
  title_style = gtk_rc_style_copy (page_style);
Sven Neumann's avatar
Sven Neumann committed
630

631
  title_style->bg[GTK_STATE_NORMAL] = title_color;
632

633
  pango_font_description_free (title_style->font_desc);
634
  title_style->font_desc = pango_font_description_from_string ("sans 20");
Sven Neumann's avatar
Sven Neumann committed
635

636
637
638
639
640
  TITLE_STYLE (dialog);

  footer_label = gtk_label_new (NULL);
  PAGE_STYLE (footer_label);
  gtk_label_set_justify (GTK_LABEL (footer_label), GTK_JUSTIFY_RIGHT);
641
  gtk_box_pack_end (GTK_BOX (eek_box), footer_label, FALSE, FALSE,0 );
642
643
644
645
646
647
648
649
650
651
  gtk_widget_show (footer_label);

  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox);

  ebox = gtk_event_box_new ();
  TITLE_STYLE (ebox);
  gtk_widget_set_events (ebox, GDK_EXPOSURE_MASK);
  gtk_box_pack_start (GTK_BOX (vbox), ebox, FALSE, FALSE, 0);
  gtk_widget_show (ebox);
652

653
654
655
656
657
  hbox = gtk_hbox_new (FALSE, 8);
  gtk_container_set_border_width (GTK_CONTAINER (hbox), 8);
  gtk_container_add (GTK_CONTAINER (ebox), hbox);
  gtk_widget_show (hbox);

658
659
660
661
662
663
664
665
666
667
668
669
670
  filename = g_build_filename (gimp_data_directory(),
                               "images", "wilber-wizard.png", NULL);
  wilber = gdk_pixbuf_new_from_file (filename, NULL);
  g_free (filename);

  if (wilber)
    {
      title_image = gtk_image_new_from_pixbuf (wilber);
      g_object_unref (wilber);

      gtk_box_pack_start (GTK_BOX (hbox), title_image, FALSE, FALSE, 8);
      gtk_widget_show (title_image);
    }
671
672
673
674
675
676
677
678
679
680
681
682
683

  title_label = gtk_label_new (NULL);
  TITLE_STYLE (title_label);  
  gtk_label_set_justify (GTK_LABEL (title_label), GTK_JUSTIFY_LEFT);
  gtk_box_pack_start (GTK_BOX (hbox), title_label, FALSE, FALSE, 0);
  gtk_widget_show (title_label);

  hbox = gtk_hbox_new (FALSE, 0);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
  gtk_widget_show (hbox);

  ebox = gtk_event_box_new ();
  TITLE_STYLE (ebox);  
684
  gtk_widget_set_size_request (ebox, 16, -1);
685
686
687
688
689
690
691
692
693
694
695
696
697
698
  gtk_box_pack_start (GTK_BOX (hbox), ebox, FALSE, FALSE, 0);
  gtk_widget_show (ebox);

  ebox = gtk_event_box_new ();
  PAGE_STYLE (ebox);  
  gtk_box_pack_start (GTK_BOX (hbox), ebox, TRUE, TRUE, 0);
  gtk_widget_show (ebox);

  table = gtk_table_new (3, 3, FALSE);
  gtk_table_set_col_spacing (GTK_TABLE (table), 1, 8);
  gtk_container_add (GTK_CONTAINER (ebox), table);
  gtk_widget_show (table);

  darea = gtk_drawing_area_new ();
699
700
  TITLE_STYLE (darea);
  gtk_widget_set_size_request (darea, 16, 16);
701
702
703
  g_signal_connect (G_OBJECT (darea), "expose_event",
                    G_CALLBACK (user_install_corner_expose),
                    GINT_TO_POINTER (GTK_CORNER_TOP_LEFT));
704
705
706
707
708
  gtk_table_attach (GTK_TABLE (table), darea, 0, 1, 0, 1,
		    GTK_SHRINK, GTK_SHRINK, 0, 0);
  gtk_widget_show (darea);

  darea = gtk_drawing_area_new ();
709
  TITLE_STYLE (darea);
710
  gtk_widget_set_size_request (darea, 16, 16);
711
712
713
  g_signal_connect (G_OBJECT (darea), "expose_event",
                    G_CALLBACK (user_install_corner_expose),
                    GINT_TO_POINTER (GTK_CORNER_BOTTOM_LEFT));
714
715
716
  gtk_table_attach (GTK_TABLE (table), darea, 0, 1, 2, 3,
		    GTK_SHRINK, GTK_SHRINK, 0, 0);
  gtk_widget_show (darea);
Sven Neumann's avatar
Sven Neumann committed
717
718
719
720

  notebook = gtk_notebook_new ();
  gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
  gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook), FALSE);
721
  gtk_table_attach_defaults (GTK_TABLE (table), notebook, 1, 2, 1, 2);
Sven Neumann's avatar
Sven Neumann committed
722
723
  gtk_widget_show (notebook);

724
725
  gtk_widget_show (vbox);

Sven Neumann's avatar
Sven Neumann committed
726
  /*  Page 1  */
727
  page = user_install_notebook_append_page (GTK_NOTEBOOK (notebook),
728
729
730
731
					    _("Welcome to\n"
					      "The GIMP User Installation"),
					    _("Click \"Continue\" to enter "
					      "the GIMP user installation."));
Sven Neumann's avatar
Sven Neumann committed
732

733
  add_label (GTK_BOX (page),
Sven Neumann's avatar
Sven Neumann committed
734
	     _("The GIMP - GNU Image Manipulation Program\n"
Manish Singh's avatar
Manish Singh committed
735
	       "Copyright (C) 1995-2002\n"
Sven Neumann's avatar
Sven Neumann committed
736
737
738
739
740
741
	       "Spencer Kimball, Peter Mattis and the GIMP Development Team."));

  sep = gtk_hseparator_new ();
  gtk_box_pack_start (GTK_BOX (page), sep, FALSE, FALSE, 2);
  gtk_widget_show (sep);

742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
  add_label 
    (GTK_BOX (page),
     _("This program is free software; you can redistribute it and/or modify\n"
       "it under the terms of the GNU General Public License as published by\n"
       "the Free Software Foundation; either version 2 of the License, or\n"
       "(at your option) any later version."));
  add_label
    (GTK_BOX (page),
     _("This program is distributed in the hope that it will be useful,\n"
       "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
       "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
       "See the GNU General Public License for more details."));
  add_label
    (GTK_BOX (page),
     _("You should have received a copy of the GNU General Public License\n"
       "along with this program; if not, write to the Free Software\n"
       "Foundation, Inc., 59 Temple Place - Suite 330, Boston,\n"
       "MA 02111-1307, USA."));
760

Sven Neumann's avatar
Sven Neumann committed
761
762
  /*  Page 2  */
  {
Manish Singh's avatar
Manish Singh committed
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
    GtkWidget         *hbox;
    GtkWidget         *vbox;
    GtkWidget         *tv;
    GdkPixbuf         *file_pixbuf;
    GdkPixbuf         *folder_pixbuf;
    GtkWidget         *notebook2;
    GtkWidget         *page2;
    GtkWidget         *label;
    gchar             *str;
    GtkTreeStore      *tree;
    GtkTreeViewColumn *column;
    GtkCellRenderer   *cell;
    GtkTreeSelection  *sel;
    GtkTreeIter        iter, child;
    gint               i;

779
    page = user_install_notebook_append_page (GTK_NOTEBOOK (notebook),
780
					      _("Personal GIMP Folder"),
781
					      _("Click \"Continue\" to create "
782
						"your personal GIMP folder."));
Sven Neumann's avatar
Sven Neumann committed
783
784
785
786
787

    hbox = gtk_hbox_new (FALSE, 8);
    gtk_box_pack_start (GTK_BOX (page), hbox, FALSE, FALSE, 0);
    gtk_widget_show (hbox);

Manish Singh's avatar
Manish Singh committed
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
    tree = gtk_tree_store_new (NUM_COLUMNS, G_TYPE_STRING, GDK_TYPE_PIXBUF,
					    G_TYPE_INT);
    tv = gtk_tree_view_new_with_model (GTK_TREE_MODEL (tree));
    g_object_unref (tree);

    column = gtk_tree_view_column_new ();

    cell = gtk_cell_renderer_pixbuf_new ();
    gtk_tree_view_column_pack_start (column, cell, FALSE);
    gtk_tree_view_column_set_attributes (column, cell,
					 "pixbuf", PIXBUF_COLUMN,
					 NULL);

    cell = gtk_cell_renderer_text_new ();
    gtk_tree_view_column_pack_start (column, cell, TRUE);
    gtk_tree_view_column_set_attributes (column, cell,
					 "text", DIRENT_COLUMN,
					 NULL);

    gtk_tree_view_append_column (GTK_TREE_VIEW (tv), column);

    PAGE_STYLE (tv);
    gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tv), FALSE);
    gtk_box_pack_start (GTK_BOX (hbox), tv, FALSE, FALSE, 0);
    gtk_widget_show (tv);
Sven Neumann's avatar
Sven Neumann committed
813
814
815
816
817

    vbox = gtk_vbox_new (FALSE, 6);
    gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
    gtk_widget_show (vbox);

818
    str = g_strdup_printf (_("For a proper GIMP installation, a folder named\n"
819
			     "'%s' needs to be created."), gimp_directory ());
820
    add_label (GTK_BOX (vbox), str);
821
822
    g_free (str);

823
    add_label (GTK_BOX (vbox),
824
825
	       _("This folder will contain a number of important files.\n"
		 "Click on one of the files or folders in the tree\n"
Sven Neumann's avatar
Sven Neumann committed
826
827
828
829
830
831
832
833
834
835
836
837
838
839
		 "to get more information about the selected item."));

    notebook2 = gtk_notebook_new ();
    gtk_container_set_border_width (GTK_CONTAINER (notebook2), 8);
    gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook2), FALSE);
    gtk_notebook_set_show_border (GTK_NOTEBOOK (notebook2), FALSE);
    gtk_box_pack_start (GTK_BOX (vbox), notebook2, TRUE, TRUE, 0);
    gtk_widget_show (notebook2);

    /*  empty page  */
    page2 = gtk_vbox_new (FALSE, 0);
    gtk_widget_show (page2);
    gtk_notebook_append_page (GTK_NOTEBOOK (notebook2), page2, NULL);

Manish Singh's avatar
Manish Singh committed
840
841
842
843
    sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv));
    g_signal_connect (G_OBJECT (sel), "changed",
		      G_CALLBACK (user_install_sel_changed),
		      notebook2);
Sven Neumann's avatar
Sven Neumann committed
844

845
846
847
848
849
850
    file_pixbuf = gtk_widget_render_icon (tv,
                                          GTK_STOCK_NEW, GTK_ICON_SIZE_MENU,
                                          NULL);
    folder_pixbuf = gtk_widget_render_icon (tv,
                                            GTK_STOCK_OPEN, GTK_ICON_SIZE_MENU,
                                            NULL);
Sven Neumann's avatar
Sven Neumann committed
851

Manish Singh's avatar
Manish Singh committed
852
853
854
855
856
857
    gtk_tree_store_append (tree, &iter, NULL);
    gtk_tree_store_set (tree, &iter,
			DIRENT_COLUMN, gimp_directory (),
			PIXBUF_COLUMN, folder_pixbuf,
			DESC_COLUMN, 0,
			-1);
Sven Neumann's avatar
Sven Neumann committed
858

859
    for (i = 0; i < G_N_ELEMENTS (tree_items); i++)
Sven Neumann's avatar
Sven Neumann committed
860
      {
Manish Singh's avatar
Manish Singh committed
861
862
863
864
865
866
867
868
	gtk_tree_store_append (tree, &child, &iter);
	gtk_tree_store_set (tree, &child,
			    DIRENT_COLUMN, tree_items[i].text,
			    PIXBUF_COLUMN,
			    tree_items[i].directory ? folder_pixbuf
						    : file_pixbuf,
			    DESC_COLUMN, i + 1,
			    -1);
Sven Neumann's avatar
Sven Neumann committed
869
870
871

	page2 = gtk_vbox_new (FALSE, 0);
	label = gtk_label_new (gettext (tree_items[i].description));
872
	PAGE_STYLE (label);
Sven Neumann's avatar
Sven Neumann committed
873
874
875
876
877
878
879
880
881
	gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
	gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
	gtk_box_pack_start (GTK_BOX (page2), label, TRUE, TRUE, 0);
	gtk_widget_show (label);
	gtk_widget_show (page2);

	gtk_notebook_append_page (GTK_NOTEBOOK (notebook2), page2, NULL);
      }

Manish Singh's avatar
Manish Singh committed
882
    gtk_tree_view_expand_all (GTK_TREE_VIEW (tv));
Sven Neumann's avatar
Sven Neumann committed
883

Manish Singh's avatar
Manish Singh committed
884
885
886
    g_signal_connect (tv, "size_allocate",
		      G_CALLBACK (user_install_tv_fix_size_request),
		      NULL);
Sven Neumann's avatar
Sven Neumann committed
887

Manish Singh's avatar
Manish Singh committed
888
889
    g_object_unref (file_pixbuf);
    g_object_unref (folder_pixbuf);
Sven Neumann's avatar
Sven Neumann committed
890
891
892
893
  }
  
  /*  Page 3  */
  page = log_page =
894
    user_install_notebook_append_page (GTK_NOTEBOOK (notebook),
895
				       _("User Installation Log"),
896
897
                                       _("Please wait while your personal\n"
                                         "GIMP folder is being created..."));
Sven Neumann's avatar
Sven Neumann committed
898
899
900

  /*  Page 4  */
  page = tuning_page = 
901
    user_install_notebook_append_page (GTK_NOTEBOOK (notebook),
902
903
				       _("GIMP Performance Tuning"),
				       _("Click \"Continue\" to accept the settings above."));
Sven Neumann's avatar
Sven Neumann committed
904
  
905
  add_label (GTK_BOX (page),
Sven Neumann's avatar
Sven Neumann committed
906
907
908
909
910
911
912
913
	     _("For optimal GIMP performance, some settings may have to be adjusted."));

  sep = gtk_hseparator_new ();
  gtk_box_pack_start (GTK_BOX (page), sep, FALSE, FALSE, 2);
  gtk_widget_show (sep);

  /*  Page 5  */
  page = resolution_page = 
914
    user_install_notebook_append_page (GTK_NOTEBOOK (notebook),
915
916
				       _("Monitor Resolution"),
				       _("Click \"Continue\" to start The GIMP."));
917

918
  add_label (GTK_BOX (resolution_page),
Sven Neumann's avatar
Sven Neumann committed
919
920
921
922
923
924
925
	     _("To display images in their natural size, "
	       "GIMP needs to know your monitor resolution."));

  sep = gtk_hseparator_new ();
  gtk_box_pack_start (GTK_BOX (page), sep, FALSE, FALSE, 2);
  gtk_widget_show (sep);

926
  /*  EEK page  */
927
  page = user_install_notebook_append_page (GTK_NOTEBOOK (notebook),
928
929
					    _("Aborting Installation..."),
					    NULL);
930

931
  user_install_notebook_set_page (GTK_NOTEBOOK (notebook), 0);
932

Manish Singh's avatar
Manish Singh committed
933
934
935
  gtk_widget_grab_focus (continue_button);
  gtk_widget_grab_default (continue_button);

Sven Neumann's avatar
Sven Neumann committed
936
  gtk_widget_show (dialog);
Elliot Lee's avatar
Elliot Lee committed
937
938
}

Sven Neumann's avatar
Sven Neumann committed
939
940
941
942

/*********************/
/*  Local functions  */

943
944
static gboolean
copy_file (gchar   *source,
945
           gchar   *dest,
946
           GError **error)
Tor Lillqvist's avatar
Tor Lillqvist committed
947
{
948
  gchar  buffer[4096];
949
950
  FILE  *sfile, *dfile;
  gint   nbytes;
951
952
953

  sfile = fopen (source, "rb");
  if (sfile == NULL)
Tor Lillqvist's avatar
Tor Lillqvist committed
954
    {
955
956
957
958
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
                   _("Cannot open '%s' for reading: %s"),
                   source, g_strerror (errno));
      return FALSE;
Tor Lillqvist's avatar
Tor Lillqvist committed
959
960
    }

961
962
963
  dfile = fopen (dest, "wb");
  if (dfile == NULL)
    {
964
965
966
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
                   _("Cannot open '%s' for writing: %s"),
                   dest, g_strerror (errno));
967
      fclose (sfile);
968
      return FALSE;
969
    }
Tor Lillqvist's avatar
Tor Lillqvist committed
970

971
972
973
974
  while ((nbytes = fread (buffer, 1, sizeof (buffer), sfile)) > 0)
    {
      if (fwrite (buffer, 1, nbytes, dfile) < nbytes)
	{
975
976
	  g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
                       _("Error while writing '%s': %s"),
977
                       dest, g_strerror (errno));
978
979
	  fclose (sfile);
	  fclose (dfile);
980
	  return FALSE;
981
982
	}
    }
983

984
985
  if (ferror (sfile))
    {
986
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
987
                   _("Error while reading '%s': %s"),
988
                   source, g_strerror (errno));
989
990
      fclose (sfile);
      fclose (dfile);
991
      return FALSE;
992
    }
Tor Lillqvist's avatar
Tor Lillqvist committed
993

994
  fclose (sfile);
995
996
997
998

  if (fclose (dfile) == EOF)
    {
      g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
999
                   _("Error while writing '%s': %s"),
1000
1001
1002
                   dest, g_strerror (errno));
      return FALSE;
    }
Tor Lillqvist's avatar
Tor Lillqvist committed
1003

1004
1005
  return TRUE;
}
Tor Lillqvist's avatar
Tor Lillqvist committed
1006

Sven Neumann's avatar
Sven Neumann committed
1007
static gboolean
1008
user_install_run (void)
Elliot Lee's avatar
Elliot Lee committed
1009
{
1010
  GtkWidget     *scrolled_window;
1011
  GtkTextBuffer *log_buffer;
1012
1013
1014
1015
1016
1017
  GtkWidget     *log_view;
  GError        *error = NULL;
  gchar          dest[1000];
  gchar          source[1000];
  gchar          log_line[1000];
  gint           i;
1018

1019
1020
1021
1022
  scrolled_window = gtk_scrolled_window_new (NULL, NULL);
  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
				  GTK_POLICY_AUTOMATIC,
				  GTK_POLICY_AUTOMATIC);
1023
  gtk_box_pack_start (GTK_BOX (log_page), scrolled_window, TRUE, TRUE, 0);
1024
1025
1026
1027
1028
1029
  gtk_widget_show (scrolled_window);

  log_buffer = gtk_text_buffer_new (NULL);

  log_view = gtk_text_view_new_with_buffer (log_buffer);
  g_object_unref (log_buffer);
1030

1031
1032
  PAGE_STYLE (log_view);
  gtk_text_view_set_editable (GTK_TEXT_VIEW (log_view), FALSE);
1033

1034
1035
  gtk_container_add (GTK_CONTAINER (scrolled_window), log_view);
  gtk_widget_show (log_view);
1036

1037
1038
1039
  g_snprintf (log_line, sizeof (log_line), _("Creating folder '%s'\n"),
              gimp_directory ());
  gtk_text_buffer_insert_at_cursor (log_buffer, log_line, -1);
1040

1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
  while (gtk_events_pending ())
    gtk_main_iteration ();

  if (mkdir (gimp_directory (), 0755) == -1)
    {
      g_set_error (&error, G_FILE_ERROR, g_file_error_from_errno (errno),
                   _("Cannot create folder '%s': %s"),
                   gimp_directory (), g_strerror (errno));
      goto break_out_of_loop;
    }
  gtk_text_buffer_insert_at_cursor (log_buffer, _("  Success\n"), -1);

  while (gtk_events_pending ())
    gtk_main_iteration ();
1055

1056
1057
  for (i = 0; i < G_N_ELEMENTS (tree_items); i++)
    {