[evince] [libview] Handle layers state actions



commit 7e3392ba15113588d1f141a624df852007e75774
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Wed Sep 15 16:58:00 2010 +0200

    [libview] Handle layers state actions
    
    Show/Hide layers according to the action and emit a signal to notify
    that layers have changed.

 libview/ev-view-private.h |    1 +
 libview/ev-view.c         |   42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)
---
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index a365507..5b5fd19 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -212,6 +212,7 @@ struct _EvViewClass {
 					   EvSourceLink   *link);
 	void    (*annot_added)            (EvView         *view,
 					   EvAnnotation   *annot);
+	void    (*layers_changed)         (EvView         *view);
 };
 
 void _get_page_size_for_scale_and_rotation (EvDocument *document,
diff --git a/libview/ev-view.c b/libview/ev-view.c
index 85cf501..ba73354 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -32,6 +32,7 @@
 #include "ev-document-forms.h"
 #include "ev-document-images.h"
 #include "ev-document-links.h"
+#include "ev-document-layers.h"
 #include "ev-document-misc.h"
 #include "ev-pixbuf-cache.h"
 #include "ev-page-cache.h"
@@ -56,6 +57,7 @@ enum {
 	SIGNAL_SELECTION_CHANGED,
 	SIGNAL_SYNC_SOURCE,
 	SIGNAL_ANNOT_ADDED,
+	SIGNAL_LAYERS_CHANGED,
 	N_SIGNALS
 };
 
@@ -1738,6 +1740,38 @@ ev_view_handle_link (EvView *view, EvLink *link)
 			ev_view_goto_dest (view, dest);
 		}
 			break;
+	        case EV_LINK_ACTION_TYPE_LAYERS_STATE: {
+			GList            *show, *hide, *toggle;
+			GList            *l;
+			EvDocumentLayers *document_layers;
+
+			document_layers = EV_DOCUMENT_LAYERS (view->document);
+
+			show = ev_link_action_get_show_list (action);
+			for (l = show; l; l = g_list_next (l)) {
+				ev_document_layers_show_layer (document_layers, EV_LAYER (l->data));
+			}
+
+			hide = ev_link_action_get_hide_list (action);
+			for (l = hide; l; l = g_list_next (l)) {
+				ev_document_layers_hide_layer (document_layers, EV_LAYER (l->data));
+			}
+
+			toggle = ev_link_action_get_toggle_list (action);
+			for (l = toggle; l; l = g_list_next (l)) {
+				EvLayer *layer = EV_LAYER (l->data);
+
+				if (ev_document_layers_layer_is_visible (document_layers, layer)) {
+					ev_document_layers_hide_layer (document_layers, layer);
+				} else {
+					ev_document_layers_show_layer (document_layers, layer);
+				}
+			}
+
+			g_signal_emit (view, signals[SIGNAL_LAYERS_CHANGED], 0);
+			ev_view_reload_page (view, view->current_page, NULL);
+		}
+			break;
 	        case EV_LINK_ACTION_TYPE_GOTO_REMOTE:
 	        case EV_LINK_ACTION_TYPE_EXTERNAL_URI:
 	        case EV_LINK_ACTION_TYPE_LAUNCH:
@@ -4678,6 +4712,14 @@ ev_view_class_init (EvViewClass *class)
 		         g_cclosure_marshal_VOID__OBJECT,
 		         G_TYPE_NONE, 1,
 			 EV_TYPE_ANNOTATION);
+	signals[SIGNAL_LAYERS_CHANGED] = g_signal_new ("layers-changed",
+	  	         G_TYPE_FROM_CLASS (object_class),
+		         G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+		         G_STRUCT_OFFSET (EvViewClass, layers_changed),
+		         NULL, NULL,
+		         g_cclosure_marshal_VOID__VOID,
+		         G_TYPE_NONE, 0,
+			 G_TYPE_NONE);
 
 	binding_set = gtk_binding_set_by_class (class);
 



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