Re: document_save question



Hello

Well, Jani, it would be nice to make this function common for all
backends somehow. It surely should stay there still, since we are going
to implement writing of PDF annotations in the future. But this fix
certainly has low priority.

this makes tiff and pixbuf use a common save helper function. If it looks ok to you
it can be used for the other backends too, adding Gnome-vfs saving capabilities later
to pdf and ps too, while in the same time making the backends not directly use the gvfs API.

thanks
Jani



=== modified file 'backend/ev-document.c'
--- backend/ev-document.c
+++ backend/ev-document.c
@@ -23,6 +23,11 @@
 #include "ev-document.h"
 
 #include "ev-backend-marshalers.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>
 
 static void ev_document_class_init (gpointer g_class);
 
@@ -105,6 +110,39 @@
 }
 
 gboolean
+ev_document_save_helper (const char *document_uri,
+		  	 const char  *uri,
+		  	 GError     **error)
+{
+	GnomeVFSResult result;
+	GnomeVFSURI *source_uri;
+	GnomeVFSURI *target_uri;
+	
+	if (!document_uri)
+		return FALSE;
+	
+	source_uri = gnome_vfs_uri_new (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);
+
+}
+
+gboolean
 ev_document_save (EvDocument  *document,
 		  const char  *uri,
 		  GError     **error)

=== modified file 'pixbuf/pixbuf-document.c'
--- pixbuf/pixbuf-document.c
+++ pixbuf/pixbuf-document.c
@@ -20,11 +20,6 @@
 #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,7 @@
 		      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_document_save_helper(pixbuf_document->uri, uri, error); 
 }
 
 static int

=== modified file 'tiff/tiff-document.c'
--- tiff/tiff-document.c
+++ tiff/tiff-document.c
@@ -30,11 +30,6 @@
 #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,7 @@
 		      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_document_save_helper(tiff_document->uri, uri, error); 
 }
 
 static int



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]