[poppler] 6 commits - glib/demo glib/poppler-annot.cc glib/poppler-annot.h glib/poppler-document.cc glib/poppler-page.cc glib/poppler-page.h glib/poppler-private.h glib/reference poppler/Annot.cc poppler/Annot.h poppler/Page.cc

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Tue Jul 20 05:03:36 PDT 2010


 glib/demo/annots.c                  |  114 ++++++++++++++
 glib/poppler-annot.cc               |  278 ++++++++++++++++++++++++++++++++----
 glib/poppler-annot.h                |   26 +++
 glib/poppler-document.cc            |    7 
 glib/poppler-page.cc                |   19 ++
 glib/poppler-page.h                 |    2 
 glib/poppler-private.h              |    6 
 glib/reference/poppler-sections.txt |   18 ++
 poppler/Annot.cc                    |   17 ++
 poppler/Annot.h                     |    4 
 poppler/Page.cc                     |    2 
 11 files changed, 465 insertions(+), 28 deletions(-)

New commits:
commit 02d85dd2cc154dbb6caa04a349532033d833edd1
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Tue Jul 20 13:53:56 2010 +0200

    [glib-demo] Add support for adding annots in annot demo

diff --git a/glib/demo/annots.c b/glib/demo/annots.c
index f960387..856fbef 100644
--- a/glib/demo/annots.c
+++ b/glib/demo/annots.c
@@ -657,6 +657,113 @@ pgd_annots_selection_changed (GtkTreeSelection *treeselection,
     }
 }
 
