]> www.fi.muni.cz Git - evince.git/commitdiff
Use common save function for backends.
authorJani Monoses <jani.monoses@gmail.com>
Thu, 19 Jan 2006 15:12:56 +0000 (15:12 +0000)
committerNickolay V. Shmyrev <nshmyrev@src.gnome.org>
Thu, 19 Jan 2006 15:12:56 +0000 (15:12 +0000)
2006-01-19  Jani Monoses <jani.monoses@gmail.com>

* comics/comics-document.c: (comics_document_save):
* djvu/djvu-document.c: (djvu_document_save):
* dvi/dvi-document.c: (dvi_document_save):
* lib/ev-file-helpers.c: (ev_tmp_filename), (ev_xfer_uri_simple):
* lib/ev-file-helpers.h:
* pixbuf/pixbuf-document.c: (pixbuf_document_save):
* tiff/tiff-document.c: (tiff_document_save):

Use common save function for backends.

ChangeLog
comics/comics-document.c
djvu/djvu-document.c
dvi/dvi-document.c
lib/ev-file-helpers.c
lib/ev-file-helpers.h
pixbuf/pixbuf-document.c
tiff/tiff-document.c

index 883b28b9b0878065ed526950c3de9f456ef332f5..5d740070a77adf1f9046c744179f44bda6390552 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-01-19  Jani Monoses <jani.monoses@gmail.com>
+
+       * comics/comics-document.c: (comics_document_save):
+       * djvu/djvu-document.c: (djvu_document_save):
+       * dvi/dvi-document.c: (dvi_document_save):
+       * lib/ev-file-helpers.c: (ev_tmp_filename), (ev_xfer_uri_simple):
+       * lib/ev-file-helpers.h:
+       * pixbuf/pixbuf-document.c: (pixbuf_document_save):
+       * tiff/tiff-document.c: (tiff_document_save):
+       
+       Use common save function for backends.
+
 2006-01-18  Jani Monoses <jani.monoses@gmail.com>
 
        * backend/ev-document-types.c:
index 93cd009a294062b7f8aeabb248773e5672bd787a..7877f50a0b8d2db8c17fadf23311cd5855c4a79e 100644 (file)
@@ -21,7 +21,6 @@
 #include <string.h>
 #include <glib/gi18n.h>
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
-#include <libgnomevfs/gnome-vfs-xfer.h>
 
 #include "comics-document.h"
 #include "ev-document-misc.h"
@@ -164,22 +163,8 @@ comics_document_save (EvDocument *document,
                      GError    **error)
 {
        ComicsDocument *comics_document = COMICS_DOCUMENT (document);
-       GnomeVFSURI *source, *target;
-       GnomeVFSResult ret;
-       source = gnome_vfs_uri_new (comics_document->archive);
-       target = gnome_vfs_uri_new (uri);
-
-       ret = gnome_vfs_xfer_uri (source, target,
-                                 GNOME_VFS_XFER_DEFAULT,
-                                 GNOME_VFS_XFER_ERROR_MODE_ABORT,
-                                 GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
-                                 NULL, NULL);
-
-       gnome_vfs_uri_unref (source);
-       gnome_vfs_uri_unref (target);
-
-       return ret == GNOME_VFS_OK;
+
+       return ev_xfer_uri_simple (comics_document->archive, uri, error);
 }
 
 static int
index 8819e73494fcca1b423d247301926998ce069d73..135d81cfa144bf97e75a5f2108f85fe00070eaf5 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 {
@@ -105,31 +100,8 @@ djvu_document_save (EvDocument  *document,
                      GError     **error)
 {
        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);
+
+       return ev_xfer_uri_simple (djvu_document->uri, uri, error);
 }
 
 static int
index 6ecbc3a29503d893ef98b3f3310033f4d576c136..81a2af273ea417779613f4f54fb288eef31162f0 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;
 
@@ -132,32 +128,8 @@ dvi_document_save (EvDocument  *document,
                      GError     **error)
 {
        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;
+
+       return ev_xfer_uri_simple (dvi_document->uri, uri, error);
 }
 
 static int
index 247e511d11f67724b7d8eba84c9b98d21095f9b2..130c62b20a48c91475db47c47be066e04beed654 100644 (file)
 #endif
 
 #include <sys/stat.h>
+#include <unistd.h>
 #include <glib.h>
 #include <libgnome/gnome-init.h>
-#include <unistd.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>
 
 #include "ev-file-helpers.h"
 
@@ -124,3 +128,36 @@ ev_tmp_filename (void)
                        
        return filename;
 }
+
+gboolean
+ev_xfer_uri_simple (const char *from,
+                   const char *to,
+                   GError     **error)
+{
+       GnomeVFSResult result;
+       GnomeVFSURI *source_uri;
+       GnomeVFSURI *target_uri;
+       
+       if (!from)
+               return FALSE;
+       
+       source_uri = gnome_vfs_uri_new (from);
+       target_uri = gnome_vfs_uri_new (to);
+
+       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,
+                            G_FILE_ERROR,
+                            G_FILE_ERROR_FAILED,
+                            gnome_vfs_result_to_string (result));
+       return (result == GNOME_VFS_OK);
+
+}
index 1d19c6d2aef8f4154a77a49ac852241909ccf933..2cc817ac2370b7e331a57e99fd30f5414294430d 100644 (file)
@@ -33,6 +33,10 @@ void        ev_file_helpers_shutdown (void);
 
 gchar*      ev_tmp_filename          (void);
 
+gboolean   ev_xfer_uri_simple        (const char *from,
+                                     const char *to,
+                                     GError     **error);
+
 G_END_DECLS
 
 #endif /* EPHY_FILE_HELPERS_H */
index f19d2d5e6f2a9899ce8373de56edfcddebb338cf..e3d064da4f95cbc2e9dfdcdcc5e43bb20a5547ef 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;
@@ -84,31 +79,8 @@ pixbuf_document_save (EvDocument  *document,
                      GError     **error)
 {
        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);
+
+       return ev_xfer_uri_simple (pixbuf_document->uri, uri, error); 
 }
 
 static int
index 7f27ad600fba5f01dbf0752ce3ab5cf604ccc683..9f465a7c5fc2293aa381cec4e530edc5e30fa259 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;
@@ -128,31 +123,8 @@ tiff_document_save (EvDocument  *document,
                      GError     **error)
 {              
        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);
+
+       return ev_xfer_uri_simple (tiff_document->uri, uri, error); 
 }
 
 static int