aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2014-08-20 23:15:39 +0200
committerThomas White <taw@bitwiz.org.uk>2014-08-22 20:32:42 +0200
commitf96a0887eae53fd40633418689b8ddcb054b640d (patch)
treec3d4abf2a5487f42bb170db3a5929d97e20f549e /src
parent6497ab1b885436c6312aeab0b5e2dd74c6917662 (diff)
Insert SCBlock for new slide in the right place
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.c5
-rw-r--r--src/sc_parse.c21
-rw-r--r--src/sc_parse.h3
3 files changed, 26 insertions, 3 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 20a35b7..39d19f5 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -670,9 +670,8 @@ static gint add_slide_sig(GtkWidget *widget, struct presentation *p)
cur_slide_number = slide_number(p, p->cur_edit_slide);
new = add_slide(p, cur_slide_number+1);
- /* FIXME: position */
- new->scblocks = sc_block_append_inside(p->scblocks, "slide",
- NULL, NULL);
+ new->scblocks = sc_block_insert_after(p->cur_edit_slide->scblocks,
+ "slide", NULL, NULL);
change_edit_slide(p, new);
diff --git a/src/sc_parse.c b/src/sc_parse.c
index a37775d..0881464 100644
--- a/src/sc_parse.c
+++ b/src/sc_parse.c
@@ -170,6 +170,27 @@ SCBlock *sc_block_append_inside(SCBlock *parent,
}
+/* Insert a new block to the chain, just after "afterme".
+ * "name", "options" and "contents" will not be copied. Returns the block just
+ * created, or NULL on error. */
+SCBlock *sc_block_insert_after(SCBlock *afterme,
+ char *name, char *opt, char *contents)
+{
+ SCBlock *bl;
+
+ bl = sc_block_new();
+ if ( bl == NULL ) return NULL;
+
+ bl->name = name;
+ bl->options = opt;
+ bl->contents = contents;
+ bl->child = NULL;
+ bl->next = afterme->next;
+ afterme->next = bl;
+
+ return bl;
+}
+
/* Frees "bl" and all its children */
void sc_block_free(SCBlock *bl)
diff --git a/src/sc_parse.h b/src/sc_parse.h
index 5bd50d8..2fa01be 100644
--- a/src/sc_parse.h
+++ b/src/sc_parse.h
@@ -48,6 +48,9 @@ extern SCBlock *sc_block_append(SCBlock *bl,
extern SCBlock *sc_block_append_inside(SCBlock *bl,
char *name, char *opt, char *contents);
+extern SCBlock *sc_block_insert_after(SCBlock *afterme,
+ char *name, char *opt, char *contents);
+
extern struct frame *sc_block_frame(const SCBlock *bl);
extern void sc_block_set_frame(SCBlock *bl, struct frame *fr);