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

« back to all changes in this revision

Viewing changes to libgimpconfig/gimpcolorconfig.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
/* LIBGIMP - The GIMP Library
 
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 
3
 *
 
4
 * GimpColorConfig class
 
5
 * Copyright (C) 2004  Stefan Döhla <stefan@doehla.de>
 
6
 *
 
7
 * This library is free software; you can redistribute it and/or
 
8
 * modify it under the terms of the GNU Lesser General Public
 
9
 * License as published by the Free Software Foundation; either
 
10
 * version 2 of the License, or (at your option) any later version.
 
11
 *
 
12
 * This library 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 GNU
 
15
 * Library General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU Lesser General Public
 
18
 * License along with this library; if not, write to the
 
19
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
20
 * Boston, MA 02111-1307, USA.
 
21
 */
 
22
 
 
23
#include "config.h"
 
24
 
 
25
#include <glib-object.h>
 
26
 
 
27
#include "gimpconfigtypes.h"
 
28
 
 
29
#include "gimpcolorconfig-enums.h"
 
30
 
 
31
#include "gimpcolorconfig.h"
 
32
#include "gimpconfig-iface.h"
 
33
#include "gimpconfig-params.h"
 
34
#include "gimpconfig-path.h"
 
35
 
 
36
#include "libgimp/libgimp-intl.h"
 
37
 
 
38
 
 
39
#define COLOR_MANAGEMENT_MODE_BLURB \
 
40
  N_("Mode of operation for color management.")
 
41
#define DISPLAY_PROFILE_BLURB \
 
42
  N_("The color profile of your (primary) monitor.")
 
43
#define DISPLAY_PROFILE_FROM_GDK_BLURB \
 
44
  N_("When enabled, GIMP will try to use the display color profile from " \
 
45
     "the windowing system.  The configured monitor profile is then only " \
 
46
     "used as a fallback.")
 
47
#define RGB_PROFILE_BLURB \
 
48
  N_("The default RGB working space color profile.")
 
49
#define CMYK_PROFILE_BLURB \
 
50
  N_("The CMYK color profile used to convert between RGB and CMYK.")
 
51
#define PRINTER_PROFILE_BLURB \
 
52
  N_("The color profile used for simulating a printed version (softproof).")
 
53
#define DISPLAY_RENDERING_INTENT_BLURB \
 
54
  N_("Sets how colors are mapped for your display.")
 
55
#define SIMULATION_RENDERING_INTENT_BLURB \
 
56
  N_("Sets how colors are converted from RGB working space to the " \
 
57
     "print simulation device.")
 
58
 
 
59
 
 
60
enum
 
61
{
 
62
  PROP_0,
 
63
  PROP_MODE,
 
64
  PROP_RGB_PROFILE,
 
65
  PROP_CMYK_PROFILE,
 
66
  PROP_DISPLAY_PROFILE,
 
67
  PROP_DISPLAY_PROFILE_FROM_GDK,
 
68
  PROP_PRINTER_PROFILE,
 
69
  PROP_DISPLAY_RENDERING_INTENT,
 
70
  PROP_SIMULATION_RENDERING_INTENT,
 
71
  PROP_DISPLAY_MODULE
 
72
};
 
73
 
 
74
 
 
75
static void  gimp_color_config_finalize     (GObject      *object);
 
76
static void  gimp_color_config_set_property (GObject      *object,
 
77
                                             guint         property_id,
 
78
                                             const GValue *value,
 
79
                                             GParamSpec   *pspec);
 
80
static void  gimp_color_config_get_property (GObject      *object,
 
81
                                             guint         property_id,
 
82
                                             GValue       *value,
 
83
                                             GParamSpec   *pspec);
 
84
 
 
85
 
 
86
G_DEFINE_TYPE_WITH_CODE (GimpColorConfig, gimp_color_config, G_TYPE_OBJECT,
 
87
                         G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL)
 
88
                         gimp_type_set_translation_domain (g_define_type_id,
 
89
                                                           GETTEXT_PACKAGE "-libgimp"))
 
