aboutsummaryrefslogtreecommitdiff
path: root/src/presentation.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/presentation.c')
-rw-r--r--src/presentation.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/presentation.c b/src/presentation.c
index d338a1a..bc0089f 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -127,22 +127,22 @@ struct presentation *new_presentation(const char *imagestore)
int save_presentation(struct presentation *p, GFile *file)
{
- FILE *fh;
- char *filename;
-
- /* FIXME: Do this properly using GFile */
- filename = g_file_get_path(file);
- printf("Saving to %s\n", filename);
+ GFileOutputStream *fh;
+ int r;
+ GError *error = NULL;
- fh = fopen(filename, "w");
- if ( fh == NULL ) return 1;
+ fh = g_file_replace(file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &error);
+ if ( fh == NULL ) {
+ fprintf(stderr, "Open failed: %s\n", error->message);
+ return 1;
+ }
+ r = save_sc_block(G_OUTPUT_STREAM(fh), p->scblocks);
+ g_object_unref(fh);
- save_sc_block(fh, p->scblocks);
+ if ( r ) return 1;
imagestore_set_parent(p->is, g_file_get_parent(file));
- p->filename = strdup(filename);
-
- fclose(fh);
+ p->filename = g_file_get_uri(file);
p->saved = 1;
update_titlebar(p->narrative_window);
return 0;