[poppler] 4 commits - glib/demo glib/poppler-annot.cc glib/poppler-annot.h glib/poppler.h glib/poppler-page.cc glib/poppler-page.h glib/poppler-private.h glib/reference

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Tue Nov 19 09:07:21 PST 2013


 glib/demo/annots.c                  |  133 +++++++++++++++++++++++++++++++++---
 glib/poppler-annot.cc               |   79 +++++++++++++++++++++
 glib/poppler-annot.h                |   12 +++
 glib/poppler-page.cc                |   57 +++++++++++++++
 glib/poppler-page.h                 |   20 +++++
 glib/poppler-private.h              |    1 
 glib/poppler.h                      |    2 
 glib/reference/poppler-sections.txt |   12 +++
 8 files changed, 308 insertions(+), 8 deletions(-)

New commits:
commit c784c4c3a582aaa4e10c223665cb876e12b7c16f
Author: Germán Poo-Caamaño <gpoo at gnome.org>
Date:   Mon Nov 18 00:57:53 2013 -0800

    glib-demo: Add support for simple line annotations
    
    https://bugs.freedesktop.org/show_bug.cgi?id=70981

diff --git a/glib/demo/annots.c b/glib/demo/annots.c
index 9ca320a..0dc311a 100644
--- a/glib/demo/annots.c
+++ b/glib/demo/annots.c
@@ -52,6 +52,7 @@ typedef enum {
 typedef struct {
     PopplerDocument *doc;
     PopplerPage     *page;
+    PopplerAnnot    *active_annot;
 
     GtkWidget       *tree_view;
     GtkListStore    *model;
@@ -72,6 +73,7 @@ typedef struct {
     GdkPoint         start;
     GdkPoint         stop;
     GdkCursorType    cursor;
+    guint            annotations_idle;
 } PgdAnnotsDemo;
 
 static void pgd_annots_viewer_queue_redraw (PgdAnnotsDemo *demo);
@@ -82,6 +84,11 @@ pgd_annots_free (PgdAnnotsDemo *demo)
     if (!demo)
         return;
 
+    if (demo->annotations_idle > 0) {
+        g_source_remove (demo->annotations_idle);
+        demo->annotations_idle = 0;
+    }
+
     if (demo->doc) {
         g_object_unref (demo->doc);
         demo->doc = NULL;
@@ -641,12 +648,13 @@ pgd_annot_view_set_annot (PgdAnnotsDemo *demo,
 static void
 pgd_annots_add_annot_to_model (PgdAnnotsDemo *demo,
                                PopplerAnnot *annot,
-                               PopplerRectangle area)
+                               PopplerRectangle area,
+                               gboolean selected)
 {
-    GtkTreeIter          iter;
-    GdkPixbuf           *pixbuf;
-    PopplerAnnotFlag     flags;
-    gchar               *x1, *y1, *x2, *y2;
+    GtkTreeIter      iter;
+    GdkPixbuf        *pixbuf;
+    PopplerAnnotFlag  flags;
+    gchar            *x1, *y1, *x2, *y2;
 
     x1 = g_strdup_printf ("%.2f", area.x1);
     y1 = g_strdup_printf ("%.2f", area.y1);
@@ -670,6 +678,14 @@ pgd_annots_add_annot_to_model (PgdAnnotsDemo *demo,
                         ANNOTS_COLUMN, annot,
                         -1);
 
+    if (selected) {
+        GtkTreePath *path;
+
+        path = gtk_tree_model_get_path (GTK_TREE_MODEL (demo->model), &iter);
+        gtk_tree_view_set_cursor (GTK_TREE_VIEW (demo->tree_view), path, NULL, FALSE);
+        gtk_tree_path_free (path);
+    }
+
     if (pixbuf)
         g_object_unref (pixbuf);
 
@@ -720,7 +736,8 @@ pgd_annots_get_annots (PgdAnnotsDemo *demo)
         PopplerAnnotMapping *amapping;
 
         amapping = (PopplerAnnotMapping *) l->data;
-        pgd_annots_add_annot_to_model (demo, amapping->annot, amapping->area);
+        pgd_annots_add_annot_to_model (demo, amapping->annot,
+                                       amapping->area, FALSE);
     }
 
     poppler_page_free_annot_mapping (mapping);
@@ -842,13 +859,28 @@ pgd_annots_add_annot (PgdAnnotsDemo *demo)
             annot = poppler_annot_text_new (demo->doc, &rect);
 
             break;
+        case POPPLER_ANNOT_LINE: {
+            PopplerPoint start, end;
+
+            start.x = rect.x1;
+            start.y = rect.y1;
+            end.x = rect.x2;
+            end.y = rect.y2;
+
+            annot = poppler_annot_line_new (demo->doc, &rect);
+            poppler_annot_line_set_vertices (POPPLER_ANNOT_LINE (annot),
+                                             &start, &end);
+        }
+            break;
         default:
             g_assert_not_reached ();
     }
 
+    demo->active_annot = annot;
+
     poppler_annot_set_color (annot, &color);
     poppler_page_add_annot (demo->page, annot);
-    pgd_annots_add_annot_to_model (demo, annot, rect);
+    pgd_annots_add_annot_to_model (demo, annot, rect, TRUE);
     g_object_unref (annot);
 }
 
@@ -858,6 +890,7 @@ pgd_annots_finish_add_annot (PgdAnnotsDemo *demo)
     g_assert (demo->mode == MODE_ADD || demo->mode == MODE_DRAWING);
 
     demo->mode = MODE_NORMAL;
+    demo->start.x = -1;
     pgd_annots_update_cursor (demo, GDK_LAST_CURSOR);
     pgd_annots_viewer_queue_redraw (demo);
 
@@ -928,13 +961,17 @@ pgd_annots_viewer_redraw (PgdAnnotsDemo *demo)
 
     gtk_widget_queue_draw (demo->darea);
 
+    demo->annotations_idle = 0;
+
     return FALSE;
 }
 
 static void
 pgd_annots_viewer_queue_redraw (PgdAnnotsDemo *demo)
 {
-    g_idle_add ((GSourceFunc)pgd_annots_viewer_redraw, demo);
+    if (demo->annotations_idle == 0)
+        demo->annotations_idle = g_idle_add ((GSourceFunc)pgd_annots_viewer_redraw,
+                                             demo);
 }
 
 static void
