]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-sidebar-attachments.c
libdocument: Clean up temp file handling
[evince.git] / shell / ev-sidebar-attachments.c
index d89617b1d6471ffc126b558e83376abeab009727..74e89c4163d1756e3789ec263d9213c44aa69eaf 100644 (file)
@@ -410,7 +410,7 @@ ev_sidebar_attachments_drag_data_get (GtkWidget        *widget,
                GtkTreePath  *path;
                GtkTreeIter   iter;
                GFile        *file;
-               gchar        *filename;
+               gchar        *filename, *template, *name;
                GError       *error = NULL;
                
                path = (GtkTreePath *) l->data;
@@ -421,13 +421,12 @@ ev_sidebar_attachments_drag_data_get (GtkWidget        *widget,
                                    COLUMN_ATTACHMENT, &attachment,
                                    -1);
 
-               filename = g_build_filename (ev_tmp_dir (),
-                                            ev_attachment_get_name (attachment),
-                                            NULL);
-               file = g_file_new_for_path (filename);
-               g_free (filename);
+                /* 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 (ev_attachment_save (attachment, file, &error)) {
+               if (file != NULL && ev_attachment_save (attachment, file, &error)) {
                        gchar *uri;
 
                        uri = g_file_get_uri (file);