~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/core/gimpdatafactory.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * gimpdatafactory.c
27
27
#include <glib-object.h>
28
28
 
29
29
#include "libgimpbase/gimpbase.h"
 
30
#include "libgimpmath/gimpmath.h"
 
31
#include "libgimpconfig/gimpconfig.h"
30
32
 
31
33
#include "core-types.h"
32
34
 
33
 
#include "config/gimpbaseconfig.h"
34
 
#include "config/gimpconfig-path.h"
35
 
 
36
35
#include "gimp.h"
37
36
#include "gimpcontext.h"
38
37
#include "gimpdata.h"
45
44
#define WRITABLE_PATH_KEY "gimp-data-factory-writable-path"
46
45
 
47
46
 
48
 
static void    gimp_data_factory_class_init   (GimpDataFactoryClass   *klass);
49
 
static void    gimp_data_factory_init         (GimpDataFactory        *factory);
50
 
 
51
 
static void    gimp_data_factory_finalize     (GObject                *object);
52
 
 
53
 
static gint64  gimp_data_factory_get_memsize  (GimpObject             *object,
54
 
                                               gint64                 *gui_size);
55
 
 
56
 
static gchar * gimp_data_factory_get_save_dir (GimpDataFactory        *factory);
57
 
static void    gimp_data_factory_load_data    (const GimpDatafileData *file_data,
58
 
                                               gpointer                user_data);
59
 
 
60
 
 
61
 
static GimpObjectClass *parent_class = NULL;
62
 
 
63
 
 
64
 
GType
65
 
gimp_data_factory_get_type (void)
66
 
{
67
 
  static GType factory_type = 0;
68
 
 
69
 
  if (! factory_type)
70
 
    {
71
 
      static const GTypeInfo factory_info =
72
 
      {
73
 
        sizeof (GimpDataFactoryClass),
74
 
        (GBaseInitFunc) NULL,
75
 
        (GBaseFinalizeFunc) NULL,
76
 
        (GClassInitFunc) gimp_data_factory_class_init,
77
 
        NULL,           /* class_finalize */
78
 
        NULL,           /* class_data     */
79
 
        sizeof (GimpDataFactory),
80
 
        0,              /* n_preallocs    */
81
 
        (GInstanceInitFunc) gimp_data_factory_init,
82
 
      };
83
 
 
84
 
      factory_type = g_type_register_static (GIMP_TYPE_OBJECT,
85
 
                                             "GimpDataFactory",
86
 
                                             &factory_info, 0);
87
 
    }
88
 
 
89
 
  return factory_type;
90
 
}
 
47
static void    gimp_data_factory_finalize     (GObject              *object);
 
48
 
 
49
static void    gimp_data_factory_data_load    (GimpDataFactory      *factory,
 
50
                                               GHashTable           *cache);
 
51
 
 
52
static gint64  gimp_data_factory_get_memsize  (GimpObject           *object,
 
53
                                               gint64               *gui_size);
 
54
 
 
55
static gchar * gimp_data_factory_get_save_dir (GimpDataFactory      *factory);
 
56
 
 
57
static void    gimp_data_factory_load_data  (const GimpDatafileData *file_data,
 
58
                                             gpointer                data);
 
59
 
 
60
 
 
61
G_DEFINE_TYPE (GimpDataFactory, gimp_data_factory, GIMP_TYPE_OBJECT)
 
62
 
 
63
#define parent_class gimp_data_factory_parent_class
 
64
 
91
65
 
92
66
static void
93
67
gimp_data_factory_class_init (GimpDataFactoryClass *klass)
95
69
  GObjectClass    *object_class      = G_OBJECT_CLASS (klass);
96
70
  GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
97
71
 
98
 
  parent_class = g_type_class_peek_parent (klass);
99
 
 
100
72
  object_class->finalize         = gimp_data_factory_finalize;
101
73
 
102
74
  gimp_object_class->get_memsize = gimp_data_factory_get_memsize;
158
130
GimpDataFactory *
159
131
gimp_data_factory_new (Gimp                             *gimp,
160
132
                       GType                             data_type,
161
 
                       const gchar                      *path_property_name,
 
133
                       const gchar                      *path_property_name,
162
134
                       const gchar                      *writable_property_name,
163
 
                       const GimpDataFactoryLoaderEntry *loader_entries,
164
 
                       gint                              n_loader_entries,
165
 
                       GimpDataNewFunc                   new_func,
166
 
                       GimpDataGetStandardFunc           standard_func)
 
