|
65 | 65 | _("The preferred RGB working space color profile. It will be offered " \
|
66 | 66 | "next to the built-in RGB profile when a color profile can be chosen.")
|
67 | 67 |
|
| 68 | +#define GRAY_PROFILE_BLURB \ |
| 69 | + _("The preferred grayscale working space color profile. It will be offered " \ |
| 70 | + "next to the built-in grayscale profile when a color profile can be chosen.") |
| 71 | + |
68 | 72 | #define CMYK_PROFILE_BLURB \
|
69 | 73 | _("The CMYK color profile used to convert between RGB and CMYK.")
|
70 | 74 |
|
|
106 | 110 | PROP_0,
|
107 | 111 | PROP_MODE,
|
108 | 112 | PROP_RGB_PROFILE,
|
| 113 | + PROP_GRAY_PROFILE, |
109 | 114 | PROP_CMYK_PROFILE,
|
110 | 115 | PROP_DISPLAY_PROFILE,
|
111 | 116 | PROP_DISPLAY_PROFILE_FROM_GDK,
|
@@ -133,6 +138,9 @@ static void gimp_color_config_get_property (GObject *object,
|
133 | 138 | static void gimp_color_config_set_rgb_profile (GimpColorConfig *config,
|
134 | 139 | const gchar *filename,
|
135 | 140 | GError **error);
|
| 141 | +static void gimp_color_config_set_gray_profile (GimpColorConfig *config, |
| 142 | + const gchar *filename, |
| 143 | + GError **error); |
136 | 144 | static void gimp_color_config_set_cmyk_profile (GimpColorConfig *config,
|
137 | 145 | const gchar *filename,
|
138 | 146 | GError **error);
|
@@ -173,6 +181,10 @@ gimp_color_config_class_init (GimpColorConfigClass *klass)
|
173 | 181 | "rgb-profile", RGB_PROFILE_BLURB,
|
174 | 182 | GIMP_CONFIG_PATH_FILE, NULL,
|
175 | 183 | GIMP_PARAM_STATIC_STRINGS);
|
| 184 | + GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_GRAY_PROFILE, |
| 185 | + "gray-profile", GRAY_PROFILE_BLURB, |
| 186 | + GIMP_CONFIG_PATH_FILE, NULL, |
| 187 | + GIMP_PARAM_STATIC_STRINGS); |
176 | 188 | GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_CMYK_PROFILE,
|
177 | 189 | "cmyk-profile", CMYK_PROFILE_BLURB,
|
178 | 190 | GIMP_CONFIG_PATH_FILE, NULL,
|
@@ -241,6 +253,9 @@ gimp_color_config_finalize (GObject *object)
|
241 | 253 | if (color_config->rgb_profile)
|
242 | 254 | g_free (color_config->rgb_profile);
|
243 | 255 |
|
| 256 | + if (color_config->gray_profile) |
| 257 | + g_free (color_config->gray_profile); |
| 258 | + |
244 | 259 | if (color_config->cmyk_profile)
|
245 | 260 | g_free (color_config->cmyk_profile);
|
246 | 261 |
|
@@ -275,6 +290,11 @@ gimp_color_config_set_property (GObject *object,
|
275 | 290 | g_value_get_string (value),
|
276 | 291 | &error);
|
277 | 292 | break;
|
| 293 | + case PROP_GRAY_PROFILE: |
| 294 | + gimp_color_config_set_gray_profile (color_config, |
| 295 | + g_value_get_string (value), |
| 296 | + &error); |
| 297 | + break; |
278 | 298 | case PROP_CMYK_PROFILE:
|
279 | 299 | gimp_color_config_set_cmyk_profile (color_config,
|
280 | 300 | g_value_get_string (value),
|
@@ -344,6 +364,9 @@ gimp_color_config_get_property (GObject *object,
|
344 | 364 | case PROP_RGB_PROFILE:
|
345 | 365 | g_value_set_string (value, color_config->rgb_profile);
|
346 | 366 | break;
|
| 367 | + case PROP_GRAY_PROFILE: |
| 368 | + g_value_set_string (value, color_config->gray_profile); |
| 369 | + break; |
347 | 370 | case PROP_CMYK_PROFILE:
|
348 | 371 | g_value_set_string (value, color_config->cmyk_profile);
|
349 | 372 | break;
|
@@ -415,6 +438,37 @@ gimp_color_config_get_rgb_color_profile (GimpColorConfig *config,
|
415 | 438 | return profile;
|
416 | 439 | }
|
417 | 440 |
|
| 441 | +GimpColorProfile * |
| 442 | +gimp_color_config_get_gray_color_profile (GimpColorConfig *config, |
| 443 | + GError **error) |
| 444 | +{ |
| 445 | + GimpColorProfile *profile = NULL; |
| 446 | + |
| 447 | + g_return_val_if_fail (GIMP_IS_COLOR_CONFIG (config), NULL); |
| 448 | + g_return_val_if_fail (error == NULL || *error == NULL, NULL); |
| 449 | + |
| 450 | + if (config->gray_profile) |
| 451 | + { |
| 452 | + GFile *file = g_file_new_for_path (config->gray_profile); |
| 453 | + |
| 454 | + profile = gimp_color_profile_new_from_file (file, error); |
| 455 | + |
| 456 | + if (profile && ! gimp_color_profile_is_gray (profile)) |
| 457 | + { |
| 458 | + g_object_unref (profile); |
| 459 | + profile = NULL; |
| 460 | + |
| 461 | + g_set_error (error, GIMP_CONFIG_ERROR, 0, |
| 462 | + _("Color profile '%s' is not for GRAY color space."), |
| 463 | + gimp_file_get_utf8_name (file)); |
| 464 | + } |
| 465 | + |
| 466 | + g_object_unref (file); |
| 467 | + } |
| 468 | + |
| 469 | + return profile; |
| 470 | +} |
| 471 | + |
418 | 472 | GimpColorProfile *
|
419 | 473 | gimp_color_config_get_cmyk_color_profile (GimpColorConfig *config,
|
420 | 474 | GError **error)
|
@@ -530,6 +584,47 @@ gimp_color_config_set_rgb_profile (GimpColorConfig *config,
|
530 | 584 | }
|
531 | 585 | }
|
532 | 586 |
|
| 587 | +static void |
| 588 | +gimp_color_config_set_gray_profile (GimpColorConfig *config, |
| 589 | + const gchar *filename, |
| 590 | + GError **error) |
| 591 | +{ |
| 592 | + gboolean success = TRUE; |
| 593 | + |
| 594 | + if (filename) |
| 595 | + { |
| 596 | + GimpColorProfile *profile; |
| 597 | + GFile *file = g_file_new_for_path (filename); |
| 598 | + |
| 599 | + profile = gimp_color_profile_new_from_file (file, error); |
| 600 | + |
| 601 | + if (profile) |
| 602 | + { |
| 603 | + if (! gimp_color_profile_is_gray (profile)) |
| 604 | + { |
| 605 | + g_set_error (error, GIMP_CONFIG_ERROR, 0, |
| 606 | + _("Color profile '%s' is not for GRAY color space."), |
| 607 | + gimp_file_get_utf8_name (file)); |
| 608 | + success = FALSE; |
| 609 | + } |
| 610 | + |
| 611 | + g_object_unref (profile); |
| 612 | + } |
| 613 | + else |
| 614 | + { |
| 615 | + success = FALSE; |
| 616 | + } |
| 617 | + |
| 618 | + g_object_unref (file); |
| 619 | + } |
| 620 | + |
| 621 | + if (success) |
| 622 | + { |
| 623 | + g_free (config->gray_profile); |
| 624 | + config->gray_profile = g_strdup (filename); |
| 625 | + } |
| 626 | +} |
| 627 | + |
533 | 628 | static void
|
534 | 629 | gimp_color_config_set_cmyk_profile (GimpColorConfig *config,
|
535 | 630 | const gchar *filename,
|
|
0 commit comments