aboutsummaryrefslogtreecommitdiff
path: root/libstorycode
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-02-26 21:21:36 +0100
committerThomas White <taw@bitwiz.me.uk>2019-02-26 21:21:36 +0100
commit4904182915c1a02c8ac6fb26397cb12e0aab51b9 (patch)
treea84cf5506c2ddd7426d23008dd47379c2f8da5bf /libstorycode
parent237f336f9bb0d2d34784612d59cf1622a9edd952 (diff)
Skeleton of main program
Diffstat (limited to 'libstorycode')
-rw-r--r--libstorycode/presentation.c32
-rw-r--r--libstorycode/presentation.h4
2 files changed, 36 insertions, 0 deletions
diff --git a/libstorycode/presentation.c b/libstorycode/presentation.c
index 6a4d019..6eb7a50 100644
--- a/libstorycode/presentation.c
+++ b/libstorycode/presentation.c
@@ -29,11 +29,14 @@
#include <string.h>
#include <assert.h>
#include <stdio.h>
+#include <gio/gio.h>
#include "presentation.h"
#include "stylesheet.h"
#include "slide.h"
#include "narrative.h"
+#include "imagestore.h"
+#include "storycode.h"
struct _presentation
{
@@ -59,6 +62,35 @@ Presentation *presentation_new()
}
+Presentation *presentation_load(GFile *file)
+{
+ GBytes *bytes;
+ const char *text;
+ size_t len;
+ Presentation *p;
+ ImageStore *is;
+
+ bytes = g_file_load_bytes(file, NULL, NULL, NULL);
+ if ( bytes == NULL ) return NULL;
+
+ text = g_bytes_get_data(bytes, &len);
+ p = storycode_parse_presentation(text);
+ g_bytes_unref(bytes);
+ if ( p == NULL ) return NULL;
+
+ is = imagestore_new(".");
+ imagestore_set_parent(is, g_file_get_parent(file));
+ return p;
+}
+
+
+int presentation_save(Presentation *p, GFile *file)
+{
+ /* FIXME: Implementation */
+ return 1;
+}
+
+
void presentation_free(Presentation *p)
{
free(p);
diff --git a/libstorycode/presentation.h b/libstorycode/presentation.h
index 80c6186..250d7a6 100644
--- a/libstorycode/presentation.h
+++ b/libstorycode/presentation.h
@@ -27,12 +27,16 @@
#include <config.h>
#endif
+#include <gio/gio.h>
+
typedef struct _presentation Presentation;
#include "stylesheet.h"
#include "narrative.h"
extern Presentation *presentation_new(void);
+extern Presentation *presentation_load(GFile *file);
+extern int presentation_save(Presentation *p, GFile *file);
extern void presentation_free(Presentation *p);
extern void presentation_add_stylesheet(Presentation *p, Stylesheet *ss);