From 81100c4e659c6b11f2e36f48a171325ddff76676 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sun, 15 Nov 2015 16:17:17 +0100 Subject: Move PangoLanguage higher up --- src/narrative_window.c | 4 ++-- src/presentation.c | 6 ++++++ src/presentation.h | 3 ++- src/render.c | 12 +++++++----- src/render.h | 5 +++-- src/sc_editor.c | 9 ++++++--- src/sc_editor.h | 3 ++- src/slide_window.c | 5 +++-- src/slideshow.c | 2 +- tests/render_test.c | 3 ++- tests/render_test_sc1.c | 3 ++- 11 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/narrative_window.c b/src/narrative_window.c index ad4fc2c..ac4da22 100644 --- a/src/narrative_window.c +++ b/src/narrative_window.c @@ -426,7 +426,7 @@ static cairo_surface_t *render_thumbnail(int w, int h, void *bvp, void *vp) stylesheets[1] = NULL; /* FIXME: Cache like crazy here */ surf = render_sc(scblocks, w, h, 1024.0, 768.0, stylesheets, NULL, - p->is, ISZ_THUMBNAIL, 0, &top); + p->is, ISZ_THUMBNAIL, 0, &top, p->lang); frame_free(top); return surf; @@ -469,7 +469,7 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *app) stylesheets[0] = p->stylesheet; stylesheets[1] = narrative_stylesheet(); stylesheets[2] = NULL; - nw->sceditor = sc_editor_new(nw->p->scblocks, stylesheets); + nw->sceditor = sc_editor_new(nw->p->scblocks, stylesheets, p->lang); cbl = sc_callback_list_new(); sc_callback_list_add_callback(cbl, "sthumb", create_thumbnail, render_thumbnail, p); diff --git a/src/presentation.c b/src/presentation.c index e95bd92..a51762f 100644 --- a/src/presentation.c +++ b/src/presentation.c @@ -226,6 +226,9 @@ struct presentation *new_presentation() new->stylesheet = NULL; new->is = imagestore_new(); + /* FIXME: Hardcoded */ + new->lang = pango_language_from_string("en_GB"); + return new; } @@ -344,6 +347,9 @@ int load_presentation(struct presentation *p, const char *filename) p->scblocks = sc_parse(everything); free(everything); + /* FIXME: Hardcoded */ + p->lang = pango_language_from_string("en_GB"); + if ( p->scblocks == NULL ) r = 1; if ( r ) { diff --git a/src/presentation.h b/src/presentation.h index 54d21b1..51d0cf1 100644 --- a/src/presentation.h +++ b/src/presentation.h @@ -1,7 +1,7 @@ /* * presentation.h * - * Copyright © 2013-2014 Thomas White + * Copyright © 2013-2015 Thomas White * * This file is part of Colloquium. * @@ -55,6 +55,7 @@ struct presentation char *filename; char *titlebar; /* basename(filename) or "(untitled)" */ int completely_empty; + PangoLanguage *lang; ImageStore *is; diff --git a/src/render.c b/src/render.c index 7aaa8b4..ae8094a 100644 --- a/src/render.c +++ b/src/render.c @@ -492,7 +492,7 @@ static struct frame *render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *su cairo_t *cr, double log_w, double log_h, SCBlock **stylesheets, SCCallbackList *cbl, ImageStore *is, enum is_size isz, - int slide_number) + int slide_number, PangoLanguage *lang) { struct frame *top; @@ -501,7 +501,7 @@ static struct frame *render_sc_to_surface(SCBlock *scblocks, cairo_surface_t *su cairo_fill(cr); top = interp_and_shape(scblocks, stylesheets, cbl, is, isz, - slide_number, cr, log_w, log_h); + slide_number, cr, log_w, log_h, lang); recursive_wrap(top, is, isz); @@ -515,7 +515,8 @@ cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, double log_w, double log_h, SCBlock **stylesheets, SCCallbackList *cbl, ImageStore *is, enum is_size isz, - int slide_number, struct frame **ptop) + int slide_number, struct frame **ptop, + PangoLanguage *lang) { cairo_surface_t *surf; cairo_t *cr; @@ -525,7 +526,8 @@ cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, cr = cairo_create(surf); cairo_scale(cr, w/log_w, h/log_h); top = render_sc_to_surface(scblocks, surf, cr, log_w, log_h, - stylesheets, cbl, is, isz,slide_number); + stylesheets, cbl, is, isz,slide_number, + lang); cairo_destroy(cr); *ptop = top; @@ -573,7 +575,7 @@ int export_pdf(struct presentation *p, const char *filename) render_sc_to_surface(s->scblocks, surf, cr, p->slide_width, p->slide_height, stylesheets, NULL, - p->is, ISZ_SLIDESHOW, i); + p->is, ISZ_SLIDESHOW, i, p->lang); cairo_restore(cr); diff --git a/src/render.h b/src/render.h index 10da19f..486f129 100644 --- a/src/render.h +++ b/src/render.h @@ -37,7 +37,8 @@ extern cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h, double log_w, double log_h, SCBlock **stylesheets, SCCallbackList *cbl, ImageStore *is, enum is_size isz, - int slide_number, struct frame **ptop); + int slide_number, struct frame **ptop, + PangoLanguage *lang); /* Interpret StoryCode and measure boxes. * Needs to be followed by: wrap_contents() (recursively) @@ -47,7 +48,7 @@ extern struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets, SCCallbackList *cbl, ImageStore *is, enum is_size isz, int slide_number, cairo_t *cr, - double w, double h); + double w, double h, PangoLanguage *lang); extern int recursive_wrap(struct frame *fr, ImageStore *is, enum is_size isz); diff --git a/src/sc_editor.c b/src/sc_editor.c index f1af23f..bdfc842 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -132,7 +132,8 @@ static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event, h = e->log_h; } e->top = interp_and_shape(e->scblocks, e->stylesheets, e->cbl, - e->is, ISZ_EDITOR, 0, cr, w, h); + e->is, ISZ_EDITOR, 0, cr, w, h, + e->lang); recursive_wrap(e->top, e->is, ISZ_EDITOR); cairo_destroy(cr); } @@ -318,7 +319,7 @@ static void full_rerender(SCEditor *e) cairo_t *cr = gdk_cairo_create(gtk_widget_get_window(GTK_WIDGET(e))); e->top = interp_and_shape(e->scblocks, e->stylesheets, e->cbl, - e->is, ISZ_EDITOR, 0, cr, e->w, 0.0); + e->is, ISZ_EDITOR, 0, cr, e->w, 0.0, e->lang); cairo_destroy(cr); e->top->x = 0.0; @@ -1785,7 +1786,8 @@ void sc_editor_set_callbacks(SCEditor *e, SCCallbackList *cbl) } -SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets) +SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets, + PangoLanguage *lang) { SCEditor *sceditor; GtkTargetEntry targets[1]; @@ -1807,6 +1809,7 @@ SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets) sceditor->cbl = NULL; sceditor->scroll_pos = 0; sceditor->flow = 0; + sceditor->lang = lang; sceditor->stylesheets = copy_ss_list(stylesheets); diff --git a/src/sc_editor.h b/src/sc_editor.h index 289b56f..4f5ba63 100644 --- a/src/sc_editor.h +++ b/src/sc_editor.h @@ -164,7 +164,8 @@ typedef struct _sceditorclass SCEditorClass; extern void sc_editor_set_scblock(SCEditor *e, SCBlock *scblocks); extern GtkWidget *sc_editor_get_widget(SCEditor *e); -extern SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets); +extern SCEditor *sc_editor_new(SCBlock *scblocks, SCBlock **stylesheets, + PangoLanguage *lang); extern void sc_editor_set_size(SCEditor *e, int w, int h); extern void sc_editor_set_logical_size(SCEditor *e, double w, double h); extern void sc_editor_set_flow(SCEditor *e, int flow); diff --git a/src/slide_window.c b/src/slide_window.c index 42569b2..eb8ecaa 100644 --- a/src/slide_window.c +++ b/src/slide_window.c @@ -127,7 +127,7 @@ static void UNUSED update_style_menus(SlideWindow *sw) free(sw->style_menu); /* Get the list of styles from the style sheet */ - scin = sc_interp_new(NULL, NULL); + scin = sc_interp_new(NULL, sw->p->lang, NULL); if ( scin == NULL ) { fprintf(stderr, "Failed to set up interpreter.\n"); return; @@ -631,7 +631,8 @@ SlideWindow *slide_window_open(struct presentation *p, GApplication *app) stylesheets[0] = p->stylesheet; stylesheets[1] = NULL; - sw->sceditor = sc_editor_new(sw->cur_slide->scblocks, stylesheets); + sw->sceditor = sc_editor_new(sw->cur_slide->scblocks, stylesheets, + p->lang); scroll = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, diff --git a/src/slideshow.c b/src/slideshow.c index b33a41b..7c23606 100644 --- a/src/slideshow.c +++ b/src/slideshow.c @@ -86,7 +86,7 @@ void slideshow_rerender(SlideShow *ss) ss->slide_width, ss->slide_height, ss->p->slide_width, ss->p->slide_height, stylesheets, NULL, ss->p->is, ISZ_SLIDESHOW, n, - &ss->top); + &ss->top, ss->p->lang); } diff --git a/tests/render_test.c b/tests/render_test.c index 51d4a3a..5c99542 100644 --- a/tests/render_test.c +++ b/tests/render_test.c @@ -52,12 +52,13 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, gpointer data) cairo_surface_t *surface; SCBlock *scblocks = data; struct frame *top; + PangoLanguage *lang = pango_language_from_string("en_GB"); w = gtk_widget_get_allocated_width(da); h = gtk_widget_get_allocated_height(da); surface = render_sc(scblocks, w, h, w, h, NULL, NULL, NULL, - ISZ_EDITOR, 1, &top); + ISZ_EDITOR, 1, &top, lang); cairo_rectangle(cr, 0.0, 0.0, w, h); cairo_set_source_surface(cr, surface, 0.0, 0.0); cairo_fill(cr); diff --git a/tests/render_test_sc1.c b/tests/render_test_sc1.c index 8a6ff8b..eae8689 100644 --- a/tests/render_test_sc1.c +++ b/tests/render_test_sc1.c @@ -51,12 +51,13 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, gpointer data) cairo_surface_t *surface; SCBlock *scblocks = data; struct frame *top; + PangoLanguage *lang = pango_language_from_string("en_GB"); w = gtk_widget_get_allocated_width(da); h = gtk_widget_get_allocated_height(da); surface = render_sc(scblocks, w, h, w, h, NULL, NULL, NULL, - ISZ_EDITOR, 1, &top); + ISZ_EDITOR, 1, &top, lang); cairo_rectangle(cr, 0.0, 0.0, w, h); cairo_set_source_surface(cr, surface, 0.0, 0.0); cairo_fill(cr); -- cgit v1.2.3