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

« back to all changes in this revision

Viewing changes to app/core/gimp.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-2002 Spencer Kimball, Peter Mattis, and others
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
23
23
#include <glib-object.h>
24
24
 
25
25
#include "libgimpbase/gimpbase.h"
 
26
#include "libgimpconfig/gimpconfig.h"
26
27
 
27
28
#include "core-types.h"
28
29
 
29
 
#include "config/gimpconfig.h"
30
 
#include "config/gimpconfig-params.h"
31
 
#include "config/gimpconfig-path.h"
32
30
#include "config/gimprc.h"
33
31
 
34
 
#include "pdb/procedural_db.h"
 
32
#include "pdb/gimppdb.h"
 
33
#include "pdb/gimp-pdb-compat.h"
 
34
#include "pdb/internal_procs.h"
35
35
 
36
 
#include "plug-in/plug-ins.h"
 
36
#include "plug-in/gimppluginmanager.h"
 
37
#include "plug-in/gimppluginmanager-restore.h"
37
38
 
38
39
#include "paint/gimp-paint.h"
39
40
 
42
43
#include "xcf/xcf.h"
43
44
 
44
45
#include "gimp.h"
 
46
#include "gimp-contexts.h"
45
47
#include "gimp-documents.h"
46
48
#include "gimp-gradients.h"
47
49
#include "gimp-modules.h"
50
52
#include "gimp-units.h"
51
53
#include "gimp-utils.h"
52
54
#include "gimpbrush.h"
53
 
#include "gimpbrushgenerated.h"
54
 
#include "gimpbrushpipe.h"
 
55
#include "gimpbrush-load.h"
 
56
#include "gimpbrushgenerated-load.h"
 
57
#include "gimpbrushclipboard.h"
 
58
#include "gimpbrushpipe-load.h"
55
59
#include "gimpbuffer.h"
56
60
#include "gimpcontext.h"
57
61
#include "gimpdatafactory.h"
58
62
#include "gimpdocumentlist.h"
59
 
#include "gimpenvirontable.h"
60
63
#include "gimpgradient.h"
61
64
#include "gimpgradient-load.h"
62
65
#include "gimpimage.h"
64
67
#include "gimplist.h"
65
68
#include "gimpmarshal.h"
66
69
#include "gimppalette.h"
 
70
#include "gimppalette-load.h"
67
71
#include "gimppattern.h"
 
72
#include "gimppattern-load.h"
 
73
#include "gimppatternclipboard.h"
68
74
#include "gimpparasitelist.h"
 
75
#include "gimpprogress.h"
69
76
#include "gimptemplate.h"
70
77
#include "gimptoolinfo.h"
71
78
 
78
85
  RESTORE,
79
86
  EXIT,
80
87
  BUFFER_CHANGED,
81
 
  LAST_PLUG_IN_CHANGED,
82
88
  LAST_SIGNAL
83
89
};
84
90
 
85
91
 
86
 
static void       gimp_class_init           (GimpClass         *klass);
87
 
static void       gimp_init                 (Gimp              *gimp);
88
 
 
89
 
static void       gimp_dispose              (GObject           *object);
90
 
static void       gimp_finalize             (GObject           *object);
91
 
 
92
 
static gint64     gimp_get_memsize          (GimpObject        *object,
93
 
                                             gint64            *gui_size);
94
 
 
95
 
static void       gimp_real_initialize      (Gimp              *gimp,
96
 
                                             GimpInitStatusFunc status_callback);
97
 
static void       gimp_real_restore         (Gimp              *gimp,
98
 
                                             GimpInitStatusFunc status_callback);
99
 
static gboolean   gimp_real_exit            (Gimp              *gimp,
100
 
                                             gboolean           force);
101
 
 
102
 
static void       gimp_global_config_notify (GObject           *global_config,
103
 
                                             GParamSpec        *param_spec,
104
 
                                             GObject           *edit_config);
105
 
static void       gimp_edit_config_notify   (GObject           *edit_config,
106
 
                                             GParamSpec        *param_spec,
107
 
                                             GObject           *global_config);
108
 
 
109
 
 
110
 