135
                       const GimpDataFactoryLoaderEntry *loader_entries,
 
136
                       gint                              n_loader_entries,
 
137
                       GimpDataNewFunc                   new_func,
 
138
                       GimpDataGetStandardFunc           standard_func)
167
139
{
168
140
  GimpDataFactory *factory;
169
141
 
195
167
 
196
168
void
197
169
gimp_data_factory_data_init (GimpDataFactory *factory,
198
 
                             gboolean         no_data /* FIXME */)
 
170
                             gboolean         no_data)
 
171
{
 
172
  g_return_if_fail (GIMP_IS_DATA_FACTORY (factory));
 
173
 
 
174
  /*  Freeze and thaw the container even if no_data,
 
175
   *  this creates the standard data that serves as fallback.
 
176
   */
 
177
  gimp_container_freeze (factory->container);
 
178
 
 
179
  if (! no_data)
 
180
    {
 
181
      if (factory->gimp->be_verbose)
 
182
        {
 
183
          const gchar *name = gimp_object_get_name (GIMP_OBJECT (factory));
 
184
 
 
185
          g_print ("Loading '%s' data\n", name ? name : "???");
 
186
        }
 
187
 
 
188
      gimp_data_factory_data_load (factory, NULL);
 
189
    }
 
190
 
 
191
  gimp_container_thaw (factory->container);
 
192
}
 
193
 
 
194
typedef struct
 
195
{
 
196
  GimpDataFactory *factory;
 
197
  GHashTable      *cache;
 
198
} GimpDataLoadContext;
 
199
 
 
200
static gboolean
 
201
gimp_data_factory_refresh_cache_remove (gpointer key,
 
202
                                        gpointer value,
 
203
                                        gpointer user_data)
 
204
{
 
205
  g_list_foreach (value, (GFunc) g_object_unref, NULL);
 
206
  g_list_free (value);
 
207
 
 
208
  return TRUE;
 
209
}
 
210
 
 
211
static void
 
212
gimp_data_factory_data_move_to_cache (GimpDataFactory *factory,
 
213
                                      gpointer         object,
 
214
                                      gpointer         data)
 
215
{
 
216
  GHashTable  *cache    = data;
 
217
  GList       *list;
 
218
  const gchar *filename = GIMP_DATA (object)->filename;
 
219
 
 
220
  g_object_ref (object);
 
221
 
 
222
  gimp_container_remove (factory->container, GIMP_OBJECT (object));
 
223
 
 
224
  list = g_hash_table_lookup (cache, filename);
 
225
  list = g_list_prepend (list, object);
 
226
 
 
227
  g_hash_table_insert (cache, (gpointer) filename, list);
 
228
}
 
229
 
 
230
static void
 
231
gimp_data_factory_data_foreach (GimpDataFactory *factory,
 
232
                                void (*callback) (GimpDataFactory *factory,
 
233
                                                  gpointer         expr,
 
234
                                                  gpointer         context),
 
235
                                gpointer         context)
 
236
{
 
237
  GimpList *list;
 
238
 
 
239
  if (gimp_container_is_empty (factory->container))
 
240
    return;
 
241
 
 
242
  list = GIMP_LIST (factory->container);
 
243
 
 
244
  gimp_container_freeze (factory->container);
 
245
 
 
246
  if (list->list)
 
247
    {
 
248
      if (GIMP_DATA (list->list->data)->internal)
 
249
        {
 
250
          /*  if there are internal objects in the list, skip them  */
 
251
          GList *glist;
 
252
 
 
253
          for (glist = list->list; glist; glist = g_list_next (glist))
 
254
            {
 
255
              if (glist->next && ! GIMP_DATA (glist->next->data)->internal)
 
256
                {
 
257
                  while (glist->next)
 
258
                    callback (factory, glist->next->data, context);
 
259
 
 
260
                  break;
 
261
                }
 
262
            }
 
263
        }
 
264
      else
 
265
        {
 
266
          /*  otherwise delete everything  */
 
267
          while (list->list)
 
268
            callback (factory, list->list->data, context);
 
269
        }
 
270
    }
 
271
 
 
272
  gimp_container_thaw (factory->container);
 
273
}
 
