aboutsummaryrefslogtreecommitdiff
path: root/src/presentation.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2016-01-05 21:04:48 +0100
committerThomas White <taw@bitwiz.org.uk>2016-01-05 21:04:48 +0100
commit7d83e3cdfd2604364a1a240248db2a6de275a99d (patch)
treef6f1a1b214a102a524fa34bf79108995332c4609 /src/presentation.c
parent057ddb969f7ed42b329b87bd8a9bdebbc649427d (diff)
next/prev slide fixes
Diffstat (limited to 'src/presentation.c')
-rw-r--r--src/presentation.c34
1 files changed, 27 insertions, 7 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);
}