]> www.fi.muni.cz Git - evince.git/blobdiff - dvi/dvi-document.c
Translation updated by Ivar Smolin.
[evince.git] / dvi / dvi-document.c
index d0307e3a2661226be08b50adc65ab56f3e47d5f8..81a2af273ea417779613f4f54fb288eef31162f0 100644 (file)
@@ -54,6 +54,8 @@ struct _DviDocument
        
        double base_width;
        double base_height;
+       
+       gchar *uri;
 };
 
 typedef struct _DviDocumentClass DviDocumentClass;
@@ -113,6 +115,8 @@ dvi_document_load (EvDocument  *document,
 
     dvi_context_mutex = g_mutex_new ();
 
+    g_free (dvi_document->uri);
+    dvi_document->uri = g_strdup (uri);
 
     return TRUE;
 }
@@ -123,8 +127,9 @@ dvi_document_save (EvDocument  *document,
                      const char  *uri,
                      GError     **error)
 {
-       g_warning ("dvi_document_save not implemented"); /* FIXME */
-       return TRUE;
+       DviDocument *dvi_document = DVI_DOCUMENT (document);
+
+       return ev_xfer_uri_simple (dvi_document->uri, uri, error);
 }
 
 static int
@@ -141,20 +146,19 @@ dvi_document_get_page_size (EvDocument   *document,
                            double    *height)
 {
        DviDocument * dvi_document = DVI_DOCUMENT (document);   
-       
-       if (width != NULL)
-           *width = dvi_document->base_width;
 
-       if (height != NULL)
-           *height = dvi_document->base_height;
-                           
+        *width = dvi_document->base_width;
+        *height = dvi_document->base_height;;
+                                   
        return;
 }
 
 static GdkPixbuf *
-dvi_document_render_pixbuf (EvDocument  *document, int page, double scale)
+dvi_document_render_pixbuf (EvDocument  *document,
+                           EvRenderContext *rc)
 {
        GdkPixbuf *pixbuf;
+       GdkPixbuf *rotated_pixbuf;
 
        DviDocument *dvi_document = DVI_DOCUMENT(document);
 
@@ -168,14 +172,14 @@ dvi_document_render_pixbuf (EvDocument  *document, int page, double scale)
         */
        g_mutex_lock (dvi_context_mutex);
        
-       mdvi_setpage(dvi_document->context,  page);
+       mdvi_setpage(dvi_document->context,  rc->page);
        
        mdvi_set_shrink (dvi_document->context, 
-                        (int)((dvi_document->params->hshrink - 1) / scale) + 1,
-                        (int)((dvi_document->params->vshrink - 1) / scale) + 1);
+                        (int)((dvi_document->params->hshrink - 1) / rc->scale) + 1,
+                        (int)((dvi_document->params->vshrink - 1) / rc->scale) + 1);
 
-       required_width = dvi_document->base_width * scale;
-       required_height = dvi_document->base_height * scale;
+       required_width = dvi_document->base_width * rc->scale;
+       required_height = dvi_document->base_height * rc->scale;
        proposed_width = dvi_document->context->dvi_page_w * dvi_document->context->params.conv;
        proposed_height = dvi_document->context->dvi_page_h * dvi_document->context->params.vconv;
        
@@ -192,7 +196,10 @@ dvi_document_render_pixbuf (EvDocument  *document, int page, double scale)
 
        g_mutex_unlock (dvi_context_mutex);
 
-       return pixbuf;
+       rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
+       g_object_unref (pixbuf);
+
+       return rotated_pixbuf;
 }
 
 static void
@@ -208,6 +215,8 @@ dvi_document_finalize (GObject *object)
 
        if (dvi_document->params)
                g_free (dvi_document->params);
+
+        g_free (dvi_document->uri);
                
        G_OBJECT_CLASS (dvi_document_parent_class)->finalize (object);
 }
@@ -251,10 +260,10 @@ dvi_document_document_iface_init (EvDocumentIface *iface)
 
 static void
 dvi_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
-                                          gint                  page,
-                                          gint                  suggested_width,
-                                          gint                  *width,
-                                          gint                  *height)
+                                       gint                  page,
+                                       gint                  suggested_width,
+                                       gint                  *width,
+                                       gint                  *height)
 {      
        DviDocument *dvi_document = DVI_DOCUMENT (document); 
        gdouble page_ratio;
@@ -269,12 +278,14 @@ dvi_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
 static GdkPixbuf *
 dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails   *document,
                                       gint                      page,
+                                      gint                      rotation,
                                       gint                      width,
                                       gboolean                  border)
 {
        DviDocument *dvi_document = DVI_DOCUMENT (document);
        GdkPixbuf *pixbuf;
        GdkPixbuf *border_pixbuf;
+       GdkPixbuf *rotated_pixbuf;
        gint thumb_width, thumb_height;
        gint proposed_width, proposed_height;
        
@@ -306,18 +317,17 @@ dvi_document_thumbnails_get_thumbnail (EvDocumentThumbnails   *document,
        pixbuf = mdvi_pixbuf_device_get_pixbuf (&dvi_document->context->device);
 
        g_mutex_unlock (dvi_context_mutex);
-
-       if (border) {
-               border_pixbuf = ev_document_misc_get_thumbnail_frame (thumb_width, thumb_height, NULL);
-               gdk_pixbuf_copy_area (pixbuf, 0, 0, 
-                                     thumb_width - 2, thumb_height - 2,
-                                     border_pixbuf, 2, 2);
-               g_object_unref (pixbuf);
-               pixbuf = border_pixbuf;
-       }
        
+       rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rotation);
+       g_object_unref (pixbuf);
        
-       return pixbuf;
+        if (border) {
+             GdkPixbuf *tmp_pixbuf = rotated_pixbuf;
+             rotated_pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, 0, tmp_pixbuf);
+             g_object_unref (tmp_pixbuf);
+       }
+
+       return rotated_pixbuf;
 }
 
 static void