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

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 6 22:41:31 UTC 2018


 glib/demo/forms.c          |   58 ++++++++++++++++++++++++++++++++++++++-------
 glib/poppler-form-field.cc |   57 ++++++++++++++++++++++++++++++++++++++++++++
 glib/poppler-form-field.h  |   24 ++++++++++++++++++
 glib/poppler-private.h     |    4 +++
 4 files changed, 134 insertions(+), 9 deletions(-)

New commits:
commit b8cae8886a2894502dc12ceba63f2aab62ab3992
Author: Albert Astals Cid <tsdgeos at yahoo.es>
Date:   Tue Nov 6 22:11:28 2018 +0000

    Update since to 0.72

diff --git a/glib/poppler-form-field.cc b/glib/poppler-form-field.cc
index 1881ef6e..7bb9c692 100644
--- a/glib/poppler-form-field.cc
+++ b/glib/poppler-form-field.cc
@@ -208,7 +208,7 @@ poppler_form_field_get_action (PopplerFormField *field)
  *               object is owned by @field and should not be freed.
  *
  *
- * Since: 0.71
+ * Since: 0.72
  */
 PopplerAction *
 poppler_form_field_get_additional_action (PopplerFormField           *field,
diff --git a/glib/poppler-form-field.h b/glib/poppler-form-field.h
index 7c7f73cb..541bc44d 100644
--- a/glib/poppler-form-field.h
+++ b/glib/poppler-form-field.h
@@ -69,7 +69,7 @@ typedef enum
  *
  * Form field additional action types to be passed to @poppler_form_field_get_additional_action
  *
- * Since: 0.71
+ * Since: 0.72
  */
 typedef enum
 {
commit d09f763b3ea5581f7819b46b659f3d9b1b5fd78c
Author: Elliott Sales de Andrade <quantum.analyst at gmail.com>
Date:   Thu Nov 7 00:51:11 2013 -0500

    glib: Support getting form widget additional actions.

diff --git a/glib/demo/forms.c b/glib/demo/forms.c
index 11c64894..98c28f0e 100644
--- a/glib/demo/forms.c
+++ b/glib/demo/forms.c
@@ -182,6 +182,46 @@ pgd_form_field_view_set_field (GtkWidget        *field_view,
 		gtk_widget_show (action_view);
 	}
 
+	action = poppler_form_field_get_additional_action (field, POPPLER_ADDITIONAL_ACTION_FIELD_MODIFIED);
+	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_GRID (table), "<b>Field Modified Action:</b>", action_view, &row);
+		gtk_widget_show (action_view);
+	}
+
+	action = poppler_form_field_get_additional_action (field, POPPLER_ADDITIONAL_ACTION_FORMAT_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_GRID (table), "<b>Field Format Action:</b>", action_view, &row);
+		gtk_widget_show (action_view);
+	}
+
+	action = poppler_form_field_get_additional_action (field, POPPLER_ADDITIONAL_ACTION_VALIDATE_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_GRID (table), "<b>Validate Field Action:</b>", action_view, &row);
+		gtk_widget_show (action_view);
+	}
+
+	action = poppler_form_field_get_additional_action (field, POPPLER_ADDITIONAL_ACTION_CALCULATE_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_GRID (table), "<b>Calculate Field 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),
diff --git a/glib/poppler-form-field.cc b/glib/poppler-form-field.cc
index 2e1244b0..1881ef6e 100644
--- a/glib/poppler-form-field.cc
+++ b/glib/poppler-form-field.cc
@@ -196,6 +196,63 @@ poppler_form_field_get_action (PopplerFormField *field)
   return field->action;
 }
 
