aboutsummaryrefslogtreecommitdiff
path: root/src/presentation.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2013-09-17 21:31:23 +0200
committerThomas White <taw@bitwiz.org.uk>2013-09-17 21:31:23 +0200
commit4e90a9c416a66e3ab6170e2a557d8966d93fbbd2 (patch)
treeb12c2eebbe9385f857b5d29929004756c26018f5 /src/presentation.c
parent057871cbe90d434f9462213f929054302f8da3ab (diff)
Delete completely empty frames
Diffstat (limited to 'src/presentation.c')
-rw-r--r--src/presentation.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/presentation.c b/src/presentation.c
index c406840..3c4e593 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -553,6 +553,60 @@ int load_presentation(struct presentation *p, const char *filename)
}
+static struct frame *find_parent(struct frame *fr, struct frame *search)
+{
+ int i;
+
+ for ( i=0; i<fr->num_children; i++ ) {
+ if ( fr->children[i] == search ) {
+ return fr;
+ }
+ }
+
+ for ( i=0; i<fr->num_children; i++ ) {
+ struct frame *tt;
+ tt = find_parent(fr->children[i], search);
+ if ( tt != NULL ) return tt;
+ }
+
+ return NULL;
+}
+
+
+static void delete_subframe(struct slide *s, struct frame *fr)
+{
+ struct frame *parent;
+ int i, idx, found;
+
+ parent = find_parent(s->top, fr);
+ if ( parent == NULL ) {
+ fprintf(stderr, "Couldn't find parent when deleting frame.\n");
+ return;
+ }
+
+
+ found = 0;
+ for ( i=0; i<parent->num_children; i++ ) {
+ if ( parent->children[i] == fr ) {
+ idx = i;
+ found = 1;
+ break;
+ }
+ }
+
+ if ( !found ) {
+ fprintf(stderr, "Couldn't find child when deleting frame.\n");
+ return;
+ }
+
+ for ( i=idx; i<parent->num_children-1; i++ ) {
+ parent->children[i] = parent->children[i+1];
+ }
+
+ parent->num_children--;
+}
+
+
void set_edit(struct presentation *p, struct slide *s)
{
p->cur_edit_slide = s;
@@ -561,6 +615,16 @@ void set_edit(struct presentation *p, struct slide *s)
void set_selection(struct presentation *p, struct frame *fr)
{
+ if ( p->n_selection != 0 ) {
+ int i;
+ for ( i=0; i<p->n_selection; i++ ) {
+ if ( p->selection[i]->empty ) {
+ delete_subframe(p->cur_edit_slide,
+ p->selection[i]);
+ }
+ }
+ }
+
p->selection[0] = fr;
p->n_selection = 1;