90
 
 
91
#define parent_class gimp_color_config_parent_class
 
92
 
 
93
 
 
94
static void
 
95
gimp_color_config_class_init (GimpColorConfigClass *klass)
 
96
{
 
97
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
98
 
 
99
  object_class->finalize     = gimp_color_config_finalize;
 
100
  object_class->set_property = gimp_color_config_set_property;
 
101
  object_class->get_property = gimp_color_config_get_property;
 
102
 
 
103
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_MODE,
 
104
                                 "mode", COLOR_MANAGEMENT_MODE_BLURB,
 
105
                                 GIMP_TYPE_COLOR_MANAGEMENT_MODE,
 
106
                                 GIMP_COLOR_MANAGEMENT_DISPLAY,
 
107
                                 GIMP_PARAM_STATIC_STRINGS);
 
108
  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_RGB_PROFILE,
 
109
                                 "rgb-profile", RGB_PROFILE_BLURB,
 
110
                                 GIMP_CONFIG_PATH_FILE, NULL,
 
111
                                 GIMP_PARAM_STATIC_STRINGS);
 
112
  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_CMYK_PROFILE,
 
113
                                 "cmyk-profile", CMYK_PROFILE_BLURB,
 
114
                                 GIMP_CONFIG_PATH_FILE, NULL,
 
115
                                 GIMP_PARAM_STATIC_STRINGS);
 
116
  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_DISPLAY_PROFILE,
 
117
                                 "display-profile", DISPLAY_PROFILE_BLURB,
 
118
                                 GIMP_CONFIG_PATH_FILE, NULL,
 
119
                                 GIMP_PARAM_STATIC_STRINGS);
 
120
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DISPLAY_PROFILE_FROM_GDK,
 
121
                                    "display-profile-from-gdk",
 
122
                                    DISPLAY_PROFILE_FROM_GDK_BLURB,
 
123
                                    TRUE,
 
124
                                    GIMP_PARAM_STATIC_STRINGS);
 
125
  GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_PRINTER_PROFILE,
 
126
                                 "printer-profile", PRINTER_PROFILE_BLURB,
 
127
                                 GIMP_CONFIG_PATH_FILE, NULL,
 
128
                                 GIMP_PARAM_STATIC_STRINGS);
 
129
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_DISPLAY_RENDERING_INTENT,
 
130
                                 "display-rendering-intent",
 
131
                                 DISPLAY_RENDERING_INTENT_BLURB,
 
132
                                 GIMP_TYPE_COLOR_RENDERING_INTENT,
 
133
                                 GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL,
 
134
                                 GIMP_PARAM_STATIC_STRINGS);
 
135
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_SIMULATION_RENDERING_INTENT,
 
136
                                 "simulation-rendering-intent",
 
137
                                 SIMULATION_RENDERING_INTENT_BLURB,
 
138
                                 GIMP_TYPE_COLOR_RENDERING_INTENT,
 
139
                                 GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL,
 
140
                                 GIMP_PARAM_STATIC_STRINGS);
 
141
  GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_DISPLAY_MODULE,
 
142
                                   "display-module", NULL,
 
143
                                   "CdisplayLcms",
 
144
                                   GIMP_PARAM_STATIC_STRINGS);
 
145
}
 
146
 
 
147
static void
 
148
gimp_color_config_init (GimpColorConfig *config)
 
149
{
 
150
}
 
151
 
 
152
static void
 
153
gimp_color_config_finalize (GObject *object)
 
154
{
 
155
  GimpColorConfig *color_config = GIMP_COLOR_CONFIG (object);
 
156
 
 
157
  if (color_config->rgb_profile)
 
158
    g_free (color_config->rgb_profile);
 
159
 
 
160
  if (color_config->cmyk_profile)
 
161
    g_free (color_config->cmyk_profile);
 
162
 
 
163
  if (color_config->display_profile)
 
164
    g_free (color_config->display_profile);
 
165
 
 
166
  if (color_config->printer_profile)
 
167
    g_free (color_config->printer_profile);
 
168
 
 
169
  if (color_config->display_module)
 
170
    g_free (color_config->display_module);
 
171
 
 
172
  G_OBJECT_CLASS (parent_class)->finalize (object);
 
173
}
 
