[gimp] libgimpconfig: add a new set of macros to register serialitable properties



commit a3f127bf5f819c0de218df0c630a6b8c372c0ca6
Author: Michael Natterer <mitch gimp org>
Date:   Tue Feb 9 23:21:22 2016 +0100

    libgimpconfig: add a new set of macros to register serialitable properties
    
    The old GIMP_CONFIG_INSTALL_PROP_FOO() have the problem of always
    passing NULL as the GParamSpec's "nick". I have no clue what we were
    thinking back then, but this has always been a major design flaw
    because (among other problems) it makes it impossible to fully
    auto-generate GUIs based on properties.
    
    Added GIMP_CONFIG_PROP_FOO() macros which do have a "nick" parameter,
    will deprecate the old macros as soon as everything is ported.

 libgimpconfig/gimpconfig-params.h |  128 +++++++++++++++++++++++++------------
 1 files changed, 88 insertions(+), 40 deletions(-)
---
diff --git a/libgimpconfig/gimpconfig-params.h b/libgimpconfig/gimpconfig-params.h
index c88b393..ee7299c 100644
--- a/libgimpconfig/gimpconfig-params.h
+++ b/libgimpconfig/gimpconfig-params.h
@@ -52,7 +52,7 @@ G_BEGIN_DECLS
  * GIMP_CONFIG_PARAM_DEFAULTS  - Don't serialize this property if it has the
  *                               default value.
  * GIMP_CONFIG_PARAM_IGNORE    - This property exists for obscure reasons
- *                               and is needed for backward compatibility.
+ *                               or is needed for backward compatibility.
  *                               Ignore the value read and don't serialize it.
  */
 
@@ -71,106 +71,154 @@ G_BEGIN_DECLS
 
 /* some convenience macros to install object properties */
 
