[evince] [pdf] Add support for OCG State actions



commit e39bde3f3b8ce3c111c27f7aa6b384c7a5f98672
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Wed Sep 15 16:49:48 2010 +0200

    [pdf] Add support for OCG State actions

 backend/pdf/ev-poppler.cc |   43 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc
index 0c5c898..aa080e6 100644
--- a/backend/pdf/ev-poppler.cc
+++ b/backend/pdf/ev-poppler.cc
@@ -1212,8 +1212,47 @@ ev_link_from_action (PdfDocument   *pdf_document,
 	        case POPPLER_ACTION_RENDITION:
 			unimplemented_action = "POPPLER_ACTION_RENDITION";
 			break;
-	        case POPPLER_ACTION_OCG_STATE:
-			unimplemented_action = "POPPLER_ACTION_OCG_STATE";
+	        case POPPLER_ACTION_OCG_STATE: {
+			GList *on_list = NULL;
+			GList *off_list = NULL;
+			GList *toggle_list = NULL;
+			GList *l, *m;
+
+			for (l = action->ocg_state.state_list; l; l = g_list_next (l)) {
+				PopplerActionLayer *action_layer = (PopplerActionLayer *)l->data;
+
+				for (m = action_layer->layers; m; m = g_list_next (m)) {
+					PopplerLayer *layer = (PopplerLayer *)m->data;
+					EvLayer      *ev_layer;
+
+					ev_layer = ev_layer_new (poppler_layer_is_parent (layer),
+								 poppler_layer_get_radio_button_group_id (layer));
+					g_object_set_data_full (G_OBJECT (ev_layer),
+								"poppler-layer",
+								g_object_ref (layer),
+								(GDestroyNotify)g_object_unref);
+
+					switch (action_layer->action) {
+					case POPPLER_ACTION_LAYER_ON:
+						on_list = g_list_prepend (on_list, ev_layer);
+						break;
+					case POPPLER_ACTION_LAYER_OFF:
+						off_list = g_list_prepend (off_list, ev_layer);
+						break;
+					case POPPLER_ACTION_LAYER_TOGGLE:
+						toggle_list = g_list_prepend (toggle_list, ev_layer);
+						break;
+					}
+				}
+			}
+
+			/* The action takes the ownership of the lists */
+			ev_action = ev_link_action_new_layers_state (g_list_reverse (on_list),
+								     g_list_reverse (off_list),
+								     g_list_reverse (toggle_list));
+
+
+		}
 			break;
 #endif
 	        case POPPLER_ACTION_UNKNOWN:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]