@@ -968,6 +1005,44 @@ pgd_annots_drawing_area_button_press (GtkWidget      *area,
 }
 
 static gboolean
+pgd_annots_drawing_area_motion_notify (GtkWidget      *area,
+                                       GdkEventMotion *event,
+                                       PgdAnnotsDemo  *demo)
+{
+    PopplerRectangle rect;
+    PopplerPoint start, end;
+    gdouble width, height;
+
+    if (!demo->page || demo->mode != MODE_DRAWING || demo->start.x == -1)
+        return FALSE;
+
+    demo->stop.x = event->x;
+    demo->stop.y = event->y;
+
+    poppler_page_get_size (demo->page, &width, &height);
+
+    /* Keep the drawing within the page */
+    demo->stop.x = CLAMP (demo->stop.x, 0, width);
+    demo->stop.y = CLAMP (demo->stop.y, 0, height);
+
+    rect.x1 = start.x = demo->start.x;
+    rect.y1 = start.y = height - demo->start.y;
+    rect.x2 = end.x = demo->stop.x;
+    rect.y2 = end.y = height - demo->stop.y;
+
+    poppler_annot_set_rectangle (demo->active_annot, &rect);
+
+    if (demo->annot_type == POPPLER_ANNOT_LINE)
+        poppler_annot_line_set_vertices (POPPLER_ANNOT_LINE (demo->active_annot),
+                                         &start, &end);
+
+    pgd_annot_view_set_annot (demo, demo->active_annot);
+    pgd_annots_viewer_queue_redraw (demo);
+
+    return TRUE;
+}
+
+static gboolean
 pgd_annots_drawing_area_button_release (GtkWidget      *area,
                                         GdkEventButton *event,
                                         PgdAnnotsDemo  *demo)
