+
+static void
+pdf_document_forms_form_field_button_set_state (EvDocumentForms *document,
+ EvFormField *field,
+ gboolean state)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document);
+ PopplerFormField *poppler_field;
+
+ poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ if (!poppler_field)
+ return;
+
+ poppler_form_field_button_set_state (poppler_field, state);
+ g_object_unref (poppler_field);
+}
+
+static gboolean
+pdf_document_forms_form_field_button_get_state (EvDocumentForms *document,
+ EvFormField *field)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document);
+ PopplerFormField *poppler_field;
+ gboolean state;
+
+ poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ if (!poppler_field)
+ return FALSE;
+
+ state = poppler_form_field_button_get_state (poppler_field);
+ g_object_unref (poppler_field);
+
+ return state;
+}
+
+static gchar *
+pdf_document_forms_form_field_choice_get_item (EvDocumentForms *document,
+ EvFormField *field,
+ gint index)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document);
+ PopplerFormField *poppler_field;
+ gchar *text;
+
+ poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ if (!poppler_field)
+ return NULL;
+
+ text = poppler_form_field_choice_get_item (poppler_field, index);
+ g_object_unref (poppler_field);
+
+ return text;
+}
+
+static int
+pdf_document_forms_form_field_choice_get_n_items (EvDocumentForms *document,
+ EvFormField *field)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document);
+ PopplerFormField *poppler_field;
+ gint n_items;
+
+ poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ if (!poppler_field)
+ return -1;
+
+ n_items = poppler_form_field_choice_get_n_items (poppler_field);
+ g_object_unref (poppler_field);
+
+ return n_items;
+}
+
+static gboolean
+pdf_document_forms_form_field_choice_is_item_selected (EvDocumentForms *document,
+ EvFormField *field,
+ gint index)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document);
+ PopplerFormField *poppler_field;
+ gboolean selected;
+
+ poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ if (!poppler_field)
+ return FALSE;
+
+ selected = poppler_form_field_choice_is_item_selected (poppler_field, index);
+ g_object_unref (poppler_field);
+
+ return selected;
+}
+
+static void
+pdf_document_forms_form_field_choice_select_item (EvDocumentForms *document,
+ EvFormField *field,
+ gint index)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document);
+ PopplerFormField *poppler_field;
+
+ poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ if (!poppler_field)
+ return;
+
+ poppler_form_field_choice_select_item (poppler_field, index);
+ g_object_unref (poppler_field);
+}
+
+static void
+pdf_document_forms_form_field_choice_toggle_item (EvDocumentForms *document,
+ EvFormField *field,
+ gint index)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document);
+ PopplerFormField *poppler_field;
+
+ poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ if (!poppler_field)
+ return;
+
+ poppler_form_field_choice_toggle_item (poppler_field, index);
+ g_object_unref (poppler_field);
+}
+
+static void
+pdf_document_forms_form_field_choice_unselect_all (EvDocumentForms *document,
+ EvFormField *field)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document);
+ PopplerFormField *poppler_field;
+
+ poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ if (!poppler_field)
+ return;
+
+ poppler_form_field_choice_unselect_all (poppler_field);
+ g_object_unref (poppler_field);
+}
+
+static void
+pdf_document_forms_form_field_choice_set_text (EvDocumentForms *document,
+ EvFormField *field,
+ const gchar *text)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document);
+ PopplerFormField *poppler_field;
+
+ poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ if (!poppler_field)
+ return;
+
+ poppler_form_field_choice_set_text (poppler_field, text);
+ g_object_unref (poppler_field);
+}
+
+static gchar *
+pdf_document_forms_form_field_choice_get_text (EvDocumentForms *document,
+ EvFormField *field)
+{
+ PdfDocument *pdf_document = PDF_DOCUMENT (document);
+ PopplerFormField *poppler_field;
+ gchar *text;
+
+ poppler_field = poppler_document_get_form_field (pdf_document->document, field->id);
+ if (!poppler_field)
+ return NULL;
+
+ text = poppler_form_field_choice_get_text (poppler_field);
+ g_object_unref (poppler_field);
+
+ return text;
+}
+
+static void
+pdf_document_document_forms_iface_init (EvDocumentFormsIface *iface)
+{
+ iface->get_form_fields = pdf_document_forms_get_form_fields;
+ iface->form_field_text_get_text = pdf_document_forms_form_field_text_get_text;
+ iface->form_field_text_set_text = pdf_document_forms_form_field_text_set_text;
+ iface->form_field_button_set_state = pdf_document_forms_form_field_button_set_state;
+ iface->form_field_button_get_state = pdf_document_forms_form_field_button_get_state;
+ iface->form_field_choice_get_item = pdf_document_forms_form_field_choice_get_item;
+ iface->form_field_choice_get_n_items = pdf_document_forms_form_field_choice_get_n_items;
+ iface->form_field_choice_is_item_selected = pdf_document_forms_form_field_choice_is_item_selected;
+ iface->form_field_choice_select_item = pdf_document_forms_form_field_choice_select_item;
+ iface->form_field_choice_toggle_item = pdf_document_forms_form_field_choice_toggle_item;
+ iface->form_field_choice_unselect_all = pdf_document_forms_form_field_choice_unselect_all;
+ iface->form_field_choice_set_text = pdf_document_forms_form_field_choice_set_text;
+ iface->form_field_choice_get_text = pdf_document_forms_form_field_choice_get_text;
+}
+