aboutsummaryrefslogtreecommitdiff
path: root/src/presentation.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2018-04-01 11:08:38 +0200
committerThomas White <taw@bitwiz.me.uk>2018-04-01 11:08:38 +0200
commit6acebfa0b19e106c6dca91eceb31c6d1975828b5 (patch)
treed5e685310c8b2b93ce4246c2b518a259bb78c960 /src/presentation.c
parentd21213ef38b2027e3ac668d6906d0ff439b1885a (diff)
Use GFile for presentation loading
Diffstat (limited to 'src/presentation.c')
-rw-r--r--src/presentation.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/presentation.c b/src/presentation.c
index 1c822c4..d338a1a 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -125,22 +125,22 @@ struct presentation *new_presentation(const char *imagestore)
}
-int save_presentation(struct presentation *p, const char *filename)
+int save_presentation(struct presentation *p, GFile *file)
{
FILE *fh;
- char *old_fn;
+ char *filename;
+
+ /* FIXME: Do this properly using GFile */
+ filename = g_file_get_path(file);
+ printf("Saving to %s\n", filename);
fh = fopen(filename, "w");
if ( fh == NULL ) return 1;
save_sc_block(fh, p->scblocks);
- /* Slightly fiddly because someone might
- * do save_presentation(p, p->filename) */
- old_fn = p->filename;
- imagestore_set_presentation_file(p->is, filename);
+ imagestore_set_parent(p->is, g_file_get_parent(file));
p->filename = strdup(filename);
- if ( old_fn != NULL ) free(old_fn);
fclose(fh);
p->saved = 1;
@@ -331,21 +331,20 @@ static void set_slide_size_from_stylesheet(struct presentation *p)
}
-int load_presentation(struct presentation *p, const char *filename)
+int load_presentation(struct presentation *p, GFile *file)
{
int r = 0;
char *everything;
assert(p->completely_empty);
- everything = load_everything(filename);
- if ( everything == NULL ) {
- fprintf(stderr, "Failed to load '%s'\n", filename);
+ if ( !g_file_load_contents(file, NULL, &everything, NULL, NULL, NULL) ) {
+ fprintf(stderr, "Failed to load '%s'\n", g_file_get_uri(file));
return 1;
}
p->scblocks = sc_parse(everything);
- free(everything);
+ g_free(everything);
p->lang = pango_language_get_default();
@@ -361,8 +360,8 @@ int load_presentation(struct presentation *p, const char *filename)
set_slide_size_from_stylesheet(p);
assert(p->filename == NULL);
- p->filename = strdup(filename);
- imagestore_set_presentation_file(p->is, filename);
+ p->filename = g_file_get_uri(file);
+ imagestore_set_parent(p->is, g_file_get_parent(file));
return 0;
}