aboutsummaryrefslogtreecommitdiff
path: root/src/notes.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2014-09-13 09:54:11 +0200
committerThomas White <taw@bitwiz.org.uk>2014-09-13 09:54:11 +0200
commit7b302ea4b906b162c37c3370434165f6e83a9def (patch)
tree8af7639781698cf6722ce329abf47589e79ad5da /src/notes.c
parent28026ebf0fde1eb1b51f3808b4f3fc681039e887 (diff)
Restore notes
Diffstat (limited to 'src/notes.c')
-rw-r--r--src/notes.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/src/notes.c b/src/notes.c
index 2e57d25..2210f55 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -51,11 +51,20 @@ static void set_notes_title(struct presentation *p)
static void update_notes(struct presentation *p)
{
GtkTextBuffer *tb;
+ const char *ntext;
+ SCBlock *ch;
if ( p->notes == NULL ) return;
+ ch = sc_block_child(p->cur_edit_slide->notes);
+ if ( ch != NULL ) {
+ ntext = sc_block_contents(ch);
+ } else {
+ ntext = "NOTES ERROR";
+ }
+
tb = gtk_text_view_get_buffer(GTK_TEXT_VIEW(p->notes->v));
- gtk_text_buffer_set_text(tb, p->cur_edit_slide->notes, -1);
+ gtk_text_buffer_set_text(tb, ntext, -1);
}
@@ -64,6 +73,7 @@ void grab_current_notes(struct presentation *p)
gchar *text;
GtkTextBuffer *tb;
GtkTextIter i1, i2;
+ SCBlock *ch;
struct notes *n = p->notes;
if ( n == NULL ) return;
@@ -73,8 +83,12 @@ void grab_current_notes(struct presentation *p)
gtk_text_buffer_get_end_iter(tb, &i2);
text = gtk_text_buffer_get_text(tb, &i1, &i2, TRUE);
- free(n->slide->notes);
- n->slide->notes = text;
+ ch = sc_block_child(n->slide->notes);
+ if ( ch != NULL ) {
+ sc_block_set_contents(ch, text);
+ } else {
+ fprintf(stderr, "NOTES ERROR\n");
+ }
}
@@ -130,3 +144,29 @@ void open_notes(struct presentation *p)
update_notes(p);
}
+
+
+void attach_notes(struct slide *s)
+{
+ SCBlock *bl = s->scblocks;
+
+ while ( bl != NULL ) {
+
+ const char *name = sc_block_name(bl);
+
+ if ( (name != NULL) && (strcmp(name, "notes") == 0) ) {
+ s->notes = bl;
+ if ( sc_block_child(bl) == NULL ) {
+ sc_block_append_inside(s->notes, NULL, NULL,
+ strdup(""));
+ }
+ return;
+ }
+
+ bl = sc_block_next(bl);
+
+ }
+
+ s->notes = sc_block_append_end(s->scblocks, "notes", NULL, NULL);
+ sc_block_append_inside(s->notes, NULL, NULL, strdup(""));
+}