~ubuntu-branches/ubuntu/saucy/gimp/saucy-updates

« back to all changes in this revision

Viewing changes to .pc/string-format.patch/app/file/file-open.c

  • Committer: Package Import Robot
  • Author(s): Micah Gersten
  • Date: 2012-02-22 23:47:53 UTC
  • mfrom: (1.1.25) (0.4.15 sid)
  • Revision ID: package-import@ubuntu.com-20120222234753-2a4wqdkb2bbx4mjb
Tags: 2.6.12-1ubuntu1
* Merge from Debian unstable (LP: #925674). Remaining Changes:
  - debian/patches/02_help-message.patch,
    debian/patches/03_gimp.desktop.in.in.patch:
    + Update some strings for Ubuntu
  - debian/patches/ghost-cursor.patch: fix Wacom tablet cursor events
  - debian/control:
    + Update description
  - debian/rules:
    + Set gettext domain and update translation templates

* Drop poppler patch as it's been applied upstream
  - drop debian/patches/poppler0.18.patch
  - update debian/patches/series
* fix LP: #680521 - Embed page setup dialog functionality in the print dialog
  - add debian/patches/embed-page-setup-dialog.patch
  - update debian/patches/series

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* GIMP - The GNU Image Manipulation Program
2
 
 * Copyright (C) 1995, 1996, 1997 Spencer Kimball and Peter Mattis
3
 
 * Copyright (C) 1997 Josh MacDonald
4
 
 *
5
 
 * file-open.c
6
 
 *
7
 
 * This program is free software; you can redistribute it and/or modify
8
 
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; either version 2 of the License, or
10
 
 * (at your option) any later version.
11
 
 *
12
 
 * This program is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 * GNU General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU General Public License
18
 
 * along with this program; if not, write to the Free Software
19
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
 
 */
21
 
 
22
 
#include "config.h"
23
 
 
24
 
#include <errno.h>
25
 
#include <stdlib.h>
26
 
#include <string.h>
27
 
 
28
 
#ifdef HAVE_SYS_PARAM_H
29
 
#include <sys/param.h>
30
 
#endif
31
 
 
32
 
#ifdef HAVE_UNISTD_H
33
 
#include <unistd.h>
34
 
#endif
35
 
 
36
 
#include <glib-object.h>
37
 
#include <glib/gstdio.h>
38
 
 
39
 
#ifdef G_OS_WIN32
40
 
#include <io.h>
41
 
#define R_OK 4
42
 
#endif
43
 
 
44
 
#include "libgimpconfig/gimpconfig.h"
45
 
 
46
 
#include "core/core-types.h"
47
 
 
48
 
#include "config/gimpcoreconfig.h"
49
 
 
50
 
#include "core/gimp.h"
51
 
#include "core/gimpcontext.h"
52
 
#include "core/gimpdocumentlist.h"
53
 
#include "core/gimpimage.h"
54
 
#include "core/gimpimage-merge.h"
55
 
#include "core/gimpimage-undo.h"
56
 
#include "core/gimpimagefile.h"
57
 
#include "core/gimplayer.h"
58
 
#include "core/gimpparamspecs.h"
59
 
#include "core/gimpprogress.h"
60
 
 
61
 
#include "pdb/gimppdb.h"
62
 
 
63
 
#include "plug-in/gimppluginmanager.h"
64
 
#include "plug-in/gimppluginprocedure.h"
65
 
#include "plug-in/gimppluginerror.h"
66
 
#include "plug-in/plug-in-icc-profile.h"
67
 
 
68
 
#include "file-open.h"
69
 
#include "file-procedure.h"
70
 
#include "file-utils.h"
71
 
 
72
 
#include "gimp-intl.h"
73
 
 
74
 
 
75
 
static void  file_open_sanitize_image       (GimpImage    *image,
76
 
                                             gboolean      as_new);
77
 
static void  file_open_convert_items        (GimpImage    *dest_image,
78
 
                                             const gchar  *basename,
79
 
                                             GList        *items);
80
 
static void  file_open_handle_color_profile (GimpImage    *image,
81
 
                                             GimpContext  *context,
82
 
                                             GimpProgress *progress,
83
 
                                             GimpRunMode   run_mode);
84
 
 
85
 
 
86
 
/*  public functions  */
87
 
 
88
 
GimpImage *
89
 
file_open_image (Gimp                *gimp,
90
 
                 GimpContext         *context,
91
 
                 GimpProgress        *progress,
92
 
                 const gchar         *uri,
93
 
                 const gchar         *entered_filename,
94
 
                 gboolean             as_new,
95
 
                 GimpPlugInProcedure *file_proc,
96
 
                 GimpRunMode          run_mode,
97
 
                 GimpPDBStatusType   *status,
98
 
                 const gchar        **mime_type,
99
 
                 GError             **error)
100
 
{
101
 
  GValueArray *return_vals;
102
 
  gchar       *filename;
103
 
  GimpImage   *image = NULL;
104
 
 
105
 
  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
106
 
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
107
 
  g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
108
 
  g_return_val_if_fail (status != NULL, NULL);
109
 
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
110
 
 
111
 
  *status = GIMP_PDB_EXECUTION_ERROR;
112
 
 
113
 
  if (! file_proc)
114
 
    file_proc = file_procedure_find (gimp->plug_in_manager->load_procs, uri,
115
 
                                     error);
116
 
 
117
 
  if (! file_proc)
118
 
    return NULL;
119
 
 
120
 
  filename = file_utils_filename_from_uri (uri);
121
 
 
122
 
  if (filename)
123
 
    {
124
 
      /* check if we are opening a file */
125
 
      if (g_file_test (filename, G_FILE_TEST_EXISTS))
126
 
        {
127
 
          if (! g_file_test (filename, G_FILE_TEST_IS_REGULAR))
128
 
            {
129
 
              g_free (filename);
130
 
              g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
131
 
                           _("Not a regular file"));
132
 
              return NULL;
133
 
            }
134
 
 
135
 
          if (g_access (filename, R_OK) != 0)
136
 
            {
137
 
              g_free (filename);
138
 
              g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_ACCES,
139
 
                           g_strerror (errno));
140
 
              return NULL;
141
 
            }
142
 
        }
143
 
    }