static GimpObjectClass *parent_class = NULL;
 
92
static void      gimp_dispose              (GObject           *object);
 
93
static void      gimp_finalize             (GObject           *object);
 
94
 
 
95
static gint64    gimp_get_memsize          (GimpObject        *object,
 
96
                                            gint64            *gui_size);
 
97
 
 
98
static void      gimp_real_initialize      (Gimp              *gimp,
 
99
                                            GimpInitStatusFunc status_callback);
 
100
static void      gimp_real_restore         (Gimp              *gimp,
 
101
                                            GimpInitStatusFunc status_callback);
 
102
static gboolean  gimp_real_exit            (Gimp              *gimp,
 
103
                                            gboolean           force);
 
104
 
 
105
static void      gimp_global_config_notify (GObject           *global_config,
 
106
                                            GParamSpec        *param_spec,
 
107
                                            GObject           *edit_config);
 
108
static void      gimp_edit_config_notify   (GObject           *edit_config,
 
109
                                            GParamSpec        *param_spec,
 
110
                                            GObject           *global_config);
 
111
 
 
112
 
 
113
G_DEFINE_TYPE (Gimp, gimp, GIMP_TYPE_OBJECT)
 
114
 
 
115
#define parent_class gimp_parent_class
111
116
 
112
117
static guint gimp_signals[LAST_SIGNAL] = { 0, };
113
118
 
114
119
 
115
 
GType
116
 
gimp_get_type (void)
117
 
{
118
 
  static GType object_type = 0;
119
 
 
120
 
  if (! object_type)
121
 
    {
122
 
      static const GTypeInfo object_info =
123
 
      {
124
 
        sizeof (GimpClass),
125
 
        (GBaseInitFunc) NULL,
126
 
        (GBaseFinalizeFunc) NULL,
127
 
        (GClassInitFunc) gimp_class_init,
128
 
        NULL,                /* class_finalize */
129
 
        NULL,                /* class_data     */
130
 
        sizeof (Gimp),
131
 
        0,              /* n_preallocs    */
132
 
        (GInstanceInitFunc) gimp_init,
133
 
      };
134
 
 
135
 
      object_type = g_type_register_static (GIMP_TYPE_OBJECT,
136
 
                                            "Gimp",
137
 
                                            &object_info, 0);
138
 
    }
139
 
 
140
 
  return object_type;
141
 
}
142
 
 
143
120
static void
144
121
gimp_class_init (GimpClass *klass)
145
122
{
146
123
  GObjectClass    *object_class      = G_OBJECT_CLASS (klass);
147
124
  GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
148
125
 
149
 
  parent_class = g_type_class_peek_parent (klass);
150
 
 
151
126
  gimp_signals[INITIALIZE] =
152
127
    g_signal_new ("initialize",
153
128
                  G_TYPE_FROM_CLASS (klass),
173
148
                  G_TYPE_FROM_CLASS (klass),
174
149
                  G_SIGNAL_RUN_LAST,
175
150
                  G_STRUCT_OFFSET (GimpClass, exit),
176
 
                  gimp_boolean_handled_accum, NULL,
 
151
                  g_signal_accumulator_true_handled, NULL,
177
152
                  gimp_marshal_BOOLEAN__BOOLEAN,
178
153
                  G_TYPE_BOOLEAN, 1,
179
154
                  G_TYPE_BOOLEAN);
187
162
                  gimp_marshal_VOID__VOID,
188
163
                  G_TYPE_NONE, 0);
189
164
 
190
 
  gimp_signals[LAST_PLUG_IN_CHANGED] =
191
 
    g_signal_new ("last-plug-in-changed",
192
 
                  G_TYPE_FROM_CLASS (klass),
193
 
                  G_SIGNAL_RUN_LAST,
194
 
                  G_STRUCT_OFFSET (GimpClass, last_plug_in_changed),
195
 
                  NULL, NULL,
196
 
                  gimp_marshal_VOID__VOID,
197
 
                  G_TYPE_NONE, 0);
198
 
 
199
165
  object_class->dispose          = gimp_dispose;
200
166
  object_class->finalize         = gimp_finalize;
