[planner: 5/32] libgnomecanvas: Restore GnomeCanvasPoints
- From: Mart Raudsepp <mraudsepp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [planner: 5/32] libgnomecanvas: Restore GnomeCanvasPoints
- Date: Sun, 20 Jun 2021 18:13:50 +0000 (UTC)
commit a958918982802cb14d43490a592edb7d58d7ac36
Author: Mart Raudsepp <leio gentoo org>
Date: Sun Mar 21 14:59:43 2021 +0200
libgnomecanvas: Restore GnomeCanvasPoints
We'll need it temporarily for GnomeCanvasLine, which uses it.
This is essentially a revert of evolution
commit cf21582a93e0b40b1400891b0ea2b0d52482c759
src/libgnomecanvas/gnome-canvas-util.c | 61 ++++++++++++++++++++++++++++++++
src/libgnomecanvas/gnome-canvas-util.h | 22 ++++++++++++
src/libgnomecanvas/libgnomecanvas.h | 7 ++++
src/libgnomecanvas/libgnomecanvastypes.c | 43 ++++++++++++++++++++++
4 files changed, 133 insertions(+)
---
diff --git a/src/libgnomecanvas/gnome-canvas-util.c b/src/libgnomecanvas/gnome-canvas-util.c
index d42cf93f..f8e33934 100644
--- a/src/libgnomecanvas/gnome-canvas-util.c
+++ b/src/libgnomecanvas/gnome-canvas-util.c
@@ -41,6 +41,67 @@
#include "gnome-canvas.h"
#include "gnome-canvas-util.h"
+/**
+ * gnome_canvas_points_new:
+ * @num_points: The number of points to allocate space for in the array.
+ *
+ * Creates a structure that should be used to pass an array of points to
+ * items.
+ *
+ * Return value: A newly-created array of points. It should be filled in
+ * by the user.
+ **/
+GnomeCanvasPoints *
+gnome_canvas_points_new (gint num_points)
+{
+ GnomeCanvasPoints *points;
+
+ g_return_val_if_fail (num_points > 1, NULL);
+
+ points = g_new (GnomeCanvasPoints, 1);
+ points->num_points = num_points;
+ points->coords = g_new (double, 2 * num_points);
+ points->ref_count = 1;
+
+ return points;
+}
+
+/**
+ * gnome_canvas_points_ref:
+ * @points: A canvas points structure.
+ *
+ * Increases the reference count of the specified points structure.
+ *
+ * Return value: The canvas points structure itself.
+ **/
+GnomeCanvasPoints *
+gnome_canvas_points_ref (GnomeCanvasPoints *points)
+{
+ g_return_val_if_fail (points != NULL, NULL);
+
+ points->ref_count += 1;
+ return points;
+}
+
+/**
+ * gnome_canvas_points_free:
+ * @points: A canvas points structure.
+ *
+ * Decreases the reference count of the specified points structure. If it
+ * reaches zero, then the structure is freed.
+ **/
+void
+gnome_canvas_points_free (GnomeCanvasPoints *points)
+{
+ g_return_if_fail (points != NULL);
+
+ points->ref_count -= 1;
+ if (points->ref_count == 0) {
+ g_free (points->coords);
+ g_free (points);
+ }
+}
+
/* Here are some helper functions for aa rendering: */
/**
diff --git a/src/libgnomecanvas/gnome-canvas-util.h b/src/libgnomecanvas/gnome-canvas-util.h
index c4d2325c..ed491048 100644
--- a/src/libgnomecanvas/gnome-canvas-util.h
+++ b/src/libgnomecanvas/gnome-canvas-util.h
@@ -34,6 +34,28 @@
G_BEGIN_DECLS
+typedef struct _GnomeCanvasPoints GnomeCanvasPoints;
+
+/* This structure defines an array of points. X coordinates are stored in the even-numbered
+ * indices, and Y coordinates are stored in the odd-numbered indices. num_points indicates the
+ * number of points, so the array is 2*num_points elements big.
+ */
+struct _GnomeCanvasPoints {
+ gdouble *coords;
+ gint num_points;
+ gint ref_count;
+};
+
+/* Allocate a new GnomeCanvasPoints structure with enough space for the specified number of points */
+GnomeCanvasPoints *gnome_canvas_points_new (gint num_points);
+
+/* Increate ref count */
+GnomeCanvasPoints *gnome_canvas_points_ref (GnomeCanvasPoints *points);
+#define gnome_canvas_points_unref gnome_canvas_points_free
+
+/* Decrease ref count and free structure if it has reached zero */
+void gnome_canvas_points_free (GnomeCanvasPoints *points);
+
/* Sets the svp to the new value, requesting repaint on what's changed. This
* function takes responsibility for freeing new_svp. This routine also adds the
* svp's bbox to the item's.
diff --git a/src/libgnomecanvas/libgnomecanvas.h b/src/libgnomecanvas/libgnomecanvas.h
index 028afbed..c8c70862 100644
--- a/src/libgnomecanvas/libgnomecanvas.h
+++ b/src/libgnomecanvas/libgnomecanvas.h
@@ -30,4 +30,11 @@
#include <libgnomecanvas/gnome-canvas-rect.h>
#include <libgnomecanvas/gnome-canvas-util.h>
+G_BEGIN_DECLS
+
+GType gnome_canvas_points_get_type (void);
+#define GNOME_TYPE_CANVAS_POINTS gnome_canvas_points_get_type()
+
+G_END_DECLS
+
#endif /* LIBGNOMECANVAS_H */
diff --git a/src/libgnomecanvas/libgnomecanvastypes.c b/src/libgnomecanvas/libgnomecanvastypes.c
new file mode 100644
index 00000000..c7c4fcf3
--- /dev/null
+++ b/src/libgnomecanvas/libgnomecanvastypes.c
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 1999, 2000 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This file is part of the Gnome Library.
+ *
+ * The Gnome Library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * The Gnome Library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with the Gnome Library; see the file COPYING.LIB. If not,
+ * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+/*
+ @NOTATION@
+ */
+
+#include <config.h>
+#include <glib-object.h>
+
+#include <libgnomecanvas/libgnomecanvas.h>
+
+GType
+gnome_canvas_points_get_type (void)
+{
+ static GType type_canvas_points = 0;
+
+ if (!type_canvas_points)
+ type_canvas_points = g_boxed_type_register_static
+ ("GnomeCanvasPoints",
+ (GBoxedCopyFunc) gnome_canvas_points_ref,
+ (GBoxedFreeFunc) gnome_canvas_points_unref);
+
+ return type_canvas_points;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]