144
 
  else
145
 
    {
146
 
      filename = g_strdup (uri);
147
 
    }
148
 
 
149
 
  return_vals =
150
 
    gimp_pdb_execute_procedure_by_name (gimp->pdb,
151
 
                                        context, progress, error,
152
 
                                        GIMP_OBJECT (file_proc)->name,
153
 
                                        GIMP_TYPE_INT32, run_mode,
154
 
                                        G_TYPE_STRING,   filename,
155
 
                                        G_TYPE_STRING,   entered_filename,
156
 
                                        G_TYPE_NONE);
157
 
 
158
 
  g_free (filename);
159
 
 
160
 
  *status = g_value_get_enum (&return_vals->values[0]);
161
 
 
162
 
  if (*status == GIMP_PDB_SUCCESS)
163
 
    {
164
 
      image = gimp_value_get_image (&return_vals->values[1], gimp);
165
 
 
166
 
      if (image)
167
 
        {
168
 
          file_open_sanitize_image (image, as_new);
169
 
 
170
 
          /* Only set the load procedure if it hasn't already been set. */
171
 
          if (! gimp_image_get_load_proc (image))
172
 
            gimp_image_set_load_proc (image, file_proc);
173
 
 
174
 
          file_proc = gimp_image_get_load_proc (image);
175
 
 
176
 
          if (mime_type)
177
 
            *mime_type = file_proc->mime_type;
178
 
        }
179
 
      else
180
 
        {
181
 
          if (error && ! *error)
182
 
            g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
183
 
                         _("%s plug-in returned SUCCESS but did not "
184
 
                           "return an image"),
185
 
                         gimp_plug_in_procedure_get_label (file_proc));
186
 
 
187
 
          *status = GIMP_PDB_EXECUTION_ERROR;
188
 
        }
189
 
    }
190
 
  else if (*status != GIMP_PDB_CANCEL)
191
 
    {
192
 
      if (error && ! *error)
193
 
        g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
194
 
                     _("%s plug-In could not open image"),
195
 
                     gimp_plug_in_procedure_get_label (file_proc));
196
 
    }
197
 
 
198
 
  g_value_array_free (return_vals);
199
 
 
200
 
  if (image)
201
 
    {
202
 
      file_open_handle_color_profile (image, context, progress, run_mode);
203
 
    }
204
 
 
205
 
  return image;
206
 
}
207
 
 
208
 
