From 2b2a139a94c932d50a5ad5a5ab91f997493e5b5a Mon Sep 17 00:00:00 2001 From: Thomas White Date: Wed, 17 Oct 2018 14:50:28 +0200 Subject: Switch to new Stylesheet type --- src/narrative_window.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) (limited to 'src/narrative_window.c') diff --git a/src/narrative_window.c b/src/narrative_window.c index 1631f2f..7a19562 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -185,7 +185,7 @@ static void delete_slide_sig(GSimpleAction *action, GVariant *parameter, } -static struct template_id *get_templates(SCBlock *ss, int *n) +static struct template_id *get_templates(Stylesheet *ss, int *n) { /* FIXME: From JSON stylesheet */ *n = 0; @@ -210,7 +210,7 @@ static void update_template_menus(NarrativeWindow *nw) } -static SCBlock *get_slide_template(SCBlock *ss) +static SCBlock *get_slide_template(Stylesheet *ss) { struct template_id *templates; int i, n_templates; @@ -244,36 +244,20 @@ static gint load_ss_response_sig(GtkWidget *d, gint response, if ( response == GTK_RESPONSE_ACCEPT ) { char *filename; - char *stext; + Stylesheet *new_ss; filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(d)); - printf("Loading %s\n",filename); - stext = load_everything(filename); - if ( stext != NULL ) { + new_ss = stylesheet_load(filename); + if ( new_ss != NULL ) { - SCBlock *bl; - SCBlock *ss; - bl = sc_parse(stext); - free(stext); - ss = find_stylesheet(bl); + stylesheet_free(nw->p->stylesheet); + nw->p->stylesheet = new_ss; + sc_editor_set_stylesheet(nw->sceditor, new_ss); - if ( ss != NULL ) { + /* Full rerender */ + sc_editor_set_scblock(nw->sceditor, nw->dummy_top); - /* Substitute the style sheet in - * presentation Storycode */ - replace_stylesheet(nw->p, ss); - - sc_editor_set_stylesheet(nw->sceditor, ss); - - /* Full rerender, first block may have - * changed */ - sc_editor_set_scblock(nw->sceditor, - nw->dummy_top); - - } else { - fprintf(stderr, _("Not a style sheet\n")); - } } else { fprintf(stderr, _("Failed to load\n")); } -- cgit v1.2.3