274
 
 
275
static void
 
276
gimp_data_factory_data_load (GimpDataFactory *factory,
 
277
                             GHashTable      *cache)
199
278
{
200
279
  gchar *path;
201
280
  gchar *writable_path;
202
281
 
203
 
  g_return_if_fail (GIMP_IS_DATA_FACTORY (factory));
204
 
 
205
 
  gimp_container_freeze (factory->container);
206
 
 
207
 
  gimp_data_factory_data_free (factory);
208
 
 
209
282
  g_object_get (factory->gimp->config,
210
283
                factory->path_property_name,     &path,
211
284
                factory->writable_property_name, &writable_path,
213
286
 
214
287
  if (path && strlen (path))
215
288
    {
216
 
      GList *writable_list = NULL;
217
 
      gchar *tmp;
 
289
      GList               *writable_list = NULL;
 
290
      gchar               *tmp;
 
291
      GimpDataLoadContext  context;
 
292
 
 
293
      context.factory = factory;
 
294
      context.cache   = cache;
218
295
 
219
296
      tmp = gimp_config_path_expand (path, TRUE, NULL);
220
297
      g_free (path);
228
305
 
229
306
          writable_list = gimp_path_parse (writable_path, 16, TRUE, NULL);
230
307
 
231
 
          g_object_set_data (G_OBJECT (factory), WRITABLE_PATH_KEY,
232
 
                             writable_list);
 
308
          g_object_set_data (G_OBJECT (factory),
 
309
                             WRITABLE_PATH_KEY, writable_list);
233
310
        }
234
311
 
235
 
      gimp_datafiles_read_directories (path,
236
 
                                       G_FILE_TEST_EXISTS,
237
 
                                       gimp_data_factory_load_data,
238
 
                                       factory);
 
312
      gimp_datafiles_read_directories (path, G_FILE_TEST_EXISTS,
 
313
                                       gimp_data_factory_load_data, &context);
239
314
 
240
315
      if (writable_path)
241
316
        {
246
321
 
247
322
  g_free (path);
248
323
  g_free (writable_path);
 
324
}
 
325
 
 
326
static void
 
327
gimp_data_factory_data_reload (GimpDataFactory *factory)
 
328
{
 
329
 
 
330
  GHashTable *cache;
 
331
 
 
332
  g_return_if_fail (GIMP_IS_DATA_FACTORY (factory));
 
333
 
 
334
  cache = g_hash_table_new (g_str_hash, g_str_equal);
 
335
 
 
336
  gimp_data_factory_data_foreach (factory,
 
337
                                  gimp_data_factory_data_move_to_cache, cache);
 
338
 
 
339
  /* Now the cache contains a filename => list-of-objects mapping of
 
340
   * the old objects. So we should now traverse the directory and for
 
341
   * each file load it only if it's mtime is newer.
 
342
   *
 
343
   * Once a file was added, it is removed from the cache, so the only
 
344
   * objects remaining there will be those that are not present on the
 
345
   * disk (that have to be destroyed)
 
346
   */
 
347
  gimp_data_factory_data_load (factory, cache);
 
348
 
 
349
  /* Now all the data is loaded. Free what remains in the cache. */
 
350
  g_hash_table_foreach_remove (cache,
 
351
                               gimp_data_factory_refresh_cache_remove, NULL);
 
352
  g_hash_table_destroy (cache);
 
353
}
 
354
 
 
355
void
 
356
gimp_data_factory_data_refresh (GimpDataFactory *factory)
 
357
{
 
358
  g_return_if_fail (GIMP_IS_DATA_FACTORY (factory));
 
359
 
 
360
  gimp_container_freeze (factory->container);
 
361
 
 
362
  gimp_data_factory_data_save (factory);
 
363
 
 
364
  gimp_data_factory_data_reload (factory);
249
365
 
250
366
  gimp_container_thaw (factory->container);
251
367
}
258
374
 
259
375
  g_return_if_fail (GIMP_IS_DATA_FACTORY (factory));
260
376
 
261
 
  if (gimp_container_num_children (factory->container) == 0)
 
377
  if (gimp_container_is_empty (factory->container))
262
378
    return;
263
379
 
264
380
  writable_dir = gimp_data_factory_get_save_dir (factory);
288
404
               */
289
405
              if (error)
290
406
                {
291
 
                  g_message (_("Warning: Failed to save data:\n\n%s"),
292
 
                             error->message);
 
407
                  gimp_message (factory->gimp, NULL, GIMP_MESSAGE_ERROR,
 
408
                                _("Failed to save data:\n\n%s"),
 
409
                                error->message);
293
410
                  g_clear_error (&error);
294
411
                }
295
412
            }
301
418
  g_free (writable_dir);
302
419
}
303
420
 
 
421
static void
 
