aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mainwindow.c14
-rw-r--r--src/presentation.c2
-rw-r--r--src/render.c14
-rw-r--r--src/render.h2
-rw-r--r--src/sc_interp.c29
-rw-r--r--src/sc_interp.h2
-rw-r--r--src/slide_sorter.c9
-rw-r--r--tests/render_test.c2
-rw-r--r--tests/render_test_sc1.c2
9 files changed, 48 insertions, 28 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 62dbe98..5b03828 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -50,20 +50,21 @@
void rerender_slide(struct presentation *p)
{
struct slide *s = p->cur_edit_slide;
+ int n = slide_number(p, s);
free_render_buffers(s);
s->rendered_thumb = render_slide(s, s->parent->thumb_slide_width,
p->slide_width, p->slide_height, p->is,
- ISZ_THUMBNAIL);
+ ISZ_THUMBNAIL, n);
s->rendered_proj = render_slide(s, s->parent->proj_slide_width,
p->slide_width, p->slide_height, p->is,
- ISZ_SLIDESHOW);
+ ISZ_SLIDESHOW, n);
s->rendered_edit = render_slide(s, s->parent->edit_slide_width,
p->slide_width, p->slide_height, p->is,
- ISZ_EDITOR);
+ ISZ_EDITOR, n);
}
@@ -71,17 +72,18 @@ void rerender_slide(struct presentation *p)
static void render_edit_and_proj(struct presentation *p)
{
struct slide *s = p->cur_edit_slide;
+ int n = slide_number(p, s);
if ( s->rendered_proj == NULL ) {
s->rendered_proj = render_slide(s, s->parent->proj_slide_width,
p->slide_width, p->slide_height,
- p->is, ISZ_SLIDESHOW);
+ p->is, ISZ_SLIDESHOW, n);
}
if ( s->rendered_edit == NULL ) {
s->rendered_edit = render_slide(s, s->parent->edit_slide_width,
- p->slide_width, p->slide_height,
- p->is, ISZ_EDITOR);
+ p->slide_width, p->slide_height,
+ p->is, ISZ_EDITOR, n);
}
}
diff --git a/src/presentation.c b/src/presentation.c
index 952688b..5afd041 100644
--- a/src/presentation.c
+++ b/src/presentation.c
@@ -446,7 +446,7 @@ next:
s->rendered_thumb = render_slide(s, p->thumb_slide_width,
p->slide_width,
p->slide_height,
- p->is, ISZ_THUMBNAIL);
+ p->is, ISZ_THUMBNAIL, i);
}
return 0;
diff --git a/src/render.c b/src/render.c
index 8e1645e..f42d2cc 100644
--- a/src/render.c
+++ b/src/render.c
@@ -328,11 +328,12 @@ void free_render_buffers_except_thumb(struct slide *s)
static void render_slide_to_surface(struct slide *s, cairo_surface_t *surf,
cairo_t *cr, enum is_size isz,
double scale, double w, double h,
- ImageStore *is)
+ ImageStore *is, int slide_number)
{
PangoFontMap *fontmap;
PangoContext *pc;
SCInterpreter *scin;
+ char snum[64];
cairo_scale(cr, scale, scale);
@@ -358,6 +359,9 @@ static void render_slide_to_surface(struct slide *s, cairo_surface_t *surf,
return;
}
+ snprintf(snum, 63, "%i", slide_number);
+ add_macro(scin, "slidenumber", snum);
+
/* "The rendering pipeline" */
sc_interp_run_stylesheet(scin, s->parent->stylesheet);
renew_frame(s->top);
@@ -380,7 +384,8 @@ static void render_slide_to_surface(struct slide *s, cairo_surface_t *surf,
* Render the entire slide.
*/
cairo_surface_t *render_slide(struct slide *s, int w, double ww, double hh,
- ImageStore *is, enum is_size isz)
+ ImageStore *is, enum is_size isz,
+ int slide_number)
{
cairo_surface_t *surf;
cairo_t *cr;
@@ -397,7 +402,8 @@ cairo_surface_t *render_slide(struct slide *s, int w, double ww, double hh,
surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, w, h);
cr = cairo_create(surf);
- render_slide_to_surface(s, surf, cr, isz, scale, w, h, is);
+ render_slide_to_surface(s, surf, cr, isz, scale, w, h, is,
+ slide_number);
cairo_destroy(cr);
return surf;
}
@@ -441,7 +447,7 @@ int export_pdf(struct presentation *p, const char *filename)
s->top->h = w*r;
render_slide_to_surface(s, surf, cr, ISZ_SLIDESHOW, scale,
- w, w*r, p->is);
+ w, w*r, p->is, i);
cairo_restore(cr);
diff --git a/src/render.h b/src/render.h
index 8dcb7b5..3099d35 100644
--- a/src/render.h
+++ b/src/render.h
@@ -32,7 +32,7 @@
extern cairo_surface_t *render_slide(struct slide *s, int w,
double ww, double hh, ImageStore *is,
- enum is_size isz);
+ enum is_size isz, int slide_number);
extern void free_render_buffers(struct slide *s);
extern void free_render_buffers_except_thumb(struct slide *s);
extern int export_pdf(struct presentation *p, const char *filename);
diff --git a/src/sc_interp.c b/src/sc_interp.c
index e6f5680..541c259 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -704,16 +704,6 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl)
}
-static int add_macro(struct macro *m, char *mname, SCBlock *bl)
-{
- m->name = mname;
- m->bl = bl;
- m->prev = NULL; /* FIXME: Stacking */
-
- return 0;
-}
-
-
static int try_add_macro(SCInterpreter *scin, const char *options, SCBlock *bl)
{
struct sc_state *st = &scin->state[scin->j];
@@ -729,7 +719,10 @@ static int try_add_macro(SCInterpreter *scin, const char *options, SCBlock *bl)
for ( i=0; i<st->n_macros; i++ ) {
if ( strcmp(st->macros[i].name, nn) == 0 ) {
- return add_macro(&st->macros[i], nn, bl);
+ st->macros[i].name = nn;
+ st->macros[i].bl = bl;
+ st->macros[i].prev = NULL; /* FIXME: Stacking */
+ return 0;
}
}
@@ -750,7 +743,19 @@ static int try_add_macro(SCInterpreter *scin, const char *options, SCBlock *bl)
}
i = st->n_macros++;
- return add_macro(&st->macros[i], nn, bl);
+
+ st->macros[i].name = nn;
+ st->macros[i].bl = bl;
+ st->macros[i].prev = NULL; /* FIXME: Stacking */
+
+ return 0;
+}
+
+
+void add_macro(SCInterpreter *scin, const char *mname, const char *contents)
+{
+ SCBlock *bl = sc_parse(contents);
+ try_add_macro(scin, mname, bl);
}
diff --git a/src/sc_interp.h b/src/sc_interp.h
index 20e2150..a4e9f43 100644
--- a/src/sc_interp.h
+++ b/src/sc_interp.h
@@ -42,6 +42,8 @@ extern int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl);
extern void find_stylesheet(struct presentation *p);
extern void sc_interp_run_stylesheet(SCInterpreter *scin, SCBlock *bl);
+extern void add_macro(SCInterpreter *scin, const char *mname,
+ const char *contents);
/* Get the current state of the interpreter */
extern struct frame *sc_interp_get_frame(SCInterpreter *scin);
diff --git a/src/slide_sorter.c b/src/slide_sorter.c
index dcbfc30..c64e408 100644
--- a/src/slide_sorter.c
+++ b/src/slide_sorter.c
@@ -329,11 +329,15 @@ static gboolean dnd_drop(GtkWidget *widget, GdkDragContext *drag_context,
* gets there first. When re-arranging slides, this might not happen */
static void fixup_proj(struct presentation *p, struct slide *s)
{
+ int n;
+
if ( s->rendered_proj != NULL ) return;
+ n = slide_number(p, s);
+
s->rendered_proj = render_slide(s, s->parent->proj_slide_width,
p->slide_width, p->slide_height,
- p->is, ISZ_SLIDESHOW);
+ p->is, ISZ_SLIDESHOW, n);
}
@@ -367,13 +371,14 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context,
if ( s != NULL ) {
/* FIXME: Do something */
+ int sn = slide_number(n->p, s);
s->rendered_thumb = render_slide(s,
n->p->thumb_slide_width,
n->p->slide_width,
n->p->slide_height,
n->p->is,
- ISZ_THUMBNAIL);
+ ISZ_THUMBNAIL, sn);
/* FIXME: Transfer the notes as well */
diff --git a/tests/render_test.c b/tests/render_test.c
index 2bf856d..faaf1c4 100644
--- a/tests/render_test.c
+++ b/tests/render_test.c
@@ -60,7 +60,7 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, gpointer data)
cairo_fill(cr);
if ( s->rendered_edit != NULL ) cairo_surface_destroy(s->rendered_edit);
- s->rendered_edit = render_slide(s, w, w, h, NULL, ISZ_EDITOR);
+ s->rendered_edit = render_slide(s, w, w, h, NULL, ISZ_EDITOR, 1);
cairo_rectangle(cr, 0.0, 0.0, w, h);
cairo_set_source_surface(cr, s->rendered_edit, 0.0, 0.0);
cairo_fill(cr);
diff --git a/tests/render_test_sc1.c b/tests/render_test_sc1.c
index 4cb0c91..bf60241 100644
--- a/tests/render_test_sc1.c
+++ b/tests/render_test_sc1.c
@@ -58,7 +58,7 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, gpointer data)
cairo_fill(cr);
if ( s->rendered_edit != NULL ) cairo_surface_destroy(s->rendered_edit);
- s->rendered_edit = render_slide(s, w, w, h, NULL, ISZ_EDITOR);
+ s->rendered_edit = render_slide(s, w, w, h, NULL, ISZ_EDITOR, 1);
cairo_rectangle(cr, 0.0, 0.0, w, h);
cairo_set_source_surface(cr, s->rendered_edit, 0.0, 0.0);
cairo_fill(cr);