diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/narrative_window.c | 12 | ||||
-rw-r--r-- | src/render.c | 10 | ||||
-rw-r--r-- | src/render.h | 9 | ||||
-rw-r--r-- | src/sc_editor.c | 11 | ||||
-rw-r--r-- | src/sc_editor.h | 3 | ||||
-rw-r--r-- | src/sc_interp.c | 38 | ||||
-rw-r--r-- | src/sc_interp.h | 10 | ||||
-rw-r--r-- | src/slideshow.c | 2 |
8 files changed, 83 insertions, 12 deletions
diff --git a/src/narrative_window.c b/src/narrative_window.c index b5ecf9f..da1d8f1 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -190,7 +190,14 @@ static void update_toolbar(NarrativeWindow *nw) static SCBlock *narrative_stylesheet() { - return sc_parse("\\stylesheet{\\ss[slide]{\nSLIDE\n}}"); + return sc_parse("\\stylesheet{\\ss[slide]{\n\\callback[sthumb]\n}}"); +} + + +static cairo_surface_t *render_thumbnail(SCBlock *scblocks, void *vp) +{ + struct presentation *p = vp; + return NULL; } @@ -202,6 +209,7 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *app) GtkWidget *toolbar; GtkToolItem *button; SCBlock *stylesheets[3]; + SCCallbackList *cbl; if ( p->narrative_window != NULL ) { fprintf(stderr, "Narrative window is already open!\n"); @@ -229,6 +237,8 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *app) stylesheets[1] = narrative_stylesheet(); stylesheets[2] = NULL; nw->sceditor = sc_editor_new(nw->p->scblocks, stylesheets); + cbl = sc_callback_list_new(); + sc_editor_set_callbacks(nw->sceditor, cbl); toolbar = gtk_toolbar_new(); gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS); diff --git a/src/render.c b/src/render.c index 9220750..3822ec7 100644 --- a/src/render.c +++ b/src/render.c @@ -345,7 +345,7 @@ static int recursive_wrap_and_draw(struct frame *fr, cairo_t *cr, static void render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, cairo_t *cr, double log_w, double log_h, - SCBlock **stylesheets, + SCBlock **stylesheets, SCCallbackList *cbl, ImageStore *is, enum is_size isz, int slide_number) { @@ -387,6 +387,8 @@ static void render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, return; } + sc_interp_set_callbacks(scin, cbl); + snprintf(snum, 63, "%i", slide_number); add_macro(scin, "slidenumber", snum); @@ -421,7 +423,7 @@ static void render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *surf, */ cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, double log_w, double log_h, - SCBlock **stylesheets, + SCBlock **stylesheets, SCCallbackList *cbl, ImageStore *is, enum is_size isz, int slide_number) { @@ -432,7 +434,7 @@ cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, cr = cairo_create(surf); cairo_scale(cr, w/log_w, h/log_h); render_sc_to_surface(scblocks, surf, cr, log_w, log_h, - stylesheets, is, isz,slide_number); + stylesheets, cbl, is, isz,slide_number); cairo_destroy(cr); return surf; } @@ -476,7 +478,7 @@ int export_pdf(struct presentation *p, const char *filename) cairo_fill(cr); render_sc_to_surface(s->scblocks, surf, cr, p->slide_width, - p->slide_height, stylesheets, + p->slide_height, stylesheets, NULL, p->is, ISZ_SLIDESHOW, i); cairo_restore(cr); diff --git a/src/render.h b/src/render.h index 0f51851..386df63 100644 --- a/src/render.h +++ b/src/render.h @@ -29,12 +29,13 @@ #include "presentation.h" #include "imagestore.h" +#include "sc_interp.h" extern cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, - double log_w, double log_h, - SCBlock **stylesheets, - ImageStore *is, enum is_size isz, - int slide_number); + double log_w, double log_h, + SCBlock **stylesheets, SCCallbackList *cbl, + ImageStore *is, enum is_size isz, + int slide_number); extern int export_pdf(struct presentation *p, const char *filename); diff --git a/src/sc_editor.c b/src/sc_editor.c index ca64c8e..7fa8af4 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -74,7 +74,8 @@ static void rerender(SCEditor *e) } e->surface = render_sc(e->scblocks, e->w, e->h, e->log_w, e->log_h, - e->stylesheets, e->is, ISZ_EDITOR, e->slidenum); + e->stylesheets, e->cbl, e->is, ISZ_EDITOR, + e->slidenum); } @@ -1462,6 +1463,13 @@ static SCBlock **copy_ss_list(SCBlock **stylesheets) } +void sc_editor_set_callbacks(SCEditor *e, SCCallbackList *cbl) +{ + if ( e->cbl != NULL ) sc_callback_list_free(e->cbl); + e->cbl = cbl; +} + + SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets) { SCEditor *sceditor; @@ -1480,6 +1488,7 @@ SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets) sceditor->slidenum = 0; sceditor->min_border = 0.0; sceditor->top_editable = 0; + sceditor->cbl = NULL; sceditor->stylesheets = copy_ss_list(stylesheets); diff --git a/src/sc_editor.h b/src/sc_editor.h index b8f4fa9..81e0bae 100644 --- a/src/sc_editor.h +++ b/src/sc_editor.h @@ -31,6 +31,7 @@ #include <glib-object.h> #include "frame.h" +#include "sc_interp.h" struct presentation; @@ -94,6 +95,7 @@ struct _sceditor cairo_surface_t *surface; SCBlock **stylesheets; ImageStore *is; + SCCallbackList *cbl; /* Pointers to the frame currently being edited */ struct frame *selection; @@ -159,5 +161,6 @@ extern void sc_editor_set_slidenum(SCEditor *e, int slidenum); extern void sc_editor_set_min_border(SCEditor *e, double min_border); extern void sc_editor_set_top_frame_editable(SCEditor *e, int top_frame_editable); +extern void sc_editor_set_callbacks(SCEditor *e, SCCallbackList *cbl); #endif /* SC_EDITOR_H */ diff --git a/src/sc_interp.c b/src/sc_interp.c index 703b73f..bed8fa2 100644 --- a/src/sc_interp.c +++ b/src/sc_interp.c @@ -60,6 +60,7 @@ struct sc_state struct macro *macros; /* Contents need to be copied on push */ SCBlock *macro_contents; + SCBlock *macro_real_block; }; @@ -77,6 +78,32 @@ struct _scinterp }; +SCCallbackList *sc_callback_list_new() +{ +} + + +void sc_callback_list_free(SCCallbackList *cbl) +{ +} + + +void sc_callback_list_add_callback(SCCallbackList *cbl, const char *name, + cairo_surface_t *(*func)(SCBlock *bl, void *p)) +{ +} + + +void sc_interp_set_callbacks(SCInterpreter *scin, SCCallbackList *cbl) +{ +} + + +static void do_callback(SCInterpreter *scin, const char *name) +{ +} + + PangoFont *sc_interp_get_font(SCInterpreter *scin) { struct sc_state *st = &scin->state[scin->j]; @@ -331,6 +358,13 @@ struct frame *sc_interp_get_frame(SCInterpreter *scin) } +SCBlock *sc_interp_get_macro_real_block(SCInterpreter *scin) +{ + struct sc_state *st = &scin->state[scin->j]; + return st->macro_real_block; +} + + static void set_frame(SCInterpreter *scin, struct frame *fr) { struct sc_state *st = &scin->state[scin->j]; @@ -705,6 +739,7 @@ static void exec_macro(SCBlock *bl, SCInterpreter *scin, SCBlock *child) struct sc_state *st = &scin->state[scin->j]; st->macro_contents = child; + st->macro_real_block = bl; mchild = sc_block_macro_child(bl); if ( mchild == NULL ) { @@ -801,7 +836,8 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl) } else if ( strcmp(name, "bggradv") == 0 ) { set_frame_bggrad(sc_interp_get_frame(scin), options, GRAD_VERT); - + } else if ( strcmp(name, "callback") == 0 ) { + do_callback(scin, options); } else { diff --git a/src/sc_interp.h b/src/sc_interp.h index a4e9f43..017f9ea 100644 --- a/src/sc_interp.h +++ b/src/sc_interp.h @@ -31,6 +31,7 @@ struct presentation; typedef struct _scinterp SCInterpreter; +typedef struct _sccallbacklist SCCallbackList; extern SCInterpreter *sc_interp_new(PangoContext *pc, struct frame *top); extern void sc_interp_destroy(SCInterpreter *scin); @@ -45,6 +46,14 @@ extern void sc_interp_run_stylesheet(SCInterpreter *scin, SCBlock *bl); extern void add_macro(SCInterpreter *scin, const char *mname, const char *contents); + +/* Callback lists */ +extern SCCallbackList *sc_callback_list_new(); +extern void sc_callback_list_free(SCCallbackList *cbl); +extern void sc_callback_list_add_callback(SCCallbackList *cbl, const char *name, + cairo_surface_t *(*func)(SCBlock *bl, void *p)); +extern void sc_interp_set_callbacks(SCInterpreter *scin, SCCallbackList *cbl); + /* Get the current state of the interpreter */ extern struct frame *sc_interp_get_frame(SCInterpreter *scin); extern PangoFont *sc_interp_get_font(SCInterpreter *scin); @@ -53,6 +62,7 @@ extern double *sc_interp_get_fgcol(SCInterpreter *scin); extern int sc_interp_get_ascent(SCInterpreter *scin); extern int sc_interp_get_height(SCInterpreter *scin); extern void update_geom(struct frame *fr); +extern SCBlock *sc_interp_get_macro_real_block(SCInterpreter *scin); struct style_id diff --git a/src/slideshow.c b/src/slideshow.c index 34bb0d5..1018a71 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -81,7 +81,7 @@ void slideshow_rerender(SlideShow *ss) ss->surface = render_sc(ss->cur_slide->scblocks, ss->slide_width, ss->slide_height, ss->p->slide_width, ss->p->slide_height, - stylesheets, ss->p->is, ISZ_SLIDESHOW, n); + stylesheets, NULL, ss->p->is, ISZ_SLIDESHOW, n); } |