/*  Attempts to load a thumbnail by using a registered thumbnail loader.  */
209
 
GimpImage *
210
 
file_open_thumbnail (Gimp          *gimp,
211
 
                     GimpContext   *context,
212
 
                     GimpProgress  *progress,
213
 
                     const gchar   *uri,
214
 
                     gint           size,
215
 
                     const gchar  **mime_type,
216
 
                     gint          *image_width,
217
 
                     gint          *image_height,
218
 
                     GError       **error)
219
 
{
220
 
  GimpPlugInProcedure *file_proc;
221
 
  GimpProcedure       *procedure;
222
 
 
223
 
  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
224
 
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
225
 
  g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
226
 
  g_return_val_if_fail (mime_type != NULL, NULL);
227
 
  g_return_val_if_fail (image_width != NULL, NULL);
228
 
  g_return_val_if_fail (image_height != NULL, NULL);
229
 
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
230
 
 
231
 
  *image_width  = 0;
232
 
  *image_height = 0;
233
 
 
234
 
  file_proc = file_procedure_find (gimp->plug_in_manager->load_procs, uri,
235
 
                                   NULL);
236
 
 
237
 
  if (! file_proc || ! file_proc->thumb_loader)
238
 
    return NULL;
239
 
 
240
 
  procedure = gimp_pdb_lookup_procedure (gimp->pdb, file_proc->thumb_loader);
241
 
 
242
 
  if (procedure && procedure->num_args >= 2 && procedure->num_values >= 1)
243
 
    {
244
 
      GimpPDBStatusType  status;
245
 
      GValueArray       *return_vals;
246
 
      gchar             *filename;
247
 
      GimpImage         *image = NULL;
248
 
 
249
 
      filename = file_utils_filename_from_uri (uri);
250
 
 
251
 
      if (! filename)
252
 
        filename = g_strdup (uri);
253
 
 
254
 
      return_vals =
255
 
        gimp_pdb_execute_procedure_by_name (gimp->pdb,
256
 
                                            context, progress, error,
257
 
                                            GIMP_OBJECT (procedure)->name,
258
 
                                            G_TYPE_STRING,   filename,
259
 
                                            GIMP_TYPE_INT32, size,
260
 
                                            G_TYPE_NONE);
261
 
 
262
 
      g_free (filename);
263
 
 
264
 
      status = g_value_get_enum (&return_vals->values[0]);
265
 
 
266
 
      if (status == GIMP_PDB_SUCCESS)
267
 
        {
268
 
          image = gimp_value_get_image (&return_vals->values[1], gimp);
269
 
 
270
 
          if (return_vals->n_values >= 3)
271
 
            {
272
 
              *image_width  = MAX (0,
273
 
                                   g_value_get_int (&return_vals->values[2]));
274
 
              *image_height = MAX (0,
275
 
                                   g_value_get_int (&return_vals->values[3]));
276
 
            }
277
 
 
278
 
          if (image)
279
 
            {
280
 
              file_open_sanitize_image (image, FALSE);
281
 
 
282
 
              *mime_type = file_proc->mime_type;
283
 
 
284
 
#ifdef GIMP_UNSTABLE
285
 
              g_printerr ("opened thumbnail at %d x %d\n",
286
 
                          gimp_image_get_width  (image),
287
 
                          gimp_image_get_height (image));
288
 
#endif
289
 
            }
290
 
        }
291
 
 
292
 
      g_value_array_free (return_vals);
293
 
 
294
 
      return image;
295
 
    }
296
 
 
297
 
  return NULL;
298
 
}
299
 
 
300
 
GimpImage *
301
 
file_open_with_display (Gimp               *gimp,
302
 
                        GimpContext        *context,
303
 
                        GimpProgress       *progress,
304
 
                        const gchar        *uri,
305
 
                        gboolean            as_new,
306
 
                        GimpPDBStatusType  *status,
307
 
                        GError            **error)
308
 
{
309
 
  return file_open_with_proc_and_display (gimp, context, progress,
310
 
                                          uri, uri, as_new, NULL,
311
 
                                          status, error);
312
 
}
313
 
 
314
 
GimpImage *
315
 
