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

« back to all changes in this revision

Viewing changes to app/config/gimpconfig-dump.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
 * GimpConfig object property dumper.
5
 
 * Copyright (C) 2001-2003  Sven Neumann <sven@gimp.org>
 
5
 * Copyright (C) 2001-2006  Sven Neumann <sven@gimp.org>
6
6
 *
7
7
 * This program is free software; you can redistribute it and/or modify
8
8
 * it under the terms of the GNU General Public License as published by
21
21
 
22
22
#include "config.h"
23
23
 
24
 
#include "stdlib.h"
25
 
#include "string.h"
 
24
#include <stdlib.h>
 
25
#include <string.h>
 
26
 
26
27
#ifdef HAVE_UNISTD_H
27
28
#include <unistd.h>
28
29
#endif
31
32
 
32
33
#include "libgimpbase/gimpbase.h"
33
34
#include "libgimpcolor/gimpcolor.h"
 
35
#include "libgimpconfig/gimpconfig.h"
34
36
 
35
37
#ifdef G_OS_WIN32
36
38
#include "libgimpbase/gimpwin32-io.h"
38
40
 
39
41
#include "config-types.h"
40
42
 
41
 
#include "gimpconfig.h"
42
43
#include "gimpconfig-dump.h"
43
 
#include "gimpconfig-params.h"
44
 
#include "gimpconfig-serialize.h"
45
 
#include "gimpconfig-types.h"
46
 
#include "gimpconfigwriter.h"
47
44
#include "gimprc.h"
48
45
 
49
46
 
50
47
 
51
48
static void    dump_gimprc_system   (GimpConfig       *rc,
52
 
                                     GimpConfigWriter *writer,
 
49
                                     GimpConfigWriter *writer,
53
50
                                     gint              fd);
54
51
static void    dump_gimprc_manpage  (GimpConfig       *rc,
55
 
                                     GimpConfigWriter *writer,
 
52
                                     GimpConfigWriter *writer,
56
53
                                     gint              fd);
57
54
static gchar * dump_describe_param  (GParamSpec       *param_spec);
58
55
static void    dump_with_linebreaks (gint              fd,
59
 
                                     const gchar      *text);
 
56
                                     const gchar      *text);
60
57
 
61
58
 
62
59
gboolean
75
72
 
76
73
    case GIMP_CONFIG_DUMP_GIMPRC:
77
74
      gimp_config_writer_comment (writer,
78
 
                                  "Dump of the GIMP default configuration");
 
75
                                  "Dump of the GIMP default configuration");
79
76
      gimp_config_writer_linefeed (writer);
80
77
      gimp_config_serialize_properties (rc, writer);
81
78
      gimp_config_writer_linefeed (writer);
97
94
}
98
95
 
99
96
 
100
 
static const gchar *system_gimprc_header =
 
97
static const gchar system_gimprc_header[] =
101
98
"This is the system-wide gimprc file.  Any change made in this file "
102
99
"will affect all users of this system, provided that they are not "
103
100
"overriding the default values in their personal gimprc file.\n"
114
111
 
115
112
static void
116
113
dump_gimprc_system (GimpConfig       *rc,
117
 
                    GimpConfigWriter *writer,
 
114
                    GimpConfigWriter *writer,
118
115
                    gint              fd)
119
116
{
120
117
  GObjectClass  *klass;
133
130
      GParamSpec *prop_spec = property_specs[i];
134
131
      gchar      *comment;
135
132
 
136
 
      if (! (prop_spec->flags & GIMP_PARAM_SERIALIZE))
 
133
      if (! (prop_spec->flags & GIMP_CONFIG_PARAM_SERIALIZE))
137
134
        continue;
138
135
 
139
 
      if (prop_spec->flags & GIMP_PARAM_IGNORE)
 
136
      if (prop_spec->flags & GIMP_CONFIG_PARAM_IGNORE)
140
137
        continue;
141
138
 
142
139
      comment = dump_describe_param (prop_spec);
143
140
      if (comment)
144
 
        {
145
 
          gimp_config_writer_comment (writer, comment);
146
 
          g_free (comment);
147
 
        }
 
141
        {
 
142
          gimp_config_writer_comment (writer, comment);
 
143
          g_free (comment);
 
144
        }
148
145
 
149
146
      gimp_config_writer_comment_mode (writer, TRUE);
150
147
      gimp_config_writer_linefeed (writer);
159
156
}
160
157
 
161
158
 
162
 
static const gchar *man_page_header =
 
159
static const gchar man_page_header[] =
163
160
".\\\" This man-page is auto-generated by gimp --dump-gimprc-manpage.\n"
164
161
"\n"
165
162
".TH GIMPRC 5 \"Version @GIMP_VERSION@\" \"GIMP Manual Pages\"\n"
230
227
"@gimpsysconfdir@.\n"
231
228
"\n";
232
229
 
