aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/narrative_window.c13
-rw-r--r--src/sc_editor.c8
-rw-r--r--src/sc_parse.c13
-rw-r--r--src/sc_parse.h2
-rw-r--r--src/slide_window.c6
5 files changed, 31 insertions, 11 deletions
diff --git a/src/narrative_window.c b/src/narrative_window.c
index 02960a5..968ea5c 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -51,6 +51,7 @@ struct _narrative_window
SCEditor *sceditor;
GApplication *app;
struct presentation *p;
+ SCBlock *dummy_top;
SCSlideshow *show;
PRClock *pr_clock;
};
@@ -154,7 +155,7 @@ static void delete_slide_sig(GSimpleAction *action, GVariant *parameter,
return;
}
- sc_block_delete(&nw->p->scblocks, ns);
+ sc_block_delete(&nw->dummy_top, ns);
/* Full rerender */
sc_editor_set_scblock(nw->sceditor,
@@ -285,7 +286,7 @@ static gint load_ss_response_sig(GtkWidget *d, gint response,
/* Full rerender, first block may have
* changed */
sc_editor_set_scblock(nw->sceditor,
- nw->p->scblocks);
+ nw->dummy_top);
} else {
fprintf(stderr, "Not a style sheet\n");
@@ -802,11 +803,17 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *papp
stylesheets = get_ss_list(p);
+ /* If the presentation is completely empty, give ourselves at least
+ * something to work with */
if ( nw->p->scblocks == NULL ) {
nw->p->scblocks = sc_parse("");
}
- nw->sceditor = sc_editor_new(nw->p->scblocks, stylesheets, p->lang,
+ /* Put everything we have inside \presentation{}.
+ * SCEditor will start processing one level down */
+ nw->dummy_top = sc_block_new_parent(nw->p->scblocks, "presentation");
+
+ nw->sceditor = sc_editor_new(nw->dummy_top, stylesheets, p->lang,
colloquium_get_imagestore(app));
free(stylesheets);
cbl = sc_callback_list_new();
diff --git a/src/sc_editor.c b/src/sc_editor.c
index e7b3cd1..08ddb46 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -203,7 +203,8 @@ static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event,
w = e->log_w;
h = e->log_h;
}
- e->top = interp_and_shape(e->scblocks, e->stylesheets, e->cbl,
+ e->top = interp_and_shape(sc_block_child(e->scblocks),
+ e->stylesheets, e->cbl,
e->is, e->slidenum, pc,
w, h, e->lang);
recursive_wrap(e->top, pc);
@@ -402,7 +403,8 @@ static void full_rerender(SCEditor *e)
pc = gdk_pango_context_get();
- e->top = interp_and_shape(e->scblocks, e->stylesheets, e->cbl,
+ e->top = interp_and_shape(sc_block_child(e->scblocks),
+ e->stylesheets, e->cbl,
e->is, e->slidenum,
pc, e->log_w, 0.0, e->lang);
@@ -484,7 +486,9 @@ void sc_editor_copy_selected_frame(SCEditor *e)
void sc_editor_delete_selected_frame(SCEditor *e)
{
+ SCBlock *scb_old = e->scblocks;
sc_block_delete(&e->scblocks, e->selection->scblocks);
+ assert(scb_old == e->scblocks);
full_rerender(e);
emit_change_sig(e);
}
diff --git a/src/sc_parse.c b/src/sc_parse.c
index 28de7c2..9970566 100644
--- a/src/sc_parse.c
+++ b/src/sc_parse.c
@@ -263,7 +263,7 @@ int sc_block_unlink(SCBlock **top, SCBlock *deleteme)
}
if ( parent->child == deleteme ) {
- parent->child = NULL;
+ parent->child = deleteme->next;
}
return 0;
}
@@ -817,3 +817,14 @@ SCBlock *sc_block_split(SCBlock *bl, size_t pos)
return n;
}
+
+
+/* Return a new block which is the parent for "bl" */
+SCBlock *sc_block_new_parent(SCBlock *bl, const char *name)
+{
+ SCBlock *n = sc_block_new();
+ if ( n == NULL ) return NULL;
+ n->name = s_strdup(name);
+ n->child = bl;
+ return n;
+}
diff --git a/src/sc_parse.h b/src/sc_parse.h
index 01140d4..be7d0ee 100644
--- a/src/sc_parse.h
+++ b/src/sc_parse.h
@@ -48,6 +48,8 @@ extern SCBlock *sc_block_append(SCBlock *bl,
char *name, char *opt, char *contents,
SCBlock **blfp);
+extern SCBlock *sc_block_new_parent(SCBlock *bl, const char *name);
+
extern void sc_block_append_p(SCBlock *bl, SCBlock *bln);
extern void sc_block_append_block(SCBlock *bl, SCBlock *bln);
diff --git a/src/slide_window.c b/src/slide_window.c
index f24a1db..5dbf6b3 100644
--- a/src/slide_window.c
+++ b/src/slide_window.c
@@ -258,11 +258,7 @@ SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks,
stylesheets[1] = NULL;
sw->scblocks = scblocks;
- ch = sc_block_child(scblocks);
- if ( ch == NULL ) {
- ch = sc_block_append_inside(scblocks, NULL, NULL, "");
- }
- sw->sceditor = sc_editor_new(ch, stylesheets, p->lang,
+ sw->sceditor = sc_editor_new(scblocks, stylesheets, p->lang,
colloquium_get_imagestore(app));
sc_editor_set_slidenum(sw->sceditor, slide_number(sw->p, scblocks));
sc_editor_set_scale(sw->sceditor, 1);