201
167
 
232
198
 
233
199
  gimp_modules_init (gimp);
234
200
 
235
 
  gimp->environ_table       = gimp_environ_table_new ();
236
 
 
237
 
  gimp->plug_in_debug       = NULL;
 
201
  gimp->plug_in_manager     = gimp_plug_in_manager_new (gimp);
238
202
 
239
203
  gimp->images              = gimp_list_new_weak (GIMP_TYPE_IMAGE, FALSE);
240
 
  gimp_object_set_name (GIMP_OBJECT (gimp->images), "images");
 
204
  gimp_object_set_static_name (GIMP_OBJECT (gimp->images), "images");
241
205
 
242
 
  gimp->next_image_ID       = 1;
243
 
  gimp->next_guide_ID       = 1;
244
 
  gimp->image_table         = g_hash_table_new (g_direct_hash, NULL);
 
206
  gimp->next_image_ID        = 1;
 
207
  gimp->next_guide_ID        = 1;
 
208
  gimp->next_sample_point_ID = 1;
 
209
  gimp->image_table          = g_hash_table_new (g_direct_hash, NULL);
245
210
 
246
211
  gimp->next_item_ID        = 1;
247
212
  gimp->item_table          = g_hash_table_new (g_direct_hash, NULL);
248
213
 
249
214
  gimp->displays            = gimp_list_new_weak (GIMP_TYPE_OBJECT, FALSE);
250
 
  gimp_object_set_name (GIMP_OBJECT (gimp->displays), "displays");
 
215
  gimp_object_set_static_name (GIMP_OBJECT (gimp->displays), "displays");
251
216
 
252
217
  gimp->next_display_ID     = 1;
253
218
 
254
219
  gimp->global_buffer       = NULL;
255
220
  gimp->named_buffers       = gimp_list_new (GIMP_TYPE_BUFFER, TRUE);
256
 
  gimp_object_set_name (GIMP_OBJECT (gimp->named_buffers), "named buffers");
 
221
  gimp_object_set_static_name (GIMP_OBJECT (gimp->named_buffers),
 
222
                               "named buffers");
257
223
 
258
224
  gimp->fonts               = NULL;
259
225
  gimp->brush_factory       = NULL;
261
227
  gimp->gradient_factory    = NULL;
262
228
  gimp->palette_factory     = NULL;
263
229
 
264
 
  procedural_db_init (gimp);
265
 
 
266
 
  gimp->load_procs          = NULL;
267
 
  gimp->save_procs          = NULL;
 
230
  gimp->pdb                 = gimp_pdb_new (gimp);
268
231
 
269
232
  xcf_init (gimp);
270
233
 
271
234
  gimp->tool_info_list      = gimp_list_new (GIMP_TYPE_TOOL_INFO, FALSE);
272
 
  gimp_object_set_name (GIMP_OBJECT (gimp->tool_info_list), "tool infos");
 
235
  gimp_object_set_static_name (GIMP_OBJECT (gimp->tool_info_list),
 
236
                               "tool infos");
273
237
 
274
238
  gimp->standard_tool_info  = NULL;
275
239
 
276
240
  gimp->documents           = gimp_document_list_new (gimp);
277
241
 
278
242
  gimp->templates           = gimp_list_new (GIMP_TYPE_TEMPLATE, TRUE);
279
 
  gimp_object_set_name (GIMP_OBJECT (gimp->tool_info_list), "templates");
 
243
  gimp_object_set_static_name (GIMP_OBJECT (gimp->templates), "templates");
280
244
 
281
245
  gimp->image_new_last_template = NULL;
282
 
  gimp->have_current_cut_buffer = FALSE;
283
246
 
284
247
  gimp->context_list        = NULL;
285
248
  gimp->default_context     = NULL;
317
280
  if (gimp->be_verbose)
318
281
    g_print ("EXIT: gimp_finalize\n");
319
282
 
320
 
  gimp_set_user_context (gimp, NULL);
321
 
  gimp_set_default_context (gimp, NULL);
 
283
  gimp_contexts_exit (gimp);
322
284
 
323
285
  if (gimp->image_new_last_template)
