gimpcolorconfig.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319
  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. #include "config.h"
  23. #include <glib-object.h>
  24. #include "gimpconfigtypes.h"
  25. #include "gimpcolorconfig-enums.h"
  26. #include "gimpcolorconfig.h"
  27. #include "gimpconfig-iface.h"
  28. #include "gimpconfig-params.h"
  29. #include "gimpconfig-path.h"
  30. #include "libgimp/libgimp-intl.h"
  31. #define COLOR_MANAGEMENT_MODE_BLURB \
  32. N_("Mode of operation for color management.")
  33. #define DISPLAY_PROFILE_BLURB \
  34. N_("The color profile of your (primary) monitor.")
  35. #define DISPLAY_PROFILE_FROM_GDK_BLURB \
  36. N_("When enabled, the GIMP will try to use the display color profile " \
  37. "from the windowing system. The configured monitor profile is then " \
  38. "only used as a fallback.")
  39. #define RGB_PROFILE_BLURB \
  40. N_("The default RGB workspace color profile.")
  41. #define CMYK_PROFILE_BLURB \
  42. N_("The CMYK color profile used to convert between RGB and CMYK.")
  43. #define PRINTER_PROFILE_BLURB \
  44. N_("The color profile used for simulating a printed version (softproof).")
  45. #define DISPLAY_RENDERING_INTENT_BLURB \
  46. N_("Sets how colors are mapped for your display.")
  47. #define SIMULATION_RENDERING_INTENT_BLURB \
  48. N_("Sets how colors are converted from workspace to the print simulation " \
  49. "device.")
  50. #define OPEN_BEHAVIOUR_NO_PROFILE_BLURB \
  51. "Defines what will be done if no color profile is available."
  52. #define OPEN_BEHAVIOUR_RGB_PROFILE_BLURB \
  53. "Defines what will be done if an RGB profile is available."
  54. #define OPEN_BEHAVIOUR_CMYK_PROFILE_BLURB \
  55. "Defines what will be done if a CMYK profile is available."
  56. enum
  57. {
  58. PROP_0,
  59. PROP_MODE,
  60. PROP_RGB_PROFILE,
  61. PROP_CMYK_PROFILE,
  62. PROP_DISPLAY_PROFILE,
  63. PROP_DISPLAY_PROFILE_FROM_GDK,
  64. PROP_PRINTER_PROFILE,
  65. PROP_DISPLAY_RENDERING_INTENT,
  66. PROP_SIMULATION_RENDERING_INTENT,
  67. PROP_DISPLAY_MODULE
  68. #if 0
  69. PROP_OPEN_BEHAVIOUR_NO_PROFILE,
  70. PROP_OPEN_BEHAVIOUR_RGB_PROFILE,
  71. PROP_OPEN_BEHAVIOUR_CMYK_PROFILE
  72. #endif
  73. };
  74. static void gimp_color_config_finalize (GObject *object);
  75. static void gimp_color_config_set_property (GObject *object,
  76. guint property_id,
  77. const GValue *value,
  78. GParamSpec *pspec);
  79. static void gimp_color_config_get_property (GObject *object,
  80. guint property_id,
  81. GValue *value,
  82. GParamSpec *pspec);
  83. G_DEFINE_TYPE_WITH_CODE (GimpColorConfig, gimp_color_config, G_TYPE_OBJECT,
  84. G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL)
  85. gimp_type_set_translation_domain (g_define_type_id,
  86. GETTEXT_PACKAGE "-libgimp"))
  87. #define parent_class gimp_color_config_parent_class
  88. static void
  89. gimp_color_config_class_init (GimpColorConfigClass *klass)
  90. {
  91. GObjectClass *object_class = G_OBJECT_CLASS (klass);
  92. object_class->finalize = gimp_color_config_finalize;
  93. object_class->set_property = gimp_color_config_set_property;
  94. object_class->get_property = gimp_color_config_get_property;
  95. GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_MODE,
  96. "mode", COLOR_MANAGEMENT_MODE_BLURB,
  97. GIMP_TYPE_COLOR_MANAGEMENT_MODE,
  98. GIMP_COLOR_MANAGEMENT_DISPLAY,
  99. GIMP_PARAM_STATIC_STRINGS);
  100. GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_RGB_PROFILE,
  101. "rgb-profile", RGB_PROFILE_BLURB,
  102. GIMP_CONFIG_PATH_FILE, NULL,
  103. GIMP_PARAM_STATIC_STRINGS);
  104. GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_CMYK_PROFILE,
  105. "cmyk-profile", CMYK_PROFILE_BLURB,
  106. GIMP_CONFIG_PATH_FILE, NULL,
  107. GIMP_PARAM_STATIC_STRINGS);
  108. GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_DISPLAY_PROFILE,
  109. "display-profile", DISPLAY_PROFILE_BLURB,
  110. GIMP_CONFIG_PATH_FILE, NULL,
  111. GIMP_PARAM_STATIC_STRINGS);
  112. GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_DISPLAY_PROFILE_FROM_GDK,
  113. "display-profile-from-gdk",
  114. DISPLAY_PROFILE_FROM_GDK_BLURB,
  115. TRUE,
  116. GIMP_PARAM_STATIC_STRINGS);
  117. GIMP_CONFIG_INSTALL_PROP_PATH (object_class, PROP_PRINTER_PROFILE,
  118. "printer-profile", PRINTER_PROFILE_BLURB,
  119. GIMP_CONFIG_PATH_FILE, NULL,
  120. GIMP_PARAM_STATIC_STRINGS);
  121. GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_DISPLAY_RENDERING_INTENT,
  122. "display-rendering-intent",
  123. DISPLAY_RENDERING_INTENT_BLURB,
  124. GIMP_TYPE_COLOR_RENDERING_INTENT,
  125. GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL,
  126. GIMP_PARAM_STATIC_STRINGS);
  127. GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_SIMULATION_RENDERING_INTENT,
  128. "simulation-rendering-intent",
  129. SIMULATION_RENDERING_INTENT_BLURB,
  130. GIMP_TYPE_COLOR_RENDERING_INTENT,
  131. GIMP_COLOR_RENDERING_INTENT_PERCEPTUAL,
  132. GIMP_PARAM_STATIC_STRINGS);
  133. GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_DISPLAY_MODULE,
  134. "display-module", NULL,
  135. "CdisplayLcms",
  136. GIMP_PARAM_STATIC_STRINGS);
  137. #if 0
  138. GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_OPEN_BEHAVIOUR_NO_PROFILE,
  139. "open-behaviour-no-profile",
  140. OPEN_BEHAVIOUR_NO_PROFILE_BLURB,
  141. GIMP_TYPE_COLOR_FILE_OPEN_BEHAVIOUR,
  142. GIMP_COLOR_FILE_OPEN_ASK,
  143. GIMP_PARAM_STATIC_STRINGS);
  144. GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_OPEN_BEHAVIOUR_RGB_PROFILE,
  145. "open-behaviour-rgb-profile",
  146. OPEN_BEHAVIOUR_RGB_PROFILE_BLURB,
  147. GIMP_TYPE_COLOR_FILE_OPEN_BEHAVIOUR,
  148. GIMP_COLOR_FILE_OPEN_ASK,
  149. GIMP_PARAM_STATIC_STRINGS);
  150. GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_OPEN_BEHAVIOUR_CMYK_PROFILE,
  151. "open-behaviour-cmyk-profile",
  152. OPEN_BEHAVIOUR_CMYK_PROFILE_BLURB,
  153. GIMP_TYPE_COLOR_FILE_OPEN_BEHAVIOUR,
  154. GIMP_COLOR_FILE_OPEN_ASK,
  155. GIMP_PARAM_STATIC_STRINGS);
  156. #endif
  157. }
  158. static void
  159. gimp_color_config_init (GimpColorConfig *config)
  160. {
  161. }
  162. static void
  163. gimp_color_config_finalize (GObject *object)
  164. {
  165. GimpColorConfig *color_config = GIMP_COLOR_CONFIG (object);
  166. if (color_config->rgb_profile)
  167. g_free (color_config->rgb_profile);
  168. if (color_config->cmyk_profile)
  169. g_free (color_config->cmyk_profile);
  170. if (color_config->display_profile)
  171. g_free (color_config->display_profile);
  172. if (color_config->printer_profile)
  173. g_free (color_config->printer_profile);
  174. if (color_config->display_module)
  175. g_free (color_config->display_module);
  176. G_OBJECT_CLASS (parent_class)->finalize (object);
  177. }
  178. static void
  179. gimp_color_config_set_property (GObject *object,
  180. guint property_id,
  181. const GValue *value,
  182. GParamSpec *pspec)
  183. {
  184. GimpColorConfig *color_config = GIMP_COLOR_CONFIG (object);
  185. switch (property_id)
  186. {
  187. case PROP_MODE:
  188. color_config->mode = g_value_get_enum (value);
  189. break;
  190. case PROP_RGB_PROFILE:
  191. g_free (color_config->rgb_profile);
  192. color_config->rgb_profile = g_value_dup_string (value);
  193. break;
  194. case PROP_CMYK_PROFILE:
  195. g_free (color_config->cmyk_profile);
  196. color_config->cmyk_profile = g_value_dup_string (value);
  197. break;
  198. case PROP_DISPLAY_PROFILE:
  199. g_free (color_config->display_profile);
  200. color_config->display_profile = g_value_dup_string (value);
  201. break;
  202. case PROP_DISPLAY_PROFILE_FROM_GDK:
  203. color_config->display_profile_from_gdk = g_value_get_boolean (value);
  204. break;
  205. case PROP_PRINTER_PROFILE:
  206. g_free (color_config->printer_profile);
  207. color_config->printer_profile = g_value_dup_string (value);
  208. break;
  209. case PROP_DISPLAY_RENDERING_INTENT:
  210. color_config->display_intent = g_value_get_enum (value);
  211. break;
  212. case PROP_SIMULATION_RENDERING_INTENT:
  213. color_config->simulation_intent = g_value_get_enum (value);
  214. break;
  215. case PROP_DISPLAY_MODULE:
  216. g_free (color_config->display_module);
  217. color_config->display_module = g_value_dup_string (value);
  218. break;
  219. #if 0
  220. case PROP_OPEN_BEHAVIOUR_NO_PROFILE:
  221. color_config->open_behaviour_no_profile = g_value_get_enum (value);
  222. break;
  223. case PROP_OPEN_BEHAVIOUR_RGB_PROFILE:
  224. color_config->open_behaviour_rgb_profile = g_value_get_enum (value);
  225. break;
  226. case PROP_OPEN_BEHAVIOUR_CMYK_PROFILE:
  227. color_config->open_behaviour_cmyk_profile = g_value_get_enum (value);
  228. break;
  229. #endif
  230. default:
  231. G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
  232. break;
  233. }
  234. }
  235. static void
  236. gimp_color_config_get_property (GObject *object,
  237. guint property_id,
  238. GValue *value,
  239. GParamSpec *pspec)
  240. {
  241. GimpColorConfig *color_config = GIMP_COLOR_CONFIG (object);
  242. switch (property_id)
  243. {
  244. case PROP_MODE:
  245. g_value_set_enum (value, color_config->mode);
  246. break;
  247. case PROP_RGB_PROFILE:
  248. g_value_set_string (value, color_config->rgb_profile);
  249. break;
  250. case PROP_CMYK_PROFILE:
  251. g_value_set_string (value, color_config->cmyk_profile);
  252. break;
  253. case PROP_DISPLAY_PROFILE:
  254. g_value_set_string (value, color_config->display_profile);
  255. break;
  256. case PROP_DISPLAY_PROFILE_FROM_GDK:
  257. g_value_set_boolean (value, color_config->display_profile_from_gdk);
  258. break;
  259. case PROP_PRINTER_PROFILE:
  260. g_value_set_string (value, color_config->printer_profile);
  261. break;
  262. case PROP_DISPLAY_RENDERING_INTENT:
  263. g_value_set_enum (value, color_config->display_intent);
  264. break;
  265. case PROP_SIMULATION_RENDERING_INTENT:
  266. g_value_set_enum (value, color_config->simulation_intent);
  267. break;
  268. case PROP_DISPLAY_MODULE:
  269. g_value_set_string (value, color_config->display_module);
  270. break;
  271. #if 0
  272. case PROP_OPEN_BEHAVIOUR_NO_PROFILE:
  273. g_value_set_enum (value, color_config->open_behaviour_no_profile);
  274. break;
  275. case PROP_OPEN_BEHAVIOUR_RGB_PROFILE:
  276. g_value_set_enum (value, color_config->open_behaviour_rgb_profile);
  277. break;
  278. case PROP_OPEN_BEHAVIOUR_CMYK_PROFILE:
  279. g_value_set_enum (value, color_config->open_behaviour_cmyk_profile);
  280. break;
  281. #endif
  282. default:
  283. G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
  284. break;
  285. }
  286. }