]> www.fi.muni.cz Git - evince.git/commitdiff
Save a copy implemented for various backends.
authorNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Mon, 17 Oct 2005 18:41:22 +0000 (18:41 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Mon, 17 Oct 2005 18:41:22 +0000 (18:41 +0000)
* configure.ac:
* djvu/djvu-document.c: (djvu_document_load), (djvu_document_save),
(djvu_document_finalize):
* dvi/dvi-document.c: (dvi_document_load), (dvi_document_save),
(dvi_document_finalize):
* pixbuf/pixbuf-document.c: (pixbuf_document_load),
(pixbuf_document_save), (pixbuf_document_finalize):
* tiff/tiff-document.c: (tiff_document_load), (tiff_document_save),
(tiff_document_finalize):

Save a copy implemented for various backends.

ChangeLog
configure.ac
djvu/djvu-document.c
dvi/dvi-document.c
pixbuf/pixbuf-document.c
tiff/tiff-document.c

index 5df13cc94694a3a6274d24a77be5c8f6deb5446f..591a3056046d10db905f65455790f81d91e615da 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,18 @@
-2005-10-17  Daniel Gryniewicz <dang@gentoo.org >
+2005-10-17  Nickolay V. Shmyrev  <<nshmyrev@yandex.ru>>
+
+       * configure.ac:
+       * djvu/djvu-document.c: (djvu_document_load), (djvu_document_save),
+       (djvu_document_finalize):
+       * dvi/dvi-document.c: (dvi_document_load), (dvi_document_save),
+       (dvi_document_finalize):
+       * pixbuf/pixbuf-document.c: (pixbuf_document_load),
+       (pixbuf_document_save), (pixbuf_document_finalize):
+       * tiff/tiff-document.c: (tiff_document_load), (tiff_document_save),
+       (tiff_document_finalize):
+       
+       Save a copy implemented for various backends.
+
+2005-10-17  Daniel Gryniewicz <dang@gentoo.org>
 
        * configure.ac:
        
index 3fd1e9b41f531ad2499526f5838a074bc2ec79e8..a85e6f8777977aa5f5bac0c122631ea22accde89 100644 (file)
@@ -50,7 +50,7 @@ LIBGNOMEUI_REQUIRED=2.6.0
 KEYRING_REQUIRED=0.4.2
 
 PKG_CHECK_MODULES(LIB, gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED)
-PKG_CHECK_MODULES(BACKEND, gtk+-2.0 >= $GTK_REQUIRED)
+PKG_CHECK_MODULES(BACKEND, gtk+-2.0 >= $GTK_REQUIRED gnome-vfs-2.0)
 PKG_CHECK_MODULES(FRONTEND_CORE, gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED libglade-2.0 poppler-glib >= $POPPLER_REQUIRED)
 PKG_CHECK_MODULES(POPPLER, poppler-glib >= $POPPLER_REQUIRED)
 PKG_CHECK_MODULES(SHELL_CORE, gtk+-2.0 >= $GTK_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gnome-vfs-2.0 libgnomeprint-2.2 >= 2.5.1 libgnomeprintui-2.2 libglade-2.0 gconf-2.0 poppler-glib >= $POPPLER_REQUIRED gnome-keyring-1 >= $KEYRING_REQUIRED)
index 9f22537f3751fd76c558095c8f3ea24ab6496c09..3814787545a3a5b5ed283365dcb204e22147c709 100644 (file)
 #include <gtk/gtk.h>
 #include <gdk-pixbuf/gdk-pixbuf-core.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>
+
 #define SCALE_FACTOR 0.2
 
 enum {
@@ -44,6 +49,8 @@ struct _DjvuDocument
        ddjvu_context_t  *d_context;
        ddjvu_document_t *d_document;
        ddjvu_format_t   *d_format;
+       
+       gchar *uri;
 };
 
 typedef struct _DjvuDocumentClass DjvuDocumentClass;
@@ -85,6 +92,8 @@ djvu_document_load (EvDocument  *document,
                    ddjvu_message_wait (djvu_document->d_context);
                    ddjvu_message_pop (djvu_document->d_context);       
        }
+       g_free (djvu_document->uri);
+       djvu_document->uri = g_strdup (uri);
 
        return TRUE;
 }
