]> www.fi.muni.cz Git - evince.git/blobdiff - dvi/dvi-document.c
Updated Czech translation.
[evince.git] / dvi / dvi-document.c
index 05bc5b617b27b2e405a44499c9aa399e32261840..6ecbc3a29503d893ef98b3f3310033f4d576c136 100644 (file)
 
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
+#include <libgnomevfs/gnome-vfs-uri.h>
+#include <libgnomevfs/gnome-vfs-utils.h>
+#include <libgnomevfs/gnome-vfs-ops.h>
+#include <libgnomevfs/gnome-vfs-xfer.h>
 
 GMutex *dvi_context_mutex = NULL;
 
@@ -54,6 +58,8 @@ struct _DviDocument
        
        double base_width;
        double base_height;
+       
+       gchar *uri;
 };
 
 typedef struct _DviDocumentClass DviDocumentClass;
@@ -113,6 +119,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,7 +131,32 @@ dvi_document_save (EvDocument  *document,
                      const char  *uri,
                      GError     **error)
 {
-       g_warning ("dvi_document_save not implemented"); /* FIXME */
+       DviDocument *dvi_document = DVI_DOCUMENT (document);
+       GnomeVFSResult result;
+       GnomeVFSURI *source_uri;
+       GnomeVFSURI *target_uri;
+       
+       if (!dvi_document->uri)
+               return FALSE;
+       
+       source_uri = gnome_vfs_uri_new (dvi_document->uri);
+       target_uri = gnome_vfs_uri_new (uri);
+
+       result = gnome_vfs_xfer_uri (source_uri, target_uri, 
+                                    GNOME_VFS_XFER_DEFAULT | GNOME_VFS_XFER_FOLLOW_LINKS,
+                                    GNOME_VFS_XFER_ERROR_MODE_ABORT,
+                                    GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
+                                    NULL,
+                                    NULL);
+       gnome_vfs_uri_unref (target_uri);
+       gnome_vfs_uri_unref (source_uri);
+    
+       if (result != GNOME_VFS_OK)
+               g_set_error (error,
+                            EV_DOCUMENT_ERROR,
+                            0,
+                            gnome_vfs_result_to_string (result));                      
+       return (result == GNOME_VFS_OK);
        return TRUE;
 }
 
@@ -191,7 +224,7 @@ dvi_document_render_pixbuf (EvDocument  *document,
 
        g_mutex_unlock (dvi_context_mutex);
 
-       rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, rc->rotation);
+       rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rc->rotation);
        g_object_unref (pixbuf);
 
        return rotated_pixbuf;
@@ -210,6 +243,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);
 }
@@ -310,19 +345,15 @@ 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, rotation);
+       rotated_pixbuf = gdk_pixbuf_rotate_simple (pixbuf, 360 - rotation);
        g_object_unref (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;
 }