+static void
+pgd_annots_add_annot (GtkWidget     *button,
+		      PgdAnnotsDemo *demo)
+{
+    GtkWidget   *hbox, *vbox;
+    GtkWidget   *type_selector;
+    GtkWidget   *label;
+    GtkWidget   *rect_hbox;
+    GtkWidget   *rect_x1, *rect_y1, *rect_x2, *rect_y2;
+    GtkWidget   *dialog;
+    PopplerPage *page;
+    gdouble      width, height;
+    PopplerAnnot *annot;
+    PopplerRectangle rect;
+
+    page = poppler_document_get_page (demo->doc, demo->num_page);
+    if (!page)
+	    return;
+    poppler_page_get_size (page, &width, &height);
+
+    dialog = gtk_dialog_new_with_buttons ("Add new annotation",
+					  GTK_WINDOW (gtk_widget_get_toplevel (button)),
+					  GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+					  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+					  "Add annotation", GTK_RESPONSE_ACCEPT,
+					  NULL);
+
+    vbox = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+    type_selector = gtk_combo_box_new_text ();
+    gtk_combo_box_append_text (GTK_COMBO_BOX (type_selector), "POPPLER_ANNOT_UNKNOWN");
+    gtk_combo_box_append_text (GTK_COMBO_BOX (type_selector), "POPPLER_ANNOT_TEXT");
+    gtk_combo_box_set_active (GTK_COMBO_BOX (type_selector), 1);
+    gtk_box_pack_start (GTK_BOX (vbox), type_selector, TRUE, TRUE, 0);
+    gtk_widget_show (type_selector);
+
+    hbox = gtk_hbox_new (FALSE, 6);
+
+    rect_hbox = gtk_hbox_new (FALSE, 6);
+
+    label = gtk_label_new ("x1:");
+    gtk_box_pack_start (GTK_BOX (rect_hbox), label, TRUE, TRUE, 0);
+    gtk_widget_show (label);
+
+    rect_x1 = gtk_spin_button_new_with_range (0, width, 1.0);
+    gtk_box_pack_start (GTK_BOX (rect_hbox), rect_x1, TRUE, TRUE, 0);
+    gtk_widget_show (rect_x1);
+
+    gtk_box_pack_start (GTK_BOX (hbox), rect_hbox, FALSE, TRUE, 0);
+    gtk_widget_show (rect_hbox);
+
+    rect_hbox = gtk_hbox_new (FALSE, 6);
+
+    label = gtk_label_new ("x2:");
+    gtk_box_pack_start (GTK_BOX (rect_hbox), label, TRUE, TRUE, 0);
+    gtk_widget_show (label);
+
+    rect_x2 = gtk_spin_button_new_with_range (0, width, 1.0);
+    gtk_box_pack_start (GTK_BOX (rect_hbox), rect_x2, TRUE, TRUE, 0);
+    gtk_widget_show (rect_x2);
+
+    gtk_box_pack_start (GTK_BOX (hbox), rect_hbox, FALSE, TRUE, 0);
+    gtk_widget_show (rect_hbox);
+
+    rect_hbox = gtk_hbox_new (FALSE, 6);
+
+    label = gtk_label_new ("y1:");
+    gtk_box_pack_start (GTK_BOX (rect_hbox), label, TRUE, TRUE, 0);
+    gtk_widget_show (label);
+
+    rect_y1 = gtk_spin_button_new_with_range (0, height, 1.0);
+    gtk_box_pack_start (GTK_BOX (rect_hbox), rect_y1, TRUE, TRUE, 0);
+    gtk_widget_show (rect_y1);
+
+    gtk_box_pack_start (GTK_BOX (hbox), rect_hbox, FALSE, TRUE, 0);
+    gtk_widget_show (rect_hbox);
+
+    rect_hbox = gtk_hbox_new (FALSE, 6);
+
+    label = gtk_label_new ("y2:");
+    gtk_box_pack_start (GTK_BOX (rect_hbox), label, TRUE, TRUE, 0);
+    gtk_widget_show (label);
+
+    rect_y2 = gtk_spin_button_new_with_range (0, height, 1.0);
+    gtk_box_pack_start (GTK_BOX (rect_hbox), rect_y2, TRUE, TRUE, 0);
+    gtk_widget_show (rect_y2);
+
+    gtk_box_pack_start (GTK_BOX (hbox), rect_hbox, FALSE, TRUE, 0);
+    gtk_widget_show (rect_hbox);
+
+    gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+    gtk_widget_show (hbox);
+
+    gtk_dialog_run (GTK_DIALOG (dialog));
+
+    rect.x1 = gtk_spin_button_get_value (GTK_SPIN_BUTTON (rect_x1));
+    rect.x2 = gtk_spin_button_get_value (GTK_SPIN_BUTTON (rect_x2));
+    rect.y1 = height - gtk_spin_button_get_value (GTK_SPIN_BUTTON (rect_y2));
+    rect.y2 = height - gtk_spin_button_get_value (GTK_SPIN_BUTTON (rect_y1));
+    annot = poppler_annot_text_new (demo->doc, &rect);
+    poppler_page_add_annot (page, annot);
+
+    g_object_unref (page);
+
+    gtk_widget_destroy (dialog);
+}
+
 GtkWidget *
 pgd_annots_create_widget (PopplerDocument *document)
 {
@@ -706,6 +813,13 @@ pgd_annots_create_widget (PopplerDocument *document)
     gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
     gtk_widget_show (button);
 
+    button = gtk_button_new_with_label ("Add Annot");
+    g_signal_connect (G_OBJECT (button), "clicked",
+		      G_CALLBACK (pgd_annots_add_annot),
+		      (gpointer) demo);
+    gtk_box_pack_end (GTK_BOX (hbox), button, FALSE, FALSE, 0);
+    gtk_widget_show (button);
+
     gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0);
     gtk_widget_show (hbox);
 
commit 969cb850f5c2bc31de82c591b2b3210b5cfabf5f
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Tue Jul 20 13:53:29 2010 +0200

    [glib] docs: Add new symbols to poppler-sections.txt

diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt
index ab91b9a..d3e4c3a 100644
--- a/glib/reference/poppler-sections.txt
+++ b/glib/reference/poppler-sections.txt
@@ -44,6 +44,7 @@ poppler_page_get_form_field_mapping
 poppler_page_free_form_field_mapping
 poppler_page_get_annot_mapping
 poppler_page_free_annot_mapping
+poppler_page_add_annot
 poppler_rectangle_new
 poppler_rectangle_copy
 poppler_rectangle_free
@@ -345,20 +346,37 @@ poppler_annot_get_flags
 poppler_annot_get_name
 poppler_annot_get_page_index
 poppler_annot_get_color
+poppler_annot_set_color
 poppler_annot_get_contents
 poppler_annot_set_contents
 poppler_annot_get_modified
 poppler_annot_markup_get_label