324
286
    {
348
310
 
349
311
  xcf_exit (gimp);
350
312
 
351
 
  procedural_db_free (gimp);
352
 
 
353
 
  if (gimp->load_procs)
354
 
    {
355
 
      g_slist_free (gimp->load_procs);
356
 
      gimp->load_procs = NULL;
357
 
    }
358
 
 
359
 
  if (gimp->save_procs)
360
 
    {
361
 
      g_slist_free (gimp->save_procs);
362
 
      gimp->save_procs = NULL;
 
313
  if (gimp->pdb)
 
314
    {
 
315
      g_object_unref (gimp->pdb);
 
316
      gimp->pdb = NULL;
363
317
    }
364
318
 
365
319
  if (gimp->brush_factory)
428
382
      gimp->images = NULL;
429
383
    }
430
384
 
431
 
  if (gimp->environ_table)
 
385
  if (gimp->plug_in_manager)
432
386
    {
433
 
      g_object_unref (gimp->environ_table);
434
 
      gimp->environ_table = NULL;
 
387
      g_object_unref (gimp->plug_in_manager);
 
388
      gimp->plug_in_manager = NULL;
435
389
    }
436
390
 
437
391
  if (gimp->module_db)
457
411
      gimp->session_name = NULL;
458
412
    }
459
413
 
460
 
  if (gimp->user_units)
461
 
    gimp_units_exit (gimp);
 
414
  gimp_units_exit (gimp);
462
415
 
463
416
  G_OBJECT_CLASS (parent_class)->finalize (object);
464
417
}
475
428
  memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->parasites),
476
429
                                      gui_size);
477
430
 
 
431
  memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->paint_info_list),
 
432
                                      gui_size);
 
433
 
478
434
  memsize += gimp_g_object_get_memsize (G_OBJECT (gimp->module_db));
 
435
  memsize += gimp_g_object_get_memsize (G_OBJECT (gimp->plug_in_manager));
479
436
 
480
 
  memsize += gimp_g_hash_table_get_memsize (gimp->image_table);
481
 
  memsize += gimp_g_hash_table_get_memsize (gimp->item_table);
 
437
  memsize += gimp_g_hash_table_get_memsize (gimp->image_table, 0);
 
438
  memsize += gimp_g_hash_table_get_memsize (gimp->item_table,  0);
482
439
 
483
440
  memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->displays), gui_size);
484
441
 
499
456
              gimp_object_get_memsize (GIMP_OBJECT (gimp->palette_factory),
500
457
                                       gui_size));
501
458
 
502
 
  memsize += gimp_g_hash_table_get_memsize (gimp->procedural_ht);
503
 
  memsize += gimp_g_hash_table_get_memsize (gimp->procedural_compat_ht);
504
 
 
505
 
  memsize += gimp_g_list_get_memsize (gimp->procedural_db_data_list,
506
 
                                      0 /* FIXME */);
507
 
 
508
 
  memsize += gimp_g_slist_get_memsize (gimp->load_procs, 0 /* FIXME */);
509
 
  memsize += gimp_g_slist_get_memsize (gimp->save_procs, 0 /* FIXME */);
 
459
  memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->pdb), gui_size);
510
460
 
