diff options
author | Thomas White <taw@bitwiz.org.uk> | 2015-12-26 22:56:22 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2015-12-26 23:18:09 +0100 |
commit | 057ddb969f7ed42b329b87bd8a9bdebbc649427d (patch) | |
tree | 44a94b873b14abf59197ef3dd7211d438cf6c72b /src | |
parent | 55a8c269d2e77f798f9ca55d7a4afb7a9f98a701 (diff) |
Remove "struct slide" and the slide list
Diffstat (limited to 'src')
-rw-r--r-- | src/narrative_window.c | 37 | ||||
-rw-r--r-- | src/notes.c | 63 | ||||
-rw-r--r-- | src/notes.h | 8 | ||||
-rw-r--r-- | src/pr_clock.c | 4 | ||||
-rw-r--r-- | src/pr_clock.h | 4 | ||||
-rw-r--r-- | src/presentation.c | 252 | ||||
-rw-r--r-- | src/presentation.h | 25 | ||||
-rw-r--r-- | src/render.c | 18 | ||||
-rw-r--r-- | src/sc_editor.c | 6 | ||||
-rw-r--r-- | src/sc_editor.h | 1 | ||||
-rw-r--r-- | src/slide_window.c | 74 | ||||
-rw-r--r-- | src/slide_window.h | 2 | ||||
-rw-r--r-- | src/slideshow.c | 8 | ||||
-rw-r--r-- | src/slideshow.h | 6 |
14 files changed, 230 insertions, 278 deletions
diff --git a/src/narrative_window.c b/src/narrative_window.c index db9adb7..807305f 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -50,7 +50,7 @@ struct _narrative_window GApplication *app; struct presentation *p; SlideShow *show; - struct slide *sel_slide; + SCBlock *sel_slide; }; @@ -67,7 +67,7 @@ static void update_toolbar(NarrativeWindow *nw) gtk_widget_set_sensitive(GTK_WIDGET(nw->bprev), TRUE); } - if ( cur_slide_number == nw->p->num_slides-1 ) { + if ( cur_slide_number == num_slides(nw->p)-1 ) { gtk_widget_set_sensitive(GTK_WIDGET(nw->bnext), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(nw->blast), FALSE); } else { @@ -151,14 +151,11 @@ static void delete_frame_sig(GSimpleAction *action, GVariant *parameter, gpointe static void add_slide_sig(GSimpleAction *action, GVariant *parameter, gpointer vp) { - struct slide *slide; int n_slides; SCBlock *block; SCBlock *nsblock; NarrativeWindow *nw = vp; - slide = new_slide(); - /* Link it into the SC structure */ nsblock = sc_parse("\\slide{}"); insert_scblock(nsblock, nw->sceditor); @@ -177,8 +174,6 @@ static void add_slide_sig(GSimpleAction *action, GVariant *parameter, gpointer v next: block = sc_block_next(block); } - slide->scblocks = sc_block_child(nsblock); - insert_slide(nw->p, slide, n_slides); } @@ -192,10 +187,11 @@ static void ss_end_show(SlideShow *ss, void *vp) static void ss_next_slide(SlideShow *ss, void *vp) { NarrativeWindow *nw = vp; - int cur_slide_number; - cur_slide_number = slide_number(nw->p, nw->sel_slide); - if ( cur_slide_number == nw->p->num_slides-1 ) return; - nw->sel_slide = nw->p->slides[cur_slide_number+1]; + SCBlock *tt; + + tt = next_slide(nw->p, nw->sel_slide); + if ( tt == NULL ) return; /* Already on last slide */ + nw->sel_slide = tt; if ( slideshow_linked(nw->show) ) { change_proj_slide(nw->show, nw->sel_slide); } /* else leave the slideshow alone */ @@ -206,10 +202,11 @@ static void ss_next_slide(SlideShow *ss, void *vp) static void ss_prev_slide(SlideShow *ss, void *vp) { NarrativeWindow *nw = vp; - int cur_slide_number; - cur_slide_number = slide_number(nw->p, nw->sel_slide); - if ( cur_slide_number == 0 ) return; - nw->sel_slide = nw->p->slides[cur_slide_number-1]; + SCBlock *tt; + + tt = prev_slide(nw->p, nw->sel_slide); + if ( tt == NULL ) return; /* Already on first slide */ + nw->sel_slide = tt; if ( slideshow_linked(nw->show) ) { change_proj_slide(nw->show, nw->sel_slide); } /* else leave the slideshow alone */ @@ -218,7 +215,7 @@ static void ss_prev_slide(SlideShow *ss, void *vp) static void first_slide_sig(GSimpleAction *action, GVariant *parameter, - gpointer vp) + gpointer vp) { //NarrativeWindow *nw = vp; } @@ -252,7 +249,7 @@ static void ss_changed_link(SlideShow *ss, void *vp) } -static struct slide *ss_cur_slide(SlideShow *ss, void *vp) +static SCBlock *ss_cur_slide(SlideShow *ss, void *vp) { NarrativeWindow *nw = vp; return nw->sel_slide; @@ -265,7 +262,7 @@ static void start_slideshow_sig(GSimpleAction *action, GVariant *parameter, NarrativeWindow *nw = vp; struct sscontrolfuncs ssc; - if ( nw->p->num_slides == 0 ) return; + if ( num_slides(nw->p) == 0 ) return; ssc.next_slide = ss_next_slide; ssc.prev_slide = ss_prev_slide; @@ -273,7 +270,7 @@ static void start_slideshow_sig(GSimpleAction *action, GVariant *parameter, ssc.changed_link = ss_changed_link; ssc.end_show = ss_end_show; - nw->sel_slide = nw->p->slides[0]; + nw->sel_slide = first_slide(nw->p); nw->show = try_start_slideshow(nw->p, ssc, nw); } @@ -537,7 +534,7 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *app) gtk_actionable_set_action_name(GTK_ACTIONABLE(nw->blast), "win.last"); - nw->sel_slide = nw->p->slides[0]; + nw->sel_slide = NULL; update_toolbar(nw); scroll = gtk_scrolled_window_new(NULL, NULL); diff --git a/src/notes.c b/src/notes.c index 6f05707..c19cf58 100644 --- a/src/notes.c +++ b/src/notes.c @@ -38,11 +38,36 @@ struct notes GtkWidget *window; GtkWidget *v; - struct slide *cur_slide; + SCBlock *bl; SlideWindow *sw; }; +static SCBlock *find_notes_block(SCBlock *s) +{ + SCBlock *bl = s; + while ( bl != NULL ) { + + const char *name = sc_block_name(bl); + + if ( (name != NULL) && (strcmp(name, "notes") == 0) ) { + if ( sc_block_child(bl) == NULL ) { + sc_block_append_inside(s, NULL, NULL, + strdup("")); + } + return bl; + } + + bl = sc_block_next(bl); + + } + + bl = sc_block_append_end(s, "notes", NULL, NULL); + sc_block_append_inside(bl, NULL, NULL, strdup("")); + return bl; +} + + static void update_notes(struct notes *notes) { GtkTextBuffer *tb; @@ -51,7 +76,7 @@ static void update_notes(struct notes *notes) if ( notes == NULL ) return; - ch = sc_block_child(notes->cur_slide->notes); + ch = sc_block_child(notes->bl); if ( ch != NULL ) { ntext = sc_block_contents(ch); } else { @@ -77,7 +102,7 @@ void grab_current_notes(struct notes *n) gtk_text_buffer_get_end_iter(tb, &i2); text = gtk_text_buffer_get_text(tb, &i1, &i2, TRUE); - ch = sc_block_child(n->cur_slide->notes); + ch = sc_block_child(n->bl); if ( ch != NULL ) { sc_block_set_contents(ch, text); } else { @@ -86,11 +111,11 @@ void grab_current_notes(struct notes *n) } -void notes_set_slide(struct notes *notes, struct slide *np) +void notes_set_slide(struct notes *notes, SCBlock *np) { if ( notes == NULL ) return; grab_current_notes(notes); - notes->cur_slide = np; + notes->bl = find_notes_block(np); update_notes(notes); } @@ -103,7 +128,7 @@ static gint close_notes_sig(GtkWidget *w, struct notes *notes) } -struct notes *open_notes(SlideWindow *sw, struct slide *slide) +struct notes *open_notes(SlideWindow *sw, SCBlock *slide) { struct notes *n; GtkWidget *sc; @@ -112,7 +137,6 @@ struct notes *open_notes(SlideWindow *sw, struct slide *slide) n = malloc(sizeof(struct notes)); if ( n == NULL ) return NULL; n->sw = sw; - n->cur_slide = slide; n->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(n->window), 800, 256); @@ -138,28 +162,3 @@ struct notes *open_notes(SlideWindow *sw, struct slide *slide) return n; } - -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("")); -} diff --git a/src/notes.h b/src/notes.h index 426cb7e..1939d3b 100644 --- a/src/notes.h +++ b/src/notes.h @@ -1,7 +1,7 @@ /* * notes.h * - * Copyright © 2013-2014 Thomas White <taw@bitwiz.org.uk> + * Copyright © 2013-2016 Thomas White <taw@bitwiz.org.uk> * * This file is part of Colloquium. * @@ -29,12 +29,10 @@ struct notes; -extern struct notes *open_notes(SlideWindow *sw, struct slide *slide); +extern struct notes *open_notes(SlideWindow *sw, SCBlock *slide); -extern void notes_set_slide(struct notes *n, struct slide *np); +extern void notes_set_slide(struct notes *n, SCBlock *np); extern void grab_current_notes(struct notes *n); -extern void attach_notes(struct slide *s); - #endif /* NOTES_H */ diff --git a/src/pr_clock.c b/src/pr_clock.c index 1f8840b..79b9d15 100644 --- a/src/pr_clock.c +++ b/src/pr_clock.c @@ -200,7 +200,7 @@ static gboolean update_clock(gpointer data) } -void notify_clock_slide_changed(struct presentation *p, struct slide *np) +void notify_clock_slide_changed(struct presentation *p, SCBlock *np) { struct pr_clock *n = p->clock; int sr; @@ -209,7 +209,7 @@ void notify_clock_slide_changed(struct presentation *p, struct slide *np) sr = slide_number(p, np); n->cur_slide = sr; - n->last_slide = p->num_slides; + n->last_slide = num_slides(p); if ( sr > n->slide_reached ) n->slide_reached = sr; diff --git a/src/pr_clock.h b/src/pr_clock.h index edebcff..919d61b 100644 --- a/src/pr_clock.h +++ b/src/pr_clock.h @@ -1,7 +1,7 @@ /* * pr_clock.h * - * Copyright © 2013 Thomas White <taw@bitwiz.org.uk> + * Copyright © 2013-2016 Thomas White <taw@bitwiz.org.uk> * * This file is part of Colloquium. * @@ -32,7 +32,7 @@ struct pr_clock; extern void open_clock(struct presentation *p); extern void notify_clock_slide_changed(struct presentation *p, - struct slide *np); + SCBlock *np); #endif /* CLOCK_H */ diff --git a/src/presentation.c b/src/presentation.c index a51762f..da9b8c0 100644 --- a/src/presentation.c +++ b/src/presentation.c @@ -43,13 +43,8 @@ void free_presentation(struct presentation *p) { - int i; int final = 0; - for ( i=0; i<p->num_slides; i++ ) { - free_slide(p->slides[i]); - } - /* FIXME: Loads of stuff leaks here */ free(p->filename); imagestore_destroy(p->is); @@ -61,94 +56,6 @@ void free_presentation(struct presentation *p) } -/* "pos" is the index that the caller would like this slide to have */ -int insert_slide(struct presentation *p, struct slide *new, int pos) -{ - struct slide **try; - int i; - - try = realloc(p->slides, (1+p->num_slides)*sizeof(struct slide *)); - if ( try == NULL ) { - free(new); - return 1; - } - p->slides = try; - p->completely_empty = 0; - - if ( p->num_slides > 0 ) { - int j = pos; - if ( j == 0 ) j = 1; - for ( i=p->num_slides; i>=j; i-- ) { - p->slides[i] = p->slides[i-1]; - } - } - - p->slides[pos] = new; - p->num_slides++; - - new->parent = p; - - return 0; -} - - -static void delete_slide_index(struct presentation *p, int pos) -{ - int i; - - for ( i=pos; i<p->num_slides-1; i++ ) { - p->slides[i] = p->slides[i+1]; - } - - p->num_slides--; - - /* Don't bother to resize the array */ -} - - -void delete_slide(struct presentation *p, struct slide *s) -{ - int idx; - - idx = slide_number(p, s); - delete_slide_index(p, idx); - - free_slide(s); -} - - -struct slide *new_slide() -{ - struct slide *new; - - new = calloc(1, sizeof(struct slide)); - if ( new == NULL ) return NULL; - - new->scblocks = NULL; - new->notes = NULL; - - return new; -} - - -void free_slide(struct slide *s) -{ - free(s); -} - - -struct slide *add_slide(struct presentation *p, int pos) -{ - struct slide *s = new_slide(); - if ( insert_slide(p, s, pos) ) { - free_slide(s); - return NULL; - } - - return s; -} - - static char *safe_basename(const char *in) { int i; @@ -193,18 +100,6 @@ char *get_titlebar_string(struct presentation *p) } -int slide_number(struct presentation *p, struct slide *s) -{ - int i; - - for ( i=0; i<p->num_slides; i++ ) { - if ( p->slides[i] == s ) return i; - } - - return p->num_slides; -} - - struct presentation *new_presentation() { struct presentation *new; @@ -218,10 +113,6 @@ struct presentation *new_presentation() new->slide_width = 1024.0; new->slide_height = 768.0; - new->num_slides = 0; - new->slides = NULL; - add_slide(new, 0); - new->completely_empty = 1; new->stylesheet = NULL; new->is = imagestore_new(); @@ -307,18 +198,132 @@ static char *fgets_long(FILE *fh, size_t *lp) } +static int safe_strcmp(const char *a, const char *b) +{ + if ( a == NULL ) return 1; + if ( b == NULL ) return 1; + return strcmp(a, b); +} + + +int slide_number(struct presentation *p, SCBlock *sl) +{ + SCBlock *bl = p->scblocks; + int n = 0; + + while ( bl != NULL ) { + if ( safe_strcmp(sc_block_name(bl), "slide") == 0 ) { + n++; + if ( sc_block_child(bl) == sl ) return n; + } + bl = sc_block_next(bl); + } + + return 0; +} + + +int num_slides(struct presentation *p) +{ + SCBlock *bl = p->scblocks; + int n = 0; + + while ( bl != NULL ) { + if ( safe_strcmp(sc_block_name(bl), "slide") == 0 ) { + n++; + } + bl = sc_block_next(bl); + } + + return n; +} + + +SCBlock *first_slide(struct presentation *p) +{ + SCBlock *bl = p->scblocks; + + while ( bl != NULL ) { + if ( safe_strcmp(sc_block_name(bl), "slide") == 0 ) { + return bl; + } + bl = sc_block_next(bl); + } + + fprintf(stderr, "Couldn't find first slide!\n"); + return NULL; +} + + +SCBlock *last_slide(struct presentation *p) +{ + SCBlock *bl = p->scblocks; + SCBlock *l = NULL; + + while ( bl != NULL ) { + if ( safe_strcmp(sc_block_name(bl), "slide") == 0 ) { + l = bl; + } + bl = sc_block_next(bl); + } + + if ( l == NULL ) { + fprintf(stderr, "Couldn't find last slide!\n"); + } + return l; +} + + +SCBlock *next_slide(struct presentation *p, SCBlock *sl) +{ + SCBlock *bl = p->scblocks; + int found = 0; + + while ( bl != NULL ) { + if ( safe_strcmp(sc_block_name(bl), "slide") == 0 ) { + if ( found ) return bl; + if ( bl == sl ) { + found = 1; + } + } + bl = sc_block_next(bl); + } + + fprintf(stderr, "Couldn't find next slide!\n"); + return NULL; +} + + +SCBlock *prev_slide(struct presentation *p, SCBlock *sl) +{ + SCBlock *bl = p->scblocks; + SCBlock *l = NULL; + + while ( bl != NULL ) { + if ( safe_strcmp(sc_block_name(bl), "slide") == 0 ) { + if ( bl == sl ) return l; + l = bl; + } + bl = sc_block_next(bl); + } + + if ( l == NULL ) { + fprintf(stderr, "Couldn't find previous slide!\n"); + } + return NULL; +} + + int load_presentation(struct presentation *p, const char *filename) { FILE *fh; int r = 0; char *everything; size_t el = 1; - SCBlock *block; everything = strdup(""); assert(p->completely_empty); - delete_slide(p, p->slides[0]); fh = fopen(filename, "r"); if ( fh == NULL ) return 1; @@ -360,31 +365,6 @@ int load_presentation(struct presentation *p, const char *filename) find_stylesheet(p); - block = p->scblocks; - while ( block != NULL ) { - - const char *n = sc_block_name(block); - - if ( n == NULL ) goto next; - - if ( strcmp(n, "slide") == 0 ) { - - struct slide *s = add_slide(p, p->num_slides); - - if ( s != NULL ) { - - s->scblocks = sc_block_child(block); - attach_notes(s); - - } - - } - -next: - block = sc_block_next(block); - - } - assert(p->filename == NULL); p->filename = strdup(filename); update_titlebar(p); diff --git a/src/presentation.h b/src/presentation.h index 51d0cf1..513b5dc 100644 --- a/src/presentation.h +++ b/src/presentation.h @@ -39,15 +39,6 @@ struct slide; #include "narrative_window.h" #include "slide_window.h" -struct slide -{ - struct presentation *parent; - struct slide_template *st; - - SCBlock *scblocks; - SCBlock *notes; -}; - struct menu_pl; struct presentation @@ -71,9 +62,6 @@ struct presentation double slide_width; double slide_height; - unsigned int num_slides; - struct slide **slides; - SCBlock *stylesheet; SCBlock *scblocks; @@ -85,13 +73,12 @@ extern void free_presentation(struct presentation *p); extern char *get_titlebar_string(struct presentation *p); -extern struct slide *new_slide(void); -extern struct slide *add_slide(struct presentation *p, int pos); -extern int insert_slide(struct presentation *p, struct slide *s, int pos); -extern void free_slide(struct slide *s); -extern void delete_slide(struct presentation *p, struct slide *s); - -extern int slide_number(struct presentation *p, struct slide *s); +extern int slide_number(struct presentation *p, SCBlock *sl); +extern int num_slides(struct presentation *p); +extern SCBlock *first_slide(struct presentation *p); +extern SCBlock *last_slide(struct presentation *p); +extern SCBlock *next_slide(struct presentation *p, SCBlock *sl); +extern SCBlock *prev_slide(struct presentation *p, SCBlock *sl); extern int load_presentation(struct presentation *p, const char *filename); extern int save_presentation(struct presentation *p, const char *filename); diff --git a/src/render.c b/src/render.c index eb74857..cdf3b0a 100644 --- a/src/render.c +++ b/src/render.c @@ -543,12 +543,13 @@ cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, int export_pdf(struct presentation *p, const char *filename) { - int i; double r; double w = 2048.0; double scale; cairo_surface_t *surf; cairo_t *cr; + SCBlock *bl; + int i; r = p->slide_height / p->slide_width; @@ -561,12 +562,16 @@ int export_pdf(struct presentation *p, const char *filename) cr = cairo_create(surf); scale = w / p->slide_width; - for ( i=0; i<p->num_slides; i++ ) { + i = 1; + while ( bl != NULL ) { + + if ( strcmp(sc_block_name(bl), "slide") != 0 ) { + bl = sc_block_next(bl); + continue; + } - struct slide *s; SCBlock *stylesheets[2]; - s = p->slides[i]; stylesheets[0] = p->stylesheet; stylesheets[1] = NULL; @@ -578,7 +583,7 @@ int export_pdf(struct presentation *p, const char *filename) cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); cairo_fill(cr); - render_sc_to_surface(s->scblocks, surf, cr, p->slide_width, + render_sc_to_surface(sc_block_child(bl), surf, cr, p->slide_width, p->slide_height, stylesheets, NULL, p->is, ISZ_SLIDESHOW, i, p->lang); @@ -586,6 +591,9 @@ int export_pdf(struct presentation *p, const char *filename) cairo_show_page(cr); + bl = sc_block_next(bl); + i++; + } cairo_surface_finish(surf); diff --git a/src/sc_editor.c b/src/sc_editor.c index 4c0e58a..24b97c1 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -1792,6 +1792,12 @@ void sc_editor_set_scblock(SCEditor *e, SCBlock *scblocks) } +SCBlock *sc_editor_get_scblock(SCEditor *e) +{ + return e->scblocks; +} + + static void update_size_request(SCEditor *e) { gtk_widget_set_size_request(GTK_WIDGET(e), 0, e->h + 2.0*e->min_border); diff --git a/src/sc_editor.h b/src/sc_editor.h index 4f5ba63..166e640 100644 --- a/src/sc_editor.h +++ b/src/sc_editor.h @@ -163,6 +163,7 @@ typedef struct _sceditor SCEditor; typedef struct _sceditorclass SCEditorClass; extern void sc_editor_set_scblock(SCEditor *e, SCBlock *scblocks); +extern SCBlock *sc_editor_get_scblock(SCEditor *e); extern GtkWidget *sc_editor_get_widget(SCEditor *e); extern SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets, PangoLanguage *lang); diff --git a/src/slide_window.c b/src/slide_window.c index f44a699..8b26af0 100644 --- a/src/slide_window.c +++ b/src/slide_window.c @@ -60,19 +60,19 @@ struct _slidewindow struct menu_pl *style_menu; int n_style_menu; - struct slide *cur_slide; /* FIXME: SPOT inside SCEditor */ - SlideShow *show; struct notes *notes; }; +#define CUR_SLIDE(sw) (sc_editor_get_scblock(sw->sceditor)) + static void update_toolbar(SlideWindow *sw) { int cur_slide_number; - cur_slide_number = slide_number(sw->p, sw->cur_slide); + cur_slide_number = slide_number(sw->p, CUR_SLIDE(sw)); if ( cur_slide_number == 0 ) { gtk_widget_set_sensitive(GTK_WIDGET(sw->bfirst), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(sw->bprev), FALSE); @@ -81,7 +81,7 @@ static void update_toolbar(SlideWindow *sw) gtk_widget_set_sensitive(GTK_WIDGET(sw->bprev), TRUE); } - if ( cur_slide_number == sw->p->num_slides-1 ) { + if ( cur_slide_number == num_slides(sw->p)-1 ) { gtk_widget_set_sensitive(GTK_WIDGET(sw->bnext), FALSE); gtk_widget_set_sensitive(GTK_WIDGET(sw->blast), FALSE); } else { @@ -103,7 +103,7 @@ struct menu_pl static gint UNUSED add_furniture(GtkWidget *widget, struct menu_pl *pl) { - sc_block_append_end(pl->sw->cur_slide->scblocks, + sc_block_append_end(CUR_SLIDE(pl->sw), strdup(pl->style_name), NULL, NULL); //do_slide_update(pl->p, pl->sw->pc); FIXME @@ -239,17 +239,9 @@ static void delete_frame_sig(GSimpleAction *action, GVariant *parameter, static void add_slide_sig(GSimpleAction *action, GVariant *parameter, gpointer vp) { SlideWindow *sw = vp; - struct slide *new; - int cur_slide_number; - - cur_slide_number = slide_number(sw->p, sw->cur_slide); - - new = add_slide(sw->p, cur_slide_number+1); - new->scblocks = sc_block_insert_after(sw->cur_slide->scblocks, - "slide", NULL, NULL); - + SCBlock *new; + new = sc_block_insert_after(CUR_SLIDE(sw), "slide", NULL, NULL); change_edit_slide(sw, new); - } @@ -305,14 +297,12 @@ void slidewindow_notes_closed(SlideWindow *sw) /* Change the editor's slide to "np" */ -void change_edit_slide(SlideWindow *sw, struct slide *np) +void change_edit_slide(SlideWindow *sw, SCBlock *np) { - sw->cur_slide = np; - update_toolbar(sw); sc_editor_set_slidenum(sw->sceditor, 1+slide_number(sw->p, np)); - sc_editor_set_scblock(sw->sceditor, np->scblocks); + sc_editor_set_scblock(sw->sceditor, np); if ( sw->notes != NULL ) notes_set_slide(sw->notes, np); @@ -324,35 +314,31 @@ void change_edit_slide(SlideWindow *sw, struct slide *np) static void change_slide_first(SlideWindow *sw) { - change_edit_slide(sw, sw->p->slides[0]); + change_edit_slide(sw, first_slide(sw->p)); } static void change_slide_backwards(SlideWindow *sw) { - int cur_slide_number; - - cur_slide_number = slide_number(sw->p, sw->cur_slide); - if ( cur_slide_number == 0 ) return; - - change_edit_slide(sw, sw->p->slides[cur_slide_number-1]); + SCBlock *tt; + tt = prev_slide(sw->p, CUR_SLIDE(sw)); + if ( tt == NULL ) return; + change_edit_slide(sw, tt); } static void change_slide_forwards(SlideWindow *sw) { - int cur_slide_number; - - cur_slide_number = slide_number(sw->p, sw->cur_slide); - if ( cur_slide_number == sw->p->num_slides-1 ) return; - - change_edit_slide(sw, sw->p->slides[cur_slide_number+1]); + SCBlock *tt; + tt = next_slide(sw->p, CUR_SLIDE(sw)); + if ( tt == NULL ) return; + change_edit_slide(sw, tt); } static void change_slide_last(SlideWindow *sw) { - change_edit_slide(sw, sw->p->slides[sw->p->num_slides-1]); + change_edit_slide(sw, last_slide(sw->p)); } @@ -392,7 +378,7 @@ static void open_notes_sig(GSimpleAction *action, GVariant *parameter, gpointer vp) { SlideWindow *sw = vp; - sw->notes = open_notes(sw, sw->cur_slide); + sw->notes = open_notes(sw, CUR_SLIDE(sw)); } @@ -474,10 +460,10 @@ static void ss_changed_link(SlideShow *ss, void *vp) } -static struct slide *ss_cur_slide(SlideShow *ss, void *vp) +static SCBlock *ss_cur_slide(SlideShow *ss, void *vp) { SlideWindow *sw = vp; - return sw->cur_slide; + return CUR_SLIDE(sw); } @@ -558,15 +544,6 @@ SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks) sw->window = window; sw->p = p; - /* FIXME: Horrible bodge. */ - int i; - sw->cur_slide = p->slides[0]; - for ( i=0; i<p->num_slides; i++ ) { - if ( p->slides[i]->scblocks == sc_block_child(scblocks) ) { - sw->cur_slide = p->slides[i]; - } - } - sw->show = NULL; update_titlebar(p); @@ -631,12 +608,9 @@ SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks) gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(sw->blast)); gtk_actionable_set_action_name(GTK_ACTIONABLE(sw->blast), "win.last"); - update_toolbar(sw); - stylesheets[0] = p->stylesheet; stylesheets[1] = NULL; - sw->sceditor = sc_editor_new(sw->cur_slide->scblocks, stylesheets, - p->lang); + sw->sceditor = sc_editor_new(scblocks, stylesheets, p->lang); scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, @@ -661,6 +635,8 @@ SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks) /* Initial background colour */ slidewindow_set_background(sw); + update_toolbar(sw); + gtk_widget_show_all(window); return sw; diff --git a/src/slide_window.h b/src/slide_window.h index cd18378..ddc29af 100644 --- a/src/slide_window.h +++ b/src/slide_window.h @@ -30,7 +30,7 @@ typedef struct _slidewindow SlideWindow; extern SlideWindow *slide_window_open(struct presentation *p, SCBlock *scblocks); -extern void change_edit_slide(SlideWindow *sw, struct slide *np); +extern void change_edit_slide(SlideWindow *sw, SCBlock *np); extern void update_titlebar(struct presentation *p); extern void slidewindow_notes_closed(SlideWindow *sw); diff --git a/src/slideshow.c b/src/slideshow.c index 7c23606..6a8faf9 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -42,7 +42,7 @@ struct _slideshow struct presentation *p; struct sscontrolfuncs ssc; void *vp; /* Controller's private word */ - struct slide *cur_slide; + SCBlock *cur_slide; GtkWidget *window; GtkWidget *drawingarea; GdkCursor *blank_cursor; @@ -82,7 +82,7 @@ void slideshow_rerender(SlideShow *ss) stylesheets[1] = NULL; n = slide_number(ss->p, ss->cur_slide); - ss->surface = render_sc(ss->cur_slide->scblocks, + ss->surface = render_sc(ss->cur_slide, ss->slide_width, ss->slide_height, ss->p->slide_width, ss->p->slide_height, stylesheets, NULL, ss->p->is, ISZ_SLIDESHOW, n, @@ -138,7 +138,7 @@ static gboolean ss_draw_sig(GtkWidget *da, cairo_t *cr, SlideShow *ss) } -void change_proj_slide(SlideShow *ss, struct slide *np) +void change_proj_slide(SlideShow *ss, SCBlock *np) { ss->cur_slide = np; @@ -241,7 +241,7 @@ static gboolean ss_realize_sig(GtkWidget *w, SlideShow *ss) } -struct slide *slideshow_slide(SlideShow *ss) +SCBlock *slideshow_slide(SlideShow *ss) { if ( ss == NULL ) return NULL; return ss->cur_slide; diff --git a/src/slideshow.h b/src/slideshow.h index 99d5549..5124808 100644 --- a/src/slideshow.h +++ b/src/slideshow.h @@ -39,7 +39,7 @@ struct sscontrolfuncs /* Controller should return what it thinks is the current slide * (this might not be what is on the screen, e.g. if the display * is unlinked) */ - struct slide *(*current_slide)(SlideShow *ss, void *vp); + SCBlock *(*current_slide)(SlideShow *ss, void *vp); /* Controller should update whatever visual representation of * whether or not the display is linked */ @@ -53,8 +53,8 @@ extern SlideShow *try_start_slideshow(struct presentation *p, struct sscontrolfuncs ssc, void *vp); extern void end_slideshow(SlideShow *ss); -extern void change_proj_slide(SlideShow *ss, struct slide *np); -extern struct slide *slideshow_slide(SlideShow *ss); +extern void change_proj_slide(SlideShow *ss, SCBlock *np); +extern SCBlock *slideshow_slide(SlideShow *ss); extern void toggle_slideshow_link(SlideShow *ss); extern int slideshow_linked(SlideShow *ss); |