mirror of https://github.com/GNOME/gimp.git
app: wrap GimpBezierDesc in a boxed type to make property handling easier
This commit is contained in:
parent
914ac9aa11
commit
6b8141d548
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue