]> www.fi.muni.cz Git - evince.git/blobdiff - pdf/ev-poppler.cc
Expand links when specified by the document. Depend on a poppler api
[evince.git] / pdf / ev-poppler.cc
index 7c60d9cff351c7350f922903436d1d744e6d0e34..aebe7ce5dbceaeba0274aff9e252e2c25b24a7b4 100644 (file)
@@ -56,6 +56,8 @@ struct _PdfDocument
        PopplerPSFile *ps_file;
        gchar *password;
 
+       PopplerOrientation orientation;
+
        PopplerFontInfo *font_info;
        PopplerFontsIter *fonts_iter;
        int fonts_scanned_pages;
@@ -204,11 +206,11 @@ pdf_document_get_page_size (EvDocument   *document,
                            double       *width,
                            double       *height)
 {
+       PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerPage *poppler_page;
 
-       poppler_page = poppler_document_get_page (PDF_DOCUMENT (document)->document,
-                                                 page);
-
+       poppler_page = poppler_document_get_page (pdf_document->document, page);
+       poppler_page_set_orientation (poppler_page, pdf_document->orientation);
        poppler_page_get_size (poppler_page, width, height);
 }
 
@@ -282,6 +284,7 @@ pdf_document_render_pixbuf (EvDocument   *document,
        pdf_document = PDF_DOCUMENT (document);
        poppler_page = poppler_document_get_page (pdf_document->document,
                                                  page);
+       poppler_page_set_orientation (poppler_page, pdf_document->orientation);
 
        poppler_page_get_size (poppler_page, &width_points, &height_points);
        width = (int) ((width_points * scale) + 0.5);
@@ -485,6 +488,33 @@ pdf_document_get_text (EvDocument *document, int page, EvRectangle *rect)
        return poppler_page_get_text (poppler_page, &r);
 }
 
+static void
+pdf_document_set_orientation (EvDocument *document, EvOrientation orientation)
+{
+       PdfDocument *pdf_document = PDF_DOCUMENT (document);
+       PopplerOrientation poppler_orientation;
+
+       switch (orientation) {
+               case EV_ORIENTATION_DOCUMENT:
+                       poppler_orientation = POPPLER_ORIENTATION_DOCUMENT;
+                       break;
+               case EV_ORIENTATION_PORTRAIT:
+                       poppler_orientation = POPPLER_ORIENTATION_PORTRAIT;
+                       break;
+               case EV_ORIENTATION_LANDSCAPE:
+                       poppler_orientation = POPPLER_ORIENTATION_LANDSCAPE;
+                       break;
+               case EV_ORIENTATION_UPSIDEDOWN:
+                       poppler_orientation = POPPLER_ORIENTATION_UPSIDEDOWN;
+                       break;
+               case EV_ORIENTATION_SEASCAPE:
+                       poppler_orientation = POPPLER_ORIENTATION_SEASCAPE;
+                       break;
+       }
+
+       pdf_document->orientation = poppler_orientation;
+}
+
 static void
 pdf_document_document_iface_init (EvDocumentIface *iface)
 {
@@ -498,6 +528,7 @@ pdf_document_document_iface_init (EvDocumentIface *iface)
        iface->get_text = pdf_document_get_text;
        iface->can_get_text = pdf_document_can_get_text;
        iface->get_info = pdf_document_get_info;
+       iface->set_orientation = pdf_document_set_orientation;
 };
 
 static void
@@ -627,8 +658,14 @@ build_tree (PdfDocument      *pdf_document,
                PopplerIndexIter *child;
                PopplerAction *action;
                EvLink *link;
+               gboolean expand;
                
                action = poppler_index_iter_get_action (iter);
+#ifdef POPPLER_LINK_IS_OPEN
+               expand = poppler_index_iter_is_open (iter);
+#else
+               expand = TRUE;
+#endif
                if (action) {
                        gtk_tree_store_append (GTK_TREE_STORE (model), &tree_iter, parent);
                        link = ev_link_from_action (action);
@@ -637,6 +674,7 @@ build_tree (PdfDocument      *pdf_document,
                        gtk_tree_store_set (GTK_TREE_STORE (model), &tree_iter,
                                            EV_DOCUMENT_LINKS_COLUMN_MARKUP, ev_link_get_title (link),
                                            EV_DOCUMENT_LINKS_COLUMN_LINK, link,
+                                           EV_DOCUMENT_LINKS_COLUMN_EXPAND, expand,
                                            -1);
                        child = poppler_index_iter_get_child (iter);
                        if (child)
@@ -657,16 +695,16 @@ pdf_document_links_get_links_model (EvDocumentLinks *document_links)
        g_return_val_if_fail (PDF_IS_DOCUMENT (document_links), NULL);
 
        iter = poppler_index_iter_new (pdf_document->document);
-       /* Create the model iff we have items*/
+       /* Create the model if we have items*/
        if (iter != NULL) {
                model = (GtkTreeModel *) gtk_tree_store_new (EV_DOCUMENT_LINKS_COLUMN_NUM_COLUMNS,
                                                             G_TYPE_STRING,
-                                                            G_TYPE_POINTER);
+                                                            G_TYPE_POINTER,
+                                                            G_TYPE_BOOLEAN);
                build_tree (pdf_document, model, NULL, iter);
                poppler_index_iter_free (iter);
        }
        
-
        return model;
 }