X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=backend%2Fdjvu%2Fdjvu-document.c;h=89925e4efe720ee931f13e1bc569b4a6e0865584;hb=223cc03e0275c77c4482ed0495b3bd15993a3ab8;hp=7ab5c76cc00f35b40439f7360f6bba3d07c2e361;hpb=8521bad72ca742fe3fced95a66076ed93cd77253;p=evince.git diff --git a/backend/djvu/djvu-document.c b/backend/djvu/djvu-document.c index 7ab5c76c..89925e4e 100644 --- a/backend/djvu/djvu-document.c +++ b/backend/djvu/djvu-document.c @@ -14,7 +14,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "config.h" @@ -24,7 +24,6 @@ #include "djvu-text-page.h" #include "djvu-links.h" #include "djvu-document-private.h" -#include "ev-document-thumbnails.h" #include "ev-file-exporter.h" #include "ev-document-misc.h" #include "ev-document-find.h" @@ -51,15 +50,13 @@ struct _DjvuDocumentClass typedef struct _DjvuDocumentClass DjvuDocumentClass; -static void djvu_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface); -static void djvu_document_file_exporter_iface_init (EvFileExporterIface *iface); -static void djvu_document_find_iface_init (EvDocumentFindIface *iface); -static void djvu_document_document_links_iface_init (EvDocumentLinksIface *iface); -static void djvu_selection_iface_init (EvSelectionIface *iface); +static void djvu_document_file_exporter_iface_init (EvFileExporterInterface *iface); +static void djvu_document_find_iface_init (EvDocumentFindInterface *iface); +static void djvu_document_document_links_iface_init (EvDocumentLinksInterface *iface); +static void djvu_selection_iface_init (EvSelectionInterface *iface); EV_BACKEND_REGISTER_WITH_CODE (DjvuDocument, djvu_document, { - EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS, djvu_document_document_thumbnails_iface_init); EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_FILE_EXPORTER, djvu_document_file_exporter_iface_init); EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_FIND, djvu_document_find_iface_init); EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_LINKS, djvu_document_document_links_iface_init); @@ -380,6 +377,44 @@ djvu_document_render (EvDocument *document, return surface; } +static GdkPixbuf * +djvu_document_get_thumbnail (EvDocument *document, + EvRenderContext *rc) +{ + DjvuDocument *djvu_document = DJVU_DOCUMENT (document); + GdkPixbuf *pixbuf, *rotated_pixbuf; + gdouble page_width, page_height; + gint thumb_width, thumb_height; + guchar *pixels; + + g_return_val_if_fail (djvu_document->d_document, NULL); + + djvu_document_get_page_size (EV_DOCUMENT(djvu_document), rc->page, + &page_width, &page_height); + + thumb_width = (gint) (page_width * rc->scale); + thumb_height = (gint) (page_height * rc->scale); + + pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, + thumb_width, thumb_height); + gdk_pixbuf_fill (pixbuf, 0xffffffff); + pixels = gdk_pixbuf_get_pixels (pixbuf); + + while (ddjvu_thumbnail_status (djvu_document->d_document, rc->page->index, 1) < DDJVU_JOB_OK) + djvu_handle_events(djvu_document, TRUE, NULL); + + ddjvu_thumbnail_render (djvu_document->d_document, rc->page->index, + &thumb_width, &thumb_height, + djvu_document->thumbs_format, + gdk_pixbuf_get_rowstride (pixbuf), + (gchar *)pixels); + + rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation); + g_object_unref (pixbuf); + + return rotated_pixbuf; +} + static void djvu_document_finalize (GObject *object) { @@ -415,6 +450,7 @@ djvu_document_class_init (DjvuDocumentClass *klass) ev_document_class->get_n_pages = djvu_document_get_n_pages; ev_document_class->get_page_size = djvu_document_get_page_size; ev_document_class->render = djvu_document_render; + ev_document_class->get_thumbnail = djvu_document_get_thumbnail; } static gchar * @@ -443,7 +479,7 @@ djvu_text_copy (DjvuDocument *djvu_document, static gchar * djvu_selection_get_selected_text (EvSelection *selection, - EvRenderContext *rc, + EvPage *page, EvSelectionStyle style, EvRectangle *points) { @@ -453,13 +489,13 @@ djvu_selection_get_selected_text (EvSelection *selection, gchar *text; djvu_document_get_page_size (EV_DOCUMENT (djvu_document), - rc->page, &width, &height); + page, &width, &height); rectangle.x1 = points->x1 / SCALE_FACTOR; rectangle.y1 = (height - points->y2) / SCALE_FACTOR; rectangle.x2 = points->x2 / SCALE_FACTOR; rectangle.y2 = (height - points->y1) / SCALE_FACTOR; - text = djvu_text_copy (djvu_document, rc->page->index, &rectangle); + text = djvu_text_copy (djvu_document, page->index, &rectangle); if (text == NULL) text = g_strdup (""); @@ -468,85 +504,11 @@ djvu_selection_get_selected_text (EvSelection *selection, } static void -djvu_selection_iface_init (EvSelectionIface *iface) +djvu_selection_iface_init (EvSelectionInterface *iface) { iface->get_selected_text = djvu_selection_get_selected_text; } -static void -djvu_document_thumbnails_get_dimensions (EvDocumentThumbnails *document, - EvRenderContext *rc, - gint *width, - gint *height) -{ - DjvuDocument *djvu_document = DJVU_DOCUMENT (document); - gdouble page_width, page_height; - - djvu_document_get_page_size (EV_DOCUMENT(djvu_document), rc->page, - &page_width, &page_height); - - if (rc->rotation == 90 || rc->rotation == 270) { - *width = (gint) (page_height * rc->scale); - *height = (gint) (page_width * rc->scale); - } else { - *width = (gint) (page_width * rc->scale); - *height = (gint) (page_height * rc->scale); - } -} - -static GdkPixbuf * -djvu_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document, - EvRenderContext *rc, - gboolean border) -{ - DjvuDocument *djvu_document = DJVU_DOCUMENT (document); - GdkPixbuf *pixbuf, *rotated_pixbuf; - gdouble page_width, page_height; - gint thumb_width, thumb_height; - guchar *pixels; - - g_return_val_if_fail (djvu_document->d_document, NULL); - - djvu_document_get_page_size (EV_DOCUMENT(djvu_document), rc->page, - &page_width, &page_height); - - thumb_width = (gint) (page_width * rc->scale); - thumb_height = (gint) (page_height * rc->scale); - - pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, - thumb_width, thumb_height); - gdk_pixbuf_fill (pixbuf, 0xffffffff); - pixels = gdk_pixbuf_get_pixels (pixbuf); - - while (ddjvu_thumbnail_status (djvu_document->d_document, rc->page->index, 1) < DDJVU_JOB_OK) - djvu_handle_events(djvu_document, TRUE, NULL); - - ddjvu_thumbnail_render (djvu_document->d_document, rc->page->index, - &thumb_width, &thumb_height, - djvu_document->thumbs_format, - gdk_pixbuf_get_rowstride (pixbuf), - (gchar *)pixels); - - rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation); - g_object_unref (pixbuf); - - if (border) { - GdkPixbuf *tmp_pixbuf = rotated_pixbuf; - - rotated_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf); - g_object_unref (tmp_pixbuf); - } - - return rotated_pixbuf; -} - -static void -djvu_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface) -{ - iface->get_thumbnail = djvu_document_thumbnails_get_thumbnail; - iface->get_dimensions = djvu_document_thumbnails_get_dimensions; -} - /* EvFileExporterIface */ static void djvu_document_file_exporter_begin (EvFileExporter *exporter, @@ -605,7 +567,7 @@ djvu_document_file_exporter_get_capabilities (EvFileExporter *exporter) } static void -djvu_document_file_exporter_iface_init (EvFileExporterIface *iface) +djvu_document_file_exporter_iface_init (EvFileExporterInterface *iface) { iface->begin = djvu_document_file_exporter_begin; iface->do_page = djvu_document_file_exporter_do_page; @@ -684,12 +646,12 @@ djvu_document_find_find_text (EvDocumentFind *document, } static void -djvu_document_find_iface_init (EvDocumentFindIface *iface) +djvu_document_find_iface_init (EvDocumentFindInterface *iface) { iface->find_text = djvu_document_find_find_text; } -static GList * +static EvMappingList * djvu_document_links_get_links (EvDocumentLinks *document_links, EvPage *page) { @@ -697,10 +659,11 @@ djvu_document_links_get_links (EvDocumentLinks *document_links, } static void -djvu_document_document_links_iface_init (EvDocumentLinksIface *iface) +djvu_document_document_links_iface_init (EvDocumentLinksInterface *iface) { iface->has_document_links = djvu_links_has_document_links; iface->get_links_model = djvu_links_get_links_model; iface->get_links = djvu_document_links_get_links; iface->find_link_dest = djvu_links_find_link_dest; + iface->find_link_page = djvu_links_find_link_page; }