511
461
  memsize += (gimp_object_get_memsize (GIMP_OBJECT (gimp->tool_info_list),
512
462
                                       gui_size) +
534
484
gimp_real_initialize (Gimp               *gimp,
535
485
                      GimpInitStatusFunc  status_callback)
536
486
{
537
 
  GimpContext *context;
538
 
  gchar       *path;
539
 
 
540
487
  static const GimpDataFactoryLoaderEntry brush_loader_entries[] =
541
488
  {
542
489
    { gimp_brush_load,           GIMP_BRUSH_FILE_EXTENSION,           FALSE },
543
490
    { gimp_brush_load,           GIMP_BRUSH_PIXMAP_FILE_EXTENSION,    FALSE },
 
491
    { gimp_brush_load_abr,       GIMP_BRUSH_PS_FILE_EXTENSION,        FALSE },
 
492
    { gimp_brush_load_abr,       GIMP_BRUSH_PSP_FILE_EXTENSION,       FALSE },
544
493
    { gimp_brush_generated_load, GIMP_BRUSH_GENERATED_FILE_EXTENSION, TRUE  },
545
494
    { gimp_brush_pipe_load,      GIMP_BRUSH_PIPE_FILE_EXTENSION,      FALSE }
546
495
  };
564
513
    { gimp_palette_load,         NULL /* legacy loader */,            TRUE  }
565
514
  };
566
515
 
 
516
  GimpData *clipboard_brush;
 
517
  GimpData *clipboard_pattern;
 
518
 
567
519
  if (gimp->be_verbose)
568
520
    g_print ("INIT: gimp_real_initialize\n");
569
521
 
 
522
  status_callback (_("Initialization"), NULL, 0.0);
 
523
 
570
524
  gimp_fonts_init (gimp);
571
525
 
572
526
  gimp->brush_factory =
577
531
                           G_N_ELEMENTS (brush_loader_entries),
578
532
                           gimp_brush_new,
579
533
                           gimp_brush_get_standard);
580
 
  gimp_object_set_name (GIMP_OBJECT (gimp->brush_factory), "brush factory");
 
534
  gimp_object_set_static_name (GIMP_OBJECT (gimp->brush_factory),
 
535
                               "brush factory");
581
536
 
582
537
  gimp->pattern_factory =
583
538
    gimp_data_factory_new (gimp,
587
542
                           G_N_ELEMENTS (pattern_loader_entries),
588
543
                           NULL,
589
544
                           gimp_pattern_get_standard);
590
 
  gimp_object_set_name (GIMP_OBJECT (gimp->pattern_factory), "pattern factory");
 
545
  gimp_object_set_static_name (GIMP_OBJECT (gimp->pattern_factory),
 
546
                               "pattern factory");
591
547
 
592
548
  gimp->gradient_factory =
593
549
    gimp_data_factory_new (gimp,
597
553
                           G_N_ELEMENTS (gradient_loader_entries),
598
554
                           gimp_gradient_new,
599
555
                           gimp_gradient_get_standard);
600
 
  gimp_object_set_name (GIMP_OBJECT (gimp->gradient_factory), "gradient factory");
 
556
  gimp_object_set_static_name (GIMP_OBJECT (gimp->gradient_factory),
 
557
                               "gradient factory");
601
558
 
602
559
  gimp->palette_factory =
603
560
    gimp_data_factory_new (gimp,
607
564
                           G_N_ELEMENTS (palette_loader_entries),
608
565
                           gimp_palette_new,
609
566
                           gimp_palette_get_standard);
610
 
  gimp_object_set_name (GIMP_OBJECT (gimp->palette_factory), "palette factory");
 
567
  gimp_object_set_static_name (GIMP_OBJECT (gimp->palette_factory),
 
568
                               "palette factory");
611
569
 
612
570
  gimp_paint_init (gimp);
613
571
 
615
573
  gimp->image_new_last_template =
616
574
    gimp_config_duplicate (GIMP_CONFIG (gimp->config->default_image));
617
575
 
618
 
  gimp->have_current_cut_buffer = FALSE;
619
 
 
620
 
  /*  the default context contains the user's saved preferences
621
 
   *
622
 
   *  TODO: load from disk
623
 
   */
624
 
  context = gimp_context_new (gimp, "Default", NULL);
625
 
  gimp_set_default_context (gimp, context);
626
 
  g_object_unref (context);
627
 
 
628
 
  /*  the initial user_context is a straight copy of the default context
629
 
   */
630
 
  context = gimp_context_new (gimp, "User", context);
631
 
  gimp_set_user_context (gimp, context);
632
 
  g_object_unref (context);
 
576
  /*  create user and default context  */
 
577
  gimp_contexts_init (gimp);
633
578
 
634
579
  /*  add the builtin FG -> BG etc. gradients  */
635
580
  gimp_gradients_init (gimp);
636
581
 
 
582
  /*  add the clipboard brush  */
 
583
  clipboard_brush = gimp_brush_clipboard_new (gimp);
 
