gimpconfig-params.h 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. /* LIBGIMP - The GIMP Library
  2. * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. *
  4. * ParamSpecs for config objects
  5. * Copyright (C) 2001 Sven Neumann <sven@gimp.org>
  6. * 2001-2019 Michael Natterer <mitch@gimp.org>
  7. *
  8. * This library is free software: you can redistribute it and/or
  9. * modify it under the terms of the GNU Lesser General Public
  10. * License as published by the Free Software Foundation; either
  11. * version 3 of the License, or (at your option) any later version.
  12. *
  13. * This library is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * Library General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with this library. If not, see
  20. * <https://www.gnu.org/licenses/>.
  21. */
  22. #if !defined (__GIMP_CONFIG_H_INSIDE__) && !defined (GIMP_CONFIG_COMPILATION)
  23. #error "Only <libgimpconfig/gimpconfig.h> can be included directly."
  24. #endif
  25. #ifndef __GIMP_CONFIG_PARAMS_H__
  26. #define __GIMP_CONFIG_PARAMS_H__
  27. G_BEGIN_DECLS
  28. /* For information look into the C source or the html documentation */
  29. /**
  30. * GIMP_CONFIG_PARAM_SERIALIZE:
  31. *
  32. * A property that can and should be serialized and deserialized.
  33. **/
  34. #define GIMP_CONFIG_PARAM_SERIALIZE (1 << (0 + G_PARAM_USER_SHIFT))
  35. /**
  36. * GIMP_CONFIG_PARAM_AGGREGATE:
  37. *
  38. * The object property is to be treated as part of the parent object.
  39. **/
  40. #define GIMP_CONFIG_PARAM_AGGREGATE (1 << (1 + G_PARAM_USER_SHIFT))
  41. /**
  42. * GIMP_CONFIG_PARAM_RESTART:
  43. *
  44. * Changes to this property take effect only after a restart.
  45. **/
  46. #define GIMP_CONFIG_PARAM_RESTART (1 << (2 + G_PARAM_USER_SHIFT))
  47. /**
  48. * GIMP_CONFIG_PARAM_CONFIRM:
  49. *
  50. * Changes to this property should be confirmed by the user before
  51. * being applied.
  52. **/
  53. #define GIMP_CONFIG_PARAM_CONFIRM (1 << (3 + G_PARAM_USER_SHIFT))
  54. /**
  55. * GIMP_CONFIG_PARAM_DEFAULTS:
  56. *
  57. * Don't serialize this property if it has the default value.
  58. **/
  59. #define GIMP_CONFIG_PARAM_DEFAULTS (1 << (4 + G_PARAM_USER_SHIFT))
  60. /**
  61. * GIMP_CONFIG_PARAM_IGNORE:
  62. *
  63. * This property exists for obscure reasons or is needed for backward
  64. * compatibility. Ignore the value read and don't serialize it.
  65. **/
  66. #define GIMP_CONFIG_PARAM_IGNORE (1 << (5 + G_PARAM_USER_SHIFT))
  67. /**
  68. * GIMP_CONFIG_PARAM_DONT_COMPARE:
  69. *
  70. * Ignore this property when comparing objects.
  71. **/
  72. #define GIMP_CONFIG_PARAM_DONT_COMPARE (1 << (6 + G_PARAM_USER_SHIFT))
  73. /**
  74. * GIMP_CONFIG_PARAM_FLAGS:
  75. *
  76. * The default flags that should be used for serializable #GimpConfig
  77. * properties.
  78. **/
  79. #define GIMP_CONFIG_PARAM_FLAGS (G_PARAM_READWRITE | \
  80. G_PARAM_CONSTRUCT | \
  81. G_PARAM_STATIC_STRINGS | \
  82. GIMP_CONFIG_PARAM_SERIALIZE)
  83. /* some convenience macros to install object properties */
  84. #define GIMP_CONFIG_PROP_BOOLEAN(class, id, name, nick, blurb, default, flags) \
  85. g_object_class_install_property (class, id,\
  86. g_param_spec_boolean (name, nick, blurb,\
  87. default,\
  88. flags | GIMP_CONFIG_PARAM_FLAGS))
  89. #define GIMP_CONFIG_PROP_INT(class, id, name, nick, blurb, min, max, default, flags) \
  90. g_object_class_install_property (class, id,\
  91. g_param_spec_int (name, nick, blurb,\
  92. min, max, default,\
  93. flags | GIMP_CONFIG_PARAM_FLAGS))
  94. #define GIMP_CONFIG_PROP_UINT(class, id, name, nick, blurb, min, max, default, flags) \
  95. g_object_class_install_property (class, id,\
  96. g_param_spec_uint (name, nick, blurb,\
  97. min, max, default,\
  98. flags | GIMP_CONFIG_PARAM_FLAGS))
  99. #define GIMP_CONFIG_PROP_INT64(class, id, name, nick, blurb, min, max, default, flags) \
  100. g_object_class_install_property (class, id,\
  101. g_param_spec_int64 (name, nick, blurb,\
  102. min, max, default,\
  103. flags | GIMP_CONFIG_PARAM_FLAGS))
  104. #define GIMP_CONFIG_PROP_UINT64(class, id, name, nick, blurb, min, max, default, flags) \
  105. g_object_class_install_property (class, id,\
  106. g_param_spec_uint64 (name, nick, blurb,\
  107. min, max, default,\
  108. flags | GIMP_CONFIG_PARAM_FLAGS))
  109. #define GIMP_CONFIG_PROP_UNIT(class, id, name, nick, blurb, pixels, percent, default, flags) \
  110. g_object_class_install_property (class, id,\
  111. gimp_param_spec_unit (name, nick, blurb,\
  112. pixels, percent, default,\
  113. flags | GIMP_CONFIG_PARAM_FLAGS))
  114. #define GIMP_CONFIG_PROP_MEMSIZE(class, id, name, nick, blurb, min, max, default, flags) \
  115. g_object_class_install_property (class, id,\
  116. gimp_param_spec_memsize (name, nick, blurb,\
  117. min, max, default,\
  118. flags | GIMP_CONFIG_PARAM_FLAGS))
  119. #define GIMP_CONFIG_PROP_DOUBLE(class, id, name, nick, blurb, min, max, default, flags) \
  120. g_object_class_install_property (class, id,\
  121. g_param_spec_double (name, nick, blurb,\
  122. min, max, default,\
  123. flags | GIMP_CONFIG_PARAM_FLAGS))
  124. #define GIMP_CONFIG_PROP_RESOLUTION(class, id, name, nick, blurb, default, flags) \
  125. g_object_class_install_property (class, id,\
  126. g_param_spec_double (name, nick, blurb,\
  127. GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION, \
  128. default,\
  129. flags | GIMP_CONFIG_PARAM_FLAGS))
  130. #define GIMP_CONFIG_PROP_ENUM(class, id, name, nick, blurb, enum_type, default, flags) \
  131. g_object_class_install_property (class, id,\
  132. g_param_spec_enum (name, nick, blurb,\
  133. enum_type, default,\
  134. flags | GIMP_CONFIG_PARAM_FLAGS))
  135. #define GIMP_CONFIG_PROP_STRING(class, id, name, nick, blurb, default, flags) \
  136. g_object_class_install_property (class, id,\
  137. g_param_spec_string (name, nick, blurb,\
  138. default,\
  139. flags | GIMP_CONFIG_PARAM_FLAGS))
  140. #define GIMP_CONFIG_PROP_PATH(class, id, name, nick, blurb, path_type, default, flags) \
  141. g_object_class_install_property (class, id,\
  142. gimp_param_spec_config_path (name, nick, blurb,\
  143. path_type, default,\
  144. flags | GIMP_CONFIG_PARAM_FLAGS))
  145. #define GIMP_CONFIG_PROP_MATRIX2(class, id, name, nick, blurb, default, flags) \
  146. g_object_class_install_property (class, id,\
  147. gimp_param_spec_matrix2 (name, nick, blurb,\
  148. default,\
  149. flags | GIMP_CONFIG_PARAM_FLAGS))
  150. #define GIMP_CONFIG_PROP_FONT(class, id, name, nick, blurb, flags) \
  151. g_object_class_install_property (class, id,\
  152. g_param_spec_object (name, nick, blurb,\
  153. GIMP_TYPE_FONT,\
  154. flags | GIMP_CONFIG_PARAM_FLAGS))
  155. /* object, boxed and pointer properties are _not_ G_PARAM_CONSTRUCT */
  156. #define GIMP_CONFIG_PROP_OBJECT(class, id, name, nick, blurb, object_type, flags) \
  157. g_object_class_install_property (class, id,\
  158. g_param_spec_object (name, nick, blurb,\
  159. object_type,\
  160. flags |\
  161. G_PARAM_READWRITE |\
  162. GIMP_CONFIG_PARAM_SERIALIZE))
  163. #define GIMP_CONFIG_PROP_COLOR(class, id, name, nick, blurb, has_alpha, default, flags) \
  164. g_object_class_install_property (class, id,\
  165. gimp_param_spec_color (name, nick, blurb,\
  166. has_alpha, default,\
  167. flags |\
  168. G_PARAM_READWRITE |\
  169. GIMP_CONFIG_PARAM_SERIALIZE))
  170. #define GIMP_CONFIG_PROP_BOXED(class, id, name, nick, blurb, boxed_type, flags) \
  171. g_object_class_install_property (class, id,\
  172. g_param_spec_boxed (name, nick, blurb,\
  173. boxed_type,\
  174. flags |\
  175. G_PARAM_READWRITE |\
  176. GIMP_CONFIG_PARAM_SERIALIZE))
  177. #define GIMP_CONFIG_PROP_POINTER(class, id, name, nick, blurb, flags) \
  178. g_object_class_install_property (class, id,\
  179. g_param_spec_pointer (name, nick, blurb,\
  180. flags |\
  181. G_PARAM_READWRITE |\
  182. GIMP_CONFIG_PARAM_SERIALIZE))
  183. /* create a copy of a GParamSpec */
  184. GParamSpec * gimp_config_param_spec_duplicate (GParamSpec *pspec);
  185. G_END_DECLS
  186. #endif /* __GIMP_CONFIG_PARAMS_H__ */