+poppler_annot_markup_set_label
 poppler_annot_markup_get_subject
 poppler_annot_markup_get_opacity
+poppler_annot_markup_set_opacity
 poppler_annot_markup_has_popup
+poppler_annot_markup_set_popup
 poppler_annot_markup_get_popup_is_open
+poppler_annot_markup_set_popup_is_open
 poppler_annot_markup_get_popup_rectangle
 poppler_annot_markup_get_date
 poppler_annot_markup_get_external_data
 poppler_annot_markup_get_reply_to
+poppler_annot_text_new
 poppler_annot_text_get_icon
+POPPLER_ANNOT_TEXT_ICON_NOTE
+POPPLER_ANNOT_TEXT_ICON_COMMENT
+POPPLER_ANNOT_TEXT_ICON_KEY
+POPPLER_ANNOT_TEXT_ICON_HELP
+POPPLER_ANNOT_TEXT_ICON_NEW_PARAGRAPH
+POPPLER_ANNOT_TEXT_ICON_PARAGRAPH
+POPPLER_ANNOT_TEXT_ICON_INSERT
+POPPLER_ANNOT_TEXT_ICON_CROSS
+POPPLER_ANNOT_TEXT_ICON_CIRCLE
+poppler_annot_text_set_icon
 poppler_annot_text_get_is_open
+poppler_annot_text_set_is_open
 poppler_annot_text_get_state
 poppler_annot_free_text_get_callout_line
 poppler_annot_free_text_get_quadding
commit 251959438b6257fe71ed58e79eec60cda68a66cf
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Tue Jul 20 13:53:00 2010 +0200

    [glib] Add poppler_page_add_annot()

diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc
index 288bf11..680c8de 100644
--- a/glib/poppler-document.cc
+++ b/glib/poppler-document.cc
@@ -275,9 +275,10 @@ handle_save_error (int      err_code,
  * @document: a #PopplerDocument
  * @uri: uri of file to save
  * @error: (allow-none): return location for an error, or %NULL
- * 
- * Saves @document. Any change made in the document such as 
- * form fields filled by the user will be saved. 
+ *
+ * Saves @document. Any change made in the document such as
+ * form fields filled, annotations added or modified
+ * will be saved.
  * If @error is set, %FALSE will be returned. Possible errors
  * include those in the #G_FILE_ERROR domain.
  * 
diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc
index a4e2fc6..bc95e65 100644
--- a/glib/poppler-page.cc
+++ b/glib/poppler-page.cc
@@ -1543,6 +1543,25 @@ poppler_page_free_annot_mapping (GList *list)
   g_list_free (list);
 }
 
