aboutsummaryrefslogtreecommitdiff
path: root/src/narrative_window.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2015-01-03 18:50:15 +0000
committerThomas White <taw@bitwiz.org.uk>2015-01-03 18:50:15 +0000
commit94d1b5ea051bd4a6cb41ed0b2bc9b90f461c6e71 (patch)
treeeccf4aca724461772a33dc6c963932b295bf733b /src/narrative_window.c
parenta68d64edca4f67df49b9499272319cad93d38bbe (diff)
Thumbnails!
Diffstat (limited to 'src/narrative_window.c')
-rw-r--r--src/narrative_window.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/narrative_window.c b/src/narrative_window.c
index 7a66f14..99f227e 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -33,6 +33,8 @@
#include "presentation.h"
#include "narrative_window.h"
#include "sc_editor.h"
+#include "sc_parse.h"
+#include "render.h"
struct _narrative_window
@@ -194,18 +196,33 @@ static SCBlock *narrative_stylesheet()
}
-static cairo_surface_t *render_thumbnail(SCInterpreter *scin, SCBlock *bl,
- void *vp)
+static int create_thumbnail(SCInterpreter *scin, SCBlock *bl,
+ double *w, double *h, void **bvp, void *vp)
+{
+ SCBlock *b;
+
+ *w = 320.0;
+ *h = 256.0;
+ b = sc_interp_get_macro_real_block(scin);
+
+ *bvp = b;
+
+ return 1;
+}
+
+
+static cairo_surface_t *render_thumbnail(int w, int h, void *bvp, void *vp)
{
struct presentation *p = vp;
+ SCBlock *scblocks = bvp;
cairo_surface_t *surf;
- cairo_t *cr;
+ SCBlock *stylesheets[2];
- surf = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 256, 256);
- cr = cairo_create(surf);
- cairo_set_source_rgb(cr, 0.0, 0.5, 0.0);
- cairo_paint(cr);
- cairo_destroy(cr);
+ scblocks = sc_block_child(scblocks);
+ stylesheets[0] = p->stylesheet;
+ stylesheets[1] = NULL;
+ surf = render_sc(scblocks, w, h, 1024.0, 768.0, stylesheets, NULL,
+ p->is, ISZ_THUMBNAIL, 0);
return surf;
}
@@ -248,7 +265,8 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *app)
stylesheets[2] = NULL;
nw->sceditor = sc_editor_new(nw->p->scblocks, stylesheets);
cbl = sc_callback_list_new();
- sc_callback_list_add_callback(cbl, "sthumb", render_thumbnail, NULL);
+ sc_callback_list_add_callback(cbl, "sthumb", create_thumbnail,
+ render_thumbnail, p);
sc_editor_set_callbacks(nw->sceditor, cbl);
toolbar = gtk_toolbar_new();