X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=libdocument%2Fev-attachment.c;h=0e9653dc4312910c61e13fc166398a2c5642cc89;hb=c9525f15920d12cb778b342f30dacf9e3782204a;hp=2eadadf4343aa16178735a70d193823cfdb2e02c;hpb=3e53caa56a48a1b854588e9a53c863ef7071f58e;p=evince.git diff --git a/libdocument/ev-attachment.c b/libdocument/ev-attachment.c index 2eadadf4..0e9653dc 100644 --- a/libdocument/ev-attachment.c +++ b/libdocument/ev-attachment.c @@ -18,7 +18,7 @@ */ #include -#include +#include #include #include #include "ev-file-helpers.h" @@ -101,7 +101,7 @@ ev_attachment_finalize (GObject *object) attachment->priv->tmp_file = NULL; } - (* G_OBJECT_CLASS (ev_attachment_parent_class)->finalize) (object); + G_OBJECT_CLASS (ev_attachment_parent_class)->finalize (object); } static void @@ -293,7 +293,7 @@ ev_attachment_save (EvAttachment *attachment, g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), FALSE); g_return_val_if_fail (G_IS_FILE (file), FALSE); - output_stream = g_file_create (file, 0, NULL, &ioerror); + output_stream = g_file_replace (file, NULL, FALSE, 0, NULL, &ioerror); if (output_stream == NULL) { char *uri; @@ -397,7 +397,7 @@ ev_attachment_open (EvAttachment *attachment, g_return_val_if_fail (EV_IS_ATTACHMENT (attachment), FALSE); if (!attachment->priv->app) { - app_info = g_app_info_get_default_for_type (attachment->priv->mime_type, TRUE); + app_info = g_app_info_get_default_for_type (attachment->priv->mime_type, FALSE); attachment->priv->app = app_info; } @@ -411,18 +411,19 @@ ev_attachment_open (EvAttachment *attachment, return FALSE; } - if (attachment->priv->tmp_file && - g_file_query_exists (attachment->priv->tmp_file, NULL)) { + if (attachment->priv->tmp_file) { retval = ev_attachment_launch_app (attachment, screen, timestamp, error); } else { - GFile *tmpdir; + char *template; GFile *file; - - tmpdir = g_file_new_for_path (ev_tmp_dir ()); - file = g_file_get_child (tmpdir, attachment->priv->name); - if (ev_attachment_save (attachment, file, error)) { + /* FIXMEchpe: convert to filename encoding first! */ + template = g_strdup_printf ("%s.XXXXXX", ev_attachment_get_name (attachment)); + file = ev_mkstemp_file (template, error); + g_free (template); + + if (file != NULL && ev_attachment_save (attachment, file, error)) { if (attachment->priv->tmp_file) g_object_unref (attachment->priv->tmp_file); attachment->priv->tmp_file = g_object_ref (file); @@ -432,7 +433,6 @@ ev_attachment_open (EvAttachment *attachment, } g_object_unref (file); - g_object_unref (tmpdir); } return retval;