+/**
+ * poppler_page_add_annot:
+ * @page: a #PopplerPage
+ * @annot: a #PopplerAnnot to add
+ *
+ * Adds annotation @annot to @page.
+ *
+ * Since: 0.16
+ */
+void
+poppler_page_add_annot (PopplerPage  *page,
+			PopplerAnnot *annot)
+{
+  g_return_if_fail (POPPLER_IS_PAGE (page));
+  g_return_if_fail (POPPLER_IS_ANNOT (annot));
+
+  page->page->addAnnot (annot->annot);
+}
+
 /* PopplerRectangle type */
 
 POPPLER_DEFINE_BOXED_TYPE (PopplerRectangle, poppler_rectangle,
diff --git a/glib/poppler-page.h b/glib/poppler-page.h
index 6af7d89..a14689d 100644
--- a/glib/poppler-page.h
+++ b/glib/poppler-page.h
@@ -113,6 +113,8 @@ GList              *poppler_page_get_form_field_mapping  (PopplerPage        *pa
 void                poppler_page_free_form_field_mapping (GList              *list);
 GList                 *poppler_page_get_annot_mapping    (PopplerPage        *page);
 void                   poppler_page_free_annot_mapping   (GList              *list);
+void                   poppler_page_add_annot            (PopplerPage        *page,
+							  PopplerAnnot       *annot);
 void 		      poppler_page_get_crop_box 	 (PopplerPage        *page,
 							  PopplerRectangle   *rect);
 gboolean               poppler_page_get_text_layout      (PopplerPage        *page,
commit 78a4f6976e708f2cc23aac49fbff0faf00e74bc3
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Tue Jul 20 13:51:16 2010 +0200

    [glib] annots: Add several setter methods

diff --git a/glib/poppler-annot.cc b/glib/poppler-annot.cc
index 3a49b01..5d8f2ea 100644
--- a/glib/poppler-annot.cc
+++ b/glib/poppler-annot.cc
@@ -35,12 +35,6 @@ typedef struct _PopplerAnnotFileAttachmentClass PopplerAnnotFileAttachmentClass;
 typedef struct _PopplerAnnotMovieClass          PopplerAnnotMovieClass;
 typedef struct _PopplerAnnotScreenClass         PopplerAnnotScreenClass;
 
-struct _PopplerAnnot
-{
-  GObject  parent_instance;
-  Annot   *annot;
-};
-
 struct _PopplerAnnotClass
 {
   GObjectClass parent_class;
@@ -184,6 +178,32 @@ _poppler_annot_text_new (Annot *annot)
   return poppler_annot;
 }
 
+/**
+ * poppler_annot_text_new:
+ * @doc: a #PopplerDocument
+ * @rect: a #PopplerRectangle
+ *
+ * Creates a new Text annotation that will be
+ * located on @rect when added to a page. See
+ * poppler_page_add_annot()
+ *
+ * Return value: A newly created #PopplerAnnotText annotation
+ *
+ * Since: 0.16
+ */
+PopplerAnnot *
+poppler_annot_text_new (PopplerDocument  *doc,
+			PopplerRectangle *rect)
+{
+  Annot *annot;
+  PDFRectangle pdf_rect(rect->x1, rect->y1,
+			rect->x2, rect->y2);
+
+  annot = new AnnotText (doc->doc->getXRef(), &pdf_rect, doc->doc->getCatalog());
+
+  return _poppler_annot_text_new (annot);
+}
+
 static void
 poppler_annot_free_text_init (PopplerAnnotFreeText *poppler_annot)
 {
@@ -546,6 +566,31 @@ poppler_annot_get_color (PopplerAnnot *poppler_annot)
 }
 
 /**
+ * poppler_annot_set_color:
+ * @poppler_annot: a #PopplerAnnot
+ * @poppler_color: (allow-none): a #PopplerColor, or %NULL
+ *
+ * Sets the color of @poppler_annot.
+ *
+ * Since: 0.16
+ */
+void
+poppler_annot_set_color (PopplerAnnot *poppler_annot,
+			 PopplerColor *poppler_color)
+{
+  AnnotColor *color = NULL;
+
+  if (poppler_color) {
+    color = new AnnotColor ((double)poppler_color->red / 65535,
+			    (double)poppler_color->green / 65535,
+			    (double)poppler_color->blue / 65535);
+  }
+
+  /* Annot takes ownership of the color */
+  poppler_annot->annot->setColor (color);
+}
+
+/**
  * poppler_annot_get_page_index:
  * @poppler_annot: a #PopplerAnnot
  *
@@ -568,13 +613,13 @@ poppler_annot_get_page_index (PopplerAnnot *poppler_annot)
 
 /* PopplerAnnotMarkup */
 /**
-* poppler_annot_markup_get_label:
-* @poppler_annot: a #PopplerAnnotMarkup
-*
-* Retrieves the label text of @poppler_annot.
-*
-* Return value: the label text of @poppler_annot.
-*/
+ * poppler_annot_markup_get_label:
+ * @poppler_annot: a #PopplerAnnotMarkup
+ *
+ * Retrieves the label text of @poppler_annot.
+ *
+ * Return value: the label text of @poppler_annot.
+ */
 gchar *
 poppler_annot_markup_get_label (PopplerAnnotMarkup *poppler_annot)
 {
@@ -591,6 +636,35 @@ poppler_annot_markup_get_label (PopplerAnnotMarkup *poppler_annot)
 }
 
 /**
+ * poppler_annot_markup_set_label:
+ * @poppler_annot: a #PopplerAnnotMarkup
+ * @label: (allow-none): a text string containing the new label, or %NULL
+ *
+ * Sets the label text of @poppler_annot, replacing the current one
+ *
+ * Since: 0.16
+ */
+void
+poppler_annot_markup_set_label (PopplerAnnotMarkup *poppler_annot,
+				const gchar        *label)
+{
+  AnnotMarkup *annot;
+  GooString *goo_tmp;
+  gchar *tmp;
+  gsize length = 0;
+
+  g_return_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot));
+
+  annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
+
+  tmp = label ? g_convert (label, -1, "UTF-16BE", "UTF-8", NULL, &length, NULL) : NULL;
+  goo_tmp = new GooString (tmp, length);
+  g_free (tmp);
+  annot->setLabel (goo_tmp);
+  delete goo_tmp;
+}
+
+/**
  * poppler_annot_markup_has_popup:
  * @poppler_annot: a #PopplerAnnotMarkup
  *
@@ -613,10 +687,36 @@ poppler_annot_markup_has_popup (PopplerAnnotMarkup *poppler_annot)
 }
 
 /**
+ * poppler_annot_markup_set_popup:
+ * @poppler_annot: a #PopplerAnnotMarkup
+ * @popup_rect: a #PopplerRectangle
+ *
+ * Associates a new popup window for editing contents of @poppler_annot.
+ * Popup window shall be displayed by viewers at @popup_rect on the page.
+ *
+ * Since: 0.16
+ */
+void
+poppler_annot_markup_set_popup (PopplerAnnotMarkup *poppler_annot,
+				PopplerRectangle   *popup_rect)
+{
+  AnnotMarkup *annot;
+  AnnotPopup  *popup;
+  PDFRectangle pdf_rect(popup_rect->x1, popup_rect->y1,
+			popup_rect->x2, popup_rect->y2);
+
+  g_return_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot));
+
+  annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
+  popup = new AnnotPopup (annot->getXRef(), &pdf_rect, (Catalog *)NULL);
+  annot->setPopup (popup);
+}
+
+/**
  * poppler_annot_markup_get_popup_is_open:
  * @poppler_annot: a #PopplerAnnotMarkup
  *
- * Retrieves the state of the popup annot related to @poppler_annot.
+ * Retrieves the state of the popup window related to @poppler_annot.
  *
  * Return value: the state of @poppler_annot. %TRUE if it's open, %FALSE in
  *               other case.
@@ -638,11 +738,39 @@ poppler_annot_markup_get_popup_is_open (PopplerAnnotMarkup *poppler_annot)
 }
 
 /**
+ * poppler_annot_markup_set_popup_is_open:
+ * @poppler_annot: a #PopplerAnnotMarkup
+ * @is_open: whether popup window should initially be displayed open
+ *
+ * Sets the state of the popup window related to @poppler_annot.
+ *
+ * Since: 0.16
+ **/
+void
+poppler_annot_markup_set_popup_is_open (PopplerAnnotMarkup *poppler_annot,
+					gboolean            is_open)
+{
+  AnnotMarkup *annot;
+  AnnotPopup *annot_popup;
+
+  g_return_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot));
+
+  annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
+
+  annot_popup = annot->getPopup ();
+  if (!annot_popup)
+    return;
+
+  if (annot_popup->getOpen () != is_open)
+    annot_popup->setOpen (is_open);
+}
+
+/**
  * poppler_annot_markup_get_popup_rectangle:
  * @poppler_annot: a #PopplerAnnotMarkup
  * @poppler_rect: (out): a #PopplerRectangle to store the popup rectangle
  *
- * Retrieves the rectangle of the popup annot related to @poppler_annot.
+ * Retrieves the rectangle of the popup window related to @poppler_annot.
  *
  * Return value: %TRUE if #PopplerRectangle was correctly filled, %FALSE otherwise
  *
@@ -674,13 +802,14 @@ poppler_annot_markup_get_popup_rectangle (PopplerAnnotMarkup *poppler_annot,
 }
 
 /**
-* poppler_annot_markup_get_opacity:
-* @poppler_annot: a #PopplerAnnotMarkup
-*
-* Retrieves the opacity value of @poppler_annot.
-*
-* Return value: the opacity value of @poppler_annot.
-*/
+ * poppler_annot_markup_get_opacity:
+ * @poppler_annot: a #PopplerAnnotMarkup
+ *
+ * Retrieves the opacity value of @poppler_annot.
+ *
+ * Return value: the opacity value of @poppler_annot,
+ *               between 0 (transparent) and 1 (opaque)
+ */
 gdouble
 poppler_annot_markup_get_opacity (PopplerAnnotMarkup *poppler_annot)
 {
@@ -693,6 +822,29 @@ poppler_annot_markup_get_opacity (PopplerAnnotMarkup *poppler_annot)
   return annot->getOpacity ();
 }
 