584
  gimp_data_make_internal (GIMP_DATA (clipboard_brush));
 
585
  gimp_container_add (gimp->brush_factory->container,
 
586
                      GIMP_OBJECT (clipboard_brush));
 
587
  g_object_unref (clipboard_brush);
 
588
 
 
589
  /*  add the clipboard pattern  */
 
590
  clipboard_pattern = gimp_pattern_clipboard_new (gimp);
 
591
  gimp_data_make_internal (GIMP_DATA (clipboard_pattern));
 
592
  gimp_container_add (gimp->pattern_factory->container,
 
593
                      GIMP_OBJECT (clipboard_pattern));
 
594
  g_object_unref (clipboard_pattern);
 
595
 
637
596
  /*  register all internal procedures  */
638
 
  (* status_callback) (_("Procedural Database"), NULL, -1);
639
 
  procedural_db_init_procs (gimp, status_callback);
640
 
 
641
 
  (* status_callback) (_("Plug-In Environment"), "", -1);
642
 
 
643
 
  path = gimp_config_path_expand (gimp->config->environ_path, TRUE, NULL);
644
 
  gimp_environ_table_load (gimp->environ_table, path);
645
 
  g_free (path);
 
597
  status_callback (NULL, _("Internal Procedures"), 0.2);
 
598
  internal_procs_init (gimp->pdb);
 
599
  gimp_pdb_compat_procs_register (gimp->pdb, gimp->pdb_compat_mode);
 
600
 
 
601
  gimp_plug_in_manager_initialize (gimp->plug_in_manager, status_callback);
 
602
 
 
603
  status_callback (NULL, "", 1.0);
646
604
}
647
605
 
648
606
static void
652
610
  if (gimp->be_verbose)
653
611
    g_print ("INIT: gimp_real_restore\n");
654
612
 
655
 
  plug_ins_init (gimp, gimp_get_user_context (gimp), status_callback);
 
613
  gimp_plug_in_manager_restore (gimp->plug_in_manager,
 
614
                                gimp_get_user_context (gimp), status_callback);
656
615
}
657
616
 
658
617
static gboolean
662
621
  if (gimp->be_verbose)
663
622
    g_print ("EXIT: gimp_real_exit\n");
664
623
 
665
 
  plug_ins_exit (gimp);
 
624
  gimp_plug_in_manager_exit (gimp->plug_in_manager);
666
625
  gimp_modules_unload (gimp);
667
626
 
668
627
  gimp_data_factory_data_save (gimp->brush_factory);
671
630
  gimp_data_factory_data_save (gimp->palette_factory);
672
631
 
673
632
  gimp_fonts_reset (gimp);
674
 
  gimp_documents_save (gimp);
 
633
 
 
634
  if (gimp->config->save_document_history)
 
635
    gimp_documents_save (gimp);
 
636
 
675
637
  gimp_templates_save (gimp);
676
638
  gimp_parasiterc_save (gimp);
677
639
  gimp_unitrc_save (gimp);
696
658
  g_return_val_if_fail (name != NULL, NULL);
697
659
 
698
660
  gimp = g_object_new (GIMP_TYPE_GIMP,
699
 
                       "name",    name,
 
661
                       "name", name,
700
662
                       NULL);
701
663
 
702
664
  gimp->session_name     = g_strdup (session_name);
759
721
 
760
722
  if (g_param_values_cmp (param_spec, &edit_value, &global_value))
