]> www.fi.muni.cz Git - evince.git/blobdiff - backend/pdf/ev-poppler.cc
help/C: documented toolbar (bug # 503638)
[evince.git] / backend / pdf / ev-poppler.cc
index 0c5c8982270a0954b99d0f1277bf88b9ec521a65..753fedc36f12385425c24b9171b5bc840af2caa8 100644 (file)
@@ -400,18 +400,6 @@ make_thumbnail_for_page (PopplerPage     *poppler_page,
                         gint             height)
 {
        GdkPixbuf *pixbuf;
-
-#ifdef POPPLER_WITH_GDK
-       pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8,
-                                width, height);
-       gdk_pixbuf_fill (pixbuf, 0xffffffff);
-
-       ev_document_fc_mutex_lock ();
-       poppler_page_render_to_pixbuf (poppler_page, 0, 0,
-                                      width, height,
-                                      rc->scale, rc->rotation, pixbuf);
-       ev_document_fc_mutex_unlock ();
-#else
        cairo_surface_t *surface;
 
        ev_document_fc_mutex_lock ();
@@ -420,7 +408,6 @@ make_thumbnail_for_page (PopplerPage     *poppler_page,
        
        pixbuf = ev_document_misc_pixbuf_from_surface (surface);
        cairo_surface_destroy (surface);
-#endif /* POPPLER_WITH_GDK */
 
        return pixbuf;
 }
@@ -431,6 +418,7 @@ pdf_document_get_thumbnail (EvDocument      *document,
 {
        PdfDocument *pdf_document = PDF_DOCUMENT (document);
        PopplerPage *poppler_page;
+       cairo_surface_t *surface;
        GdkPixbuf *pixbuf = NULL;
        GdkPixbuf *border_pixbuf;
        double page_width, page_height;
@@ -452,17 +440,11 @@ pdf_document_get_thumbnail (EvDocument      *document,
                height = temp;
        }
 
-#ifdef POPPLER_WITH_GDK
-       pixbuf = poppler_page_get_thumbnail_pixbuf (poppler_page);
-#else
-       cairo_surface_t *surface;
-       
        surface = poppler_page_get_thumbnail (poppler_page);
        if (surface) {
                pixbuf = ev_document_misc_pixbuf_from_surface (surface);
                cairo_surface_destroy (surface);
        }
-#endif /* POPPLER_WITH_GDK */
 
        if (pixbuf != NULL) {
                int thumb_width = (rc->rotation == 90 || rc->rotation == 270) ?
@@ -722,6 +704,7 @@ pdf_document_get_info (EvDocument *document)
        PopplerPermissions permissions;
        EvPage *page;
        char *metadata;
+       gboolean linearized;
 
        info = g_new0 (EvDocumentInfo, 1);
 
@@ -758,7 +741,7 @@ pdf_document_get_info (EvDocument *document)
                      "producer", &(info->producer),
                      "creation-date", &(info->creation_date),
                      "mod-date", &(info->modified_date),
-                     "linearized", &(info->linearized),
+                     "linearized", &linearized,
                      "metadata", &metadata,
                      NULL);
 
@@ -864,6 +847,8 @@ pdf_document_get_info (EvDocument *document)
                info->security = g_strdup (_("No"));
        }
 
+       info->linearized = linearized ? g_strdup (_("Yes")) : g_strdup (_("No"));
+
        return info;
 }
 
@@ -1208,14 +1193,51 @@ ev_link_from_action (PdfDocument   *pdf_document,
                case POPPLER_ACTION_MOVIE:
                        unimplemented_action = "POPPLER_ACTION_MOVIE";
                        break;
-#if POPPLER_CHECK_VERSION (0, 13, 2)
                case POPPLER_ACTION_RENDITION:
                        unimplemented_action = "POPPLER_ACTION_RENDITION";
                        break;
-               case POPPLER_ACTION_OCG_STATE:
-                       unimplemented_action = "POPPLER_ACTION_OCG_STATE";
+               case POPPLER_ACTION_OCG_STATE: {
+                       GList *on_list = NULL;
+                       GList *off_list = NULL;
+                       GList *toggle_list = NULL;
+                       GList *l, *m;
+
+                       for (l = action->ocg_state.state_list; l; l = g_list_next (l)) {
+                               PopplerActionLayer *action_layer = (PopplerActionLayer *)l->data;
+
+                               for (m = action_layer->layers; m; m = g_list_next (m)) {
+                                       PopplerLayer *layer = (PopplerLayer *)m->data;
+                                       EvLayer      *ev_layer;
+
+                                       ev_layer = ev_layer_new (poppler_layer_is_parent (layer),
+                                                                poppler_layer_get_radio_button_group_id (layer));
+                                       g_object_set_data_full (G_OBJECT (ev_layer),
+                                                               "poppler-layer",
+                                                               g_object_ref (layer),
+                                                               (GDestroyNotify)g_object_unref);
+
+                                       switch (action_layer->action) {
+                                       case POPPLER_ACTION_LAYER_ON:
+                                               on_list = g_list_prepend (on_list, ev_layer);
+                                               break;
+                                       case POPPLER_ACTION_LAYER_OFF:
+                                               off_list = g_list_prepend (off_list, ev_layer);
+                                               break;
+                                       case POPPLER_ACTION_LAYER_TOGGLE:
+                                               toggle_list = g_list_prepend (toggle_list, ev_layer);
+                                               break;
+                                       }
+                               }
+                       }
+
+                       /* The action takes the ownership of the lists */
+                       ev_action = ev_link_action_new_layers_state (g_list_reverse (on_list),
+                                                                    g_list_reverse (off_list),
+                                                                    g_list_reverse (toggle_list));
+
+
+               }
                        break;
-#endif
                case POPPLER_ACTION_UNKNOWN:
                        unimplemented_action = "POPPLER_ACTION_UNKNOWN";
        }
@@ -1867,31 +1889,11 @@ pdf_selection_get_selected_text (EvSelection     *selection,
                                 EvSelectionStyle style,
                                 EvRectangle     *points)
 {
-       PopplerPage *poppler_page;
-       char *retval;
-
-       poppler_page = POPPLER_PAGE (page->backend_page);
-
-#ifdef HAVE_POPPLER_PAGE_GET_SELECTED_TEXT
-       retval = poppler_page_get_selected_text (poppler_page,
-                                                (PopplerSelectionStyle)style,
-                                                (PopplerRectangle *)points);
-#else
-       PopplerRectangle r;
-       double height;
-
-       poppler_page_get_size (poppler_page, NULL, &height);
-       r.x1 = points->x1;
-       r.y1 = height - points->y2;
-       r.x2 = points->x2;
-       r.y2 = height - points->y1;
-
-       retval = poppler_page_get_text (poppler_page,
-                                       (PopplerSelectionStyle)style,
-                                       &r);
-#endif /* HAVE_POPPLER_PAGE_GET_SELECTED_TEXT */
+       g_return_val_if_fail (POPPLER_IS_PAGE (page->backend_page), NULL);
 
-       return retval;
+       return poppler_page_get_selected_text (POPPLER_PAGE (page->backend_page),
+                                              (PopplerSelectionStyle)style,
+                                              (PopplerRectangle *)points);
 }
 
 static cairo_region_t *
@@ -1977,66 +1979,33 @@ pdf_document_text_get_text_mapping (EvDocumentText *document_text,
        return retval;
 }
 
-#ifdef HAVE_POPPLER_PAGE_GET_SELECTED_TEXT
 static gchar *
 pdf_document_text_get_text (EvDocumentText  *selection,
                            EvPage          *page)
 {
-       PopplerPage *poppler_page;
-
        g_return_val_if_fail (POPPLER_IS_PAGE (page->backend_page), NULL);
 
-       poppler_page = POPPLER_PAGE (page->backend_page);
-
-       return poppler_page_get_text (poppler_page);
-}
-#else
-static gchar *
-pdf_document_text_get_text (EvDocumentText  *selection,
-                           EvPage          *page)
-{
-       PopplerPage *poppler_page;
-       PopplerRectangle r;
-
-       g_return_val_if_fail (POPPLER_IS_PAGE (page->backend_page), NULL);
-
-       poppler_page = POPPLER_PAGE (page->backend_page);
-
-       r.x1 = 0;
-       r.y1 = 0;
-       poppler_page_get_size (poppler_page, &(r.x2), &(r.y2));
-
-       return poppler_page_get_text (poppler_page,
-                                     POPPLER_SELECTION_WORD,
-                                     &r);
+       return poppler_page_get_text (POPPLER_PAGE (page->backend_page));
 }
-#endif /* HAVE_POPPLER_PAGE_GET_SELECTED_TEXT */
 
-#ifdef HAVE_POPPLER_PAGE_GET_TEXT_LAYOUT
 static gboolean
 pdf_document_text_get_text_layout (EvDocumentText  *selection,
                                   EvPage          *page,
                                   EvRectangle    **areas,
                                   guint           *n_areas)
 {
-       PopplerPage *poppler_page;
-
-       g_return_val_if_fail (POPPLER_IS_PAGE (page->backend_page), NULL);
+       g_return_val_if_fail (POPPLER_IS_PAGE (page->backend_page), FALSE);
 
-       poppler_page = POPPLER_PAGE (page->backend_page);
-
-       return poppler_page_get_text_layout (poppler_page, (PopplerRectangle **)areas, n_areas);
+       return poppler_page_get_text_layout (POPPLER_PAGE (page->backend_page),
+                                            (PopplerRectangle **)areas, n_areas);
 }
-#endif
 
 static void
 pdf_document_text_iface_init (EvDocumentTextInterface *iface)
 {
         iface->get_text_mapping = pdf_document_text_get_text_mapping;
         iface->get_text = pdf_document_text_get_text;
-#ifdef HAVE_POPPLER_PAGE_GET_TEXT_LAYOUT
         iface->get_text_layout = pdf_document_text_get_text_layout;
-#endif
 }
 
 /* Page Transitions */
@@ -2510,7 +2479,6 @@ poppler_annot_color_to_gdk_color (PopplerAnnot *poppler_annot,
 static EvAnnotationTextIcon
 get_annot_text_icon (PopplerAnnotText *poppler_annot)
 {
-#ifdef HAVE_POPPLER_PAGE_ADD_ANNOT
        gchar *icon = poppler_annot_text_get_icon (poppler_annot);
        EvAnnotationTextIcon retval;
 
@@ -2541,15 +2509,11 @@ get_annot_text_icon (PopplerAnnotText *poppler_annot)
        g_free (icon);
 
        return retval;
-#else
-       return EV_ANNOTATION_TEXT_ICON_UNKNOWN;
-#endif
 }
 
 static const gchar *
 get_poppler_annot_text_icon (EvAnnotationTextIcon icon)
 {
-#ifdef HAVE_POPPLER_PAGE_ADD_ANNOT
        switch (icon) {
        case EV_ANNOTATION_TEXT_ICON_NOTE:
                return POPPLER_ANNOT_TEXT_ICON_NOTE;
@@ -2573,9 +2537,6 @@ get_poppler_annot_text_icon (EvAnnotationTextIcon icon)
        default:
                return POPPLER_ANNOT_TEXT_ICON_NOTE;
        }
-#else
-       return "Note";
-#endif
 }
 
 static EvAnnotation *
@@ -2817,7 +2778,6 @@ pdf_document_annotations_document_is_modified (EvDocumentAnnotations *document_a
        return PDF_DOCUMENT (document_annotations)->annots_modified;
 }
 
-#ifdef HAVE_POPPLER_PAGE_ADD_ANNOT
 static void
 pdf_document_annotations_add_annotation (EvDocumentAnnotations *document_annotations,
                                         EvAnnotation          *annot,
@@ -2920,7 +2880,6 @@ pdf_document_annotations_add_annotation (EvDocumentAnnotations *document_annotat
 
        pdf_document->annots_modified = TRUE;
 }
-#endif /* HAVE_POPPLER_PAGE_ADD_ANNOT */
 
 static void
 pdf_document_annotations_save_annotation (EvDocumentAnnotations *document_annotations,
@@ -2937,7 +2896,6 @@ pdf_document_annotations_save_annotation (EvDocumentAnnotations *document_annota
                poppler_annot_set_contents (poppler_annot,
                                            ev_annotation_get_contents (annot));
 
-#ifdef HAVE_POPPLER_PAGE_ADD_ANNOT
        if (mask & EV_ANNOTATIONS_SAVE_COLOR) {
                PopplerColor color;
                GdkColor     ev_color;
@@ -2976,7 +2934,7 @@ pdf_document_annotations_save_annotation (EvDocumentAnnotations *document_annota
                        poppler_annot_text_set_icon (text, get_poppler_annot_text_icon (icon));
                }
        }
-#endif /* HAVE_POPPLER_PAGE_ADD_ANNOT */
+
        PDF_DOCUMENT (document_annotations)->annots_modified = TRUE;
 }
 
@@ -2985,9 +2943,7 @@ pdf_document_document_annotations_iface_init (EvDocumentAnnotationsInterface *if
 {
        iface->get_annotations = pdf_document_annotations_get_annotations;
        iface->document_is_modified = pdf_document_annotations_document_is_modified;
-#ifdef HAVE_POPPLER_PAGE_ADD_ANNOT
        iface->add_annotation = pdf_document_annotations_add_annotation;
-#endif
        iface->save_annotation = pdf_document_annotations_save_annotation;
 }