422
gimp_data_factory_remove_cb (GimpDataFactory *factory,
 
423
                             gpointer         data,
 
424
                             gpointer         context)
 
425
{
 
426
  gimp_container_remove (factory->container, GIMP_OBJECT (data));
 
427
}
 
428
 
304
429
void
305
430
gimp_data_factory_data_free (GimpDataFactory *factory)
306
431
{
307
 
  GimpList *list;
308
 
 
309
432
  g_return_if_fail (GIMP_IS_DATA_FACTORY (factory));
310
433
 
311
 
  if (gimp_container_num_children (factory->container) == 0)
312
 
    return;
313
 
 
314
 
  list = GIMP_LIST (factory->container);
315
 
 
316
 
  gimp_container_freeze (factory->container);
317
 
 
318
 
  if (list->list)
319
 
    {
320
 
      if (GIMP_DATA (list->list->data)->internal)
321
 
        {
322
 
          /*  if there are internal objects in the list, skip them  */
323
 
 
324
 
          GList *glist;
325
 
 
326
 
          for (glist = list->list; glist; glist = g_list_next (glist))
327
 
            {
328
 
              if (glist->next && ! GIMP_DATA (glist->next->data)->internal)
329
 
                {
330
 
                  while (glist->next)
331
 
                    {
332
 
                      gimp_container_remove (factory->container,
333
 
                                             GIMP_OBJECT (glist->next->data));
334
 
                   }
335
 
 
336
 
                  break;
337
 
                }
338
 
            }
339
 
        }
340
 
      else
341
 
        {
342
 
          /*  otherwise delete everything  */
343
 
 
344
 
          while (list->list)
345
 
            {
346
 
              gimp_container_remove (factory->container,
347
 
                                     GIMP_OBJECT (list->list->data));
348
 
            }
349
 
        }
350
 
    }
351
 
 
352
 
  gimp_container_thaw (factory->container);
 
434
  gimp_data_factory_data_foreach (factory, gimp_data_factory_remove_cb, NULL);
353
435
}
354
436
 
355
437
GimpData *
356
438
gimp_data_factory_data_new (GimpDataFactory *factory,
357
 
                            const gchar     *name)
 
439
                            const gchar     *name)
