From: Jani Monoses Date: Thu, 19 Jan 2006 15:12:56 +0000 (+0000) Subject: Use common save function for backends. X-Git-Tag: EVINCE_0_5_0~1 X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=f693b48e9ca24fec37c190cdb90682c67e8e6c28;p=evince.git Use common save function for backends. 2006-01-19 Jani Monoses * 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. --- diff --git a/ChangeLog b/ChangeLog index 883b28b9..5d740070 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2006-01-19 Jani Monoses + + * 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 * backend/ev-document-types.c: diff --git a/comics/comics-document.c b/comics/comics-document.c index 93cd009a..7877f50a 100644 --- a/comics/comics-document.c +++ b/comics/comics-document.c @@ -21,7 +21,6 @@ #include #include #include -#include #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 diff --git a/djvu/djvu-document.c b/djvu/djvu-document.c index 8819e734..135d81cf 100644 --- a/djvu/djvu-document.c +++ b/djvu/djvu-document.c @@ -25,11 +25,6 @@ #include #include -#include -#include -#include -#include - #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 diff --git a/dvi/dvi-document.c b/dvi/dvi-document.c index 6ecbc3a2..81a2af27 100644 --- a/dvi/dvi-document.c +++ b/dvi/dvi-document.c @@ -29,10 +29,6 @@ #include #include -#include -#include -#include -#include 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 diff --git a/lib/ev-file-helpers.c b/lib/ev-file-helpers.c index 247e511d..130c62b2 100644 --- a/lib/ev-file-helpers.c +++ b/lib/ev-file-helpers.c @@ -23,9 +23,13 @@ #endif #include +#include #include #include -#include +#include +#include +#include +#include #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); + +} diff --git a/lib/ev-file-helpers.h b/lib/ev-file-helpers.h index 1d19c6d2..2cc817ac 100644 --- a/lib/ev-file-helpers.h +++ b/lib/ev-file-helpers.h @@ -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 */ diff --git a/pixbuf/pixbuf-document.c b/pixbuf/pixbuf-document.c index f19d2d5e..e3d064da 100644 --- a/pixbuf/pixbuf-document.c +++ b/pixbuf/pixbuf-document.c @@ -20,11 +20,6 @@ #include "pixbuf-document.h" #include "ev-document-thumbnails.h" -#include -#include -#include -#include - 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 diff --git a/tiff/tiff-document.c b/tiff/tiff-document.c index 7f27ad60..9f465a7c 100644 --- a/tiff/tiff-document.c +++ b/tiff/tiff-document.c @@ -30,11 +30,6 @@ #include "ev-document-thumbnails.h" #include "ev-ps-exporter.h" -#include -#include -#include -#include - 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