+/**
+ * poppler_annot_markup_set_opacity:
+ * @poppler_annot: a #PopplerAnnotMarkup
+ * @opacity: a constant opacity value, between 0 (transparent) and 1 (opaque)
+ *
+ * Sets the opacity of @poppler_annot. This value applies to
+ * all visible elements of @poppler_annot in its closed state,
+ * but not to the pop-up window that appears when it's openened
+ *
+ * Since: 0.16
+ */
+void
+poppler_annot_markup_set_opacity (PopplerAnnotMarkup *poppler_annot,
+				  gdouble             opacity)
+{
+  AnnotMarkup *annot;
+
+  g_return_if_fail (POPPLER_IS_ANNOT_MARKUP (poppler_annot));
+
+  annot = static_cast<AnnotMarkup *>(POPPLER_ANNOT (poppler_annot)->annot);
+  annot->setOpacity(opacity);
+}
+
 GDate *
 poppler_annot_markup_get_date (PopplerAnnotMarkup *poppler_annot)
 {
@@ -825,13 +977,34 @@ poppler_annot_text_get_is_open (PopplerAnnotText *poppler_annot)
 }
 
 /**
+ * poppler_annot_text_set_is_open:
+ * @poppler_annot: a #PopplerAnnotText
+ * @is_open: whether annotation should initially be displayed open
+ *
+ * Sets whether @poppler_annot should initially be displayed open
+ *
+ * Since: 0.16
+ */
+void
+poppler_annot_text_set_is_open (PopplerAnnotText *poppler_annot,
+				gboolean          is_open)
+{
+  AnnotText *annot;
+
+  g_return_if_fail (POPPLER_IS_ANNOT_TEXT (poppler_annot));
+
+  annot = static_cast<AnnotText *>(POPPLER_ANNOT (poppler_annot)->annot);
+  annot->setOpen(is_open);
+}
+
+/**
  * poppler_annot_text_get_icon:
  * @poppler_annot: a #PopplerAnnotText
  *
- * Gets the icon type of @poppler_annot.
+ * Gets name of the icon of @poppler_annot.
  *
- * Return value: #PopplerAnnotTextIcon of @poppler_annot.
- **/ 
+ * Return value: a new allocated string containing the icon name
+ */
 gchar *
 poppler_annot_text_get_icon (PopplerAnnotText *poppler_annot)
 {
@@ -848,6 +1021,61 @@ poppler_annot_text_get_icon (PopplerAnnotText *poppler_annot)
 }
 
 /**
+ * poppler_annot_text_set_icon:
+ * @poppler_annot: a #PopplerAnnotText
+ * @icon: the name of an icon
+ *
+ * Sets the icon of @poppler_annot. The following predefined
+ * icons are currently supported:
+ * <variablelist>
+ *  <varlistentry>
+ *   <term>#POPPLER_ANNOT_TEXT_ICON_NOTE</term>
+ *  </varlistentry>
+ *  <varlistentry>
+ *   <term>#POPPLER_ANNOT_TEXT_ICON_COMMENT</term>
+ *  </varlistentry>
+ *  <varlistentry>
+ *   <term>#POPPLER_ANNOT_TEXT_ICON_KEY</term>
+ *  </varlistentry>
+ *  <varlistentry>
+ *   <term>#POPPLER_ANNOT_TEXT_ICON_HELP</term>
+ *  </varlistentry>
+ *  <varlistentry>
+ *   <term>#POPPLER_ANNOT_TEXT_ICON_NEW_PARAGRAPH</term>
+ *  </varlistentry>
+ *  <varlistentry>
+ *   <term>#POPPLER_ANNOT_TEXT_ICON_PARAGRAPH</term>
+ *  </varlistentry>
+ *  <varlistentry>
+ *   <term>#POPPLER_ANNOT_TEXT_ICON_INSERT</term>
+ *  </varlistentry>
+ *  <varlistentry>
+ *   <term>#POPPLER_ANNOT_TEXT_ICON_CROSS</term>
+ *  </varlistentry>
+ *  <varlistentry>
+ *   <term>#POPPLER_ANNOT_TEXT_ICON_CIRCLE</term>
+ *  </varlistentry>
+ * </variablelist>
+ *
+ * Since: 0.16
+ */
+void
+poppler_annot_text_set_icon (PopplerAnnotText *poppler_annot,
+			     const gchar      *icon)
+{
+  AnnotText *annot;
+  GooString *text;
+
+  g_return_if_fail (POPPLER_IS_ANNOT_TEXT (poppler_annot));
+
+  annot = static_cast<AnnotText *>(POPPLER_ANNOT (poppler_annot)->annot);
+
+  text = new GooString(icon);
+  annot->setIcon(text);
+  delete text;
+}
+
+/**
  * poppler_annot_text_get_state:
  * @poppler_annot: a #PopplerAnnotText
  *
diff --git a/glib/poppler-annot.h b/glib/poppler-annot.h
index 8266407..99cbb74 100644
--- a/glib/poppler-annot.h
+++ b/glib/poppler-annot.h
@@ -114,6 +114,16 @@ typedef enum
   POPPLER_ANNOT_EXTERNAL_DATA_MARKUP_UNKNOWN
 } PopplerAnnotExternalDataType;
 
+#define POPPLER_ANNOT_TEXT_ICON_NOTE          "Note"
+#define POPPLER_ANNOT_TEXT_ICON_COMMENT       "Comment"
+#define POPPLER_ANNOT_TEXT_ICON_KEY           "Key"
+#define POPPLER_ANNOT_TEXT_ICON_HELP          "Help"
+#define POPPLER_ANNOT_TEXT_ICON_NEW_PARAGRAPH "NewParagraph"
+#define POPPLER_ANNOT_TEXT_ICON_PARAGRAPH     "Paragraph"
+#define POPPLER_ANNOT_TEXT_ICON_INSERT        "Insert"
+#define POPPLER_ANNOT_TEXT_ICON_CROSS         "Cross"
+#define POPPLER_ANNOT_TEXT_ICON_CIRCLE        "Circle"
+
 typedef enum
 {
   POPPLER_ANNOT_TEXT_STATE_MARKED,
@@ -153,16 +163,26 @@ gchar                        *poppler_annot_get_name                           (
 gchar                        *poppler_annot_get_modified                       (PopplerAnnot *poppler_annot);
 PopplerAnnotFlag              poppler_annot_get_flags                          (PopplerAnnot *poppler_annot);
 PopplerColor                 *poppler_annot_get_color                          (PopplerAnnot *poppler_annot);
+void                          poppler_annot_set_color                          (PopplerAnnot *poppler_annot,
+										PopplerColor *poppler_color);
 gint                          poppler_annot_get_page_index                     (PopplerAnnot *poppler_annot);
 
 /* PopplerAnnotMarkup */
 GType                         poppler_annot_markup_get_type                    (void) G_GNUC_CONST;
 gchar                        *poppler_annot_markup_get_label                   (PopplerAnnotMarkup *poppler_annot);
