diff options
author | Thomas White <taw@bitwiz.org.uk> | 2013-05-26 23:04:05 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2013-05-26 23:04:05 +0200 |
commit | 172af97063ea7b7eae20199c99ed9e7f3333ab24 (patch) | |
tree | 9d5b4b2ad3d56d1941b21b1c7229ad99450d0665 /src/stylesheet.c | |
parent | 36a17f74e22a2d8406a98577caa73e16037980c7 (diff) |
Add default style
Diffstat (limited to 'src/stylesheet.c')
-rw-r--r-- | src/stylesheet.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/stylesheet.c b/src/stylesheet.c index 371ca62..9246cbf 100644 --- a/src/stylesheet.c +++ b/src/stylesheet.c @@ -42,6 +42,8 @@ struct _stylesheet struct slide_template **templates; int n_templates; + + struct style *default_style; }; @@ -62,6 +64,8 @@ struct style *new_style(StyleSheet *ss, const char *name) sty->lop.w = 100.0; sty->lop.h = 100.0; + if ( ss->default_style == NULL ) ss->default_style = sty; + n = ss->n_styles; styles_new = realloc(ss->styles, (n+1)*sizeof(sty)); if ( styles_new == NULL ) { @@ -250,6 +254,10 @@ StyleSheet *tree_to_stylesheet(struct ds_node *root) } + if ( get_field_i(root, "default_style", &i) == 0 ) { + ss->default_style = ss->styles[i]; + } + node = find_node(root, "templates", 0); if ( node == NULL ) { fprintf(stderr, "Couldn't find templates\n"); @@ -296,6 +304,7 @@ StyleSheet *new_stylesheet() ss->n_styles = 0; ss->styles = NULL; + ss->default_style = NULL; return ss; } @@ -433,16 +442,9 @@ void write_stylesheet(StyleSheet *ss, struct serializer *ser) } -struct style *find_style(StyleSheet *ss, const char *name) +struct style *default_style(StyleSheet *ss) { - int i; - for ( i=0; i<ss->n_styles; i++ ) { - if ( strcmp(ss->styles[i]->name, name) == 0 ) { - return ss->styles[i]; - } - } - - return NULL; + return ss->default_style; } |