]> www.fi.muni.cz Git - evince.git/blobdiff - backend/impress/impress-document.c
Updated Belarusian Translation
[evince.git] / backend / impress / impress-document.c
index 5f5982ed7fcc08b928e8012e6ec5b883cc0e5910..8ceabd43d967419d6d1155e6f6a812a4e1891b28 100644 (file)
@@ -18,6 +18,9 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  */
 
+#include "config.h"
+
+#include <config.h>
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 #include <string.h>
@@ -58,11 +61,10 @@ typedef struct _ImpressDocumentClass ImpressDocumentClass;
 static void impress_document_document_iface_init (EvDocumentIface *iface);
 static void impress_document_document_thumbnails_iface_init (EvDocumentThumbnailsIface *iface);
 
-G_DEFINE_TYPE_WITH_CODE (ImpressDocument, impress_document, G_TYPE_OBJECT,
-                         { G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT,
-                                                 impress_document_document_iface_init);
-                          G_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
-                                                 impress_document_document_thumbnails_iface_init);
+EV_BACKEND_REGISTER_WITH_CODE (ImpressDocument, impress_document,
+                        {
+                          EV_BACKEND_IMPLEMENT_INTERFACE (EV_TYPE_DOCUMENT_THUMBNAILS,
+                                                          impress_document_document_thumbnails_iface_init);
                         });
 
 /* Renderer */
@@ -355,8 +357,10 @@ imp_render_get_from_drawable (ImpressDocument *impress_document)
 
   g_return_val_if_fail (page != NULL, FALSE);
 
+  ev_document_doc_mutex_lock ();
   imp_context_set_page (impress_document->ctx, page);
   imp_render (impress_document->ctx, impress_document);
+  ev_document_doc_mutex_unlock ();
 
   impress_document->pixbuf = gdk_pixbuf_get_from_drawable (NULL,
                                         GDK_DRAWABLE (impress_document->pixmap),
@@ -370,36 +374,56 @@ imp_render_get_from_drawable (ImpressDocument *impress_document)
 }
 
 static GdkPixbuf *
-impress_document_render_pixbuf (EvDocument  *document,
+impress_document_render_pixbuf (EvDocument      *document,
                                EvRenderContext *rc)
 {
   ImpressDocument *impress_document = IMPRESS_DOCUMENT (document);
-  GdkPixbuf *scaled_pixbuf;
-
-  g_return_val_if_fail (IMPRESS_IS_DOCUMENT (document), 0);
-  g_return_val_if_fail (impress_document->imp != NULL, 0);
+  GdkPixbuf       *pixbuf;
 
+  g_return_val_if_fail (IMPRESS_IS_DOCUMENT (document), NULL);
+  g_return_val_if_fail (impress_document->imp != NULL, NULL);
+  
   impress_document->pagenum = rc->page;
 
   g_mutex_lock (impress_document->mutex);
   impress_document->cond = g_cond_new ();
 
   ev_document_fc_mutex_unlock ();
+  ev_document_doc_mutex_unlock ();
   g_idle_add ((GSourceFunc) imp_render_get_from_drawable, impress_document);
   g_cond_wait (impress_document->cond, impress_document->mutex);
   g_cond_free (impress_document->cond);
+  ev_document_doc_mutex_lock ();
   ev_document_fc_mutex_lock ();
-
+  
   g_mutex_unlock (impress_document->mutex);
 
-  scaled_pixbuf = gdk_pixbuf_scale_simple (impress_document->pixbuf,
-                                          PAGE_WIDTH * rc->scale,
-                                          PAGE_HEIGHT * rc->scale,
-                                          GDK_INTERP_BILINEAR);
-  gdk_pixbuf_unref (impress_document->pixbuf);
+  pixbuf = impress_document->pixbuf;
   impress_document->pixbuf = NULL;
 
-  return scaled_pixbuf;
+  return pixbuf;
+}
+
+static cairo_surface_t *
+impress_document_render (EvDocument      *document,
+                        EvRenderContext *rc)
+{
+  GdkPixbuf *pixbuf;
+  cairo_surface_t *surface, *scaled_surface;
+
+  pixbuf = impress_document_render_pixbuf (document, rc);
+  
+  /* FIXME: impress backend should be ported to cairo */
+  surface = ev_document_misc_surface_from_pixbuf (pixbuf);
+  g_object_unref (pixbuf);
+
+  scaled_surface = ev_document_misc_surface_rotate_and_scale (surface,
+                                                             (PAGE_WIDTH * rc->scale) + 0.5,
+                                                             (PAGE_HEIGHT * rc->scale) + 0.5,
+                                                             rc->rotation);
+  cairo_surface_destroy (surface);
+
+  return scaled_surface;
 }
 
 static void
@@ -436,12 +460,6 @@ impress_document_class_init (ImpressDocumentClass *klass)
   gobject_class->finalize = impress_document_finalize;
 }
 
-static gboolean
-impress_document_can_get_text (EvDocument *document)
-{
-  return FALSE;
-}
-
 static EvDocumentInfo *
 impress_document_get_info (EvDocument *document)
 {
@@ -458,10 +476,9 @@ impress_document_document_iface_init (EvDocumentIface *iface)
 {
   iface->load = impress_document_load;
   iface->save = impress_document_save;
-  iface->can_get_text = impress_document_can_get_text;
   iface->get_n_pages = impress_document_get_n_pages;
   iface->get_page_size = impress_document_get_page_size;
-  iface->render_pixbuf = impress_document_render_pixbuf;
+  iface->render = impress_document_render;
   iface->get_info = impress_document_get_info;
 }
 
@@ -470,20 +487,25 @@ impress_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
                                           EvRenderContext      *rc, 
                                           gboolean              border)
 {
-  GdkPixbuf *pixbuf = NULL;
-  gdouble w, h;
+  GdkPixbuf *pixbuf;
+  GdkPixbuf *scaled_pixbuf;
 
   pixbuf = impress_document_render_pixbuf (EV_DOCUMENT (document), rc);
+  scaled_pixbuf = gdk_pixbuf_scale_simple (pixbuf,
+                                          (PAGE_WIDTH * rc->scale),
+                                          (PAGE_HEIGHT * rc->scale),
+                                          GDK_INTERP_BILINEAR);
+  g_object_unref (pixbuf);
 
   if (border)
     {
-      GdkPixbuf *tmp_pixbuf = pixbuf;
+      GdkPixbuf *tmp_pixbuf = scaled_pixbuf;
       
-      pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
+      scaled_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
       g_object_unref (tmp_pixbuf);
     }
 
-  return pixbuf;
+  return scaled_pixbuf;
 }
 
 static void