+void                          poppler_annot_markup_set_label                   (PopplerAnnotMarkup *poppler_annot,
+										const gchar        *label);
 gboolean                      poppler_annot_markup_has_popup                   (PopplerAnnotMarkup *poppler_annot);
+void                          poppler_annot_markup_set_popup                   (PopplerAnnotMarkup *poppler_annot,
+										PopplerRectangle   *popup_rect);
 gboolean                      poppler_annot_markup_get_popup_is_open           (PopplerAnnotMarkup *poppler_annot);
+void                          poppler_annot_markup_set_popup_is_open           (PopplerAnnotMarkup *poppler_annot,
+										gboolean            is_open);
 gboolean                      poppler_annot_markup_get_popup_rectangle         (PopplerAnnotMarkup *poppler_annot,
 										PopplerRectangle   *poppler_rect);
 gdouble                       poppler_annot_markup_get_opacity                 (PopplerAnnotMarkup *poppler_annot);
+void                          poppler_annot_markup_set_opacity                 (PopplerAnnotMarkup *poppler_annot,
+										gdouble             opacity);
 GDate                        *poppler_annot_markup_get_date                    (PopplerAnnotMarkup *poppler_annot);
 gchar                        *poppler_annot_markup_get_subject                 (PopplerAnnotMarkup *poppler_annot);
 PopplerAnnotMarkupReplyType   poppler_annot_markup_get_reply_to                (PopplerAnnotMarkup *poppler_annot);