@@ -95,8 +104,32 @@ djvu_document_save (EvDocument  *document,
                      const char  *uri,
                      GError     **error)
 {
-       g_warning ("djvu_document_save not implemented"); /* FIXME */
-       return TRUE;
+       DjvuDocument *djvu_document = DJVU_DOCUMENT (document);
+       GnomeVFSResult result;
+       GnomeVFSURI *source_uri;
+       GnomeVFSURI *target_uri;
+       
+       if (!djvu_document->uri)
+               return FALSE;
+       
+       source_uri = gnome_vfs_uri_new (djvu_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);
 }
 
 static int
@@ -182,6 +215,7 @@ djvu_document_finalize (GObject *object)
 
        ddjvu_context_release (djvu_document->d_context);
        ddjvu_format_release (djvu_document->d_format);
+       g_free (djvu_document->uri);
        
        G_OBJECT_CLASS (djvu_document_parent_class)->finalize (object);
 }
index d4627580259b966b10e0c89944db48b4fd4f3e38..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;
 }
 
@@ -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);
 }
index e2bfaca39da7c7e9d8f1572836eb4a30a2c12979..f19d2d5e6f2a9899ce8373de56edfcddebb338cf 100644 (file)
 #include "pixbuf-document.h"
 #include "ev-document-thumbnails.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>
+
 struct _PixbufDocumentClass
 {
        GObjectClass parent_class;
@@ -30,6 +35,8 @@ struct _PixbufDocument
        GObject parent_instance;
 
        GdkPixbuf *pixbuf;
+       
+       gchar *uri;
 };
 
 typedef struct _PixbufDocumentClass PixbufDocumentClass;
@@ -65,6 +72,8 @@ pixbuf_document_load (EvDocument  *document,
                return FALSE;
 
        pixbuf_document->pixbuf = pixbuf;
+       g_free (pixbuf_document->uri);
+       pixbuf_document->uri = g_strdup (uri);
        
        return TRUE;
 }
@@ -74,8 +83,32 @@ pixbuf_document_save (EvDocument  *document,
                      const char  *uri,
                      GError     **error)
 {
-       g_warning ("pixbuf_document_save not implemented"); /* FIXME */
-       return TRUE;
+       PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (document);
+       GnomeVFSResult result;
+       GnomeVFSURI *source_uri;
+       GnomeVFSURI *target_uri;
+       
+       if (!pixbuf_document->uri)
+               return FALSE;
+       
+       source_uri = gnome_vfs_uri_new (pixbuf_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);
 }
 
 static int
@@ -120,6 +153,7 @@ pixbuf_document_finalize (GObject *object)
        PixbufDocument *pixbuf_document = PIXBUF_DOCUMENT (object);
 
        g_object_unref (pixbuf_document->pixbuf);
+       g_free (pixbuf_document->uri);
        
        G_OBJECT_CLASS (pixbuf_document_parent_class)->finalize (object);
 }
index 7831bc6f07f4b2bb861ed170910166b153514fe3..cb64678bf95b957d152c4dd9d17b29b2c8b55aef 100644 (file)
 #include "ev-document-thumbnails.h"
 #include "ev-ps-exporter.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>
+
 struct _TiffDocumentClass
 {
   GObjectClass parent_class;
@@ -42,6 +47,8 @@ struct _TiffDocument
   TIFF *tiff;
   gint n_pages;
   TIFF2PSContext *ps_export_ctx;
+  
+  gchar *uri;
 };
 
 typedef struct _TiffDocumentClass TiffDocumentClass;
@@ -108,6 +115,8 @@ tiff_document_load (EvDocument  *document,
       return FALSE;
     }
   tiff_document->tiff = tiff;
+  g_free (tiff_document->uri);
+  tiff_document->uri = g_strdup (uri);
 
   pop_handlers ();
   return TRUE;
@@ -117,8 +126,33 @@ static gboolean
 tiff_document_save (EvDocument  *document,
                      const char  *uri,
                      GError     **error)
-{
-       return FALSE;
+{              
+       TiffDocument *tiff_document = TIFF_DOCUMENT (document);
+       GnomeVFSResult result;
+       GnomeVFSURI *source_uri;
+       GnomeVFSURI *target_uri;
+       
+       if (!tiff_document->uri)
+               return FALSE;
+       
+       source_uri = gnome_vfs_uri_new (tiff_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);
 }
 
 static int
@@ -269,6 +303,7 @@ tiff_document_finalize (GObject *object)
        TiffDocument *tiff_document = TIFF_DOCUMENT (object);
 
        TIFFClose (tiff_document->tiff);
+       g_free (tiff_document->uri);
 
        G_OBJECT_CLASS (tiff_document_parent_class)->finalize (object);
 }