file_open_with_proc_and_display (Gimp                *gimp,
316
 
                                 GimpContext         *context,
317
 
                                 GimpProgress        *progress,
318
 
                                 const gchar         *uri,
319
 
                                 const gchar         *entered_filename,
320
 
                                 gboolean             as_new,
321
 
                                 GimpPlugInProcedure *file_proc,
322
 
                                 GimpPDBStatusType   *status,
323
 
                                 GError             **error)
324
 
{
325
 
  GimpImage   *image;
326
 
  const gchar *mime_type = NULL;
327
 
 
328
 
  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
329
 
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
330
 
  g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
331
 
  g_return_val_if_fail (status != NULL, NULL);
332
 
 
333
 
  image = file_open_image (gimp, context, progress,
334
 
                           uri,
335
 
                           entered_filename,
336
 
                           as_new,
337
 
                           file_proc,
338
 
                           GIMP_RUN_INTERACTIVE,
339
 
                           status,
340
 
                           &mime_type,
341
 
                           error);
342
 
 
343
 
  if (image)
344
 
    {
345
 
      gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0);
346
 
 
347
 
      if (! as_new)
348
 
        {
349
 
          GimpDocumentList *documents = GIMP_DOCUMENT_LIST (gimp->documents);
350
 
          GimpImagefile    *imagefile;
351
 
 
352
 
          imagefile = gimp_document_list_add_uri (documents, uri, mime_type);
353
 
 
354
 
          /*  can only create a thumbnail if the passed uri and the
355
 
           *  resulting image's uri match.
356
 
           */
357
 
          if (strcmp (uri, gimp_image_get_uri (image)) == 0)
358
 
            {
359
 
              /*  no need to save a thumbnail if there's a good one already  */
360
 
              if (! gimp_imagefile_check_thumbnail (imagefile))
361
 
                {
362
 
                  gimp_imagefile_save_thumbnail (imagefile, mime_type, image);
363
 
                }
364
 
            }
365
 
        }
366
 
 
367
 
      /*  the display owns the image now  */
368
 
      g_object_unref (image);
369
 
 
370
 
      /*  announce that we opened this image  */
371
 
      gimp_image_opened (image->gimp, uri);
372
 
    }
373
 
 
374
 
  return image;
375
 
}
376
 
 
377
 
GList *
378
 
file_open_layers (Gimp                *gimp,
379
 
                  GimpContext         *context,
380
 
                  GimpProgress        *progress,
381
 
                  GimpImage           *dest_image,
382
 
                  gboolean             merge_visible,
383
 
                  const gchar         *uri,
384
 
                  GimpRunMode          run_mode,
385
 
                  GimpPlugInProcedure *file_proc,
386
 
                  GimpPDBStatusType   *status,
387
 
                  GError             **error)
388
 
{
389
 
  GimpImage   *new_image;
390
 
  GList       *layers    = NULL;
391
 
  const gchar *mime_type = NULL;
392
 
 
393
 
  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
394
 
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
395
 
  g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), NULL);
396
 
  g_return_val_if_fail (GIMP_IS_IMAGE (dest_image), NULL);
397
 
  g_return_val_if_fail (uri != NULL, NULL);
398
 
  g_return_val_if_fail (status != NULL, NULL);
399
 
  g_return_val_if_fail (error == NULL || *error == NULL, NULL);
400
 
 
401
 
  new_image = file_open_image (gimp, context, progress,
402
 
                               uri, uri, FALSE,
403
 
                               file_proc,
404
 
                               run_mode,
405
 
                               status, &mime_type, error);
406
 
 
407
 
  if (new_image)