@@ -170,8 +190,14 @@ PopplerAnnotExternalDataType  poppler_annot_markup_get_external_data           (
 
 /* PopplerAnnotText */
 GType                         poppler_annot_text_get_type                      (void) G_GNUC_CONST;
+PopplerAnnot                 *poppler_annot_text_new                           (PopplerDocument  *doc,
+										PopplerRectangle *rect);
 gboolean                      poppler_annot_text_get_is_open                   (PopplerAnnotText *poppler_annot);
+void                          poppler_annot_text_set_is_open                   (PopplerAnnotText *poppler_annot,
+										gboolean          is_open);
 gchar                        *poppler_annot_text_get_icon                      (PopplerAnnotText *poppler_annot);
+void                          poppler_annot_text_set_icon                      (PopplerAnnotText *poppler_annot,
+										const gchar      *icon);
 PopplerAnnotTextState         poppler_annot_text_get_state                     (PopplerAnnotText *poppler_annot);
 
 /* PopplerAnnotFreeText */
diff --git a/glib/poppler-private.h b/glib/poppler-private.h
index a97dadb..d5b5b3e 100644
--- a/glib/poppler-private.h
+++ b/glib/poppler-private.h
@@ -68,6 +68,12 @@ struct _PopplerFormField
   FormWidget *widget;
 };
 