761
723
    {
762
 
      if (param_spec->flags & GIMP_PARAM_RESTART)
 
724
      if (param_spec->flags & GIMP_CONFIG_PARAM_RESTART)
763
725
        {
764
726
#ifdef GIMP_CONFIG_DEBUG
765
727
          g_print ("NOT Applying edit_config change of '%s' to global_config "
849
811
    g_print ("INIT: gimp_restore\n");
850
812
 
851
813
  /*  initialize  the global parasite table  */
852
 
  (* status_callback) (_("Looking for data files"), _("Parasites"), 0.0);
 
814
  status_callback (_("Looking for data files"), _("Parasites"), 0.0);
853
815
  gimp_parasiterc_load (gimp);
854
816
 
855
817
  /*  initialize the list of gimp brushes    */
856
 
  (* status_callback) (NULL, _("Brushes"), 0.1);
 
818
  status_callback (NULL, _("Brushes"), 0.1);
857
819
  gimp_data_factory_data_init (gimp->brush_factory, gimp->no_data);
858
820
 
859
821
  /*  initialize the list of gimp patterns   */
860
 
  (* status_callback) (NULL, _("Patterns"), 0.2);
 
822
  status_callback (NULL, _("Patterns"), 0.2);
861
823
  gimp_data_factory_data_init (gimp->pattern_factory, gimp->no_data);
862
824
 
863
825
  /*  initialize the list of gimp palettes   */
864
 
  (* status_callback) (NULL, _("Palettes"), 0.3);
 
826
  status_callback (NULL, _("Palettes"), 0.3);
865
827
  gimp_data_factory_data_init (gimp->palette_factory, gimp->no_data);
866
828
 
867
829
  /*  initialize the list of gimp gradients  */
868
 
  (* status_callback) (NULL, _("Gradients"), 0.4);
 
830
  status_callback (NULL, _("Gradients"), 0.4);
869
831
  gimp_data_factory_data_init (gimp->gradient_factory, gimp->no_data);
870
832
 
871
833
  /*  initialize the list of gimp fonts  */
872
 
  (* status_callback) (NULL, _("Fonts"), 0.5);
873
 
  gimp_fonts_load (gimp);
 
834
  status_callback (NULL, _("Fonts"), 0.5);
 
835
  if (! gimp->no_fonts)
 
836
    gimp_fonts_load (gimp);
874
837
 
875
838
  /*  initialize the document history  */
876
 
  (* status_callback) (NULL, _("Documents"), 0.6);
 
839
  status_callback (NULL, _("Documents"), 0.6);
877
840
  gimp_documents_load (gimp);
878
841
 
879
842
  /*  initialize the template list  */
880
 
  (* status_callback) (NULL, _("Templates"), 0.7);
 
843
  status_callback (NULL, _("Templates"), 0.7);
881
844
  gimp_templates_load (gimp);
882
845
 
883
846
  /*  initialize the module list  */
884
 
  (* status_callback) (NULL, _("Modules"), 0.8);
 
847
  status_callback (NULL, _("Modules"), 0.8);
885
848
  gimp_modules_load (gimp);
886
849
 
887
850
  g_signal_emit (gimp, gimp_signals[RESTORE], 0, status_callback);
929
892
  if (gimp->global_buffer)
930
893
    g_object_ref (gimp->global_buffer);
931
894
 
932
 
  gimp->have_current_cut_buffer = (buffer != NULL);
933
 
 
934
895
  g_signal_emit (gimp, gimp_signals[BUFFER_CHANGED], 0);
935
896
}
936
897
 
937
 
void
938
 
gimp_set_last_plug_in (Gimp          *gimp,
939
 
                       PlugInProcDef *proc_def)
940
 
{
941
 
  g_return_if_fail (GIMP_IS_GIMP (gimp));
942
 
 
943
 
  gimp->last_plug_in = proc_def;
944
 
 
945
 
  g_signal_emit (gimp, gimp_signals[LAST_PLUG_IN_CHANGED], 0);
946
 
}
947
 
 
948
898
GimpImage *
949
899
gimp_create_image (Gimp              *gimp,
950
900
                   gint               width,
952
902
                   GimpImageBaseType  type,
953
903
                   gboolean           attach_comment)
954
904
{
955
 
  GimpImage *gimage;
 
905
  GimpImage *image;
956
906
 
957
907
  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
958
908
 
959
 
  gimage = gimp_image_new (gimp, width, height, type);
960
 
 
961
 
  gimp_container_add (gimp->images, GIMP_OBJECT (gimage));
 
909
  image = gimp_image_new (gimp, width, height, type);
962
910
 
963
911
  if (attach_comment)
964
912
    {
970
918
                                                      GIMP_PARASITE_PERSISTENT,
971
919
                                                      strlen (comment) + 1,
972
920
                                                      comment);
973
 
          gimp_image_parasite_attach (gimage, parasite);
 
921
          gimp_image_parasite_attach (image, parasite);
974
922
          gimp_parasite_free (parasite);
975
923
        }
976
924
    }
977
925
 
978
 
  return gimage;
 
926
  return image;
979
927
}
980
928
 