174
 
 
175
static void
 
176
gimp_color_config_set_property (GObject      *object,
 
177
                                guint         property_id,
 
178
                                const GValue *value,
 
179
                                GParamSpec   *pspec)
 
180
{
 
181
  GimpColorConfig *color_config = GIMP_COLOR_CONFIG (object);
 
182
 
 
183
  switch (property_id)
 
184
    {
 
185
    case PROP_MODE:
 
186
      color_config->mode = g_value_get_enum (value);
 
187
      break;
 
188
    case PROP_RGB_PROFILE:
 
189
      g_free (color_config->rgb_profile);
 
190
      color_config->rgb_profile = g_value_dup_string (value);
 
191
      break;
 
192
    case PROP_CMYK_PROFILE:
 
193
      g_free (color_config->cmyk_profile);
 
194
      color_config->cmyk_profile = g_value_dup_string (value);
 
195
      break;
 
196
    case PROP_DISPLAY_PROFILE:
 
197
      g_free (color_config->display_profile);
 
198
      color_config->display_profile = g_value_dup_string (value);
 
199
      break;
 
200
    case PROP_DISPLAY_PROFILE_FROM_GDK:
 
201
      color_config->display_profile_from_gdk = g_value_get_boolean (value);
 
202
      break;
 
203
    case PROP_PRINTER_PROFILE:
 
204
      g_free (color_config->printer_profile);
 
205
      color_config->printer_profile = g_value_dup_string (value);
 
206
      break;
 
207
    case PROP_DISPLAY_RENDERING_INTENT:
 
208
      color_config->display_intent = g_value_get_enum (value);
 
209
      break;
 
210
    case PROP_SIMULATION_RENDERING_INTENT:
 
211
      color_config->simulation_intent = g_value_get_enum (value);
 
212
      break;
 
213
    case PROP_DISPLAY_MODULE:
 
214
      g_free (color_config->display_module);
 
215
      color_config->display_module = g_value_dup_string (value);
 
216
      break;
 
217
 
 
218
    default:
 
219
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
220
      break;
 
221
    }
 
222
}
 
223
 
 
224
static void
 
225
gimp_color_config_get_property (GObject    *object,
 
226
                                guint       property_id,
 
227
                                GValue     *value,
 
228
                                GParamSpec *pspec)
 
229
{
 
230
  GimpColorConfig *color_config = GIMP_COLOR_CONFIG (object);
 
231
 
 
232
  switch (property_id)
 
233
    {
 
234
    case PROP_MODE:
 
235
      g_value_set_enum (value, color_config->mode);
 
236
      break;
 
237
    case PROP_RGB_PROFILE:
 
238
      g_value_set_string (value, color_config->rgb_profile);
 
239
      break;
 
240
    case PROP_CMYK_PROFILE:
 
241
      g_value_set_string (value, color_config->cmyk_profile);
 
242
      break;
 
243
    case PROP_DISPLAY_PROFILE:
 
244
      g_value_set_string (value, color_config->display_profile);
 
245
      break;
 
246
    case PROP_DISPLAY_PROFILE_FROM_GDK:
 
247
      g_value_set_boolean (value, color_config->display_profile_from_gdk);
 
248
      break;
 
249
    case PROP_PRINTER_PROFILE:
 
250
      g_value_set_string (value, color_config->printer_profile);
 
251
      break;
 
252
    case PROP_DISPLAY_RENDERING_INTENT:
 
253
      g_value_set_enum (value, color_config->display_intent);
 
254
      break;
 
255
    case PROP_SIMULATION_RENDERING_INTENT:
 
256
      g_value_set_enum (value, color_config->simulation_intent);
 
257
      break;
 
258
    case PROP_DISPLAY_MODULE:
 
259
      g_value_set_string (value, color_config->display_module);
 
260
      break;
 
261
 
 
262
    default:
 
263
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
 
264
      break;
 
265
    }
 
266
}