@@ -1054,6 +1129,11 @@ pgd_annots_create_widget (PopplerDocument *document)
                         SELECTED_LABEL_COLUMN, "Text",
                         -1);
 
+    gtk_list_store_append (model, &iter);
+    gtk_list_store_set (model, &iter,
+                        SELECTED_TYPE_COLUMN, POPPLER_ANNOT_LINE,
+                        SELECTED_LABEL_COLUMN, "Line",
+                        -1);
     demo->type_selector = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));
     g_object_unref (model);
 
@@ -1203,6 +1283,9 @@ pgd_annots_create_widget (PopplerDocument *document)
     g_signal_connect (demo->darea, "button_press_event",
                       G_CALLBACK (pgd_annots_drawing_area_button_press),
                       (gpointer)demo);
+    g_signal_connect (demo->darea, "motion_notify_event",
+                      G_CALLBACK (pgd_annots_drawing_area_motion_notify),
+                      (gpointer)demo);
     g_signal_connect (demo->darea, "button_release_event",
                       G_CALLBACK (pgd_annots_drawing_area_button_release),
                       (gpointer)demo);
commit 2d164e06b8a84ade6689d85bba2d606c66bf62a9
Author: Germán Poo-Caamaño <gpoo at gnome.org>
Date:   Mon Nov 18 00:48:13 2013 -0800

    glib-demo: add color selection for new annotations
    
    https://bugs.freedesktop.org/show_bug.cgi?id=71727

diff --git a/glib/demo/annots.c b/glib/demo/annots.c
index c5c3643..9ca320a 100644
--- a/glib/demo/annots.c
+++ b/glib/demo/annots.c
@@ -67,6 +67,7 @@ typedef struct {
     ModeType         mode;
 
     cairo_surface_t *surface;
+    GdkRGBA          annot_color;
 
     GdkPoint         start;
     GdkPoint         stop;
@@ -433,6 +434,18 @@ pgd_annot_view_set_annot_text (GtkWidget        *table,
 }
 
 static void
+pgd_annot_color_changed (GtkButton     *button,
+                         GParamSpec    *pspec,
+                         PgdAnnotsDemo *demo)
+{
+#if GTK_CHECK_VERSION(3,4,0)
+    gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (button), &demo->annot_color);
+#else
+    gtk_color_button_get_rgba (GTK_COLOR_BUTTON (button), &demo->annot_color);
+#endif
+}
+
+static void
 pgd_annot_view_set_annot_free_text (GtkWidget            *table,
                                     PopplerAnnotFreeText *annot,
                                     gint                 *row)
@@ -807,6 +820,7 @@ static void
 pgd_annots_add_annot (PgdAnnotsDemo *demo)
 {
     PopplerRectangle  rect;
+    PopplerColor      color;
     PopplerAnnot     *annot;
     gdouble           height;
 
@@ -819,6 +833,10 @@ pgd_annots_add_annot (PgdAnnotsDemo *demo)
     rect.x2 = demo->stop.x;
     rect.y2 = height - demo->stop.y;
 
+    color.red = CLAMP ((guint) (demo->annot_color.red * 65535), 0, 65535);
+    color.green = CLAMP ((guint) (demo->annot_color.green * 65535), 0, 65535);
+    color.blue = CLAMP ((guint) (demo->annot_color.blue * 65535), 0, 65535);
+
     switch (demo->annot_type) {
         case POPPLER_ANNOT_TEXT:
             annot = poppler_annot_text_new (demo->doc, &rect);
@@ -828,6 +846,7 @@ pgd_annots_add_annot (PgdAnnotsDemo *demo)
             g_assert_not_reached ();
     }
 
+    poppler_annot_set_color (annot, &color);
     poppler_page_add_annot (demo->page, annot);
     pgd_annots_add_annot_to_model (demo, annot, rect);
     g_object_unref (annot);
@@ -1034,6 +1053,7 @@ pgd_annots_create_widget (PopplerDocument *document)
                         SELECTED_TYPE_COLUMN, POPPLER_ANNOT_TEXT,
                         SELECTED_LABEL_COLUMN, "Text",
                         -1);
