diff options
author | Thomas White <taw@bitwiz.me.uk> | 2018-10-21 18:03:01 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2018-10-21 18:03:01 +0200 |
commit | 27e08c96c71183edea9be3e189d7152c19b1beac (patch) | |
tree | 428735ad37dbfcb9598c4ae3854252a4092d3f8f /src/stylesheet.c | |
parent | a85c7fd76dd50d82841e01018b532ad790f8c564 (diff) |
Try <documentname>.ss for stylesheet
Diffstat (limited to 'src/stylesheet.c')
-rw-r--r-- | src/stylesheet.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/stylesheet.c b/src/stylesheet.c index 228c331..020107e 100644 --- a/src/stylesheet.c +++ b/src/stylesheet.c @@ -29,8 +29,10 @@ #include <stdlib.h> #include <string.h> #include <stdio.h> +#include <gio/gio.h> #include "stylesheet.h" +#include "utils.h" struct _stylesheet { @@ -38,19 +40,27 @@ struct _stylesheet { }; -Stylesheet *stylesheet_load(const char *filename) +Stylesheet *stylesheet_load(GFile *file) { JsonParser *parser; gboolean r; GError *err = NULL; Stylesheet *ss; + char *everything; + gsize len; ss = calloc(1, sizeof(Stylesheet)); if ( ss == NULL ) return NULL; parser = json_parser_new(); - r = json_parser_load_from_file(parser, filename, &err); + if ( !g_file_load_contents(file, NULL, &everything, &len, NULL, NULL) ) { + fprintf(stderr, _("Failed to load stylesheet '%s'\n"), + g_file_get_uri(file)); + return NULL; + } + + r = json_parser_load_from_data(parser, everything, len, &err); if ( r == FALSE ) { fprintf(stderr, "Failed to load style sheet: '%s'\n", err->message); return NULL; |