diff options
author | infirit <[email protected]> | 2014-12-09 11:47:09 +0100 |
---|---|---|
committer | infirit <[email protected]> | 2014-12-09 23:02:26 +0100 |
commit | 1feffa2b7fba6bab62fe044777dad6e3278e848b (patch) | |
tree | 8970004f77c2d389d421d13aca7ad9d46c9601b8 /backend/pdf/ev-poppler.cc | |
parent | e155e2912b35146d5c9abba4a4f96530eee97dec (diff) | |
download | atril-1feffa2b7fba6bab62fe044777dad6e3278e848b.tar.bz2 atril-1feffa2b7fba6bab62fe044777dad6e3278e848b.tar.xz |
Do not cache layers in the backends
se g_object_set_data instead, to attach the backend object to the
evince layer.
Based on evince commit: 08993c59369086fa8916236f580438d656ccb8f7
From: Carlos Garcia Campos <[email protected]>
Diffstat (limited to 'backend/pdf/ev-poppler.cc')
-rw-r--r-- | backend/pdf/ev-poppler.cc | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/backend/pdf/ev-poppler.cc b/backend/pdf/ev-poppler.cc index 82e83521..72d7ac92 100644 --- a/backend/pdf/ev-poppler.cc +++ b/backend/pdf/ev-poppler.cc @@ -110,7 +110,6 @@ struct _PdfDocument PdfPrintContext *print_ctx; - GList *layers; GHashTable *annots; }; @@ -206,11 +205,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); } @@ -3191,11 +3185,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; @@ -3253,30 +3248,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 |