diff options
-rw-r--r-- | src/presentation.c | 34 | ||||
-rw-r--r-- | src/sc_parse.c | 2 | ||||
-rw-r--r-- | src/slide_window.c | 2 |
3 files changed, 29 insertions, 9 deletions
diff --git a/src/presentation.c b/src/presentation.c index da9b8c0..5b67ba5 100644 --- a/src/presentation.c +++ b/src/presentation.c @@ -239,6 +239,24 @@ int num_slides(struct presentation *p) } +/* Warning: isn't very clever and assumes the block we want is at the top + * level */ +static SCBlock *parent_block(struct presentation *p, SCBlock *findme) +{ + SCBlock *bl; + + bl = p->scblocks; + + while ( bl != NULL ) { + if ( sc_block_child(bl) == findme ) return bl; + bl = sc_block_next(bl); + } + + printf("Whoops, couldn't find parent!\n"); + return bl; +} + + SCBlock *first_slide(struct presentation *p) { SCBlock *bl = p->scblocks; @@ -276,15 +294,16 @@ SCBlock *last_slide(struct presentation *p) SCBlock *next_slide(struct presentation *p, SCBlock *sl) { - SCBlock *bl = p->scblocks; + SCBlock *pp = parent_block(p, sl); + SCBlock *bl = pp; int found = 0; while ( bl != NULL ) { if ( safe_strcmp(sc_block_name(bl), "slide") == 0 ) { - if ( found ) return bl; - if ( bl == sl ) { - found = 1; - } + if ( found ) return sc_block_child(bl); + } + if ( bl == pp ) { + found = 1; } bl = sc_block_next(bl); } @@ -296,14 +315,15 @@ SCBlock *next_slide(struct presentation *p, SCBlock *sl) SCBlock *prev_slide(struct presentation *p, SCBlock *sl) { - SCBlock *bl = p->scblocks; + SCBlock *pp = parent_block(p, sl); + SCBlock *bl = pp; SCBlock *l = NULL; while ( bl != NULL ) { if ( safe_strcmp(sc_block_name(bl), "slide") == 0 ) { - if ( bl == sl ) return l; l = bl; } + if ( bl == pp ) return l; bl = sc_block_next(bl); } diff --git a/src/sc_parse.c b/src/sc_parse.c index f3c3b4e..ef9f3da 100644 --- a/src/sc_parse.c +++ b/src/sc_parse.c @@ -302,7 +302,7 @@ static void recursive_show_sc_blocks(const char *prefix, const SCBlock *bl) void show_sc_block(const SCBlock *bl, const char *prefix) { - printf("%s", prefix); + printf("%s (%p) ", prefix, bl); if ( bl->name != NULL ) printf("\\%s ", bl->name); if ( bl->options != NULL ) printf("[%s] ", bl->options); if ( bl->contents != NULL ) printf("{%s} ", bl->contents); diff --git a/src/slide_window.c b/src/slide_window.c index 8b26af0..2c35e89 100644 --- a/src/slide_window.c +++ b/src/slide_window.c @@ -610,7 +610,7 @@ SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks) "win.last"); stylesheets[0] = p->stylesheet; stylesheets[1] = NULL; - sw->sceditor = sc_editor_new(scblocks, stylesheets, p->lang); + sw->sceditor = sc_editor_new(sc_block_child(scblocks), stylesheets, p->lang); scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, |