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

« back to all changes in this revision

Viewing changes to app/config/gimpbaseconfig.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
 * GimpBaseConfig class
21
21
 
22
22
#include "config.h"
23
23
 
 
24
#ifdef HAVE_UNISTD_H
 
25
#include <unistd.h>
 
26
#endif
 
27
 
24
28
#include <glib-object.h>
25
29
 
26
30
#include "libgimpbase/gimpbase.h"
 
31
#include "libgimpconfig/gimpconfig.h"
27
32
 
28
33
#include "config-types.h"
29
34
 
30
 
#include "gimpconfig-params.h"
 
35
#include "base/pixel-processor.h"
31
36
 
32
37
#include "gimprc-blurbs.h"
33
38
#include "gimpbaseconfig.h"
34
39
 
35
40
#include "gimp-intl.h"
36
41
 
37
 
 
38
 
static void  gimp_base_config_class_init   (GimpBaseConfigClass *klass);
39
 
static void  gimp_base_config_finalize     (GObject             *object);
40
 
static void  gimp_base_config_set_property (GObject             *object,
41
 
                                            guint                property_id,
42
 
                                            const GValue        *value,
43
 
                                            GParamSpec          *pspec);
44
 
static void  gimp_base_config_get_property (GObject             *object,
45
 
                                            guint                property_id,
46
 
                                            GValue              *value,
47
 
                                            GParamSpec          *pspec);
 
42
#define NUM_PROCESSORS_DEFAULT 1
48
43
 
49
44
 
50
45
enum
52
47
  PROP_0,
53
48
  PROP_TEMP_PATH,
54
49
  PROP_SWAP_PATH,
55
 
  PROP_STINGY_MEMORY_USE,
56
50
  PROP_NUM_PROCESSORS,
57
 
  PROP_TILE_CACHE_SIZE
 
51
  PROP_TILE_CACHE_SIZE,
 
52
 
 
53
  /* ignored, only for backward compatibility: */
 
54
  PROP_STINGY_MEMORY_USE
58
55
};
59
56
 
60
 
static GObjectClass *parent_class = NULL;
61
 
 
62
 
 
63
 
GType
64
 
gimp_base_config_get_type (void)
65
 
{
66
 
  static GType config_type = 0;
67
 
 
68
 
  if (! config_type)
69
 
    {
70
 
      static const GTypeInfo config_info =
71
 
      {
72
 
        sizeof (GimpBaseConfigClass),
73
 
        NULL,           /* base_init      */
74
 
        NULL,           /* base_finalize  */
75
 
        (GClassInitFunc) gimp_base_config_class_init,
76
 
        NULL,           /* class_finalize */
77
 
        NULL,           /* class_data     */
78
 
        sizeof (GimpBaseConfig),
79
 
        0,              /* n_preallocs    */
80
 
        NULL            /* instance_init  */
81
 
      };
82
 
 
83
 
      config_type = g_type_register_static (G_TYPE_OBJECT,
84
 
                                            "GimpBaseConfig",
85
 
                                            &config_info, 0);
86
 
    }
87
 
 
88
 
  return config_type;
89
 
}
 
57
 
 
58
static void   gimp_base_config_finalize     (GObject      *object);
 
59
static void   gimp_base_config_set_property (GObject      *object,
 
60
                                             guint         property_id,
 
61
                                             const GValue *value,
 
62
                                             GParamSpec   *pspec);
 
63
static void   gimp_base_config_get_property (GObject      *object,
 
64
                                             guint         property_id,
 
65
                                             GValue       *value,
 
66
                                             GParamSpec   *pspec);
 
67
 
 
68
 
 
69
G_DEFINE_TYPE (GimpBaseConfig, gimp_base_config, G_TYPE_OBJECT)
 
70
 
 
71
#define parent_class gimp_base_config_parent_class
 
72
 
90
73
 
91
74
static void
92
75
gimp_base_config_class_init (GimpBaseConfigClass *klass)
93
76
{
94
 
  GObjectClass *object_class;
95
 
 
96
 
  parent_class = g_type_class_peek_parent (klass);
97
 
 
98
 
  object_class = G_OBJECT_CLASS (klass);
 
77
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
78
  gint          num_processors;
99
79
 
100
80
  object_class->finalize     = gimp_base_config_finalize;
101
81
  object_class->set_property = gimp_base_config_set_property;
103
83
 
104
84
  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_TEMP_PATH,
105
85
                                 "temp-path", TEMP_PATH_BLURB,
106
 
                                 GIMP_PARAM_PATH_DIR,
 
86
                                 GIMP_CONFIG_PATH_DIR,
107
87
                                 "${gimp_dir}" G_DIR_SEPARATOR_S "tmp",
108
 
                                 GIMP_PARAM_RESTART);
 
