[poppler] 2 commits - glib/demo glib/poppler-form-field.cc glib/poppler-form-field.h glib/poppler-private.h glib/reference

Carlos Garcia Campos carlosgc at kemper.freedesktop.org
Mon Mar 28 09:21:24 PDT 2011


 glib/demo/forms.c                   |   21 ++++++++++++++++-----
 glib/poppler-form-field.cc          |   34 ++++++++++++++++++++++++++++++++++
 glib/poppler-form-field.h           |    1 +
 glib/poppler-private.h              |    1 +
 glib/reference/poppler-sections.txt |    1 +
 5 files changed, 53 insertions(+), 5 deletions(-)

New commits:
commit d94d5056d5570e2f5cb578736eba12317ea63fa4
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Mon Mar 28 18:20:31 2011 +0200

    glib-demo: show the activation action of form fields if there's one

diff --git a/glib/demo/forms.c b/glib/demo/forms.c
index fc9695d..3a74ef5 100644
--- a/glib/demo/forms.c
+++ b/glib/demo/forms.c
@@ -131,11 +131,12 @@ static void
 pgd_form_field_view_set_field (GtkWidget        *field_view,
 			       PopplerFormField *field)
 {
-	GtkWidget  *alignment;
-	GtkWidget  *table;
-	GEnumValue *enum_value;
-	gchar      *text;
-	gint        row = 0;
+	GtkWidget     *alignment;
+	GtkWidget     *table;
+        PopplerAction *action;
+	GEnumValue    *enum_value;
+	gchar         *text;
+	gint           row = 0;
 
 	alignment = gtk_bin_get_child (GTK_BIN (field_view));
 	if (alignment) {
@@ -170,6 +171,16 @@ pgd_form_field_view_set_field (GtkWidget        *field_view,
 		g_free (text);
 	}
 
+        action = poppler_form_field_get_action (field);
+        if (action) {
+                GtkWidget *action_view;
+
+                action_view = pgd_action_view_new (NULL);
+                pgd_action_view_set_action (action_view, action);
+                pgd_table_add_property_with_custom_widget (GTK_TABLE (table), "<b>Action:</b>", action_view, &row);
+                gtk_widget_show (action_view);
+        }
+
 	switch (poppler_form_field_get_field_type (field)) {
 	case POPPLER_FORM_FIELD_BUTTON:
 		enum_value = g_enum_get_value ((GEnumClass *) g_type_class_ref (POPPLER_TYPE_FORM_BUTTON_TYPE),
commit ba0f36b76d0c2fd4ef39f3013fc125a53747c03f
Author: Carlos Garcia Campos <carlosgc at gnome.org>
Date:   Mon Mar 28 18:17:52 2011 +0200

    glib: Add poppler_form_field_get_action()
    
    Fixes bug #33174.

diff --git a/glib/poppler-form-field.cc b/glib/poppler-form-field.cc
index 55d3bb3..09f8be1 100644
--- a/glib/poppler-form-field.cc
+++ b/glib/poppler-form-field.cc
@@ -45,6 +45,11 @@ poppler_form_field_finalize (GObject *object)
       g_object_unref (field->document);
       field->document = NULL;
     }
+  if (field->action)
+    {
+      poppler_action_free (field->action);
+      field->action = NULL;
+    }
   field->widget = NULL;
 
   G_OBJECT_CLASS (poppler_form_field_parent_class)->finalize (object);
@@ -159,6 +164,35 @@ poppler_form_field_is_read_only (PopplerFormField *field)
   return field->widget->isReadOnly ();
 }
 
+/**
+ * poppler_form_field_get_action:
+ * @field: a #PopplerFormField
+ *
+ * Retrieves the action (#PopplerAction) that shall be
+ * performed when @field is activated, or %NULL
+ *
+ * Return value: (transfer none): the action to perform. The returned
+ *               object is owned by @field and should not be freed
+ *
+ * Since: 0.18
+ */
+PopplerAction *
+poppler_form_field_get_action (PopplerFormField *field)
+{
+  LinkAction *action;
+
+  if (field->action)
+    return field->action;
+
+  action = field->widget->getActivationAction();
+  if (!action)
+    return NULL;
+
+  field->action = _poppler_action_new (NULL, action, NULL);
+
+  return field->action;
+}
+
 /* Button Field */
 /**
  * poppler_form_field_button_get_button_type
diff --git a/glib/poppler-form-field.h b/glib/poppler-form-field.h
index 8ae718e..898e0f6 100644
--- a/glib/poppler-form-field.h
+++ b/glib/poppler-form-field.h
@@ -67,6 +67,7 @@ gboolean              poppler_form_field_is_read_only            (PopplerFormFie
 gchar                *poppler_form_field_get_partial_name        (PopplerFormField *field);
 gchar                *poppler_form_field_get_mapping_name        (PopplerFormField *field);
 gchar                *poppler_form_field_get_name                (PopplerFormField *field);
+PopplerAction        *poppler_form_field_get_action              (PopplerFormField *field);
 
 /* Button Field */
 PopplerFormButtonType poppler_form_field_button_get_button_type  (PopplerFormField *field);
diff --git a/glib/poppler-private.h b/glib/poppler-private.h
index 4e06a0e..2becc99 100644
--- a/glib/poppler-private.h
+++ b/glib/poppler-private.h
@@ -68,6 +68,7 @@ struct _PopplerFormField
   GObject parent_instance;
   PopplerDocument *document;
   FormWidget *widget;
+  PopplerAction *action;
 };
 
 struct _PopplerAnnot
diff --git a/glib/reference/poppler-sections.txt b/glib/reference/poppler-sections.txt
index 525dcb5..417f03a 100644
--- a/glib/reference/poppler-sections.txt
+++ b/glib/reference/poppler-sections.txt
@@ -277,6 +277,7 @@ poppler_form_field_get_font_size
 poppler_form_field_get_partial_name
 poppler_form_field_get_mapping_name
 poppler_form_field_get_name
+poppler_form_field_get_action
 poppler_form_field_button_get_button_type
 poppler_form_field_button_get_state
 poppler_form_field_button_set_state


More information about the poppler mailing list