408
 
    {
409
 
      GList *list;
410
 
      gint   n_visible = 0;
411
 
 
412
 
      gimp_image_undo_disable (new_image);
413
 
 
414
 
      for (list = GIMP_LIST (gimp_image_get_layers (new_image))->list;
415
 
           list;
416
 
           list = g_list_next (list))
417
 
        {
418
 
          if (! merge_visible)
419
 
            layers = g_list_prepend (layers, list->data);
420
 
 
421
 
          if (gimp_item_get_visible (list->data))
422
 
            {
423
 
              n_visible++;
424
 
 
425
 
              if (! layers)
426
 
                layers = g_list_prepend (layers, list->data);
427
 
            }
428
 
        }
429
 
 
430
 
      if (merge_visible && n_visible > 1)
431
 
        {
432
 
          GimpLayer *layer;
433
 
 
434
 
          g_list_free (layers);
435
 
 
436
 
          layer = gimp_image_merge_visible_layers (new_image, context,
437
 
                                                   GIMP_CLIP_TO_IMAGE, FALSE);
438
 
 
439
 
          layers = g_list_prepend (NULL, layer);
440
 
        }
441
 
 
442
 
      if (layers)
443
 
        {
444
 
          gchar *basename = file_utils_uri_display_basename (uri);
445
 
 
446
 
          file_open_convert_items (dest_image, basename, layers);
447
 
          g_free (basename);
448
 
 
449
 
          gimp_document_list_add_uri (GIMP_DOCUMENT_LIST (gimp->documents),
450
 
                                      uri, mime_type);
451
 
        }
452
 
      else
453
 
        {
454
 
          g_set_error (error, G_FILE_ERROR, G_FILE_ERROR_FAILED,
455
 
                       _("Image doesn't contain any layers"));
456
 
          *status = GIMP_PDB_EXECUTION_ERROR;
457
 
        }
458
 
 
459
 
      g_object_unref (new_image);
460
 
    }
461
 
 
462
 
  return g_list_reverse (layers);
463
 
}
464
 
 
465
 
 
466
 
/*  This function is called for filenames passed on the command-line
467
 
 *  or from the D-Bus service.
468
 
 */
469
 
gboolean
470
 
file_open_from_command_line (Gimp        *gimp,
471
 
                             const gchar *filename,
472
 
                             gboolean     as_new)
473
 
{
474
 
  GError   *error   = NULL;
475
 
  gchar    *uri;
476
 
  gboolean  success = FALSE;
477
 
 
478
 
  g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE);
479
 
  g_return_val_if_fail (filename != NULL, FALSE);
480
 
 
481
 
  /* we accept URI or filename */
482
 
  uri = file_utils_any_to_uri (gimp, filename, &error);
483
 
 
484
 
  if (uri)
485
 
    {
486
 
      GimpImage         *image;
487
 
      GimpObject        *display = gimp_get_empty_display (gimp);
488
 
      GimpPDBStatusType  status;
489
 
 
490
 
      image = file_open_with_display (gimp,
491
 
                                      gimp_get_user_context (gimp),
492
 
                                      GIMP_PROGRESS (display),
493
 
                                      uri, as_new,
494
 
                                      &status, &error);
495
 
 
496
 
      if (image)
497
 
        {
498
 
          success = TRUE;
499
 
        }
500
 
      else if (status != GIMP_PDB_CANCEL)
501
 
        {
502
 
          gchar *filename = file_utils_uri_display_name (uri);
503
 
 
504
 
          gimp_message (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR,
505
 
                        _("Opening '%s' failed: %s"),
506
 
                        filename, error->message);
507
 
          g_clear_error (&error);
508
 
 
509
 
          g_free (filename);
510
 
        }
511
 
 
512
 
      g_free (uri);
513
 
    }
514
 
  else
515
 
    {
516
 
      g_printerr ("conversion filename -> uri failed: %s\n",
517
 
                  error->message);
518
 
      g_clear_error (&error);
519
 
    }
520
 
 
521
 
  return success;
522
 
}
523
 
 
524
 
 
525
 
/*  private functions  */
526
 
 
527
 
static void
528
 
file_open_sanitize_image (GimpImage *image,
529
 
                          gboolean   as_new)
530
 
{
531
 
  if (as_new)
532
 
    gimp_object_set_name (GIMP_OBJECT (image), NULL);
533
 
 
534
 
  /* clear all undo steps */
535
 
  gimp_image_undo_free (image);
536
 
 
537
 
  /* make sure that undo is enabled */
538
 
  while (image->undo_freeze_count)
539
 
    gimp_image_undo_thaw (image);
540
 
 
541
 
  /* set the image to clean  */
542
 
  gimp_image_clean_all (image);
543
 
 
544
 
  /* make sure the entire projection is properly constructed, because
545
 
   * load plug-ins are not required to call gimp_drawable_update() or
546
 
   * anything.
547
 
   */
548
 
  gimp_image_update (image,
549
 
                     0, 0,
550
 
                     gimp_image_get_width  (image),
551
 
                     gimp_image_get_height (image));
552
 
  gimp_image_flush (image);
553
 
 
554
 
  /* same for drawable previews */
555
 
  gimp_image_invalidate_layer_previews (image);
556
 
  gimp_image_invalidate_channel_previews (image);
557
 
}
558
 
 
559
 
