aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/presentation.c24
-rw-r--r--src/presentation.h19
-rw-r--r--src/wrap.c37
-rw-r--r--src/wrap.h5
4 files changed, 76 insertions, 9 deletions
diff --git a/src/presentation.c b/src/presentation.c
index ccd3c18..d88352f 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -65,6 +65,15 @@ void free_presentation(struct presentation *p)
}
+static void renumber_slides(struct presentation *p)
+{
+ int i;
+ for ( i=0; i<p->num_slides; i++ ) {
+ p->slides[i]->constants->slide_number = i+1;
+ }
+}
+
+
int insert_slide(struct presentation *p, struct slide *new, int pos)
{
struct slide **try;
@@ -99,6 +108,8 @@ int insert_slide(struct presentation *p, struct slide *new, int pos)
new->parent = p;
p->num_slides++;
+ renumber_slides(p);
+
return 0;
}
@@ -114,6 +125,12 @@ struct slide *new_slide()
new->rendered_proj = NULL;
new->rendered_thumb = NULL;
+ new->constants = calloc(1, sizeof(struct slide_constants));
+ if ( new->constants == NULL ) {
+ free(new);
+ return NULL;
+ }
+
new->top = frame_new();
/* FIXME: Set zero margins etc on top level frame */
@@ -215,6 +232,13 @@ struct presentation *new_presentation()
struct presentation *new;
new = calloc(1, sizeof(struct presentation));
+ if ( new == NULL ) return NULL;
+
+ new->constants = calloc(1, sizeof(struct presentation_constants));
+ if ( new->constants == NULL ) {
+ free(new);
+ return NULL;
+ }
num_presentations++;
new->num_presentations = &num_presentations;
diff --git a/src/presentation.h b/src/presentation.h
index 49d39d8..b15f732 100644
--- a/src/presentation.h
+++ b/src/presentation.h
@@ -33,11 +33,28 @@
#include "stylesheet.h"
#include "imagestore.h"
+
+struct slide_constants
+{
+ int slide_number;
+};
+
+
+struct presentation_constants
+{
+ char *title;
+ char *author;
+ char *date;
+};
+
+
struct slide
{
struct presentation *parent;
struct slide_template *st;
+ struct slide_constants *constants;
+
/* Any of these may be NULL */
cairo_surface_t *rendered_proj;
cairo_surface_t *rendered_edit;
@@ -95,6 +112,8 @@ struct presentation
int completely_empty;
int *num_presentations;
+ struct presentation_constants *constants;
+
GtkWidget *window;
GtkWidget *drawingarea;
GtkUIManager *ui;
diff --git a/src/wrap.c b/src/wrap.c
index ee53424..de97aa0 100644
--- a/src/wrap.c
+++ b/src/wrap.c
@@ -38,6 +38,7 @@
#include "wrap.h"
#include "frame.h"
#include "stylesheet.h"
+#include "presentation.h"
static void alloc_lines(struct frame *fr)
@@ -648,7 +649,8 @@ invalid:
static void run_sc(const char *sc, struct sc_font_stack *fonts,
PangoContext *pc, struct wrap_line *boxes,
PangoLanguage *lang, size_t g_offset, int editable,
- struct frame *fr)
+ struct frame *fr, struct slide_constants *slide_constants,
+ struct presentation_constants *presentation_constants)
{
SCBlockList *bl;
SCBlockListIterator *iter;
@@ -680,7 +682,8 @@ static void run_sc(const char *sc, struct sc_font_stack *fonts,
&& (b->contents != NULL) ) {
push_font(fonts, b->options, pc);
run_sc(b->contents, fonts, pc, boxes, lang, offset,
- editable, fr);
+ editable, fr, slide_constants,
+ presentation_constants);
pop_font_or_colour(fonts);
} else if ( (strcmp(b->name, "fgcol")==0)
@@ -691,7 +694,8 @@ static void run_sc(const char *sc, struct sc_font_stack *fonts,
&& (b->contents != NULL) ) {
push_colour(fonts, b->options);
run_sc(b->contents, fonts, pc, boxes, lang, offset,
- editable, fr);
+ editable, fr, slide_constants,
+ presentation_constants);
pop_font_or_colour(fonts);
} else if ( (strcmp(b->name, "image")==0)
@@ -701,6 +705,17 @@ static void run_sc(const char *sc, struct sc_font_stack *fonts,
add_image_box(boxes, b->contents, offset, w, h,
editable);
}
+
+ } else if ( strcmp(b->name, "slidenumber")==0) {
+ char *tmp = malloc(64);
+ if ( tmp != NULL ) {
+ snprintf(tmp, 63, "%i",
+ slide_constants->slide_number);
+ add_wrap_box(boxes, tmp, offset,
+ WRAP_SPACE_NONE, pc,
+ &fonts->stack[fonts->n_fonts-1],
+ 0);
+ } /* else go away and sulk about it */
}
}
@@ -709,7 +724,9 @@ static void run_sc(const char *sc, struct sc_font_stack *fonts,
static struct wrap_line *sc_to_wrap_boxes(const char *sc, const char *prefix,
- PangoContext *pc, struct frame *fr)
+ PangoContext *pc, struct frame *fr,
+ struct slide_constants *s_constants,
+ struct presentation_constants *p_constants)
{
struct wrap_line *boxes;
PangoLanguage *lang;
@@ -734,10 +751,12 @@ static struct wrap_line *sc_to_wrap_boxes(const char *sc, const char *prefix,
set_colour(&fonts, "#000000");
if ( prefix != NULL ) {
- run_sc(prefix, &fonts, pc, boxes, lang, 0, 0, fr);
+ run_sc(prefix, &fonts, pc, boxes, lang, 0, 0, fr,
+ s_constants, p_constants);
}
if ( sc != NULL ) {
- run_sc(sc, &fonts, pc, boxes, lang, 0, 1, fr);
+ run_sc(sc, &fonts, pc, boxes, lang, 0, 1, fr,
+ s_constants, p_constants);
}
/* Empty the stack */
@@ -1226,7 +1245,9 @@ void show_boxes(struct wrap_line *boxes)
/* Wrap the StoryCode inside "fr->sc" so that it fits within width "fr->w",
* and generate fr->lines */
-int wrap_contents(struct frame *fr, PangoContext *pc)
+int wrap_contents(struct frame *fr, PangoContext *pc,
+ struct slide_constants *scc,
+ struct presentation_constants *pcc)
{
struct wrap_line *boxes;
struct wrap_line *para;
@@ -1242,7 +1263,7 @@ int wrap_contents(struct frame *fr, PangoContext *pc)
}
/* Turn the StoryCode into wrap boxes, all on one line */
- boxes = sc_to_wrap_boxes(fr->sc, prologue, pc, fr);
+ boxes = sc_to_wrap_boxes(fr->sc, prologue, pc, fr, scc, pcc);
if ( boxes == NULL ) {
fprintf(stderr, "Failed to create wrap boxes.\n");
return 1;
diff --git a/src/wrap.h b/src/wrap.h
index c3f5ef3..8da2f99 100644
--- a/src/wrap.h
+++ b/src/wrap.h
@@ -30,6 +30,7 @@
#endif
#include "frame.h"
+#include "presentation.h"
enum wrap_box_type
@@ -98,7 +99,9 @@ struct wrap_line
};
-extern int wrap_contents(struct frame *fr, PangoContext *pc);
+extern int wrap_contents(struct frame *fr, PangoContext *pc,
+ struct slide_constants *scc,
+ struct presentation_constants *pcc);
extern void get_cursor_pos(struct frame *fr, size_t pos,
double *xposd, double *yposd, double *line_height);