From cba13eb85af0714aa7ffa605773215baf5833612 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 8 Sep 2014 20:57:24 +0200 Subject: Insert furniture --- src/mainwindow.c | 4 ++-- src/sc_parse.c | 30 ++++++++++++++++++++++++++++++ src/sc_parse.h | 3 +++ 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/mainwindow.c b/src/mainwindow.c index b3f2d4b..c203736 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -195,8 +195,8 @@ struct menu_pl static gint add_furniture(GtkWidget *widget, struct menu_pl *pl) { - /* FIXME: Add it */ - printf("Adding '%s'\n", pl->style_name); + sc_block_append_end(pl->p->cur_edit_slide->scblocks, + strdup(pl->style_name), NULL, NULL); do_slide_update(pl->p, pl->p->pc); diff --git a/src/sc_parse.c b/src/sc_parse.c index 7218ec9..f30d6b0 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -132,6 +132,36 @@ SCBlock *sc_block_append(SCBlock *bl, char *name, char *opt, char *contents, } +/* Insert a new block at the end of the chain starting 'bl'. + * "name", "options" and "contents" will not be copied. Returns the block just + * created, or NULL on error. */ +SCBlock *sc_block_append_end(SCBlock *bl, char *name, char *opt, char *contents) +{ + SCBlock *bln = sc_block_new(); + + if ( bln == NULL ) return NULL; + + while ( bl->next != NULL ) { + bl = bl->next; + }; + + bln->name = name; + bln->options = opt; + bln->contents = contents; + bln->child = NULL; + bln->next = NULL; + + if ( bl == NULL ) { + bln->prev = NULL; + } else { + bl->next = bln; + bln->prev = bl; + } + + return bln; +} + + /* Append a new block to the chain inside "parent". * "name", "options" and "contents" will not be copied. Returns the block just * created, or NULL on error. */ diff --git a/src/sc_parse.h b/src/sc_parse.h index 1e3cbe9..a5c1514 100644 --- a/src/sc_parse.h +++ b/src/sc_parse.h @@ -45,6 +45,9 @@ extern SCBlock *sc_block_append(SCBlock *bl, char *name, char *opt, char *contents, SCBlock **blfp); +extern SCBlock *sc_block_append_end(SCBlock *bl, + char *name, char *opt, char *contents); + extern SCBlock *sc_block_append_inside(SCBlock *parent, char *name, char *opt, char *contents); -- cgit v1.2.3