+/**
+ * poppler_form_field_get_additional_action:
+ * @field: a #PopplerFormField
+ * @type: the type of additional action
+ *
+ * Retrieves the action (#PopplerAction) that shall be performed when
+ * an additional action is triggered on @field, or %NULL.
+ *
+ * Return value: (transfer none): the action to perform. The returned
+ *               object is owned by @field and should not be freed.
+ *
+ *
+ * Since: 0.71
+ */
+PopplerAction *
+poppler_form_field_get_additional_action (PopplerFormField           *field,
+					  PopplerAdditionalActionType type)
+{
+  Annot::FormAdditionalActionsType form_action;
+  LinkAction *link_action;
+  PopplerAction **action;
+
+  switch (type)
+  {
+    case POPPLER_ADDITIONAL_ACTION_FIELD_MODIFIED:
+      form_action = Annot::actionFieldModified;
+      action = &field->field_modified_action;
+      break;
+    case POPPLER_ADDITIONAL_ACTION_FORMAT_FIELD:
+      form_action = Annot::actionFormatField;
+      action = &field->format_field_action;
+      break;
+    case POPPLER_ADDITIONAL_ACTION_VALIDATE_FIELD:
+      form_action = Annot::actionValidateField;
+      action = &field->validate_field_action;
+      break;
+    case POPPLER_ADDITIONAL_ACTION_CALCULATE_FIELD:
+      form_action = Annot::actionCalculateField;
+      action = &field->calculate_field_action;
+      break;
+    default:
+      g_return_val_if_reached (nullptr);
+      return nullptr;
+  }
+
+  if (*action)
+    return *action;
+
+  link_action = field->widget->getAdditionalAction (form_action);
+  if (!link_action)
+    return NULL;
+
+  *action = _poppler_action_new (NULL, link_action, NULL);
+
+  return *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 94774860..7c7f73cb 100644
--- a/glib/poppler-form-field.h
+++ b/glib/poppler-form-field.h
@@ -58,6 +58,27 @@ typedef enum
   POPPLER_FORM_CHOICE_LIST
 } PopplerFormChoiceType;
 
+/**
+ * PopplerAdditionalActionType:
+ * @POPPLER_ADDITIONAL_ACTION_FIELD_MODIFIED: The action to be performed when the user modifies the field.
+ * @POPPLER_ADDITIONAL_ACTION_FORMAT_FIELD: The action to be performed before the field is formatted to
+ * display its value.
+ * @POPPLER_ADDITIONAL_ACTION_VALIDATE_FIELD: The action to be performed when the field value changes.
+ * @POPPLER_ADDITIONAL_ACTION_CALCULATE_FIELD: The action to be performed when the field needs to be
+ * recalculated.
+ *
+ * Form field additional action types to be passed to @poppler_form_field_get_additional_action
+ *
+ * Since: 0.71
+ */
+typedef enum
+{
+  POPPLER_ADDITIONAL_ACTION_FIELD_MODIFIED,
+  POPPLER_ADDITIONAL_ACTION_FORMAT_FIELD,
+  POPPLER_ADDITIONAL_ACTION_VALIDATE_FIELD,
+  POPPLER_ADDITIONAL_ACTION_CALCULATE_FIELD
+} PopplerAdditionalActionType;
+
 POPPLER_PUBLIC
 GType                 poppler_form_field_get_type                (void) G_GNUC_CONST;
 
@@ -77,6 +98,9 @@ POPPLER_PUBLIC
 gchar                *poppler_form_field_get_name                (PopplerFormField *field);
 POPPLER_PUBLIC
 PopplerAction        *poppler_form_field_get_action              (PopplerFormField *field);
+POPPLER_PUBLIC
+PopplerAction        *poppler_form_field_get_additional_action   (PopplerFormField *field,
+								  PopplerAdditionalActionType type);
 
 /* Button Field */
 POPPLER_PUBLIC
diff --git a/glib/poppler-private.h b/glib/poppler-private.h
index 5a4d131a..3e6b4b17 100644
--- a/glib/poppler-private.h
+++ b/glib/poppler-private.h
@@ -71,6 +71,10 @@ struct _PopplerFormField
   PopplerDocument *document;
   FormWidget *widget;
   PopplerAction *action;
+  PopplerAction *field_modified_action;
+  PopplerAction *format_field_action;
+  PopplerAction *validate_field_action;
+  PopplerAction *calculate_field_action;
 };
 
 struct _PopplerAnnot
commit ee6166ab599c3d5f694191707c366653afa7b0d3
Author: Elliott Sales de Andrade <quantum.analyst at gmail.com>
Date:   Thu Nov 7 00:50:38 2013 -0500

    glib-demo: Fix indent for actions code.

diff --git a/glib/demo/forms.c b/glib/demo/forms.c
index 8fa8785e..11c64894 100644
--- a/glib/demo/forms.c
+++ b/glib/demo/forms.c
@@ -130,7 +130,7 @@ pgd_form_field_view_set_field (GtkWidget        *field_view,
 			       PopplerFormField *field)
 {
 	GtkWidget     *table;
-        PopplerAction *action;
+	PopplerAction *action;
 	GEnumValue    *enum_value;
 	gchar         *text;
 	gint           row = 0;
@@ -172,15 +172,15 @@ 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 = 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_GRID (table), "<b>Action:</b>", action_view, &row);
-                gtk_widget_show (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_GRID (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:


More information about the poppler mailing list