aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2015-06-09 00:07:03 +0200
committerThomas White <taw@bitwiz.org.uk>2015-06-09 00:07:03 +0200
commit5b78853e0bbecd26c43f9cab7c4f61867644f83d (patch)
tree98fe7e2b4a21393a3bbacb886cc36791adc81b0d /src
parent0ae0bfab5fc1a8c4807123490448babc651f253b (diff)
Frame deletion stuff
Diffstat (limited to 'src')
-rw-r--r--src/presentation.c1
-rw-r--r--src/sc_editor.h1
-rw-r--r--src/sc_parse.c38
-rw-r--r--src/sc_parse.h2
-rw-r--r--src/slide_window.c14
5 files changed, 44 insertions, 12 deletions
diff --git a/src/presentation.c b/src/presentation.c
index 15a55e0..039f61a 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -439,4 +439,3 @@ void delete_subframe(struct frame *top, struct frame *fr)
parent->num_children--;
}
-
diff --git a/src/sc_editor.h b/src/sc_editor.h
index 93f2313..203910a 100644
--- a/src/sc_editor.h
+++ b/src/sc_editor.h
@@ -163,5 +163,6 @@ extern void sc_editor_set_top_frame_editable(SCEditor *e,
int top_frame_editable);
extern void sc_editor_set_callbacks(SCEditor *e, SCCallbackList *cbl);
extern void insert_scblock(SCBlock *scblock, SCEditor *e);
+extern void sc_editor_delete_selected_frame(SCEditor *e);
#endif /* SC_EDITOR_H */
diff --git a/src/sc_parse.c b/src/sc_parse.c
index ed7d7b8..4aab2af 100644
--- a/src/sc_parse.c
+++ b/src/sc_parse.c
@@ -224,6 +224,44 @@ SCBlock *sc_block_insert_after(SCBlock *afterme,
}
+static SCBlock *sc_find_parent(SCBlock *top, SCBlock *find)
+{
+ if ( top->child == find ) return top;
+ if ( top->next == find ) return top;
+
+ if ( top->child != NULL ) {
+ SCBlock *t = sc_find_parent(top->child, find);
+ if ( t != NULL ) return t;
+ }
+ if ( top->next != NULL ) {
+ SCBlock *t = sc_find_parent(top->next, find);
+ if ( t != NULL ) return t;
+ }
+ return NULL;
+}
+
+
+/* Delete "deleteme", which is somewhere under "top" */
+void sc_block_delete(SCBlock *top, SCBlock *deleteme)
+{
+ SCBlock *parent = sc_find_parent(top, deleteme);
+ if ( parent == NULL ) {
+ fprintf(stderr, "Couldn't find block parent!\n");
+ return;
+ }
+
+ if ( parent->next == deleteme ) {
+ parent->next = deleteme->next;
+ }
+
+ if ( parent->child == deleteme ) {
+ parent->child = NULL;
+ }
+
+ sc_block_free(deleteme);
+}
+
+
/* 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 373f2cd..bf1960d 100644
--- a/src/sc_parse.h
+++ b/src/sc_parse.h
@@ -59,6 +59,8 @@ extern SCBlock *sc_block_append_inside(SCBlock *parent,
extern SCBlock *sc_block_insert_after(SCBlock *afterme,
char *name, char *opt, char *contents);
+extern void sc_block_delete(SCBlock *top, SCBlock *deleteme);
+
extern struct frame *sc_block_frame(const SCBlock *bl);
extern void sc_block_set_frame(SCBlock *bl, struct frame *fr);
diff --git a/src/slide_window.c b/src/slide_window.c
index 9eb9d0d..e0cbab3 100644
--- a/src/slide_window.c
+++ b/src/slide_window.c
@@ -228,19 +228,11 @@ static void save_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
}
-static void delete_frame_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+static void delete_frame_sig(GSimpleAction *action, GVariant *parameter,
+ gpointer vp)
{
-#if 0
SlideWindow *sw = vp;
- int i;
-
- delete_subframe(sw->cur_slide, sw->p->selection);
- p->n_selection = 0;
-
- rerender_slide(p);
- redraw_editor(p);
-#endif
-/* FIXME: implement */
+ sc_editor_delete_selected_frame(sw->sceditor);
}