From a7de2d4816b4ae4727d53f0650d67afbafb01225 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 18 Nov 2016 10:56:50 +0100 Subject: Use slide template for new slides --- src/narrative_window.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'src/narrative_window.c') diff --git a/src/narrative_window.c b/src/narrative_window.c index 507e212..ca0d624 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -161,18 +161,77 @@ static void delete_slide_sig(GSimpleAction *action, GVariant *parameter, } +static struct template_id *get_templates(SCBlock *ss, int *n) +{ + struct template_id *list; + SCInterpreter *scin; + + scin = sc_interp_new(NULL, NULL, NULL); + sc_interp_run_stylesheet(scin, ss); /* ss == NULL is OK */ + list = sc_interp_get_templates(scin, n); + sc_interp_destroy(scin); + return list; +} + + +static void update_template_menus(NarrativeWindow *nw) +{ + struct template_id *templates; + int i, n_templates; + + templates = get_templates(nw->p->stylesheet, &n_templates); + + for ( i=0; isceditor); + /* Get the template */ + templ = get_slide_template(nw->p->stylesheet); /* our copy */ + show_sc_blocks(templ); + /* Link the new SCBlock in */ if ( nsblock != NULL ) { - sc_block_append(nsblock, "slide", NULL, NULL, NULL); + sc_block_append_p(nsblock, templ); } else { fprintf(stderr, "Failed to split paragraph\n"); } @@ -609,6 +668,7 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *app) "win.last"); update_toolbar(nw); + update_template_menus(nw); scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), -- cgit v1.2.3