aboutsummaryrefslogtreecommitdiff
path: root/src/narrative_window.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2017-02-04 22:49:44 +0100
committerThomas White <taw@bitwiz.org.uk>2017-02-04 22:49:44 +0100
commit930ad5b26c04363727ed2b5aa11e071ed8293c72 (patch)
treed5ba2f60b1813354def0d0138f758a7657febce1 /src/narrative_window.c
parent950e1aa6e04bc8d94147273097074b5be58bba28 (diff)
Set narrative stylesheet when replacing it
Diffstat (limited to 'src/narrative_window.c')
-rw-r--r--src/narrative_window.c55
1 files changed, 38 insertions, 17 deletions
diff --git a/src/narrative_window.c b/src/narrative_window.c
index a1a522e..04f42c7 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -223,6 +223,34 @@ static SCBlock *get_slide_template(SCBlock *ss)
}
+static SCBlock *narrative_stylesheet()
+{
+ return sc_parse("\\stylesheet{"
+ "\\ss[slide]{\\callback[sthumb]}"
+ "}");
+}
+
+
+static SCBlock **get_ss_list(struct presentation *p)
+{
+ SCBlock **stylesheets;
+
+ stylesheets = malloc(3 * sizeof(SCBlock *));
+ if ( stylesheets == NULL ) return NULL;
+
+ if ( p->stylesheet != NULL ) {
+ stylesheets[0] = p->stylesheet;
+ stylesheets[1] = narrative_stylesheet();
+ stylesheets[2] = NULL;
+ } else {
+ stylesheets[0] = narrative_stylesheet();
+ stylesheets[1] = NULL;
+ }
+
+ return stylesheets;
+}
+
+
static gint load_ss_response_sig(GtkWidget *d, gint response,
NarrativeWindow *nw)
{
@@ -243,9 +271,16 @@ static gint load_ss_response_sig(GtkWidget *d, gint response,
ss = find_stylesheet(bl);
if ( ss != NULL ) {
+ SCBlock **stylesheets;
+
/* Substitute the style sheet */
replace_stylesheet(nw->p, ss);
+ stylesheets = get_ss_list(nw->p);
+ sc_editor_set_stylesheets(nw->sceditor,
+ stylesheets);
+ free(stylesheets);
+
/* Full rerender, first block may have
* changed */
sc_editor_set_scblock(nw->sceditor,
@@ -566,14 +601,6 @@ static void nw_update_titlebar(NarrativeWindow *nw)
}
-static SCBlock *narrative_stylesheet()
-{
- return sc_parse("\\stylesheet{"
- "\\ss[slide]{\\callback[sthumb]}"
- "}");
-}
-
-
static int create_thumbnail(SCInterpreter *scin, SCBlock *bl,
double *w, double *h, void **bvp, void *vp)
{
@@ -672,7 +699,7 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *app)
GtkWidget *scroll;
GtkWidget *toolbar;
GtkToolItem *button;
- SCBlock *stylesheets[3];
+ SCBlock **stylesheets;
SCCallbackList *cbl;
GtkWidget *image;
@@ -701,20 +728,14 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *app)
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add(GTK_CONTAINER(nw->window), vbox);
- if ( p->stylesheet != NULL ) {
- stylesheets[0] = p->stylesheet;
- stylesheets[1] = narrative_stylesheet();
- stylesheets[2] = NULL;
- } else {
- stylesheets[0] = narrative_stylesheet();
- stylesheets[1] = NULL;
- }
+ stylesheets = get_ss_list(p);
if ( nw->p->scblocks == NULL ) {
nw->p->scblocks = sc_parse("");
}
nw->sceditor = sc_editor_new(nw->p->scblocks, stylesheets, p->lang);
+ free(stylesheets);
cbl = sc_callback_list_new();
sc_callback_list_add_callback(cbl, "sthumb", create_thumbnail,
render_thumbnail, click_thumbnail, p);