aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-04-30 17:51:31 +0200
committerThomas White <taw@bitwiz.me.uk>2019-04-30 18:01:22 +0200
commitc1b0437dd1f1bc6df338ad9fc15d270b9cc33884 (patch)
treed24f40699ae099abd7bae2c0ed2d6489d4144588
parent584ff995faa629c82377d3a44fb25d5100d09c76 (diff)
Create stylesheet with narrative
This means there'll ALWAYS be a default stylesheet present, avoiding crashes and a lot of special cases.
-rw-r--r--libstorycode/narrative.c2
-rw-r--r--libstorycode/scparse_priv.h1
-rw-r--r--libstorycode/storycode.y31
-rw-r--r--src/colloquium.c6
4 files changed, 21 insertions, 19 deletions
diff --git a/libstorycode/narrative.c b/libstorycode/narrative.c
index 9488285..c14ac6d 100644
--- a/libstorycode/narrative.c
+++ b/libstorycode/narrative.c
@@ -56,7 +56,7 @@ Narrative *narrative_new()
if ( n == NULL ) return NULL;
n->n_items = 0;
n->items = NULL;
- n->stylesheet = NULL;
+ n->stylesheet = stylesheet_new();
n->imagestore = imagestore_new("."); /* FIXME: From app config */
n->saved = 1;
#ifdef HAVE_PANGO
diff --git a/libstorycode/scparse_priv.h b/libstorycode/scparse_priv.h
index 22be698..3d97ead 100644
--- a/libstorycode/scparse_priv.h
+++ b/libstorycode/scparse_priv.h
@@ -40,7 +40,6 @@ enum style_mask
struct scpctx
{
Narrative *n;
- Stylesheet *ss;
Slide *s;
int n_str;
diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y
index 5d22826..fce8d37 100644
--- a/libstorycode/storycode.y
+++ b/libstorycode/storycode.y
@@ -101,9 +101,8 @@
{
ctx->n = narrative_new();
- /* These are the objects currently being created. They will be
- * added to the narrative when they're complete */
- ctx->ss = stylesheet_new();
+ /* The slide currently being created.
+ * Will be added to the narrative when complete */
ctx->s = slide_new();
ctx->max_str = 32;
@@ -164,13 +163,20 @@ void add_str(struct scpctx *ctx, char *str)
void set_style(struct scpctx *ctx, const char *element)
{
- if ( ctx->mask & STYMASK_GEOM ) stylesheet_set_geometry(ctx->ss, element, ctx->geom);
- if ( ctx->mask & STYMASK_FONT ) stylesheet_set_font(ctx->ss, element, ctx->font);
- if ( ctx->mask & STYMASK_ALIGNMENT ) stylesheet_set_alignment(ctx->ss, element, ctx->alignment);
- if ( ctx->mask & STYMASK_PADDING ) stylesheet_set_padding(ctx->ss, element, ctx->padding);
- if ( ctx->mask & STYMASK_PARASPACE ) stylesheet_set_paraspace(ctx->ss, element, ctx->paraspace);
- if ( ctx->mask & STYMASK_FGCOL ) stylesheet_set_fgcol(ctx->ss, element, ctx->fgcol);
- if ( ctx->mask & STYMASK_BGCOL ) stylesheet_set_background(ctx->ss, element, ctx->bggrad,
+ if ( ctx->mask & STYMASK_GEOM ) stylesheet_set_geometry(narrative_get_stylesheet(ctx->n),
+ element, ctx->geom);
+ if ( ctx->mask & STYMASK_FONT ) stylesheet_set_font(narrative_get_stylesheet(ctx->n),
+ element, ctx->font);
+ if ( ctx->mask & STYMASK_ALIGNMENT ) stylesheet_set_alignment(narrative_get_stylesheet(ctx->n),
+ element, ctx->alignment);
+ if ( ctx->mask & STYMASK_PADDING ) stylesheet_set_padding(narrative_get_stylesheet(ctx->n),
+ element, ctx->padding);
+ if ( ctx->mask & STYMASK_PARASPACE ) stylesheet_set_paraspace(narrative_get_stylesheet(ctx->n),
+ element, ctx->paraspace);
+ if ( ctx->mask & STYMASK_FGCOL ) stylesheet_set_fgcol(narrative_get_stylesheet(ctx->n),
+ element, ctx->fgcol);
+ if ( ctx->mask & STYMASK_BGCOL ) stylesheet_set_background(narrative_get_stylesheet(ctx->n),
+ element, ctx->bggrad,
ctx->bgcol, ctx->bgcol2);
ctx->mask = 0;
ctx->alignment = ALIGN_INHERIT;
@@ -330,7 +336,7 @@ stylesheet:
STYLES '{'
style_narrative
style_slide
- '}' { narrative_add_stylesheet(ctx->n, ctx->ss); }
+ '}' { }
;
style_narrative:
@@ -374,7 +380,8 @@ style_slidesize:
{
fprintf(stderr, "Wrong slide size units\n");
} else {
- stylesheet_set_slide_default_size(ctx->ss, $2.len, $4.len);
+ stylesheet_set_slide_default_size(narrative_get_stylesheet(ctx->n),
+ $2.len, $4.len);
}
}
;
diff --git a/src/colloquium.c b/src/colloquium.c
index d3ada61..95b5231 100644
--- a/src/colloquium.c
+++ b/src/colloquium.c
@@ -61,12 +61,8 @@ static void colloquium_activate(GApplication *papp)
{
Colloquium *app = COLLOQUIUM(papp);
if ( !app->first_run ) {
- Narrative *n;
- Stylesheet *ss;
- n = narrative_new();
- ss = stylesheet_new();
+ Narrative *n = narrative_new();
narrative_add_text(n, strdup(""));
- narrative_add_stylesheet(n, ss);
narrative_window_new(n, NULL, papp);
}
}