+
     demo->type_selector = gtk_combo_box_new_with_model (GTK_TREE_MODEL (model));
     g_object_unref (model);
 
@@ -1046,6 +1066,20 @@ pgd_annots_create_widget (PopplerDocument *document)
     gtk_box_pack_end (GTK_BOX (hbox), demo->type_selector, FALSE, FALSE, 0);
     gtk_widget_show (demo->type_selector);
 
+    button = gtk_color_button_new ();
+    demo->annot_color.red = 65535;
+    demo->annot_color.alpha = 1.0;
+#if GTK_CHECK_VERSION(3,4,0)
+    gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (button), &demo->annot_color);
+#else
+    gtk_color_button_set_rgba (GTK_COLOR_BUTTON (button), &demo->annot_color);
+#endif
+    g_signal_connect (button, "notify::color",
+                      G_CALLBACK (pgd_annot_color_changed),
+                      (gpointer)demo);
+    gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, TRUE, 0);
+    gtk_widget_show (button);
+
     gtk_widget_show (hbox);
 
     demo->timer_label = gtk_label_new (NULL);
commit 7127a2c705787f6f44b0852efeabe9fdeae7e2c0
Author: Germán Poo-Caamaño <gpoo at gnome.org>
Date:   Sun Nov 17 23:38:32 2013 -0800

    glib: Add support for simple line annotations
    
    https://bugs.freedesktop.org/show_bug.cgi?id=70981

diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc
index 9c8551b..9d073f6 100644
--- a/glib/poppler-annot.cc
+++ b/glib/poppler-annot.cc
@@ -36,6 +36,7 @@ typedef struct _PopplerAnnotTextClass           PopplerAnnotTextClass;
 typedef struct _PopplerAnnotFileAttachmentClass PopplerAnnotFileAttachmentClass;
 typedef struct _PopplerAnnotMovieClass          PopplerAnnotMovieClass;
 typedef struct _PopplerAnnotScreenClass         PopplerAnnotScreenClass;
+typedef struct _PopplerAnnotLineClass           PopplerAnnotLineClass;
 
 struct _PopplerAnnotClass
 {
@@ -106,6 +107,15 @@ struct _PopplerAnnotScreenClass
   PopplerAnnotClass parent_class;
 };
 
+struct _PopplerAnnotLine
+{
+  PopplerAnnotMarkup parent_instance;
+};
+
+struct _PopplerAnnotLineClass
+{
+  PopplerAnnotMarkupClass parent_class;
+};
 
 G_DEFINE_TYPE (PopplerAnnot, poppler_annot, G_TYPE_OBJECT)
 G_DEFINE_TYPE (PopplerAnnotMarkup, poppler_annot_markup, POPPLER_TYPE_ANNOT)
@@ -114,6 +124,7 @@ G_DEFINE_TYPE (PopplerAnnotFreeText, poppler_annot_free_text, POPPLER_TYPE_ANNOT
 G_DEFINE_TYPE (PopplerAnnotFileAttachment, poppler_annot_file_attachment, POPPLER_TYPE_ANNOT_MARKUP)
 G_DEFINE_TYPE (PopplerAnnotMovie, poppler_annot_movie, POPPLER_TYPE_ANNOT)
 G_DEFINE_TYPE (PopplerAnnotScreen, poppler_annot_screen, POPPLER_TYPE_ANNOT)
+G_DEFINE_TYPE (PopplerAnnotLine, poppler_annot_line, POPPLER_TYPE_ANNOT_MARKUP)
 
 static PopplerAnnot *
 _poppler_create_annot (GType annot_type, Annot *annot)
@@ -325,6 +336,48 @@ _poppler_annot_screen_new (Annot *annot)
   return poppler_annot;
 }
 