233
 
static const gchar *man_page_footer =
 
230
static const gchar man_page_footer[] =
234
231
".SH FILES\n"
235
232
".TP\n"
236
233
".I @gimpsysconfdir@/gimprc\n"
247
244
 
248
245
static void
249
246
dump_gimprc_manpage (GimpConfig       *rc,
250
 
                     GimpConfigWriter *writer,
 
247
                     GimpConfigWriter *writer,
251
248
                     gint              fd)
252
249
{
253
250
  GObjectClass  *klass;
265
262
      GParamSpec *prop_spec = property_specs[i];
266
263
      gchar      *desc;
267
264
 
268
 
      if (! (prop_spec->flags & GIMP_PARAM_SERIALIZE))
 
265
      if (! (prop_spec->flags & GIMP_CONFIG_PARAM_SERIALIZE))
269
266
        continue;
270
267
 
271
 
      if (prop_spec->flags & GIMP_PARAM_IGNORE)
 
268
      if (prop_spec->flags & GIMP_CONFIG_PARAM_IGNORE)
272
269
        continue;
273
270
 
274
271
      write (fd, ".TP\n", strlen (".TP\n"));
275
272
 
276
273
      if (gimp_config_serialize_property (rc, prop_spec, writer))
277
 
        {
278
 
          write (fd, "\n", 1);
279
 
 
280
 
          desc = dump_describe_param (prop_spec);
281
 
 
282
 
          dump_with_linebreaks (fd, desc);
283
 
          write (fd, "\n", 1);
284
 
 
285
 
          g_free (desc);
 
274
        {
 
275
          write (fd, "\n", 1);
 
276
 
 
277
          desc = dump_describe_param (prop_spec);
 
278
 
 
279
          dump_with_linebreaks (fd, desc);
 
280
          write (fd, "\n", 1);
 
281
 
 
282
          g_free (desc);
286
283
        }
287
284
    }
288
285
 
293
290
}
294
291
 
295
292
 
296
 
static const gchar * display_format_description =
 
293
static const gchar display_format_description[] =
297
294
"This is a format string; certain % character sequences are recognised and "
298
295
"expanded as follows:\n"
299
296
"\n"
326
323
static gchar *
327
324
dump_describe_param (GParamSpec *param_spec)
328
325
{
329
 
  GType        type;
330
 
  const gchar *blurb;
 
326
  const gchar *blurb  = g_param_spec_get_blurb (param_spec);
331
327
  const gchar *values = NULL;
332
328
 
333
 
  blurb = g_param_spec_get_blurb (param_spec);
334
 
 
335
329
  if (!blurb)
336
330
    {
337
331
      g_warning ("FIXME: Property '%s' has no blurb.", param_spec->name);
338
332
 
339
333
      blurb = g_strdup_printf ("The %s property has no description.",
340
 
                               param_spec->name);
341
 
    }
342
 
 
343
 
  type = param_spec->value_type;
344
 
 
345
 
  if (g_type_is_a (type, GIMP_TYPE_RGB))
346
 
    {
347
 
      values =
348
 
        "The color is specified in the form (color-rgba red green blue alpha) "
349
 
        "with channel values as floats between 0.0 and 1.0.";
350
 
    }
351
 
  else if (g_type_is_a (type, GIMP_TYPE_MEMSIZE))
352
 
    {
353
 
      values =
354
 
        "The integer size can contain a suffix of 'B', 'K', 'M' or 'G' which "
355
 
        "makes GIMP interpret the size as being specified in bytes, kilobytes, "
356
 
        "megabytes or gigabytes. If no suffix is specified the size defaults "
357
 
        "to being specified in kilobytes.";
358
 
    }
359
 
  else if (g_type_is_a (type, GIMP_TYPE_PATH))
360
 
    {
361
 
      switch (gimp_param_spec_path_type (param_spec))
362
 
        {
363
 
        case GIMP_PARAM_PATH_FILE:
364
 
          values = "This is a single filename.";
365
 
          break;
366
 
 
367
 
        case GIMP_PARAM_PATH_FILE_LIST:
368
 
          switch (G_SEARCHPATH_SEPARATOR)
369
 
            {
370
 
            case ':':
371
 
              values = "This is a colon-separated list of files.";
372
 
              break;
373
 
            case ';':
374
 
              values = "This is a semicolon-separated list of files.";
375
 
              break;
376
 
            default:
377
 
              g_warning ("unhandled G_SEARCHPATH_SEPARATOR value");
378
 
              break;
379
 
            }
380
 
          break;
381
 
 
382
 
        case GIMP_PARAM_PATH_DIR:
383
 
          values = "This is a single folder.";
384
 
          break;
385
 
 
386
 
        case GIMP_PARAM_PATH_DIR_LIST:
387
 
          switch (G_SEARCHPATH_SEPARATOR)
388
 
            {
389
 
            case ':':
390
 
              values = "This is a colon-separated list of folders to search.";
391
 
              break;
392
 
            case ';':
393
 
              values = "This is a semicolon-separated list of folders to search.";
394
 
              break;
395
 
            default:
396
 
              g_warning ("unhandled G_SEARCHPATH_SEPARATOR value");
397
 
              break;
398
 
            }
399
 
          break;
400
 
        }
401
 
    }
402
 
  else if (g_type_is_a (type, GIMP_TYPE_UNIT))
403
 
    {
404
 
      values =
405
 
        "The unit can be one inches, millimeters, points or picas plus "
406
 
        "those in your user units database.";
407
 
    }
408
 
  else if (g_type_is_a (type, GIMP_TYPE_CONFIG))
 
334
                               param_spec->name);
 
