summaryrefslogtreecommitdiff
path: root/libview
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-12-09 11:53:06 +0100
committerinfirit <[email protected]>2014-12-09 23:02:27 +0100
commita81dc81efad42fb0c8752bd7d33a0c3f0e81c3bd (patch)
treeb17e68510c0e0553a9d26350b0eaf0e571460111 /libview
parentee955d1c853cab401b29e8c43f1be7165bc27425 (diff)
downloadatril-a81dc81efad42fb0c8752bd7d33a0c3f0e81c3bd.tar.bz2
atril-a81dc81efad42fb0c8752bd7d33a0c3f0e81c3bd.tar.xz
[libview] Handle layers state actions
Show/Hide layers according to the action and emit a signal to notify that layers have changed. Based on evince commit: 7e3392ba15113588d1f141a624df852007e75774 From: Carlos Garcia Campos <[email protected]>
Diffstat (limited to 'libview')
-rw-r--r--libview/ev-view-private.h1
-rw-r--r--[-rwxr-xr-x]libview/ev-view.c42
2 files changed, 43 insertions, 0 deletions
diff --git a/libview/ev-view-private.h b/libview/ev-view-private.h
index 47b57679..68189432 100644
--- a/libview/ev-view-private.h
+++ b/libview/ev-view-private.h
@@ -218,6 +218,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 49436de1..0119211f 100755..100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -35,6 +35,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"
@@ -59,6 +60,7 @@ enum {
SIGNAL_SELECTION_CHANGED,
SIGNAL_SYNC_SOURCE,
SIGNAL_ANNOT_ADDED,
+ SIGNAL_LAYERS_CHANGED,
N_SIGNALS
};
@@ -1810,6 +1812,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:
@@ -4941,6 +4975,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);