+PopplerAnnot *
+_poppler_annot_line_new (Annot *annot)
+{
+  return _poppler_create_annot (POPPLER_TYPE_ANNOT_LINE, annot);
+}
+
+static void
+poppler_annot_line_init (PopplerAnnotLine *poppler_annot)
+{
+}
+
+static void
+poppler_annot_line_class_init (PopplerAnnotLineClass *klass)
+{
+}
+
+/**
+ * poppler_annot_line_new:
+ * @doc: a #PopplerDocument
+ * @rect: a #PopplerRectangle
+ *
+ * Creates a new Line annotation that will be
+ * located on @rect when added to a page. See
+ * poppler_page_add_annot()
+ *
+ * Return value: A newly created #PopplerAnnotLine annotation
+ *
+ * Since: 0.26
+ */
+PopplerAnnot *
+poppler_annot_line_new (PopplerDocument  *doc,
+			PopplerRectangle *rect)
+{
+  Annot *annot;
+  PDFRectangle pdf_rect(rect->x1, rect->y1,
+			rect->x2, rect->y2);
+
+  annot = new AnnotLine (doc->doc, &pdf_rect);
+
+  return _poppler_annot_line_new (annot);
+}
+
 
 /* Public methods */
 /**
@@ -1432,3 +1485,29 @@ poppler_annot_screen_get_action (PopplerAnnotScreen *poppler_annot)
 {
   return poppler_annot->action;
 }
+
+/* PopplerAnnotLine */
+/**
+ * poppler_annot_line_set_vertices:
+ * @poppler_annot: a #PopplerAnnotLine
+ * @start: a #PopplerPoint of the starting vertice
+ * @end: a #PopplerPoint of the ending vertice
+ *
+ * Set the coordinate points where the @poppler_annot starts and ends.
+ *
+ * Since: 0.26
+ */
+void
+poppler_annot_line_set_vertices (PopplerAnnotLine *poppler_annot,
+				 PopplerPoint     *start,
+				 PopplerPoint     *end)
+{
+  AnnotLine *annot;
+
+  g_return_if_fail (POPPLER_IS_ANNOT_LINE (poppler_annot));
+  g_return_if_fail (start != NULL);
+  g_return_if_fail (end != NULL);
+
+  annot = static_cast<AnnotLine *>(POPPLER_ANNOT (poppler_annot)->annot);
+  annot->setVertices (start->x, start->y, end->x, end->y);
+}
diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h
index 1f23822..18091f8 100644
--- a/glib/poppler-annot.h
+++ b/glib/poppler-annot.h
@@ -54,6 +54,10 @@ G_BEGIN_DECLS
 #define POPPLER_ANNOT_SCREEN(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), POPPLER_TYPE_ANNOT_SCREEN, PopplerAnnotScreen))
 #define POPPLER_IS_ANNOT_SCREEN(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_ANNOT_SCREEN))
 
+#define POPPLER_TYPE_ANNOT_LINE              (poppler_annot_line_get_type ())
+#define POPPLER_ANNOT_LINE(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), POPPLER_TYPE_ANNOT_LINE, PopplerAnnotLine))
+#define POPPLER_IS_ANNOT_LINE(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POPPLER_TYPE_ANNOT_LINE))
+
 #define POPPLER_TYPE_ANNOT_CALLOUT_LINE      (poppler_annot_callout_line_get_type ())
 
 
