[gimp/wip/nielsdg/g-define-boxed-type: 2/4] app: Use G_DEFINE_BOXED_TYPE()



commit 21ba21355dda8253e9d34743079519bfef6f35c3
Author: Niels De Graef <nielsdegraef gmail com>
Date:   Wed Jul 17 06:59:53 2019 +0200

    app: Use G_DEFINE_BOXED_TYPE()
    
    This isn't any functional change, but allows us to get rid of some of
    the GObject boilerplate.

 app/core/gimpbezierdesc.c  | 13 +------
 app/core/gimpdashpattern.c | 13 +------
 app/core/gimpparamspecs.c  | 96 ++++------------------------------------------
 app/vectors/gimpanchor.c   | 13 +------
 4 files changed, 10 insertions(+), 125 deletions(-)
---
diff --git a/app/core/gimpbezierdesc.c b/app/core/gimpbezierdesc.c
index 6047544a67..65acd9f24f 100644
--- a/app/core/gimpbezierdesc.c
+++ b/app/core/gimpbezierdesc.c
@@ -29,18 +29,7 @@
 #include "gimpboundary.h"
 
 
-GType
-gimp_bezier_desc_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpBezierDesc",
-                                         (GBoxedCopyFunc) gimp_bezier_desc_copy,
-                                         (GBoxedFreeFunc) gimp_bezier_desc_free);
-
-  return type;
-}
+G_DEFINE_BOXED_TYPE (GimpBezierDesc, gimp_bezier_desc, gimp_bezier_desc_copy, gimp_bezier_desc_free)
 
 GimpBezierDesc *
 gimp_bezier_desc_new (cairo_path_data_t *data,
diff --git a/app/core/gimpdashpattern.c b/app/core/gimpdashpattern.c
index e9fb9fc9a2..a2c7bca5b1 100644
--- a/app/core/gimpdashpattern.c
+++ b/app/core/gimpdashpattern.c
@@ -30,18 +30,7 @@
 #include "gimpdashpattern.h"
 
 
-GType
-gimp_dash_pattern_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpDashPattern",
-                                         (GBoxedCopyFunc) gimp_dash_pattern_copy,
-                                         (GBoxedFreeFunc) gimp_dash_pattern_free);
-
-  return type;
-}
+G_DEFINE_BOXED_TYPE (GimpDashPattern, gimp_dash_pattern, gimp_dash_pattern_copy, gimp_dash_pattern_free)
 
 GArray *
 gimp_dash_pattern_new_from_preset (GimpDashPreset preset)
diff --git a/app/core/gimpparamspecs.c b/app/core/gimpparamspecs.c
index 17ba6a54e3..8cdde7a0fb 100644
--- a/app/core/gimpparamspecs.c
+++ b/app/core/gimpparamspecs.c
@@ -1861,18 +1861,7 @@ gimp_array_free (GimpArray *array)
     }
 }
 
-GType
-gimp_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpArray",
-                                         (GBoxedCopyFunc) gimp_array_copy,
-                                         (GBoxedFreeFunc) gimp_array_free);
-
-  return type;
-}
+G_DEFINE_BOXED_TYPE (GimpArray, gimp_array, gimp_array_copy, gimp_array_free)
 
 
 /*
@@ -2038,19 +2027,7 @@ gimp_value_take_array (GValue *value,
 /*
  * GIMP_TYPE_INT8_ARRAY
  */
-
-GType
-gimp_int8_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpInt8Array",
-                                         (GBoxedCopyFunc) gimp_array_copy,
-                                         (GBoxedFreeFunc) gimp_array_free);
-
-  return type;
-}
+G_DEFINE_BOXED_TYPE (GimpInt8Array, gimp_int8_array, gimp_array_copy, gimp_array_free)
 
 
 /*
@@ -2160,19 +2137,7 @@ gimp_value_take_int8array (GValue *value,
 /*
  * GIMP_TYPE_INT16_ARRAY
  */
-
-GType
-gimp_int16_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpInt16Array",
-                                         (GBoxedCopyFunc) gimp_array_copy,
-                                         (GBoxedFreeFunc) gimp_array_free);
-
-  return type;
-}
+G_DEFINE_BOXED_TYPE (GimpInt16Array, gimp_int16_array, gimp_array_copy, gimp_array_free)
 
 
 /*
@@ -2285,19 +2250,7 @@ gimp_value_take_int16array (GValue *value,
 /*
  * GIMP_TYPE_INT32_ARRAY
  */
-
-GType
-gimp_int32_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpInt32Array",
-                                         (GBoxedCopyFunc) gimp_array_copy,
-                                         (GBoxedFreeFunc) gimp_array_free);
-
-  return type;
-}
+G_DEFINE_BOXED_TYPE (GimpInt32Array, gimp_int32_array, gimp_array_copy, gimp_array_free)
 
 
 /*
@@ -2410,19 +2363,7 @@ gimp_value_take_int32array (GValue *value,
 /*
  * GIMP_TYPE_FLOAT_ARRAY
  */
-
-GType
-gimp_float_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpFloatArray",
-                                         (GBoxedCopyFunc) gimp_array_copy,
-                                         (GBoxedFreeFunc) gimp_array_free);
-
-  return type;
-}
+G_DEFINE_BOXED_TYPE (GimpFloatArray, gimp_float_array, gimp_array_copy, gimp_array_free)
 
 
 /*
@@ -2599,18 +2540,7 @@ gimp_string_array_free (GimpArray *array)
     }
 }
 
-GType
-gimp_string_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpStringArray",
-                                         (GBoxedCopyFunc) gimp_string_array_copy,
-                                         (GBoxedFreeFunc) gimp_string_array_free);
-
-  return type;
-}
+G_DEFINE_BOXED_TYPE (GimpStringArray, gimp_string_array, gimp_array_copy, gimp_array_free)
 
 
 /*
@@ -2803,19 +2733,7 @@ gimp_value_take_stringarray (GValue  *value,
 /*
  * GIMP_TYPE_COLOR_ARRAY
  */
-
-GType
-gimp_color_array_get_type (void)
-{
-  static GType type = 0;
-
-  if (! type)
-    type = g_boxed_type_register_static ("GimpColorArray",
-                                         (GBoxedCopyFunc) gimp_array_copy,
-                                         (GBoxedFreeFunc) gimp_array_free);
-
-  return type;
-}
+G_DEFINE_BOXED_TYPE (GimpColorArray, gimp_color_array, gimp_array_copy, gimp_array_free)
 
 
 /*
diff --git a/app/vectors/gimpanchor.c b/app/vectors/gimpanchor.c
index f5085cdb60..fa348ae798 100644
--- a/app/vectors/gimpanchor.c
+++ b/app/vectors/gimpanchor.c
@@ -27,18 +27,7 @@
 #include "gimpanchor.h"
 
 
-GType
-gimp_anchor_get_type (void)
-{
-  static GType anchor_type = 0;
-
-  if (!anchor_type)
-    anchor_type = g_boxed_type_register_static ("GimpAnchor",
-                                                (GBoxedCopyFunc) gimp_anchor_copy,
-                                                (GBoxedFreeFunc) gimp_anchor_free);
-
-  return anchor_type;
-}
+G_DEFINE_BOXED_TYPE (GimpAnchor, gimp_anchor, gimp_anchor_copy, gimp_anchor_free)
 
 GimpAnchor *
 gimp_anchor_new (GimpAnchorType    type,


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