From 722ed1e67cbf398e806f4b4a250c48b17bffe325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Poo-Caama=C3=B1o?= Date: Sun, 17 Nov 2013 23:30:14 -0800 Subject: [PATCH] glib: Add PopplerPoint boxed type --- glib/poppler-page.cc | 54 +++++++++++++++++++++++++++++++++++ glib/poppler-page.h | 20 +++++++++++++ glib/poppler.h | 1 + glib/reference/poppler-sections.txt | 5 ++++ 4 files changed, 80 insertions(+) diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc index 9115b78..e891b9f 100644 --- a/glib/poppler-page.cc +++ b/glib/poppler-page.cc @@ -1527,6 +1527,60 @@ poppler_rectangle_free (PopplerRectangle *rectangle) g_slice_free (PopplerRectangle, rectangle); } +/* PopplerPoint type */ + +POPPLER_DEFINE_BOXED_TYPE (PopplerPoint, poppler_point, + poppler_point_copy, + poppler_point_free) + +/** + * poppler_point_new: + * + * Creates a new #PopplerPoint. It must be freed with poppler_point_free() after use. + * + * Returns: a new #PopplerPoint + * + * Since: 0.26 + **/ +PopplerPoint * +poppler_point_new (void) +{ + return g_slice_new0 (PopplerPoint); +} + +/** + * poppler_point_copy: + * @point: a #PopplerPoint to copy + * + * Creates a copy of @point. The copy must be freed with poppler_point_free() + * after use. + * + * Returns: a new allocated copy of @point + * + * Since: 0.26 + **/ +PopplerPoint * +poppler_point_copy (PopplerPoint *point) +{ + g_return_val_if_fail (point != NULL, NULL); + + return g_slice_dup (PopplerPoint, point); +} + +/** + * poppler_point_free: + * @point: a #PopplerPoint + * + * Frees the memory used by @point + * + * Since: 0.26 + **/ +void +poppler_point_free (PopplerPoint *point) +{ + g_slice_free (PopplerPoint, point); +} + /* PopplerTextAttributes type */ POPPLER_DEFINE_BOXED_TYPE (PopplerTextAttributes, poppler_text_attributes, diff --git a/glib/poppler-page.h b/glib/poppler-page.h index c081b8c..46a7c1d 100644 --- a/glib/poppler-page.h +++ b/glib/poppler-page.h @@ -127,6 +127,26 @@ PopplerRectangle *poppler_rectangle_new (void); PopplerRectangle *poppler_rectangle_copy (PopplerRectangle *rectangle); void poppler_rectangle_free (PopplerRectangle *rectangle); +/* A point on a page, with coordinates in PDF points. */ +#define POPPLER_TYPE_POINT (poppler_point_get_type ()) +/** + * PopplerPoint: + * @x: x coordinate + * @y: y coordinate + * + * A #PopplerPoint is used to describe a location point on a page + */ +struct _PopplerPoint +{ + gdouble x; + gdouble y; +}; + +GType poppler_point_get_type (void) G_GNUC_CONST; +PopplerPoint *poppler_point_new (void); +PopplerPoint *poppler_point_copy (PopplerPoint *point); +void poppler_point_free (PopplerPoint *point); + /* A color in RGB */ #define POPPLER_TYPE_COLOR (poppler_color_get_type ()) diff --git a/glib/poppler.h b/glib/poppler.h index 2d190f3..83531a5 100644 --- a/glib/poppler.h +++ b/glib/poppler.h @@ -175,6 +175,7 @@ typedef struct _PopplerDocument PopplerDocument; typedef struct _PopplerIndexIter PopplerIndexIter; typedef struct _PopplerFontsIter PopplerFontsIter; typedef struct _PopplerLayersIter PopplerLayersIter; +typedef struct _PopplerPoint PopplerPoint; typedef struct _PopplerRectangle PopplerRectangle; typedef struct _PopplerTextAttributes PopplerTextAttributes; typedef struct _PopplerColor PopplerColor; diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt index 24c005d..ce7bd00 100644 --- a/glib/reference/poppler-sections.txt +++ b/glib/reference/poppler-sections.txt @@ -381,6 +381,7 @@ PopplerAnnotMarkupReplyType PopplerAnnotTextState PopplerAnnotCalloutLine PopplerAnnotFreeTextQuadding +PopplerPoint poppler_annot_get_annot_type poppler_annot_get_flags poppler_annot_get_name @@ -430,6 +431,10 @@ poppler_annot_movie_get_title poppler_annot_callout_line_new poppler_annot_callout_line_copy poppler_annot_callout_line_free +poppler_point_copy +poppler_point_free +poppler_point_get_type +poppler_point_new POPPLER_ANNOT -- 1.7.9.5