[gimp] app: wrap GimpBezierDesc in a boxed type to make property handling easier
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: wrap GimpBezierDesc in a boxed type to make property handling easier
- Date: Fri, 8 Oct 2010 16:53:12 +0000 (UTC)
commit 6b8141d548cec2983cb681dabf6cbfd7e83f941c
Author: Michael Natterer <mitch gimp org>
Date: Fri Oct 8 18:52:28 2010 +0200
app: wrap GimpBezierDesc in a boxed type to make property handling easier
app/display/gimpcanvaspath.c | 24 +++++++--------------
app/display/gimpdisplayshell-handlers.c | 2 +-
app/vectors/gimpbezierdesc.c | 35 +++++++++++++++----------------
app/vectors/gimpbezierdesc.h | 14 ++++++++----
app/vectors/gimpvectors.c | 6 ++--
5 files changed, 38 insertions(+), 43 deletions(-)
---
diff --git a/app/display/gimpcanvaspath.c b/app/display/gimpcanvaspath.c
index 6baf446..0db0285 100644
--- a/app/display/gimpcanvaspath.c
+++ b/app/display/gimpcanvaspath.c
@@ -104,8 +104,9 @@ gimp_canvas_path_class_init (GimpCanvasPathClass *klass)
item_class->stroke = gimp_canvas_path_stroke;
g_object_class_install_property (object_class, PROP_PATH,
- g_param_spec_pointer ("path", NULL, NULL,
- GIMP_PARAM_READWRITE));
+ g_param_spec_boxed ("path", NULL, NULL,
+ GIMP_TYPE_BEZIER_DESC,
+ GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_FILLED,
g_param_spec_boolean ("filled", NULL, NULL,
@@ -133,7 +134,7 @@ gimp_canvas_path_finalize (GObject *object)
if (private->path)
{
- gimp_bezier_desc_free (private->path, TRUE);
+ gimp_bezier_desc_free (private->path);
private->path = NULL;
}
@@ -151,18 +152,9 @@ gimp_canvas_path_set_property (GObject *object,
switch (property_id)
{
case PROP_PATH:
- {
- cairo_path_t *path = g_value_get_pointer (value);
-
- if (private->path)
- {
- gimp_bezier_desc_free (private->path, TRUE);
- private->path = NULL;
- }
-
- if (path)
- private->path = gimp_bezier_desc_copy (path);
- }
+ if (private->path)
+ gimp_bezier_desc_free (private->path);
+ private->path = g_value_dup_boxed (value);
break;
case PROP_FILLED:
private->filled = g_value_get_boolean (value);
@@ -188,7 +180,7 @@ gimp_canvas_path_get_property (GObject *object,
switch (property_id)
{
case PROP_PATH:
- g_value_set_pointer (value, private->path);
+ g_value_set_boxed (value, private->path);
break;
case PROP_FILLED:
g_value_set_boolean (value, private->filled);
diff --git a/app/display/gimpdisplayshell-handlers.c b/app/display/gimpdisplayshell-handlers.c
index 6eceadd..ac333ef 100644
--- a/app/display/gimpdisplayshell-handlers.c
+++ b/app/display/gimpdisplayshell-handlers.c
@@ -823,7 +823,7 @@ static void
gimp_display_shell_active_vectors_handler (GimpImage *image,
GimpDisplayShell *shell)
{
- GimpCanvasProxyGroup *group = GIMP_CANVAS_PROXY_GROUP (shell->vectors);
+ GimpCanvasProxyGroup *group = GIMP_CANVAS_PROXY_GROUP (shell->vectors);
GimpVectors *active = gimp_image_get_active_vectors (image);
GList *list;
diff --git a/app/vectors/gimpbezierdesc.c b/app/vectors/gimpbezierdesc.c
index 8d52f63..1a88dee 100644
--- a/app/vectors/gimpbezierdesc.c
+++ b/app/vectors/gimpbezierdesc.c
@@ -28,6 +28,19 @@
#include "gimpbezierdesc.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;
+}
+
GimpBezierDesc *
gimp_bezier_desc_new (cairo_path_data_t *data,
gint n_data)
@@ -55,25 +68,11 @@ gimp_bezier_desc_copy (const GimpBezierDesc *desc)
desc->num_data);
}
-cairo_path_data_t *
-gimp_bezier_desc_free (GimpBezierDesc *desc,
- gboolean free_data)
+void
+gimp_bezier_desc_free (GimpBezierDesc *desc)
{
- cairo_path_data_t *data;
-
- g_return_val_if_fail (desc != NULL, NULL);
-
- if (free_data)
- {
- g_free (desc->data);
- data = NULL;
- }
- else
- {
- data = desc->data;
- }
+ g_return_if_fail (desc != NULL);
+ g_free (desc->data);
g_slice_free (GimpBezierDesc, desc);
-
- return data;
}
diff --git a/app/vectors/gimpbezierdesc.h b/app/vectors/gimpbezierdesc.h
index fbcacb9..a5f26d3 100644
--- a/app/vectors/gimpbezierdesc.h
+++ b/app/vectors/gimpbezierdesc.h
@@ -22,12 +22,16 @@
#define __GIMP_BEZIER_DESC_H__
+#define GIMP_TYPE_BEZIER_DESC (gimp_bezier_desc_get_type ())
+
+GType gimp_bezier_desc_get_type (void) G_GNUC_CONST;
+
+
/* takes ownership of "data" */
-GimpBezierDesc * gimp_bezier_desc_new (cairo_path_data_t *data,
- gint n_data);
-GimpBezierDesc * gimp_bezier_desc_copy (const GimpBezierDesc *desc);
-cairo_path_data_t * gimp_bezier_desc_free (GimpBezierDesc *desc,
- gboolean free_data);
+GimpBezierDesc * gimp_bezier_desc_new (cairo_path_data_t *data,
+ gint n_data);
+GimpBezierDesc * gimp_bezier_desc_copy (const GimpBezierDesc *desc);
+void gimp_bezier_desc_free (GimpBezierDesc *desc);
#endif /* __GIMP_BEZIER_DESC_H__ */
diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c
index e8d66ab..d8e0ded 100644
--- a/app/vectors/gimpvectors.c
+++ b/app/vectors/gimpvectors.c
@@ -261,7 +261,7 @@ gimp_vectors_finalize (GObject *object)
if (vectors->bezier_desc)
{
- gimp_bezier_desc_free (vectors->bezier_desc, TRUE);
+ gimp_bezier_desc_free (vectors->bezier_desc);
vectors->bezier_desc = NULL;
}
@@ -613,7 +613,7 @@ gimp_vectors_real_freeze (GimpVectors *vectors)
/* release cached bezier representation */
if (vectors->bezier_desc)
{
- gimp_bezier_desc_free (vectors->bezier_desc, TRUE);
+ gimp_bezier_desc_free (vectors->bezier_desc);
vectors->bezier_desc = NULL;
}
@@ -1158,7 +1158,7 @@ gimp_vectors_real_make_bezier (const GimpVectors *vectors)
{
cmd_array = g_array_append_vals (cmd_array, bezdesc->data,
bezdesc->num_data);
- gimp_bezier_desc_free (bezdesc, TRUE);
+ gimp_bezier_desc_free (bezdesc);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]