358
440
{
359
441
  g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
360
442
  g_return_val_if_fail (name != NULL, NULL);
362
444
 
363
445
  if (factory->data_new_func)
364
446
    {
365
 
      GimpBaseConfig *base_config;
366
 
      GimpData       *data;
367
 
 
368
 
      base_config = GIMP_BASE_CONFIG (factory->gimp->config);
369
 
 
370
 
      data = factory->data_new_func (name, base_config->stingy_memory_use);
 
447
      GimpData *data = factory->data_new_func (name);
371
448
 
372
449
      if (data)
373
450
        {
387
464
gimp_data_factory_data_duplicate (GimpDataFactory *factory,
388
465
                                  GimpData        *data)
389
466
{
390
 
  GimpBaseConfig *base_config;
391
 
  GimpData       *new_data;
 
467
  GimpData *new_data;
392
468
 
393
469
  g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
394
470
  g_return_val_if_fail (GIMP_IS_DATA (data), NULL);
395
471
 
396
 
  base_config = GIMP_BASE_CONFIG (factory->gimp->config);
397
 
 
398
 
  new_data = gimp_data_duplicate (data, base_config->stingy_memory_use);
 
472
  new_data = gimp_data_duplicate (data);
399
473
 
400
474
  if (new_data)
401
475
    {
423
497
          new_name = g_strdup_printf (_("%s copy"), name);
424
498
        }
425
499
 
426
 
      gimp_object_set_name (GIMP_OBJECT (new_data), new_name);
427
 
 
428
 
      g_free (new_name);
 
500
      gimp_object_take_name (GIMP_OBJECT (new_data), new_name);
429
501
 
430
502
      gimp_container_add (factory->container, GIMP_OBJECT (new_data));
431
503
      g_object_unref (new_data);
473
545
}
474
546
 
475
547
gboolean
476
 
gimp_data_factory_data_save_single (GimpDataFactory *factory,
477
 
                                    GimpData        *data)
 
548
gimp_data_factory_data_save_single (GimpDataFactory  *factory,
 
549
                                    GimpData         *data,
 
550
                                    GError          **error)
478
551
{
479
 
  GError *error = NULL;
480
 
 
481
552
  g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), FALSE);
482
553
  g_return_val_if_fail (GIMP_IS_DATA (data), FALSE);
 
554
  g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
483
555
 
484
556
  if (! data->dirty)
485
557
    return TRUE;
486
558
 
487
559
  if (! data->filename)
488
560
    {
489
 
      gchar *writable_dir;
490
 
 
491
 
      writable_dir = gimp_data_factory_get_save_dir (factory);
 
561
      gchar *writable_dir = gimp_data_factory_get_save_dir (factory);
492
562
 
493
563
      if (! writable_dir)
494
 
        return FALSE;
 
564
        {
 
565
          g_set_error (error, GIMP_DATA_ERROR, 0,
 
566
                       _("Failed to save data:\n\n%s"),
 
567
                       _("You don't have a writable data folder configured."));
 
568
          return FALSE;
 
569
        }
495
570
 
496
571
      gimp_data_create_filename (data, writable_dir);
497
572
 
501
576
  if (! data->writable)
502
577
    return FALSE;
503
578
 
504
 
  if (! gimp_data_save (data, &error))
 
579
  if (! gimp_data_save (data, error))
505
580
    {
506
581
      /*  check if there actually was an error (no error
507
582
       *  means the data class does not implement save)
508
583
       */
509
 
      if (error)
510
 
        {
511
 
          g_message (_("Warning: Failed to save data:\n\n%s"),
512
 
                     error->message);
513
 
          g_clear_error (&error);
514
 
        }
 
584
      if (! error)
 
585
        g_set_error (error, GIMP_DATA_ERROR, 0,
 
586
                     _("Failed to save data:\n\n%s"),
 
587
                     "Data class does not implement saving");
515
588
 
516
589
      return FALSE;
517
590
    }
554
627
 
555
628
  for (list = writable_list; list; list = g_list_next (list))
556
629
    {
557
 
      GList *found;
558
 
 
559
 
      found = g_list_find_custom (path_list, list->data, (GCompareFunc) strcmp);
560
 
 
 
630
      GList *found = g_list_find_custom (path_list,
 
631
                                         list->data, (GCompareFunc) strcmp);
561
632
      if (found)
562
633
        {
563
634
          writable_dir = g_strdup (found->data);
573
644
 
574
645
static void
575
646
gimp_data_factory_load_data (const GimpDatafileData *file_data,
576
 
                             gpointer                user_data)
 
647
                             gpointer                data)
577
648
{
578
 
  GimpDataFactory *factory = GIMP_DATA_FACTORY (user_data);
579
 
  gint             i;
 
649
  GimpDataLoadContext *context = data;
 
650
  GimpDataFactory     *factory = context->factory;
 
651
  GHashTable          *cache   = context->cache;
 
652
  gint                 i;
580
653
 
581
654
  for (i = 0; i < factory->n_loader_entries; i++)
582
655
    {
583
 
      if (factory->loader_entries[i].extension)
584
 
        {
585
 
          if (gimp_datafiles_check_extension (file_data->filename,
586
 
                                              factory->loader_entries[i].extension))
587
 
            {
588
 
              goto insert;
589
 
            }
590
 
        }
591
 
      else
592
 
        {
593
 
          goto insert;
594
 
        }
 
656
      if (! factory->loader_entries[i].extension ||
 
657
          gimp_datafiles_check_extension (file_data->filename,
 
658
                                          factory->loader_entries[i].extension))
 
659
        goto insert;
595
660
    }
596
661
 
597
662
  return;
598
663
 
599
664
 insert:
600
665
  {
601
 
    GimpBaseConfig *base_config;
602
 
    GList          *data_list;
603
 
    GError         *error = NULL;
604
 
 
605
 
    base_config = GIMP_BASE_CONFIG (factory->gimp->config);
606
 
 
607
 
    data_list =
608
 
      (* factory->loader_entries[i].load_func) (file_data->filename,
609
 
                                                base_config->stingy_memory_use,
610
 
                                                &error);
611
 
 
612
 
    if (! data_list)
 
666
    GList    *cached_data;
 
667
    gboolean  load_from_disk = TRUE;
 
668
 
 
669
    if (cache &&
 
670
        (cached_data = g_hash_table_lookup (cache, file_data->filename)))
613
671
      {
614
 
        g_message (_("Warning: Failed to load data:\n\n%s"),
615
 
                   error->message);
616
 
        g_clear_error (&error);
 
672
        GimpData *data = cached_data->data;
 
673
 
 
674
        load_from_disk = (data->mtime == 0 || data->mtime != file_data->mtime);
 
675
 
 
676
        if (! load_from_disk)
 
677
          {
 
678
            GList *list;
 
679
 
 
680
            for (list = cached_data; list; list = g_list_next (list))
 
681
              gimp_container_add (factory->container, GIMP_OBJECT (list->data));
 
682
          }
617
683
      }
618
 
    else
 
684
 
 
685
    if (load_from_disk)
619
686
      {
620
 
        GList    *writable_list;
621
 
        GList    *list;
622
 
        gboolean  writable;
623
 
        gboolean  deletable;
624
 
 
625
 
        writable_list = g_object_get_data (G_OBJECT (factory),
626
 
                                           WRITABLE_PATH_KEY);
627
 
 
628
 
        deletable = (g_list_length (data_list) == 1 &&
629
 
                     g_list_find_custom (writable_list, file_data->dirname,
630
 
                                         (GCompareFunc) strcmp) != NULL);
631
 
 
632
 
        writable = (deletable && factory->loader_entries[i].writable);
633
 
 
634
 
        for (list = data_list; list; list = g_list_next (list))
635
 
          {
636
 
            GimpData *data = list->data;
637
 
 
638
 
            gimp_data_set_filename (data, file_data->filename,
639
 
                                    writable, deletable);
640
 
            data->dirty = FALSE;
641
 
 
642
 
            gimp_container_add (factory->container, GIMP_OBJECT (data));
643
 
            g_object_unref (data);
644
 
          }
645
 
 
646
 
        g_list_free (data_list);
 
687
        GList  *data_list;
 
688
        GError *error = NULL;
 
689
 
 
690
        data_list = factory->loader_entries[i].load_func (file_data->filename,
 
691
                                                          &error);
 
692
 
 
693
        if (G_LIKELY (data_list))
 
694
          {
 
695
            GList    *writable_list;
 
696
            GList    *list;
 
697
            gboolean  writable;
 
698
            gboolean  deletable;
 
699
 
 
700
            writable_list = g_object_get_data (G_OBJECT (factory),
 
701
                                               WRITABLE_PATH_KEY);
 
702
 
 
703
            deletable = (g_list_length (data_list) == 1 &&
 
704
                         g_list_find_custom (writable_list, file_data->dirname,
 
705
                                             (GCompareFunc) strcmp) != NULL);
 
706
 
 
707
            writable = (deletable && factory->loader_entries[i].writable);
 
708
 
 
709
            for (list = data_list; list; list = g_list_next (list))
 
710
              {
 
711
                GimpData *data = list->data;
 
712
 
 
713
                gimp_data_set_filename (data, file_data->filename,
 
714
                                        writable, deletable);
 
715
                data->mtime = file_data->mtime;
 
716
                data->dirty = FALSE;
 
717
 
 
718
                gimp_container_add (factory->container, GIMP_OBJECT (data));
 
719
                g_object_unref (data);
 
720
              }
 
721
 
 
722
            g_list_free (data_list);
 
723
          }
 
724
        else
 
725
          {
 
726
            gimp_message (factory->gimp, NULL, GIMP_MESSAGE_ERROR,
 
727
                          _("Failed to load data:\n\n%s"), error->message);
 
728
            g_clear_error (&error);
 
729
          }
647
730
      }
648
731
  }
649
732
}