X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=inline;f=djvu%2Fdjvu-document.c;h=3814787545a3a5b5ed283365dcb204e22147c709;hb=205c689a78e992d1ad3cf9223f7c95bf424dda94;hp=9f22537f3751fd76c558095c8f3ea24ab6496c09;hpb=7399cf0e5de076aae5cc2b3545f07c2af4bab5be;p=evince.git diff --git a/djvu/djvu-document.c b/djvu/djvu-document.c index 9f22537f..38147875 100644 --- a/djvu/djvu-document.c +++ b/djvu/djvu-document.c @@ -25,6 +25,11 @@ #include #include +#include +#include +#include +#include + #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); }