From 172af97063ea7b7eae20199c99ed9e7f3333ab24 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 26 May 2013 23:04:05 +0200 Subject: Add default style --- src/default_stylesheet.sty | 3 +++ src/mainwindow.c | 2 +- src/stylesheet.c | 20 +++++++++++--------- src/stylesheet.h | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/default_stylesheet.sty b/src/default_stylesheet.sty index 575f190..d9c8bbd 100644 --- a/src/default_stylesheet.sty +++ b/src/default_stylesheet.sty @@ -1,5 +1,8 @@ # Colloquium default style sheet +[stylesheet] +default_style = 3 + [stylesheet/styles/0] name = "Presentation title" margin_l = 0.00 diff --git a/src/mainwindow.c b/src/mainwindow.c index 9e8a7d5..2c66adc 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -1051,7 +1051,7 @@ static struct frame *create_frame(struct presentation *p, double x, double y, fr = add_subframe(parent); fr->sc = NULL; - fr->style = find_style(p->ss, "Content"); + fr->style = default_style(p->ss); fr->lop_from_style = 0; fr->lop.x = x; fr->lop.y = y; 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; in_styles; i++ ) { - if ( strcmp(ss->styles[i]->name, name) == 0 ) { - return ss->styles[i]; - } - } - - return NULL; + return ss->default_style; } diff --git a/src/stylesheet.h b/src/stylesheet.h index 17d6070..7b2a846 100644 --- a/src/stylesheet.h +++ b/src/stylesheet.h @@ -63,7 +63,7 @@ extern void free_stylesheet(StyleSheet *ss); extern StyleSheet *default_stylesheet(void); extern struct style *new_style(StyleSheet *ss, const char *name); -extern struct style *find_style(StyleSheet *ss, const char *name); +extern struct style *default_style(StyleSheet *ss); extern struct slide_template *new_template(StyleSheet *ss, const char *name); extern void add_to_template(struct slide_template *t, struct style *sty); -- cgit v1.2.3