diff --git a/ChangeLog b/ChangeLog index 9b6f1eb1a8..973835c187 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2003-01-31 Michael Natterer + + * app/core/gimpitem.[ch]: added gimp_item_configure() and + gimp_item_copy(). + + * app/core/gimpdrawable.c (gimp_drawable_configure,copy): use them. + + * app/vectors/gimpvectors.[ch]: added gimp_vectors_new(), + gimp_vectors_copy() and gimp_vectors_copy_points(). Use the new + GimpItem functions just as GimpDrawable does. Added a + get_memsize() implementation. + + * app/vectors/gimpstroke.[ch]: made it a GimpObject and added + a get_memsize() implementation. + + * app/undo.c: implemented vectors undo as if the new GimpVectors + functions above worked. + + * app/gui/dialogs-constructors.c + * app/gui/vectors-commands.c + * app/tools/gimpvectortool.c: use gimp_vectors_new,copy(). + 2003-01-31 Sven Neumann * app/core/gimpdrawable.[ch]: added offset_x and offset_y to diff --git a/app/actions/vectors-commands.c b/app/actions/vectors-commands.c index 284c5dd99f..739332c4cf 100644 --- a/app/actions/vectors-commands.c +++ b/app/actions/vectors-commands.c @@ -122,18 +122,11 @@ vectors_duplicate_vectors_cmd_callback (GtkWidget *widget, GimpVectors *new_vectors; return_if_no_vectors (gimage, active_vectors, data); - new_vectors = NULL; - -#ifdef __GNUC__ -#warning FIXME: need gimp_vectors_copy() -#endif -#if 0 new_vectors = gimp_vectors_copy (active_vectors, G_TYPE_FROM_INSTANCE (active_vectors), TRUE); gimp_image_add_vectors (gimage, new_vectors, -1); gimp_image_flush (gimage); -#endif } void @@ -410,12 +403,10 @@ new_vectors_query_ok_callback (GtkWidget *widget, if ((gimage = options->gimage)) { - new_vectors = g_object_new (GIMP_TYPE_VECTORS, NULL); + new_vectors = gimp_vectors_new (gimage, vectors_name); gimp_image_add_vectors (gimage, new_vectors, -1); - gimp_object_set_name (GIMP_OBJECT (new_vectors), vectors_name); - gimp_image_flush (gimage); } @@ -440,12 +431,10 @@ vectors_new_vectors_query (GimpImage *gimage, { GimpVectors *new_vectors; - new_vectors = g_object_new (GIMP_TYPE_VECTORS, NULL); + new_vectors = gimp_vectors_new (gimage, _("Empty Vectors Copy")); gimp_image_add_vectors (gimage, new_vectors, -1); - gimp_object_set_name (GIMP_OBJECT (new_vectors), - _("Empty Vectors Copy")); return; } diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c index 4ae6952ae9..ebbd0b72e2 100644 --- a/app/core/gimpdrawable.c +++ b/app/core/gimpdrawable.c @@ -226,11 +226,9 @@ gimp_drawable_configure (GimpDrawable *drawable, g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (GIMP_IS_IMAGE (gimage)); - GIMP_ITEM (drawable)->ID = gimage->gimp->next_item_ID++; - - g_hash_table_insert (gimage->gimp->item_table, - GINT_TO_POINTER (GIMP_ITEM (drawable)->ID), - drawable); + /* if not already configured by gimp_item_copy() */ + if (! GIMP_ITEM (drawable)->ID) + gimp_item_configure (GIMP_ITEM (drawable), gimage, name); drawable->width = width; drawable->height = height; @@ -248,10 +246,6 @@ gimp_drawable_configure (GimpDrawable *drawable, drawable->visible = TRUE; - gimp_item_set_image (GIMP_ITEM (drawable), gimage); - - gimp_object_set_name (GIMP_OBJECT (drawable), name ? name : _("Unnamed")); - /* preview variables */ drawable->preview_cache = NULL; drawable->preview_valid = FALSE; @@ -266,49 +260,18 @@ gimp_drawable_copy (GimpDrawable *drawable, GimpImageType new_image_type; PixelRegion srcPR; PixelRegion destPR; - gchar *new_name; g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL); g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_DRAWABLE), NULL); - /* formulate the new name */ - { - const gchar *name; - gchar *ext; - gint number; - gint len; - - name = gimp_object_get_name (GIMP_OBJECT (drawable)); - - g_return_val_if_fail (name != NULL, NULL); - - ext = strrchr (name, '#'); - len = strlen (_("copy")); - - if ((strlen (name) >= len && - strcmp (&name[strlen (name) - len], _("copy")) == 0) || - (ext && (number = atoi (ext + 1)) > 0 && - ((int)(log10 (number) + 1)) == strlen (ext + 1))) - { - /* don't have redundant "copy"s */ - new_name = g_strdup (name); - } - else - { - new_name = g_strdup_printf (_("%s copy"), name); - } - } + new_drawable = GIMP_DRAWABLE (gimp_item_copy (GIMP_ITEM (drawable), + new_type, + add_alpha)); if (add_alpha) - { - new_image_type = gimp_drawable_type_with_alpha (drawable); - } + new_image_type = gimp_drawable_type_with_alpha (drawable); else - { - new_image_type = drawable->type; - } - - new_drawable = g_object_new (new_type, NULL); + new_image_type = gimp_drawable_type (drawable); gimp_drawable_configure (new_drawable, gimp_item_get_image (GIMP_ITEM (drawable)), @@ -317,34 +280,25 @@ gimp_drawable_copy (GimpDrawable *drawable, gimp_drawable_width (drawable), gimp_drawable_height (drawable), new_image_type, - new_name); - g_free (new_name); + GIMP_OBJECT (new_drawable)->name); - new_drawable->visible = drawable->visible; + new_drawable->visible = drawable->visible; pixel_region_init (&srcPR, drawable->tiles, 0, 0, - drawable->width, - drawable->height, + gimp_drawable_width (drawable), + gimp_drawable_height (drawable), FALSE); pixel_region_init (&destPR, new_drawable->tiles, 0, 0, - drawable->width, - drawable->height, + gimp_drawable_width (new_drawable), + gimp_drawable_height (new_drawable), TRUE); if (new_image_type == drawable->type) - { - copy_region (&srcPR, &destPR); - } + copy_region (&srcPR, &destPR); else - { - add_alpha_region (&srcPR, &destPR); - } - - g_object_unref (GIMP_ITEM (new_drawable)->parasites); - GIMP_ITEM (new_drawable)->parasites = - gimp_parasite_list_copy (GIMP_ITEM (drawable)->parasites); + add_alpha_region (&srcPR, &destPR); return new_drawable; } diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index 1055acb87b..24a75b6fca 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -52,6 +52,8 @@ #include "paint/gimppaintcore.h" +#include "vectors/gimpvectors.h" + #include "tools/gimpbycolorselecttool.h" #include "tools/gimppainttool.h" #include "tools/gimptransformtool.h" @@ -2710,7 +2712,9 @@ undo_push_vectors_mod (GimpImage *gimage, new->free_func = undo_free_vectors_mod; vmu->vectors = vectors; - vmu->undo_vectors = NULL; /* gimp_vectors_duplicate (vectors); */ + vmu->undo_vectors = gimp_vectors_copy (vectors, + G_TYPE_FROM_INSTANCE (vectors), + FALSE); return TRUE; } @@ -2731,11 +2735,13 @@ undo_pop_vectors_mod (GimpImage *gimage, temp = vmu->undo_vectors; - vmu->undo_vectors = NULL; /* gimp_vectors_duplicate (vmu->vectors); */ + vmu->undo_vectors = gimp_vectors_copy (vmu->vectors, + G_TYPE_FROM_INSTANCE (vmu->vectors), + FALSE); - /* gimp_vectors_copy_strokes (temp, vmu->vectors); */ + gimp_vectors_copy_strokes (temp, vmu->vectors); - /* g_object_unref (temp); */ + g_object_unref (temp); return TRUE; } @@ -2749,7 +2755,7 @@ undo_free_vectors_mod (UndoState state, vmu = (VectorsModUndo *) vmu_ptr; - /* g_object_unref (vmu->undo_vectors); */ + g_object_unref (vmu->undo_vectors); g_free (vmu); } diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c index 109a14487e..ee91c05fd3 100644 --- a/app/core/gimpitem.c +++ b/app/core/gimpitem.c @@ -279,6 +279,79 @@ gimp_item_removed (GimpItem *item) g_signal_emit (item, gimp_item_signals[REMOVED], 0); } +void +gimp_item_configure (GimpItem *item, + GimpImage *gimage, + const gchar *name) +{ + g_return_if_fail (GIMP_IS_ITEM (item)); + g_return_if_fail (item->ID == 0); + g_return_if_fail (item->gimage == 0); + g_return_if_fail (GIMP_IS_IMAGE (gimage)); + + item->ID = gimage->gimp->next_item_ID++; + + g_hash_table_insert (gimage->gimp->item_table, + GINT_TO_POINTER (item->ID), + item); + + gimp_item_set_image (item, gimage); + + gimp_object_set_name (GIMP_OBJECT (item), name ? name : _("Unnamed")); +} + +GimpItem * +gimp_item_copy (GimpItem *item, + GType new_type, + gboolean add_alpha) +{ + GimpItem *new_item; + gchar *new_name; + + g_return_val_if_fail (GIMP_IS_ITEM (item), NULL); + g_return_val_if_fail (GIMP_IS_IMAGE (item->gimage), NULL); + g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_ITEM), NULL); + + /* formulate the new name */ + { + const gchar *name; + gchar *ext; + gint number; + gint len; + + name = gimp_object_get_name (GIMP_OBJECT (item)); + + g_return_val_if_fail (name != NULL, NULL); + + ext = strrchr (name, '#'); + len = strlen (_("copy")); + + if ((strlen (name) >= len && + strcmp (&name[strlen (name) - len], _("copy")) == 0) || + (ext && (number = atoi (ext + 1)) > 0 && + ((int)(log10 (number) + 1)) == strlen (ext + 1))) + { + /* don't have redundant "copy"s */ + new_name = g_strdup (name); + } + else + { + new_name = g_strdup_printf (_("%s copy"), name); + } + } + + new_item = g_object_new (new_type, NULL); + + gimp_item_configure (new_item, gimp_item_get_image (item), new_name); + + g_free (new_name); + + g_object_unref (new_item->parasites); + new_item->parasites = gimp_parasite_list_copy (item->parasites); + + return new_item; +} + gint gimp_item_get_ID (GimpItem *item) { diff --git a/app/core/gimpitem.h b/app/core/gimpitem.h index 2ed2b9d229..b2bcbfca3d 100644 --- a/app/core/gimpitem.h +++ b/app/core/gimpitem.h @@ -57,6 +57,13 @@ GType gimp_item_get_type (void) G_GNUC_CONST; void gimp_item_removed (GimpItem *item); +void gimp_item_configure (GimpItem *item, + GimpImage *gimage, + const gchar *name); +GimpItem * gimp_item_copy (GimpItem *item, + GType new_type, + gboolean add_alpha); + gint gimp_item_get_ID (GimpItem *item); GimpItem * gimp_item_get_by_ID (Gimp *gimp, gint id); diff --git a/app/dialogs/dialogs-constructors.c b/app/dialogs/dialogs-constructors.c index a8fac7b708..d5d55ce149 100644 --- a/app/dialogs/dialogs-constructors.c +++ b/app/dialogs/dialogs-constructors.c @@ -703,17 +703,6 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory, return dockable; } -static GimpVectors * -gimp_vectors_copy (const GimpVectors *vectors, - GType new_type, - gboolean add_alpha /* unused */) -{ - g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL); - g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_VECTORS), NULL); - - return NULL; -} - GtkWidget * dialogs_vectors_list_view_new (GimpDialogFactory *factory, GimpContext *context, diff --git a/app/gui/dialogs-constructors.c b/app/gui/dialogs-constructors.c index a8fac7b708..d5d55ce149 100644 --- a/app/gui/dialogs-constructors.c +++ b/app/gui/dialogs-constructors.c @@ -703,17 +703,6 @@ dialogs_channel_list_view_new (GimpDialogFactory *factory, return dockable; } -static GimpVectors * -gimp_vectors_copy (const GimpVectors *vectors, - GType new_type, - gboolean add_alpha /* unused */) -{ - g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL); - g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_VECTORS), NULL); - - return NULL; -} - GtkWidget * dialogs_vectors_list_view_new (GimpDialogFactory *factory, GimpContext *context, diff --git a/app/gui/vectors-commands.c b/app/gui/vectors-commands.c index 284c5dd99f..739332c4cf 100644 --- a/app/gui/vectors-commands.c +++ b/app/gui/vectors-commands.c @@ -122,18 +122,11 @@ vectors_duplicate_vectors_cmd_callback (GtkWidget *widget, GimpVectors *new_vectors; return_if_no_vectors (gimage, active_vectors, data); - new_vectors = NULL; - -#ifdef __GNUC__ -#warning FIXME: need gimp_vectors_copy() -#endif -#if 0 new_vectors = gimp_vectors_copy (active_vectors, G_TYPE_FROM_INSTANCE (active_vectors), TRUE); gimp_image_add_vectors (gimage, new_vectors, -1); gimp_image_flush (gimage); -#endif } void @@ -410,12 +403,10 @@ new_vectors_query_ok_callback (GtkWidget *widget, if ((gimage = options->gimage)) { - new_vectors = g_object_new (GIMP_TYPE_VECTORS, NULL); + new_vectors = gimp_vectors_new (gimage, vectors_name); gimp_image_add_vectors (gimage, new_vectors, -1); - gimp_object_set_name (GIMP_OBJECT (new_vectors), vectors_name); - gimp_image_flush (gimage); } @@ -440,12 +431,10 @@ vectors_new_vectors_query (GimpImage *gimage, { GimpVectors *new_vectors; - new_vectors = g_object_new (GIMP_TYPE_VECTORS, NULL); + new_vectors = gimp_vectors_new (gimage, _("Empty Vectors Copy")); gimp_image_add_vectors (gimage, new_vectors, -1); - gimp_object_set_name (GIMP_OBJECT (new_vectors), - _("Empty Vectors Copy")); return; } diff --git a/app/tools/gimpvectortool.c b/app/tools/gimpvectortool.c index 2069a05875..d9ed1d41b8 100644 --- a/app/tools/gimpvectortool.c +++ b/app/tools/gimpvectortool.c @@ -302,10 +302,9 @@ gimp_vector_tool_button_press (GimpTool *tool, { GimpVectors *vectors; - vectors = g_object_new (GIMP_TYPE_VECTORS, NULL); + vectors = gimp_vectors_new (gdisp->gimage, _("Unnamed")); gimp_image_add_vectors (gdisp->gimage, vectors, -1); - gimp_object_set_name (GIMP_OBJECT (vectors), _("Unnamed")); vector_tool->vectors = g_object_ref (vectors); } diff --git a/app/undo.c b/app/undo.c index 1055acb87b..24a75b6fca 100644 --- a/app/undo.c +++ b/app/undo.c @@ -52,6 +52,8 @@ #include "paint/gimppaintcore.h" +#include "vectors/gimpvectors.h" + #include "tools/gimpbycolorselecttool.h" #include "tools/gimppainttool.h" #include "tools/gimptransformtool.h" @@ -2710,7 +2712,9 @@ undo_push_vectors_mod (GimpImage *gimage, new->free_func = undo_free_vectors_mod; vmu->vectors = vectors; - vmu->undo_vectors = NULL; /* gimp_vectors_duplicate (vectors); */ + vmu->undo_vectors = gimp_vectors_copy (vectors, + G_TYPE_FROM_INSTANCE (vectors), + FALSE); return TRUE; } @@ -2731,11 +2735,13 @@ undo_pop_vectors_mod (GimpImage *gimage, temp = vmu->undo_vectors; - vmu->undo_vectors = NULL; /* gimp_vectors_duplicate (vmu->vectors); */ + vmu->undo_vectors = gimp_vectors_copy (vmu->vectors, + G_TYPE_FROM_INSTANCE (vmu->vectors), + FALSE); - /* gimp_vectors_copy_strokes (temp, vmu->vectors); */ + gimp_vectors_copy_strokes (temp, vmu->vectors); - /* g_object_unref (temp); */ + g_object_unref (temp); return TRUE; } @@ -2749,7 +2755,7 @@ undo_free_vectors_mod (UndoState state, vmu = (VectorsModUndo *) vmu_ptr; - /* g_object_unref (vmu->undo_vectors); */ + g_object_unref (vmu->undo_vectors); g_free (vmu); } diff --git a/app/vectors/gimpstroke.c b/app/vectors/gimpstroke.c index d878790146..1a304ee825 100644 --- a/app/vectors/gimpstroke.c +++ b/app/vectors/gimpstroke.c @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include "glib-object.h" @@ -30,12 +29,6 @@ #include "gimpstroke.h" - -/* private variables */ - - -static GObjectClass *parent_class = NULL; - /* Prototypes */ static void gimp_stroke_class_init (GimpStrokeClass *klass); @@ -43,6 +36,8 @@ static void gimp_stroke_init (GimpStroke *stroke); static void gimp_stroke_finalize (GObject *object); +static gsize gimp_stroke_get_memsize (GimpObject *object); + static GimpAnchor * gimp_stroke_real_anchor_get (const GimpStroke *stroke, const GimpCoords *coord); static GimpAnchor * gimp_stroke_real_anchor_get_next (const GimpStroke *stroke, @@ -57,6 +52,11 @@ static void gimp_stroke_real_anchor_move_absolute (GimpStroke *stroke, const gint type); +/* private variables */ + +static GObjectClass *parent_class = NULL; + + GType gimp_stroke_get_type (void) { @@ -77,7 +77,7 @@ gimp_stroke_get_type (void) (GInstanceInitFunc) gimp_stroke_init, }; - stroke_type = g_type_register_static (G_TYPE_OBJECT, + stroke_type = g_type_register_static (GIMP_TYPE_OBJECT, "GimpStroke", &stroke_info, 0); } @@ -88,36 +88,40 @@ gimp_stroke_get_type (void) static void gimp_stroke_class_init (GimpStrokeClass *klass) { - GObjectClass *object_class; + GObjectClass *object_class; + GimpObjectClass *gimp_object_class; object_class = G_OBJECT_CLASS (klass); + gimp_object_class = GIMP_OBJECT_CLASS (klass); parent_class = g_type_class_peek_parent (klass); - object_class->finalize = gimp_stroke_finalize; + object_class->finalize = gimp_stroke_finalize; - klass->changed = NULL; - klass->removed = NULL; + gimp_object_class->get_memsize = gimp_stroke_get_memsize; - klass->anchor_get = gimp_stroke_real_anchor_get; - klass->anchor_get_next = gimp_stroke_real_anchor_get_next; - klass->anchor_move_relative = gimp_stroke_real_anchor_move_relative; - klass->anchor_move_absolute = gimp_stroke_real_anchor_move_absolute; - klass->anchor_delete = NULL; + klass->changed = NULL; + klass->removed = NULL; - klass->get_length = NULL; - klass->get_distance = NULL; - klass->interpolate = NULL; + klass->anchor_get = gimp_stroke_real_anchor_get; + klass->anchor_get_next = gimp_stroke_real_anchor_get_next; + klass->anchor_move_relative = gimp_stroke_real_anchor_move_relative; + klass->anchor_move_absolute = gimp_stroke_real_anchor_move_absolute; + klass->anchor_delete = NULL; - klass->temp_anchor_get = NULL; - klass->temp_anchor_set = NULL; - klass->temp_anchor_fix = NULL; + klass->get_length = NULL; + klass->get_distance = NULL; + klass->interpolate = NULL; - klass->make_bezier = NULL; + klass->temp_anchor_get = NULL; + klass->temp_anchor_set = NULL; + klass->temp_anchor_fix = NULL; - klass->get_draw_anchors = NULL; - klass->get_draw_controls = NULL; - klass->get_draw_lines = NULL; + klass->make_bezier = NULL; + + klass->get_draw_anchors = NULL; + klass->get_draw_controls = NULL; + klass->get_draw_lines = NULL; } static void @@ -130,9 +134,28 @@ gimp_stroke_init (GimpStroke *stroke) static void gimp_stroke_finalize (GObject *object) { +#ifdef __GNUC__ +#warning FIXME: implement gimp_stroke_finalize() +#endif + G_OBJECT_CLASS (parent_class)->finalize (object); } +static gsize +gimp_stroke_get_memsize (GimpObject *object) +{ + GimpStroke *stroke; + gsize memsize = 0; + + stroke = GIMP_STROKE (object); + + memsize += g_list_length (stroke->anchors) * (sizeof (GList) + + sizeof (GimpAnchor)); + + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); +} + + /* Calling the virtual functions */ GimpAnchor * diff --git a/app/vectors/gimpstroke.h b/app/vectors/gimpstroke.h index 5f7c9be3ad..22e5f499d2 100644 --- a/app/vectors/gimpstroke.h +++ b/app/vectors/gimpstroke.h @@ -23,6 +23,9 @@ #define __GIMP_STROKE_H__ +#include "core/gimpobject.h" + + #define GIMP_TYPE_STROKE (gimp_stroke_get_type ()) #define GIMP_STROKE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_STROKE, GimpStroke)) #define GIMP_STROKE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_STROKE, GimpStrokeClass)) @@ -33,7 +36,7 @@ struct _GimpStroke { - GObject parent_instance; + GimpObject parent_instance; GList *anchors; @@ -47,7 +50,7 @@ struct _GimpStroke struct _GimpStrokeClass { - GObjectClass parent_class; + GimpObjectClass parent_class; void (* changed) (GimpStroke *stroke); diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c index c73056f910..54a0deb3ad 100644 --- a/app/vectors/gimpvectors.c +++ b/app/vectors/gimpvectors.c @@ -19,7 +19,6 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #include "config.h" #include "glib-object.h" @@ -34,18 +33,19 @@ #include "gimpvectors-preview.h" +static void gimp_vectors_class_init (GimpVectorsClass *klass); +static void gimp_vectors_init (GimpVectors *vectors); + +static void gimp_vectors_finalize (GObject *object); + +static gsize gimp_vectors_get_memsize (GimpObject *object); + + /* private variables */ - static GimpItemClass *parent_class = NULL; -static void gimp_vectors_class_init (GimpVectorsClass *klass); -static void gimp_vectors_init (GimpVectors *vectors); - -static void gimp_vectors_finalize (GObject *object); - - GType gimp_vectors_get_type (void) { @@ -87,26 +87,26 @@ gimp_vectors_class_init (GimpVectorsClass *klass) parent_class = g_type_class_peek_parent (klass); - object_class->finalize = gimp_vectors_finalize; + object_class->finalize = gimp_vectors_finalize; - /* gimp_object_class->get_memsize = gimp_vectors_get_memsize; */ + gimp_object_class->get_memsize = gimp_vectors_get_memsize; - viewable_class->get_new_preview = gimp_vectors_get_new_preview; + viewable_class->get_new_preview = gimp_vectors_get_new_preview; - klass->changed = NULL; + klass->changed = NULL; - klass->stroke_add = NULL; - klass->stroke_get = NULL; - klass->stroke_get_next = NULL; - klass->stroke_get_length = NULL; + klass->stroke_add = NULL; + klass->stroke_get = NULL; + klass->stroke_get_next = NULL; + klass->stroke_get_length = NULL; - klass->anchor_get = NULL; + klass->anchor_get = NULL; - klass->get_length = NULL; - klass->get_distance = NULL; - klass->interpolate = NULL; + klass->get_length = NULL; + klass->get_distance = NULL; + klass->interpolate = NULL; - klass->make_bezier = NULL; + klass->make_bezier = NULL; } static void @@ -118,9 +118,79 @@ gimp_vectors_init (GimpVectors *vectors) static void gimp_vectors_finalize (GObject *object) { +#ifdef __GNUC__ +#warning FIXME: implement gimp_vectors_finalize() +#endif + G_OBJECT_CLASS (parent_class)->finalize (object); } +static gsize +gimp_vectors_get_memsize (GimpObject *object) +{ + GimpVectors *vectors; + GimpStroke *stroke; + gsize memsize = 0; + + vectors = GIMP_VECTORS (object); + + for (stroke = vectors->strokes; stroke; stroke = stroke->next) + memsize += gimp_object_get_memsize (GIMP_OBJECT (stroke)); + + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); +} + + +/* public functions */ + +GimpVectors * +gimp_vectors_new (GimpImage *gimage, + const gchar *name) +{ + GimpVectors *vectors; + + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL); + + vectors = g_object_new (GIMP_TYPE_VECTORS, NULL); + + gimp_item_configure (GIMP_ITEM (vectors), gimage, name); + + return vectors; +} + +GimpVectors * +gimp_vectors_copy (const GimpVectors *vectors, + GType new_type, + gboolean add_alpha /* unused */) +{ + GimpVectors *new_vectors; + + g_return_val_if_fail (GIMP_IS_VECTORS (vectors), NULL); + g_return_val_if_fail (g_type_is_a (new_type, GIMP_TYPE_VECTORS), NULL); + + new_vectors = GIMP_VECTORS (gimp_item_copy (GIMP_ITEM (vectors), + new_type, + add_alpha)); + +#ifdef __GNUC__ +#warning FIXME: implement gimp_vectors_copy() +#endif + + return new_vectors; +} + +void +gimp_vectors_copy_strokes (const GimpVectors *src_vectors, + GimpVectors *dest_vectors) +{ + g_return_if_fail (GIMP_IS_VECTORS (src_vectors)); + g_return_if_fail (GIMP_IS_VECTORS (dest_vectors)); + +#ifdef __GNUC__ +#warning FIXME: implement gimp_vectors_copy_strokes() +#endif +} + /* Calling the virtual functions */ diff --git a/app/vectors/gimpvectors.h b/app/vectors/gimpvectors.h index 1bb939e65b..4f9028f5fc 100644 --- a/app/vectors/gimpvectors.h +++ b/app/vectors/gimpvectors.h @@ -93,6 +93,15 @@ struct _GimpVectorsClass GType gimp_vectors_get_type (void) G_GNUC_CONST; +GimpVectors * gimp_vectors_new (GimpImage *gimage, + const gchar *name); + +GimpVectors * gimp_vectors_copy (const GimpVectors *vectors, + GType new_type, + gboolean add_alpha /* unused */); +void gimp_vectors_copy_strokes (const GimpVectors *src_vectors, + GimpVectors *dest_vectors); + /* accessing / modifying the anchors */