-#define GIMP_CONFIG_INSTALL_PROP_BOOLEAN(class, id, name, blurb, default, flags)\
+#define GIMP_CONFIG_PROP_BOOLEAN(class, id, name, nick, blurb, default, flags) \
   g_object_class_install_property (class, id,\
-                                   g_param_spec_boolean (name, NULL, blurb,\
+                                   g_param_spec_boolean (name, nick, blurb,\
                                    default,\
                                    flags | GIMP_CONFIG_PARAM_FLAGS))
 
-#define GIMP_CONFIG_INSTALL_PROP_RGB(class, id, name, blurb, has_alpha, default, flags) \
+#define GIMP_CONFIG_PROP_INT(class, id, name, nick, blurb, min, max, default, flags) \
   g_object_class_install_property (class, id,\
-                                   gimp_param_spec_rgb (name, NULL, blurb,\
-                                   has_alpha, default, \
+                                   g_param_spec_int (name, nick, blurb,\
+                                   min, max, default,\
                                    flags | GIMP_CONFIG_PARAM_FLAGS))
 
-#define GIMP_CONFIG_INSTALL_PROP_DOUBLE(class, id, name, blurb, min, max, default, flags)\
+#define GIMP_CONFIG_PROP_UINT(class, id, name, nick, blurb, min, max, default, flags) \
   g_object_class_install_property (class, id,\
-                                   g_param_spec_double (name, NULL, blurb,\
+                                   g_param_spec_uint (name, nick, blurb,\
                                    min, max, default,\
                                    flags | GIMP_CONFIG_PARAM_FLAGS))
 
-#define GIMP_CONFIG_INSTALL_PROP_RESOLUTION(class, id, name, blurb, default, flags)\
+#define GIMP_CONFIG_PROP_UNIT(class, id, name, nick, blurb, pixels, percent, default, flags) \
   g_object_class_install_property (class, id,\
-                                   g_param_spec_double (name, NULL, blurb,\
-                                   GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION, \
-                                   default,\
+                                   gimp_param_spec_unit (name, nick, blurb,\
+                                   pixels, percent, default,\
                                    flags | GIMP_CONFIG_PARAM_FLAGS))
 
-#define GIMP_CONFIG_INSTALL_PROP_ENUM(class, id, name, blurb, enum_type, default, flags)\
+#define GIMP_CONFIG_PROP_MEMSIZE(class, id, name, nick, blurb, min, max, default, flags) \
   g_object_class_install_property (class, id,\
-                                   g_param_spec_enum (name, NULL, blurb,\
-                                   enum_type, default,\
+                                   gimp_param_spec_memsize (name, nick, blurb,\
+                                   min, max, default,\
                                    flags | GIMP_CONFIG_PARAM_FLAGS))
 
-#define GIMP_CONFIG_INSTALL_PROP_INT(class, id, name, blurb, min, max, default, flags)\
+#define GIMP_CONFIG_PROP_DOUBLE(class, id, name, nick, blurb, min, max, default, flags) \
   g_object_class_install_property (class, id,\
-                                   g_param_spec_int (name, NULL, blurb,\
+                                   g_param_spec_double (name, nick, blurb,\
                                    min, max, default,\
                                    flags | GIMP_CONFIG_PARAM_FLAGS))
 
-#define GIMP_CONFIG_INSTALL_PROP_MATRIX2(class, id, name, blurb, default, flags)\
+#define GIMP_CONFIG_PROP_RESOLUTION(class, id, name, nick, blurb, default, flags) \
   g_object_class_install_property (class, id,\
-                                   gimp_param_spec_matrix2 (name, NULL, blurb,\
+                                   g_param_spec_double (name, nick, blurb,\
+                                   GIMP_MIN_RESOLUTION, GIMP_MAX_RESOLUTION, \
                                    default,\
                                    flags | GIMP_CONFIG_PARAM_FLAGS))
 
-#define GIMP_CONFIG_INSTALL_PROP_MEMSIZE(class, id, name, blurb, min, max, default, flags)\
+#define GIMP_CONFIG_PROP_ENUM(class, id, name, nick, blurb, enum_type, default, flags) \
   g_object_class_install_property (class, id,\
-                                   gimp_param_spec_memsize (name, NULL, blurb,\
-                                   min, max, default,\
+                                   g_param_spec_enum (name, nick, blurb,\
+                                   enum_type, default,\
                                    flags | GIMP_CONFIG_PARAM_FLAGS))
 
-#define GIMP_CONFIG_INSTALL_PROP_PATH(class, id, name, blurb, path_type, default, flags)\
+#define GIMP_CONFIG_PROP_STRING(class, id, name, nick, blurb, default, flags) \
   g_object_class_install_property (class, id,\
-                                   gimp_param_spec_config_path (name, NULL, blurb,\
-                                   path_type, default,\
+                                   g_param_spec_string (name, nick, blurb,\
+                                   default,\
                                    flags | GIMP_CONFIG_PARAM_FLAGS))
 
-#define GIMP_CONFIG_INSTALL_PROP_STRING(class, id, name, blurb, default, flags)\
+#define GIMP_CONFIG_PROP_PATH(class, id, name, nick, blurb, path_type, default, flags) \
   g_object_class_install_property (class, id,\
-                                   g_param_spec_string (name, NULL, blurb,\
-                                   default,\
+                                   gimp_param_spec_config_path (name, nick, blurb,\
+                                   path_type, default,\
                                    flags | GIMP_CONFIG_PARAM_FLAGS))
 
-#define GIMP_CONFIG_INSTALL_PROP_UINT(class, id, name, blurb, min, max, default, flags)\
+#define GIMP_CONFIG_PROP_RGB(class, id, name, nick, blurb, has_alpha, default, flags) \
   g_object_class_install_property (class, id,\
-                                   g_param_spec_uint (name, NULL, blurb,\
-                                   min, max, default,\
+                                   gimp_param_spec_rgb (name, nick, blurb,\
+                                   has_alpha, default, \
                                    flags | GIMP_CONFIG_PARAM_FLAGS))
 
-#define GIMP_CONFIG_INSTALL_PROP_UNIT(class, id, name, blurb, pixels, percent, default, flags)\
+#define GIMP_CONFIG_PROP_MATRIX2(class, id, name, nick, blurb, default, flags) \
   g_object_class_install_property (class, id,\
-                                   gimp_param_spec_unit (name, NULL, blurb,\
-                                   pixels, percent, default,\
+                                   gimp_param_spec_matrix2 (name, nick, blurb,\
+                                   default,\
                                    flags | GIMP_CONFIG_PARAM_FLAGS))
 
 
 /*  object, boxed and pointer properties are _not_ G_PARAM_CONSTRUCT  */
 
-#define GIMP_CONFIG_INSTALL_PROP_OBJECT(class, id, name, blurb, object_type, flags)\
+#define GIMP_CONFIG_PROP_OBJECT(class, id, name, nick, blurb, object_type, flags) \
   g_object_class_install_property (class, id,\
-                                   g_param_spec_object (name, NULL, blurb,\
+                                   g_param_spec_object (name, nick, blurb,\
                                    object_type,\
                                    flags |\
                                    G_PARAM_READWRITE |\
                                    GIMP_CONFIG_PARAM_SERIALIZE))
 
-#define GIMP_CONFIG_INSTALL_PROP_BOXED(class, id, name, blurb, boxed_type, flags)\
+#define GIMP_CONFIG_PROP_BOXED(class, id, name, nick, blurb, boxed_type, flags) \
   g_object_class_install_property (class, id,\
-                                   g_param_spec_boxed (name, NULL, blurb,\
+                                   g_param_spec_boxed (name, nick, blurb,\
                                    boxed_type,\
                                    flags |\
                                    G_PARAM_READWRITE |\
                                    GIMP_CONFIG_PARAM_SERIALIZE))
 
-#define GIMP_CONFIG_INSTALL_PROP_POINTER(class, id, name, blurb, flags)\
+#define GIMP_CONFIG_PROP_POINTER(class, id, name, nick, blurb, flags)    \
   g_object_class_install_property (class, id,\
-                                   g_param_spec_pointer (name, NULL, blurb,\
+                                   g_param_spec_pointer (name, nick, blurb,\
                                    flags |\
                                    G_PARAM_READWRITE |\
                                    GIMP_CONFIG_PARAM_SERIALIZE))
 
 
+/*  deprecated macros, they all lack the "nick" parameter  */
+
+#define GIMP_CONFIG_INSTALL_PROP_BOOLEAN(class, id, name, blurb, default, flags) \
+  GIMP_CONFIG_PROP_BOOLEAN(class, id, name, NULL, blurb, default, flags);
+
+#define GIMP_CONFIG_INSTALL_PROP_INT(class, id, name, blurb, min, max, default, flags) \
+  GIMP_CONFIG_PROP_INT(class, id, name, NULL, blurb, min, max, default, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_UINT(class, id, name, blurb, min, max, default, flags) \
+  GIMP_CONFIG_PROP_UINT(class, id, name, NULL, blurb, min, max, default, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_UNIT(class, id, name, blurb, pixels, percent, default, flags) \
+  GIMP_CONFIG_PROP_UNIT(class, id, name, NULL, blurb, pixels, percent, default, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_MEMSIZE(class, id, name, blurb, min, max, default, flags) \
+  GIMP_CONFIG_PROP_MEMSIZE(class, id, name, NULL, blurb, min, max, default, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_DOUBLE(class, id, name, blurb, min, max, default, flags) \
+  GIMP_CONFIG_PROP_DOUBLE(class, id, name, NULL, blurb, min, max, default, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_RESOLUTION(class, id, name, blurb, default, flags) \
+  GIMP_CONFIG_PROP_RESOLUTION(class, id, name, NULL, blurb, default, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_ENUM(class, id, name, blurb, enum_type, default, flags) \
+  GIMP_CONFIG_PROP_ENUM(class, id, name, NULL, blurb, enum_type, default, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_STRING(class, id, name, blurb, default, flags) \
+  GIMP_CONFIG_PROP_STRING(class, id, name, NULL, blurb, default, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_PATH(class, id, name, blurb, path_type, default, flags) \
+  GIMP_CONFIG_PROP_PATH(class, id, name, NULL, blurb, path_type, default, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_RGB(class, id, name, blurb, has_alpha, default, flags) \
+  GIMP_CONFIG_PROP_RGB(class, id, name, NULL, blurb, has_alpha, default, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_MATRIX2(class, id, name, blurb, default, flags) \
+  GIMP_CONFIG_PROP_MATRIX2(class, id, name, NULL, blurb, default, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_OBJECT(class, id, name, blurb, object_type, flags) \
+  GIMP_CONFIG_PROP_OBJECT(class, id, name, NULL, blurb, object_type, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_BOXED(class, id, name, blurb, boxed_type, flags) \
+  GIMP_CONFIG_PROP_BOXED(class, id, name, NULL, blurb, boxed_type, flags)
+
+#define GIMP_CONFIG_INSTALL_PROP_POINTER(class, id, name, blurb, flags) \
+  GIMP_CONFIG_PROP_POINTER(class, id, name, NULL, blurb, flags)
+
+
 G_END_DECLS
 
 #endif /* __GIMP_CONFIG_PARAMS_H__ */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]