Commit 08993c59 authored by Carlos Garcia Campos's avatar Carlos Garcia Campos

Do not cache layers in the backends

Use g_object_set_data instead, to attach the backend object to the
evince layer.
parent 8c424db7
......@@ -109,7 +109,6 @@ struct _PdfDocument
PdfPrintContext *print_ctx;
GList *layers;
GHashTable *annots;
};
......@@ -198,11 +197,6 @@ pdf_document_dispose (GObject *object)
poppler_fonts_iter_free (pdf_document->fonts_iter);
}
if (pdf_document->layers) {
g_list_foreach (pdf_document->layers, (GFunc)g_object_unref, NULL);
g_list_free (pdf_document->layers);
}
G_OBJECT_CLASS (pdf_document_parent_class)->dispose (object);
}
......@@ -3149,11 +3143,12 @@ build_layers_tree (PdfDocument *pdf_document,
markup = g_markup_escape_text (poppler_layer_get_title (layer), -1);
visible = poppler_layer_is_visible (layer);
rb_group = poppler_layer_get_radio_button_group_id (layer);
pdf_document->layers = g_list_append (pdf_document->layers,
g_object_ref (layer));
ev_layer = ev_layer_new (g_list_length (pdf_document->layers) - 1,
poppler_layer_is_parent (layer),
ev_layer = ev_layer_new (poppler_layer_is_parent (layer),
rb_group);
g_object_set_data_full (G_OBJECT (ev_layer),
"poppler-layer",
g_object_ref (layer),
(GDestroyNotify) g_object_unref);
} else {
gchar *title;
......@@ -3211,30 +3206,33 @@ static void
pdf_document_layers_show_layer (EvDocumentLayers *document,
EvLayer *layer)
{
PdfDocument *pdf_document = PDF_DOCUMENT (document);
guint layer_id = ev_layer_get_id (layer);
PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerLayer *poppler_layer;
poppler_layer_show (POPPLER_LAYER (g_list_nth_data (pdf_document->layers, layer_id)));
poppler_layer = POPPLER_LAYER (g_object_get_data (G_OBJECT (layer), "poppler-layer"));
poppler_layer_show (poppler_layer);
}
static void
pdf_document_layers_hide_layer (EvDocumentLayers *document,
EvLayer *layer)
{
PdfDocument *pdf_document = PDF_DOCUMENT (document);
guint layer_id = ev_layer_get_id (layer);
PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerLayer *poppler_layer;
poppler_layer_hide (POPPLER_LAYER (g_list_nth_data (pdf_document->layers, layer_id)));
poppler_layer = POPPLER_LAYER (g_object_get_data (G_OBJECT (layer), "poppler-layer"));
poppler_layer_hide (poppler_layer);
}
static gboolean
pdf_document_layers_layer_is_visible (EvDocumentLayers *document,
EvLayer *layer)
{
PdfDocument *pdf_document = PDF_DOCUMENT (document);
guint layer_id = ev_layer_get_id (layer);
PdfDocument *pdf_document = PDF_DOCUMENT (document);
PopplerLayer *poppler_layer;
return poppler_layer_is_visible (POPPLER_LAYER (g_list_nth_data (pdf_document->layers, layer_id)));
poppler_layer = POPPLER_LAYER (g_object_get_data (G_OBJECT (layer), "poppler-layer"));
return poppler_layer_is_visible (poppler_layer);
}
static void
......
......@@ -22,9 +22,8 @@
#include "ev-layer.h"
struct _EvLayerPrivate {
guint id;
gboolean is_parent;
gint rb_group;
gboolean is_parent;
gint rb_group;
};
#define EV_LAYER_GET_PRIVATE(object) \
......@@ -47,28 +46,18 @@ ev_layer_init (EvLayer *layer)
}
EvLayer *
ev_layer_new (guint layer_id,
gboolean is_parent,
ev_layer_new (gboolean is_parent,
gint rb_group)
{
EvLayer *layer;
layer = EV_LAYER (g_object_new (EV_TYPE_LAYER, NULL));
layer->priv->id = layer_id;
layer->priv->is_parent = is_parent;
layer->priv->rb_group = rb_group;
return layer;
}
guint
ev_layer_get_id (EvLayer *layer)
{
g_return_val_if_fail (EV_IS_LAYER (layer), 0);
return layer->priv->id;
}
gboolean
ev_layer_is_parent (EvLayer *layer)
{
......
......@@ -50,10 +50,8 @@ struct _EvLayerClass {
};
GType ev_layer_get_type (void) G_GNUC_CONST;
EvLayer *ev_layer_new (guint layer_id,
gboolean is_parent,
EvLayer *ev_layer_new (gboolean is_parent,
gint rb_group);
guint ev_layer_get_id (EvLayer *layer);
gboolean ev_layer_is_parent (EvLayer *layer);
gint ev_layer_get_rb_group (EvLayer *layer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment