+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:
#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"
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
#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 {
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
#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;
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
#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"
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);
+
+}
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 */
#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;
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
#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;
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