From 048c8f0460ab006154f01dbb4769fd94b94543eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Germ=C3=A1n=20Poo-Caama=C3=B1o?= Date: Sat, 16 Nov 2013 00:41:18 -0800 Subject: [PATCH] glib: Add PopplerPoint boxed type --- glib/poppler-annot.cc | 54 +++++++++++++++++++++++++++++++++++ glib/poppler-annot.h | 24 ++++++++++++++++ glib/poppler.h | 1 + glib/reference/poppler-sections.txt | 5 ++++ 4 files changed, 84 insertions(+) diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc index 31cc081..26d0e6b 100644 --- a/glib/poppler-annot.cc +++ b/glib/poppler-annot.cc @@ -178,6 +178,60 @@ poppler_annot_text_class_init (PopplerAnnotTextClass *klass) { } +/* 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); +} + PopplerAnnot * _poppler_annot_text_new (Annot *annot) { diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h index 88f4e46..bc32e8d 100644 --- a/glib/poppler-annot.h +++ b/glib/poppler-annot.h @@ -169,6 +169,30 @@ void poppler_annot_set_color ( PopplerColor *poppler_color); gint poppler_annot_get_page_index (PopplerAnnot *poppler_annot); +/* PopplerPoint */ + +/* An annotation 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 for an annotation + * 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); + + /* PopplerAnnotMarkup */ GType poppler_annot_markup_get_type (void) G_GNUC_CONST; gchar *poppler_annot_markup_get_label (PopplerAnnotMarkup *poppler_annot); 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 6fb14bc..aca6370 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 @@ -428,6 +429,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