aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/print.c9
-rw-r--r--src/render.c8
-rw-r--r--src/render.h2
-rw-r--r--src/sc_editor.c14
4 files changed, 12 insertions, 21 deletions
diff --git a/src/print.c b/src/print.c
index 0f3e7ff..65abe27 100644
--- a/src/print.c
+++ b/src/print.c
@@ -121,7 +121,7 @@ static void print_slide_only(GtkPrintOperation *op, GtkPrintContext *ctx,
top = interp_and_shape(sc_block_child(ps->slide), stylesheets, NULL,
ps->p->is,
- page+1, cr,
+ page+1, pc,
ps->p->slide_width, ps->p->slide_height,
ps->p->lang);
@@ -201,13 +201,13 @@ static void begin_narrative_print(GtkPrintOperation *op, GtkPrintContext *ctx,
stylesheets[1] = NULL;
}
+ pc = gtk_print_context_create_pango_context(ctx);
+
ps->top = interp_and_shape(ps->p->scblocks, stylesheets, cbl,
- ps->is, 0,
- gtk_print_context_get_cairo_context(ctx),
+ ps->is, 0, pc,
gtk_print_context_get_width(ctx),
gtk_print_context_get_height(ctx),
ps->p->lang);
- pc = gtk_print_context_create_pango_context(ctx);
recursive_wrap(ps->top, pc);
/* Count pages */
@@ -225,6 +225,7 @@ static void begin_narrative_print(GtkPrintOperation *op, GtkPrintContext *ctx,
h += paragraph_height(ps->top->paras[i]);
}
gtk_print_operation_set_n_pages(op, n_pages);
+ g_object_unref(pc);
}
diff --git a/src/render.c b/src/render.c
index 7fe789c..6ba8091 100644
--- a/src/render.c
+++ b/src/render.c
@@ -173,16 +173,13 @@ int recursive_wrap(struct frame *fr, PangoContext *pc)
struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets,
SCCallbackList *cbl, ImageStore *is,
int slide_number,
- cairo_t *cr, double w, double h,
+ PangoContext *pc, double w, double h,
PangoLanguage *lang)
{
- PangoContext *pc;
SCInterpreter *scin;
char snum[64];
struct frame *top;
- pc = pango_cairo_create_context(cr);
-
top = frame_new();
top->resizable = 0;
top->x = 0.0;
@@ -220,7 +217,6 @@ struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets,
sc_interp_add_blocks(scin, scblocks);
sc_interp_destroy(scin);
- g_object_unref(pc);
return top;
}
@@ -240,7 +236,7 @@ static struct frame *render_sc_with_context(SCBlock *scblocks,
cairo_fill(cr);
top = interp_and_shape(scblocks, stylesheets, cbl, is,
- slide_number, cr, log_w, log_h, lang);
+ slide_number, pc, log_w, log_h, lang);
recursive_wrap(top, pc);
diff --git a/src/render.h b/src/render.h
index aefa238..d361568 100644
--- a/src/render.h
+++ b/src/render.h
@@ -47,7 +47,7 @@ extern cairo_surface_t *render_sc(SCBlock *scblocks, int w, int h,
extern struct frame *interp_and_shape(SCBlock *scblocks, SCBlock **stylesheets,
SCCallbackList *cbl,
ImageStore *is,
- int slide_number, cairo_t *cr,
+ int slide_number, PangoContext *pc,
double w, double h, PangoLanguage *lang);
extern void wrap_frame(struct frame *fr, PangoContext *pc);
diff --git a/src/sc_editor.c b/src/sc_editor.c
index 1dee4b4..96e0656 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -167,10 +167,8 @@ static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event,
SCEditor *e)
{
PangoContext *pc;
- cairo_t *cr;
- cr = gdk_cairo_create(gtk_widget_get_window(widget));
- pc = pango_cairo_create_context(cr);
+ pc = gdk_pango_context_get();
if ( e->scale ) {
@@ -206,7 +204,7 @@ 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, e->slidenum, cr,
+ e->is, e->slidenum, pc,
w, h, e->lang);
recursive_wrap(e->top, pc);
}
@@ -224,7 +222,6 @@ static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event,
update_size(e);
g_object_unref(pc);
- cairo_destroy(cr);
return FALSE;
}
@@ -398,18 +395,16 @@ void sc_editor_remove_cursor(SCEditor *e)
* invalid. The cursor position will be unset. */
static void full_rerender(SCEditor *e)
{
- cairo_t *cr;
PangoContext *pc;
frame_free(e->top);
sc_editor_remove_cursor(e);
- cr = gdk_cairo_create(gtk_widget_get_window(GTK_WIDGET(e)));
- pc = pango_cairo_create_context(cr);
+ pc = gdk_pango_context_get();
e->top = interp_and_shape(e->scblocks, e->stylesheets, e->cbl,
e->is, e->slidenum,
- cr, e->log_w, 0.0, e->lang);
+ pc, e->log_w, 0.0, e->lang);
e->top->x = 0.0;
e->top->y = 0.0;
@@ -422,7 +417,6 @@ static void full_rerender(SCEditor *e)
sc_editor_redraw(e);
g_object_unref(pc);
- cairo_destroy(cr);
}