981
929
void
983
931
                          GimpContext *context)
984
932
{
985
933
  g_return_if_fail (GIMP_IS_GIMP (gimp));
986
 
  g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
987
 
 
988
 
  if (gimp->default_context)
989
 
    g_object_unref (gimp->default_context);
990
 
 
991
 
  gimp->default_context = context;
992
 
 
993
 
  if (gimp->default_context)
994
 
    g_object_ref (gimp->default_context);
 
934
  g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));
 
935
 
 
936
  if (context != gimp->default_context)
 
937
    {
 
938
      if (gimp->default_context)
 
939
        g_object_unref (gimp->default_context);
 
940
 
 
941
      gimp->default_context = context;
 
942
 
 
943
      if (gimp->default_context)
 
944
        g_object_ref (gimp->default_context);
 
945
    }
995
946
}
996
947
 
997
948
GimpContext *
1007
958
                       GimpContext *context)
1008
959
{
1009
960
  g_return_if_fail (GIMP_IS_GIMP (gimp));
1010
 
  g_return_if_fail (! context || GIMP_IS_CONTEXT (context));
1011
 
 
1012
 
  if (gimp->user_context)
1013
 
    g_object_unref (gimp->user_context);
1014
 
 
1015
 
  gimp->user_context = context;
1016
 
 
1017
 
  if (gimp->user_context)
1018
 
    g_object_ref (gimp->user_context);
 
961
  g_return_if_fail (context == NULL || GIMP_IS_CONTEXT (context));
 
962
 
 
963
  if (context != gimp->user_context)
 
964
    {
 
965
      if (gimp->user_context)
 
966
        g_object_unref (gimp->user_context);
 
967
 
 
968
      gimp->user_context = context;
 
969
 
 
970
      if (gimp->user_context)
 
971
        g_object_ref (gimp->user_context);
 
972
    }
1019
973
}
1020
974
 
1021
975
GimpContext *
1025
979
 
1026
980
  return gimp->user_context;
1027
981
}
 
982
 
 
983
GimpToolInfo *
 
984
gimp_get_tool_info (Gimp        *gimp,
 
985
                    const gchar *tool_id)
 
986
{
 
987
  gpointer info;
 
988
 
 
989
  g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
 
990
  g_return_val_if_fail (tool_id != NULL, NULL);
 
991
 
 
992
  info = gimp_container_get_child_by_name (gimp->tool_info_list, tool_id);
 
993
 
 
994
  return (GimpToolInfo *) info;
 
995
}
 
996
 
 
997
void
 
998
gimp_message (Gimp                *gimp,
 
999
              GObject             *handler,
 
1000
              GimpMessageSeverity  severity,
 
1001
              const gchar         *format,
 
1002
              ...)
 
1003
{
 
1004
  va_list args;
 
1005
 
 
1006
  va_start (args, format);
 
1007
 
 
1008
  gimp_message_valist (gimp, handler, severity, format, args);
 
1009
 
 
1010
  va_end (args);
 
1011
}
 
1012
 
 
1013
void
 
1014
gimp_message_valist (Gimp                *gimp,
 
1015
                     GObject             *handler,
 
1016
                     GimpMessageSeverity  severity,
 
1017
                     const gchar         *format,
 
1018
                     va_list              args)
 
1019
{
 
1020
  gchar *message;
 
1021
 
 
1022
  g_return_if_fail (GIMP_IS_GIMP (gimp));
 
1023
  g_return_if_fail (handler == NULL || G_IS_OBJECT (handler));
 
1024
  g_return_if_fail (format != NULL);
 
1025
 
 
1026
  message = g_strdup_vprintf (format, args);
 
1027
 
 
1028
  gimp_show_message (gimp, handler, severity, NULL, message);
 
1029
 
 
1030
  g_free (message);
 
1031
}