/* Converts items from one image to another */
560
 
static void
561
 
file_open_convert_items (GimpImage   *dest_image,
562
 
                         const gchar *basename,
563
 
                         GList       *items)
564
 
{
565
 
  GList *list;
566
 
 
567
 
  for (list = items; list; list = g_list_next (list))
568
 
    {
569
 
      GimpItem *src = list->data;
570
 
      GimpItem *item;
571
 
 
572
 
      item = gimp_item_convert (src, dest_image, G_TYPE_FROM_INSTANCE (src));
573
 
 
574
 
      if (g_list_length (items) == 1)
575
 
        {
576
 
          gimp_object_set_name (GIMP_OBJECT (item), basename);
577
 
        }
578
 
      else
579
 
        {
580
 
          gchar *name = g_strdup_printf ("%s - %s", basename,
581
 
                                         GIMP_OBJECT (src)->name);
582
 
 
583
 
          gimp_object_take_name (GIMP_OBJECT (item), name);
584
 
        }
585
 
 
586
 
      list->data = item;
587
 
    }
588
 
}
589
 
 
590
 
static void
591
 
file_open_profile_apply_rgb (GimpImage    *image,
592
 
                             GimpContext  *context,
593
 
                             GimpProgress *progress,
594
 
                             GimpRunMode   run_mode)
595
 
{
596
 
  GimpColorConfig *config = image->gimp->config->color_management;
597
 
  GError          *error  = NULL;
598
 
 
599
 
  if (gimp_image_base_type (image) == GIMP_GRAY)
600
 
    return;
601
 
 
602
 
  if (config->mode == GIMP_COLOR_MANAGEMENT_OFF)
603
 
    return;
604
 
 
605
 
  if (! plug_in_icc_profile_apply_rgb (image, context, progress, run_mode,
606
 
                                       &error))
607
 
    {
608
 
      if (error->domain == GIMP_PLUG_IN_ERROR &&
609
 
          error->code   == GIMP_PLUG_IN_NOT_FOUND)
610
 
        {
611
 
          gchar *msg = g_strdup_printf ("%s\n\n%s",
612
 
                                        error->message,
613
 
                                        _("Color management has been disabled. "
614
 
                                          "It can be enabled again in the "
615
 
                                          "Preferences dialog."));
616
 
 
617
 
          g_object_set (config, "mode", GIMP_COLOR_MANAGEMENT_OFF, NULL);
618
 
 
619
 
          gimp_message (image->gimp, G_OBJECT (progress),
620
 
                        GIMP_MESSAGE_WARNING, msg);
621
 
          g_free (msg);
622
 
        }
623
 
      else
624
 
        {
625
 
          gimp_message (image->gimp, G_OBJECT (progress),
626
 
                        GIMP_MESSAGE_ERROR, error->message);
627
 
        }
628
 
 
629
 
      g_error_free (error);
630
 
    }
631
 
}
632
 
 
633
 
static void
634
 
file_open_handle_color_profile (GimpImage    *image,
635
 
                                GimpContext  *context,
636
 
                                GimpProgress *progress,
637
 
                                GimpRunMode   run_mode)
638
 
{
639
 
  if (gimp_image_parasite_find (image, "icc-profile"))
640
 
    {
641
 
      gimp_image_undo_disable (image);
642
 
 
643
 
      switch (image->gimp->config->color_profile_policy)
644
 
        {
645
 
        case GIMP_COLOR_PROFILE_POLICY_ASK:
646
 
          if (run_mode == GIMP_RUN_INTERACTIVE)
647
 
            file_open_profile_apply_rgb (image, context, progress,
648
 
                                         GIMP_RUN_INTERACTIVE);
649
 
          break;
650
 
 
651
 
        case GIMP_COLOR_PROFILE_POLICY_KEEP:
652
 
          break;
653
 
 
654
 
        case GIMP_COLOR_PROFILE_POLICY_CONVERT:
655
 
          file_open_profile_apply_rgb (image, context, progress,
656
 
                                       GIMP_RUN_NONINTERACTIVE);
657
 
          break;
658
 
        }
659
 
 
660
 
      gimp_image_clean_all (image);
661
 
      gimp_image_undo_enable (image);
662
 
    }
663
 
}