+struct _PopplerAnnot
+{
+  GObject  parent_instance;
+  Annot   *annot;
+};
+
 typedef struct _Layer {
   /*< private >*/
   GList *kids;
commit fee488c9db60ab691ce9ff5eef284be2af897aee
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Jul 18 11:26:59 2010 +0200

    [annots] Add AnnotMarkup::setOpacity

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 1f7aca2..6a18d7f 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1527,6 +1527,14 @@ void AnnotMarkup::setPopup(AnnotPopup *new_popup) {
   }
 }
 
+void AnnotMarkup::setOpacity(double opacityA) {
+  Object obj1;
+
+  opacity = opacityA;
+  obj1.initReal(opacity);
+  update ("CA", &obj1);
+}
+
 //------------------------------------------------------------------------
 // AnnotText
 //------------------------------------------------------------------------
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 2268a82..a21b55e 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -635,6 +635,7 @@ public:
   // The annotation takes the ownership of new_popup
   void setPopup(AnnotPopup *new_popup);
   void setLabel(GooString *new_label);
+  void setOpacity(double opacityA);
 
 protected:
   GooString *label;             // T            (Default autor)
commit d15a355ede2d8510c4df847ea0b92b5357b29914
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Sun Jul 18 09:57:35 2010 +0200

    Set the page reference (P in annot dict) when adding a new annot to a page

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index cb66b65..1f7aca2 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -1098,6 +1098,15 @@ void Annot::setColor(AnnotColor *new_color) {
   }
 }
 
+void Annot::setPage(Ref *pageRef, int pageIndex)
+{
+  Object obj1;
+
+  obj1.initRef(pageRef->num, pageRef->gen);
+  update("P", &obj1);
+  page = pageIndex;
+}
+
 double Annot::getXMin() {
   return rect->x1;
 }
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 9228c2e..2268a82 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -509,7 +509,10 @@ public:
   // new_color. 
   void setColor(AnnotColor *new_color);
 
+  void setPage(Ref *pageRef, int pageIndex);
+
   // getters
+  XRef *getXRef() const { return xref; }
   Ref getRef() const { return ref; }
   AnnotSubtype getType() const { return type; }
   PDFRectangle *getRect() const { return rect; }
diff --git a/poppler/Page.cc b/poppler/Page.cc
index d52cb77..a9ad2b8 100644
--- a/poppler/Page.cc
+++ b/poppler/Page.cc
@@ -380,6 +380,8 @@ void Page::addAnnot(Annot *annot) {
     }
     obj1.free();
   }
+
+  annot->setPage(&pageRef, num);
 }
 
 Links *Page::getLinks(Catalog *catalog) {


More information about the poppler mailing list