[poppler] glib/demo glib/poppler-annot.cc glib/poppler-annot.h

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Fri May 8 00:37:27 PDT 2009


 glib/demo/annots.c    |    8 ++++++++
 glib/poppler-annot.cc |   35 +++++++++++++++++++++++++++++++++++
 glib/poppler-annot.h  |    2 ++
 3 files changed, 45 insertions(+)

New commits:
commit 810a71ea66f0e07d9849a5e9bf28911472482d1b
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Fri May 8 09:36:31 2009 +0200

    [glib] Add poppler_annot_markup_get_popup_rectangle

diff --git a/glib/demo/annots.c b/glib/demo/annots.c
index a4428db..b8744a7 100644
--- a/glib/demo/annots.c
+++ b/glib/demo/annots.c
@@ -303,6 +303,7 @@ pgd_annot_view_set_annot_markup (GtkWidget          *table,
                                  gint               *row)
 {
     gchar *text;
+    PopplerRectangle rect;
 
     text = poppler_annot_markup_get_label (markup);
     pgd_table_add_property (GTK_TABLE (table), "<b>Label:</b>", text, row);
@@ -311,6 +312,13 @@ pgd_annot_view_set_annot_markup (GtkWidget          *table,
     pgd_table_add_property (GTK_TABLE (table), "<b>Popup is open:</b>",
                             poppler_annot_markup_get_popup_is_open (markup) ? "Yes" : "No", row);
 
+    if (poppler_annot_markup_get_popup_rectangle (markup, &rect)) {
+	    text = g_strdup_printf ("X1: %.2f, Y1: %.2f, X2: %.2f, Y2: %.2f",
+				    rect.x1, rect.y1, rect.x2, rect.y2);
+	    pgd_table_add_property (GTK_TABLE (table), "<b>Popup Rectangle:</b>", text, row);
+	    g_free (text);
+    }
+
     text = g_strdup_printf ("%f", poppler_annot_markup_get_opacity (markup));
     pgd_table_add_property (GTK_TABLE (table), "<b>Opacity:</b>", text, row);
     g_free (text);
diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc
index 7746d48..b433bcf 100644
--- a/glib/poppler-annot.cc
+++ b/glib/poppler-annot.cc
@@ -438,6 +438,41 @@ poppler_annot_markup_get_popup_is_open (PopplerAnnotMarkup *poppler_annot)
 }
 
 /**
+ * poppler_annot_markup_get_popup_rectangle:
+ * @poppler_annot: a #PopplerAnnotMarkup
+ * @poppler_rect: a #PopplerRectangle to store the popup rectangle
+ *
+ * Retrieves the rectangle of the popup annot related to @poppler_annot.
+ *
+ * Return value: %TRUE if #PopplerRectangle was correctly filled,
+ *               %FALSE otherwise
+ **/
+gboolean
+poppler_annot_markup_get_popup_rectangle (PopplerAnnotMarkup *poppler_annot,
+					  PopplerRectangle   *poppler_rect)
+{
+  AnnotMarkup *annot;
+  Annot *annot_popup;
+  PDFRectangle *annot_rect;
+
+  g_return_val_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot), FALSE);
+  g_return_val_if_fail (poppler_rect != NULL, FALSE);
+
+  annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
+  annot_popup = annot->getPopup ();
+  if (!annot_popup)
+    return FALSE;
+
+  annot_rect = annot_popup->getRect ();
+  poppler_rect->x1 = annot_rect->x1;
+  poppler_rect->x2 = annot_rect->x2;
+  poppler_rect->y1 = annot_rect->y1;
+  poppler_rect->y2 = annot_rect->y2;
+
+  return TRUE;
+}
+
+/**
 * poppler_annot_markup_get_opacity:
 * @poppler_annot: a #PopplerAnnotMarkup
 *
diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h
index 76983cb..9689e82 100644
--- a/glib/poppler-annot.h
+++ b/glib/poppler-annot.h
@@ -145,6 +145,8 @@ PopplerColor                 *poppler_annot_get_color                          (
 GType                         poppler_annot_markup_get_type                    (void) G_GNUC_CONST;
 gchar                        *poppler_annot_markup_get_label                   (PopplerAnnotMarkup *poppler_annot);
 gboolean                      poppler_annot_markup_get_popup_is_open           (PopplerAnnotMarkup *poppler_annot);
+gboolean                      poppler_annot_markup_get_popup_rectangle         (PopplerAnnotMarkup *poppler_annot,
+										PopplerRectangle   *poppler_rect);
 gdouble                       poppler_annot_markup_get_opacity                 (PopplerAnnotMarkup *poppler_annot);
 GDate                        *poppler_annot_markup_get_date                    (PopplerAnnotMarkup *poppler_annot);
 gchar                        *poppler_annot_markup_get_subject                 (PopplerAnnotMarkup *poppler_annot);


More information about the poppler mailing list