335
    }
 
336
 
 
337
  if (GIMP_IS_PARAM_SPEC_RGB (param_spec))
 
338
    {
 
339
      if (gimp_param_spec_rgb_has_alpha (param_spec))
 
340
        values =
 
341
          "The color is specified in the form (color-rgba red green blue "
 
342
          "alpha) with channel values as floats in the range of 0.0 to 1.0.";
 
343
      else
 
344
        values =
 
345
          "The color is specified in the form (color-rgb red green blue) "
 
346
          "with channel values as floats in the range of 0.0 to 1.0.";
 
347
    }
 
348
  else if (GIMP_IS_PARAM_SPEC_MEMSIZE (param_spec))
 
349
    {
 
350
      values =
 
351
        "The integer size can contain a suffix of 'B', 'K', 'M' or 'G' which "
 
352
        "makes GIMP interpret the size as being specified in bytes, kilobytes, "
 
353
        "megabytes or gigabytes. If no suffix is specified the size defaults "
 
354
        "to being specified in kilobytes.";
 
355
    }
 
356
  else if (GIMP_IS_PARAM_SPEC_CONFIG_PATH (param_spec))
 
357
    {
 
358
      switch (gimp_param_spec_config_path_type (param_spec))
 
359
        {
 
360
        case GIMP_CONFIG_PATH_FILE:
 
361
          values = "This is a single filename.";
 
362
          break;
 
363
 
 
364
        case GIMP_CONFIG_PATH_FILE_LIST:
 
365
          switch (G_SEARCHPATH_SEPARATOR)
 
366
            {
 
367
            case ':':
 
368
              values = "This is a colon-separated list of files.";
 
369
              break;
 
370
            case ';':
 
371
              values = "This is a semicolon-separated list of files.";
 
372
              break;
 
373
            default:
 
374
              g_warning ("unhandled G_SEARCHPATH_SEPARATOR value");
 
375
              break;
 
376
            }
 
377
          break;
 
378
 
 
379
        case GIMP_CONFIG_PATH_DIR:
 
380
          values = "This is a single folder.";
 
381
          break;
 
382
 
 
383
        case GIMP_CONFIG_PATH_DIR_LIST:
 
384
          switch (G_SEARCHPATH_SEPARATOR)
 
385
            {
 
386
            case ':':
 
387
              values = "This is a colon-separated list of folders to search.";
 
388
              break;
 
389
            case ';':
 
390
              values = "This is a semicolon-separated list of folders to search.";
 
391
              break;
 
392
            default:
 
393
              g_warning ("unhandled G_SEARCHPATH_SEPARATOR value");
 
394
              break;
 
395
            }
 
396
          break;
 
397
        }
 
398
    }
 
399
  else if (GIMP_IS_PARAM_SPEC_UNIT (param_spec))
 
400
    {
 
401
      values =
 
402
        "The unit can be one inches, millimeters, points or picas plus "
 
403
        "those in your user units database.";
 
404
    }
 
405
  else if (g_type_is_a (param_spec->value_type, GIMP_TYPE_CONFIG))
409
406
    {
410
407
      values = "This is a parameter list.";
411
408
    }
412
409
  else