@@ -225,6 +229,14 @@ PopplerMovie                 *poppler_annot_movie_get_movie                    (
 GType                         poppler_annot_screen_get_type                    (void) G_GNUC_CONST;
 PopplerAction                *poppler_annot_screen_get_action                  (PopplerAnnotScreen *poppler_annot);
 
+/* PopplerAnnotLine */
+GType                         poppler_annot_line_get_type                      (void) G_GNUC_CONST;
+PopplerAnnot                 *poppler_annot_line_new                           (PopplerDocument  *doc,
+                                                                                PopplerRectangle *rect);
+void                          poppler_annot_line_set_vertices                  (PopplerAnnotLine *poppler_annot,
+										PopplerPoint     *start,
+										PopplerPoint     *end);
+
 /* PopplerAnnotCalloutLine */
 GType                         poppler_annot_callout_line_get_type              (void) G_GNUC_CONST;
 PopplerAnnotCalloutLine      *poppler_annot_callout_line_new                   (void);
diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc
index e891b9f..fbab9b4 100644
--- a/glib/poppler-page.cc
+++ b/glib/poppler-page.cc
@@ -1375,6 +1375,9 @@ poppler_page_get_annot_mapping (PopplerPage *page)
       case Annot::typeScreen:
         mapping->annot = _poppler_annot_screen_new (annot);
 	break;
+      case Annot::typeLine:
+        mapping->annot = _poppler_annot_line_new (annot);
+	break;
       default:
         mapping->annot = _poppler_annot_new (annot);
 	break;
diff --git a/glib/poppler-private.h b/glib/poppler-private.h
index ab39b49..bebe0c8 100644
--- a/glib/poppler-private.h
+++ b/glib/poppler-private.h
@@ -120,6 +120,7 @@ PopplerAnnot      *_poppler_annot_free_text_new (Annot *annot);
 PopplerAnnot      *_poppler_annot_file_attachment_new (Annot *annot);
 PopplerAnnot      *_poppler_annot_movie_new (Annot *annot);
 PopplerAnnot      *_poppler_annot_screen_new (Annot *annot);
+PopplerAnnot      *_poppler_annot_line_new (Annot *annot);
 
 char *_poppler_goo_string_to_utf8(GooString *s);
 gboolean _poppler_convert_pdf_date_to_gtime (GooString *date,
diff --git a/glib/poppler.h b/glib/poppler.h
index 83531a5..dd0df09 100644
--- a/glib/poppler.h
+++ b/glib/poppler.h
@@ -203,6 +203,7 @@ typedef struct _PopplerAnnotFileAttachment PopplerAnnotFileAttachment;
 typedef struct _PopplerAnnotMovie          PopplerAnnotMovie;
 typedef struct _PopplerAnnotScreen         PopplerAnnotScreen;
 typedef struct _PopplerAnnotCalloutLine    PopplerAnnotCalloutLine;
+typedef struct _PopplerAnnotLine           PopplerAnnotLine;
 
 typedef enum
 {
diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt
index ce7bd00..ce829e3 100644
--- a/glib/reference/poppler-sections.txt
+++ b/glib/reference/poppler-sections.txt
@@ -372,6 +372,7 @@ PopplerAnnotMarkup
 PopplerAnnotText
 PopplerAnnotFreeText
 PopplerAnnotFileAttachment
+PopplerAnnotLine
 PopplerAnnotMovie
 PopplerAnnotScreen
 PopplerAnnotType
@@ -431,6 +432,8 @@ poppler_annot_movie_get_title
 poppler_annot_callout_line_new
 poppler_annot_callout_line_copy
 poppler_annot_callout_line_free
+poppler_annot_line_new
+poppler_annot_line_set_vertices
 poppler_point_copy
 poppler_point_free
 poppler_point_get_type
@@ -446,6 +449,9 @@ POPPLER_TYPE_ANNOT_FILE_ATTACHMENT
 POPPLER_ANNOT_FREE_TEXT
 POPPLER_IS_ANNOT_FREE_TEXT
 POPPLER_TYPE_ANNOT_FREE_TEXT
+POPPLER_ANNOT_LINE
+POPPLER_IS_ANNOT_LINE
+POPPLER_TYPE_ANNOT_LINE
 POPPLER_ANNOT_MARKUP
 POPPLER_IS_ANNOT_MARKUP
 POPPLER_TYPE_ANNOT_MARKUP
@@ -481,6 +487,7 @@ poppler_annot_markup_reply_type_get_type
 poppler_annot_callout_line_get_type
 poppler_annot_text_state_get_type
 poppler_annot_free_text_quadding_get_type
+poppler_annot_line_get_type
 </SECTION>
 
 <SECTION>
commit 451bac9f05bab18f3aa0392ddf6eb6b569004cb8
Author: Germán Poo-Caamaño <gpoo at gnome.org>
Date:   Sun Nov 17 23:30:14 2013 -0800

    glib: Add PopplerPoint boxed type
    
    https://bugs.freedesktop.org/show_bug.cgi?id=70981

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..c54eb9c 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
 
 <SUBSECTION Standard>
 POPPLER_ANNOT


More information about the poppler mailing list