88
                                 GIMP_PARAM_STATIC_STRINGS |
 
89
                                 GIMP_CONFIG_PARAM_RESTART);
109
90
  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_SWAP_PATH,
110
91
                                 "swap-path", SWAP_PATH_BLURB,
111
 
                                 GIMP_PARAM_PATH_DIR,
 
92
                                 GIMP_CONFIG_PATH_DIR,
112
93
                                 "${gimp_dir}",
113
 
                                 GIMP_PARAM_RESTART);
114
 
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_STINGY_MEMORY_USE,
115
 
                                    "stingy-memory-use", STINGY_MEMORY_USE_BLURB,
116
 
                                    FALSE,
117
 
                                    GIMP_PARAM_IGNORE);
 
94
                                 GIMP_PARAM_STATIC_STRINGS |
 
95
                                 GIMP_CONFIG_PARAM_RESTART);
 
96
 
 
97
#if defined(HAVE_UNISTD_H) && defined(_SC_NPROCESSORS_ONLN)
 
98
  num_processors = sysconf (_SC_NPROCESSORS_ONLN);
 
99
#else
 
100
  num_processors = NUM_PROCESSORS_DEFAULT;
 
101
#endif
 
102
 
 
103
#ifdef GIMP_UNSTABLE
 
104
  num_processors = num_processors * 2;
 
105
#endif
 
106
 
118
107
  GIMP_CONFIG_INSTALL_PROP_UINT (object_class, PROP_NUM_PROCESSORS,
119
108
                                 "num-processors", NUM_PROCESSORS_BLURB,
120
 
                                 1, 30, 1,
121
 
                                 0);
 
109
                                 1, GIMP_MAX_NUM_THREADS, num_processors,
 
110
                                 GIMP_PARAM_STATIC_STRINGS);
122
111
  GIMP_CONFIG_INSTALL_PROP_MEMSIZE (object_class, PROP_TILE_CACHE_SIZE,
123
112
                                    "tile-cache-size", TILE_CACHE_SIZE_BLURB,
124
113
                                    0, MIN (G_MAXULONG, GIMP_MAX_MEMSIZE),
125
 
                                    1 << 27, /* 128MB */
126
 
                                    GIMP_PARAM_CONFIRM);
 
114
                                    1 << 30, /* 1GB */
 
115
                                    GIMP_PARAM_STATIC_STRINGS |
 
116
                                    GIMP_CONFIG_PARAM_CONFIRM);
 
117
 
 
118
  /*  only for backward compatibility:  */
 
119
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_STINGY_MEMORY_USE,
 
120
                                    "stingy-memory-use", NULL,
 
121
                                    FALSE,
 
122
                                    GIMP_CONFIG_PARAM_IGNORE);
 
123
}
 
124
 
 
125
static void
 
126
gimp_base_config_init (GimpBaseConfig *config)
 
127
{
127
128
}
128
129
 
129
130
static void
155
156
      g_free (base_config->swap_path);
156
157
      base_config->swap_path = g_value_dup_string (value);
157
158
      break;
158
 
    case PROP_STINGY_MEMORY_USE:
159
 
      base_config->stingy_memory_use = g_value_get_boolean (value);
160
 
      break;
161
159
    case PROP_NUM_PROCESSORS:
162
160
      base_config->num_processors = g_value_get_uint (value);
163
161
      break;
164
162
    case PROP_TILE_CACHE_SIZE:
165
163
      base_config->tile_cache_size = g_value_get_uint64 (value);
166
164
      break;
 
165
 
 
166
    case PROP_STINGY_MEMORY_USE:
 
167
      /* ignored */
 
168
      break;
 
169
 
167
170
    default:
168
171
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
169
172
      break;
186
189
    case PROP_SWAP_PATH:
187
190
      g_value_set_string (value, base_config->swap_path);
188
191
      break;
189
 
    case PROP_STINGY_MEMORY_USE:
190
 
      g_value_set_boolean (value, base_config->stingy_memory_use);
191
 
      break;
192
192
    case PROP_NUM_PROCESSORS:
193
193
      g_value_set_uint (value, base_config->num_processors);
194
194
      break;
195
195
    case PROP_TILE_CACHE_SIZE:
196
196
      g_value_set_uint64 (value, base_config->tile_cache_size);
197
197
      break;
 
198
 
 
199
    case PROP_STINGY_MEMORY_USE:
 
200
      /* ignored */
 
201
      break;
 
202
 
198
203
    default:
199
204
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
200
205
      break;