413
410
    {
414
 
      switch (G_TYPE_FUNDAMENTAL (type))
415
 
        {
416
 
        case G_TYPE_BOOLEAN:
417
 
          values = "Possible values are yes and no.";
418
 
          break;
419
 
        case G_TYPE_INT:
420
 
        case G_TYPE_UINT:
421
 
        case G_TYPE_LONG:
422
 
        case G_TYPE_ULONG:
423
 
          values = "This is an integer value.";
424
 
          break;
425
 
        case G_TYPE_FLOAT:
426
 
        case G_TYPE_DOUBLE:
427
 
          values = "This is a float value.";
428
 
          break;
429
 
        case G_TYPE_STRING:
430
 
          /* eek */
431
 
          if (strcmp (g_param_spec_get_name (param_spec), "image-title-format")
432
 
              &&
433
 
              strcmp (g_param_spec_get_name (param_spec), "image-status-format"))
434
 
            {
435
 
              values = "This is a string value.";
436
 
            }
437
 
          else
438
 
            {
439
 
              values = display_format_description;
440
 
            }
441
 
          break;
442
 
        case G_TYPE_ENUM:
443
 
          {
444
 
            GEnumClass *enum_class;
445
 
            GEnumValue *enum_value;
446
 
            GString    *str;
447
 
            gint        i;
448
 
 
449
 
            enum_class = g_type_class_peek (type);
450
 
 
451
 
            str = g_string_new (blurb);
452
 
 
453
 
            g_string_append (str, "  Possible values are ");
454
 
 
455
 
            for (i = 0, enum_value = enum_class->values;
456
 
                 i < enum_class->n_values;
457
 
                 i++, enum_value++)
458
 
              {
459
 
                g_string_append (str, enum_value->value_nick);
460
 
 
461
 
                switch (enum_class->n_values - i)
462
 
                  {
463
 
                  case 1:
464
 
                    g_string_append_c (str, '.');
465
 
                    break;
466
 
                  case 2:
467
 
                    g_string_append (str, " and ");
468
 
                    break;
469
 
                  default:
470
 
                    g_string_append (str, ", ");
471
 
                    break;
472
 
                  }
473
 
              }
474
 
 
475
 
            return g_string_free (str, FALSE);
476
 
          }
477
 
          break;
478
 
        default:
479
 
          break;
480
 
        }
 
411
      switch (G_TYPE_FUNDAMENTAL (param_spec->value_type))
 
412
        {
 
413
        case G_TYPE_BOOLEAN:
 
414
          values = "Possible values are yes and no.";
 
415
          break;
 
416
        case G_TYPE_INT:
 
417
        case G_TYPE_UINT:
 
418
        case G_TYPE_LONG:
 
419
        case G_TYPE_ULONG:
 
420
          values = "This is an integer value.";
 
421
          break;
 
422
        case G_TYPE_FLOAT:
 
423
        case G_TYPE_DOUBLE:
 
424
          values = "This is a float value.";
 
425
          break;
 
426
        case G_TYPE_STRING:
 
427
          /* eek */
 
428
          if (strcmp (g_param_spec_get_name (param_spec), "image-title-format")
 
429
              &&
 
430
              strcmp (g_param_spec_get_name (param_spec), "image-status-format"))
 
431
            {
 
432
              values = "This is a string value.";
 
433
            }
 
434
          else
 
435
            {
 
436
              values = display_format_description;
 
437
            }
 
438
          break;
 
439
        case G_TYPE_ENUM:
 
440
          {
 
441
            GEnumClass *enum_class;
 
442
            GEnumValue *enum_value;
 
443
            GString    *str;
 
444
            gint        i;
 
445
 
 
446
            enum_class = g_type_class_peek (param_spec->value_type);
 
447
 
 
448
            str = g_string_new (blurb);
 
449
 
 
450
            g_string_append (str, "  Possible values are ");
 
451
 
 
452
            for (i = 0, enum_value = enum_class->values;
 
453
                 i < enum_class->n_values;
 
454
                 i++, enum_value++)
 
455
              {
 
456
                g_string_append (str, enum_value->value_nick);
 
457
 
 
458
                switch (enum_class->n_values - i)
 
459
                  {
 
460
                  case 1:
 
461
                    g_string_append_c (str, '.');
 
462
                    break;
 
463
                  case 2:
 
464
                    g_string_append (str, " and ");
 
465
                    break;
 
466
                  default:
 
467
                    g_string_append (str, ", ");
 
468
                    break;
 
469
                  }
 
470
              }
 
471
 
 
472
            return g_string_free (str, FALSE);
 
473
          }
 
474
          break;
 
475
        default:
 
476
          break;
 
477
        }
481
478
    }
482
479
 
483
480
  if (!values)
484
 
    g_warning ("FIXME: Can't tell anything about a %s.", g_type_name (type));
 
481
    g_warning ("FIXME: Can't tell anything about a %s.",
 
482
               g_type_name (param_spec->value_type));
485
483
 
486
484
  return g_strdup_printf ("%s  %s", blurb, values);
487
485
}
491
489
 
492
490
static void
493
491
dump_with_linebreaks (gint         fd,
494
 
                      const gchar *text)
 
492
                      const gchar *text)
495
493
{
496
494
  gint len = strlen (text);
497
495
 
519
517
      write (fd, "\n", 1);
520
518
 
521
519
      if (*t == '\n')
522
 
        write (fd, ".br\n", 4);
 
520
        write (fd, ".br\n", 4);
523
521
 
524
522
      i++;
525
523