From 59d6e1f73994d905fadcb346ea403dd22b8aa3ea Mon Sep 17 00:00:00 2001 From: Marek Kasik Date: Wed, 10 Jun 2015 13:53:50 +0200 Subject: [PATCH 2/2] Add handling of additional actions for annotations --- backend/pdf/ev-poppler.cc | 60 ++++++++++++++++++++++++++++++++++++++ libdocument/ev-form-field.c | 10 +++++++ libdocument/ev-form-field.h | 10 +++++++ libview/ev-form-field-accessible.c | 20 +++++++------ libview/ev-view.c | 16 ++++++++++ 5 files changed, 107 insertions(+), 9 deletions(-) diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc index 1cfa954..356599d 100644 --- a/backend/pdf/ev-poppler.cc +++ b/backend/pdf/ev-poppler.cc @@ -2390,11 +2390,41 @@ ev_form_field_from_poppler_field (PdfDocument *pdf_document, gdouble font_size; gboolean is_read_only; PopplerAction *action; + PopplerAction *cursor_entering_action; + PopplerAction *cursor_leaving_action; + PopplerAction *mouse_pressed_action; + PopplerAction *mouse_released_action; + PopplerAction *focus_in_action; + PopplerAction *focus_out_action; + PopplerAction *page_opening_action; + PopplerAction *page_closing_action; + PopplerAction *page_visible_action; + PopplerAction *page_invisible_action; id = poppler_form_field_get_id (poppler_field); font_size = poppler_form_field_get_font_size (poppler_field); is_read_only = poppler_form_field_is_read_only (poppler_field); action = poppler_form_field_get_action (poppler_field); + cursor_entering_action = poppler_form_field_get_annot_additional_action (poppler_field, + POPPLER_ANNOT_ADDITIONAL_ACTION_CURSOR_ENTERING); + cursor_leaving_action = poppler_form_field_get_annot_additional_action (poppler_field, + POPPLER_ANNOT_ADDITIONAL_ACTION_CURSOR_LEAVING); + mouse_pressed_action = poppler_form_field_get_annot_additional_action (poppler_field, + POPPLER_ANNOT_ADDITIONAL_ACTION_MOUSE_PRESSED); + mouse_released_action = poppler_form_field_get_annot_additional_action (poppler_field, + POPPLER_ANNOT_ADDITIONAL_ACTION_MOUSE_RELEASED); + focus_in_action = poppler_form_field_get_annot_additional_action (poppler_field, + POPPLER_ANNOT_ADDITIONAL_ACTION_FOCUS_IN); + focus_out_action = poppler_form_field_get_annot_additional_action (poppler_field, + POPPLER_ANNOT_ADDITIONAL_ACTION_FOCUS_OUT); + page_opening_action = poppler_form_field_get_annot_additional_action (poppler_field, + POPPLER_ANNOT_ADDITIONAL_ACTION_PAGE_OPENING); + page_closing_action = poppler_form_field_get_annot_additional_action (poppler_field, + POPPLER_ANNOT_ADDITIONAL_ACTION_PAGE_CLOSING); + page_visible_action = poppler_form_field_get_annot_additional_action (poppler_field, + POPPLER_ANNOT_ADDITIONAL_ACTION_PAGE_VISIBLE); + page_invisible_action = poppler_form_field_get_annot_additional_action (poppler_field, + POPPLER_ANNOT_ADDITIONAL_ACTION_PAGE_INVISIBLE); switch (poppler_form_field_get_field_type (poppler_field)) { case POPPLER_FORM_FIELD_TEXT: { @@ -2488,6 +2518,36 @@ ev_form_field_from_poppler_field (PdfDocument *pdf_document, if (action) ev_field->activation_link = ev_link_from_action (pdf_document, action); + if (cursor_entering_action) + ev_field->cursor_entering_link = ev_link_from_action (pdf_document, cursor_entering_action); + + if (cursor_leaving_action) + ev_field->cursor_leaving_link = ev_link_from_action (pdf_document, cursor_leaving_action); + + if (mouse_pressed_action) + ev_field->mouse_pressed_link = ev_link_from_action (pdf_document, mouse_pressed_action); + + if (mouse_released_action) + ev_field->mouse_released_link = ev_link_from_action (pdf_document, mouse_released_action); + + if (focus_in_action) + ev_field->focus_in_link = ev_link_from_action (pdf_document, focus_in_action); + + if (focus_out_action) + ev_field->focus_out_link = ev_link_from_action (pdf_document, focus_out_action); + + if (page_opening_action) + ev_field->page_opening_link = ev_link_from_action (pdf_document, page_opening_action); + + if (page_closing_action) + ev_field->page_closing_link = ev_link_from_action (pdf_document, page_closing_action); + + if (page_visible_action) + ev_field->page_visible_link = ev_link_from_action (pdf_document, page_visible_action); + + if (page_invisible_action) + ev_field->page_invisible_link = ev_link_from_action (pdf_document, page_invisible_action); + return ev_field; } diff --git a/libdocument/ev-form-field.c b/libdocument/ev-form-field.c index c234e96..36a2022 100644 --- a/libdocument/ev-form-field.c +++ b/libdocument/ev-form-field.c @@ -56,6 +56,16 @@ ev_form_field_finalize (GObject *object) field->page = NULL; g_clear_object (&field->activation_link); + g_clear_object (&field->cursor_entering_link); + g_clear_object (&field->cursor_leaving_link); + g_clear_object (&field->mouse_pressed_link); + g_clear_object (&field->mouse_released_link); + g_clear_object (&field->focus_in_link); + g_clear_object (&field->focus_out_link); + g_clear_object (&field->page_opening_link); + g_clear_object (&field->page_closing_link); + g_clear_object (&field->page_visible_link); + g_clear_object (&field->page_invisible_link); (* G_OBJECT_CLASS (ev_form_field_parent_class)->finalize) (object); } diff --git a/libdocument/ev-form-field.h b/libdocument/ev-form-field.h index d0571a2..21cc753 100644 --- a/libdocument/ev-form-field.h +++ b/libdocument/ev-form-field.h @@ -110,6 +110,16 @@ struct _EvFormField gboolean is_read_only; gdouble font_size; EvLink *activation_link; + EvLink *cursor_entering_link; + EvLink *cursor_leaving_link; + EvLink *mouse_pressed_link; + EvLink *mouse_released_link; + EvLink *focus_in_link; + EvLink *focus_out_link; + EvLink *page_opening_link; + EvLink *page_closing_link; + EvLink *page_visible_link; + EvLink *page_invisible_link; EvPage *page; gboolean changed; diff --git a/libview/ev-form-field-accessible.c b/libview/ev-form-field-accessible.c index 8187d83..d29a7cd 100644 --- a/libview/ev-form-field-accessible.c +++ b/libview/ev-form-field-accessible.c @@ -321,19 +321,21 @@ ev_form_field_accessible_update_state (EvFormFieldAccessible *accessible) atk_object = ATK_OBJECT (accessible); states = ev_form_field_accessible_ref_state_set (atk_object); changed_states = atk_state_set_xor_sets (accessible->priv->saved_states, states); - if (changed_states && !atk_state_set_is_empty (accessible->priv->saved_states)) { - for (i = 0; i < ATK_STATE_LAST_DEFINED; i++) { - if (atk_state_set_contains_state (changed_states, i)) - atk_object_notify_state_change (atk_object, i, atk_state_set_contains_state (states, i)); + if (changed_states) { + if (!atk_state_set_is_empty (accessible->priv->saved_states)) { + for (i = 0; i < ATK_STATE_LAST_DEFINED; i++) { + if (atk_state_set_contains_state (changed_states, i)) + atk_object_notify_state_change (atk_object, i, atk_state_set_contains_state (states, i)); + } } - } - g_object_unref (accessible->priv->saved_states); + g_object_unref (accessible->priv->saved_states); - atk_state_set_clear_states (changed_states); - accessible->priv->saved_states = atk_state_set_or_sets (changed_states, states); + atk_state_set_clear_states (changed_states); + accessible->priv->saved_states = atk_state_set_or_sets (changed_states, states); - g_object_unref (changed_states); + g_object_unref (changed_states); + } g_object_unref (states); } diff --git a/libview/ev-view.c b/libview/ev-view.c index f128dea..26685b1 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -2754,6 +2754,12 @@ ev_view_handle_form_field (EvView *view, if (field->activation_link) ev_view_handle_link (view, field->activation_link); + if (field->mouse_pressed_link) + ev_view_handle_link (view, field->mouse_pressed_link); + + if (field->mouse_released_link) + ev_view_handle_link (view, field->mouse_released_link); + if (EV_IS_FORM_FIELD_BUTTON (field)) ev_view_form_field_button_toggle (view, field); @@ -5910,6 +5916,16 @@ ev_view_activate_form_field (EvView *view, handled = TRUE; } + if (field->mouse_pressed_link) { + ev_view_handle_link (view, field->mouse_pressed_link); + handled = TRUE; + } + + if (field->mouse_released_link) { + ev_view_handle_link (view, field->mouse_released_link); + handled = TRUE; + } + if (EV_IS_FORM_FIELD_BUTTON (field)) { ev_view_form_field_button_toggle (view, field); handled = TRUE; -- 2.4.3