aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-10-10 17:38:23 +0200
committerThomas White <taw@bitwiz.me.uk>2019-10-10 17:38:23 +0200
commit23c8103b45433c0bef316c84acbc74db4dcb5621 (patch)
tree6eaa453f85a00945546ddb9a62a0d25d81ac4c0d
parent428a3329d1b86c9daa15fa72b2fbbd54859579ca (diff)
Make symbol names unique across all files
Enables Meson unity builds, helps ctags work, and reduces space for bugs
-rw-r--r--libstorycode/gtk/gtknarrativeview.c200
-rw-r--r--libstorycode/gtk/gtknarrativeview.h10
-rw-r--r--libstorycode/gtk/gtkslideview.c251
-rw-r--r--libstorycode/gtk/gtkslideview.h10
-rw-r--r--libstorycode/narrative.c8
-rw-r--r--libstorycode/narrative_priv.h2
-rw-r--r--libstorycode/narrative_render_cairo.c31
-rw-r--r--libstorycode/render_cairo_common.c11
-rw-r--r--libstorycode/render_cairo_common.h1
-rw-r--r--libstorycode/slide_render_cairo.c55
-rw-r--r--libstorycode/slide_render_cairo.h2
-rw-r--r--libstorycode/storycode.l86
-rw-r--r--libstorycode/storycode.y41
-rw-r--r--libstorycode/stylesheet.c2
-rw-r--r--libstorycode/stylesheet.h2
-rw-r--r--src/narrative_window.c4
-rw-r--r--src/slide_window.c4
17 files changed, 348 insertions, 372 deletions
diff --git a/libstorycode/gtk/gtknarrativeview.c b/libstorycode/gtk/gtknarrativeview.c
index 25de71b..d53c851 100644
--- a/libstorycode/gtk/gtknarrativeview.c
+++ b/libstorycode/gtk/gtknarrativeview.c
@@ -60,7 +60,7 @@ G_DEFINE_TYPE_WITH_CODE(GtkNarrativeView, gtk_narrative_view,
G_IMPLEMENT_INTERFACE(GTK_TYPE_SCROLLABLE,
scroll_interface_init))
-static void redraw(GtkNarrativeView *e)
+static void gtknv_redraw(GtkNarrativeView *e)
{
gint w, h;
w = gtk_widget_get_allocated_width(GTK_WIDGET(e));
@@ -72,7 +72,7 @@ static void redraw(GtkNarrativeView *e)
static void horizontal_adjust(GtkAdjustment *adj, GtkNarrativeView *e)
{
e->h_scroll_pos = gtk_adjustment_get_value(adj);
- redraw(e);
+ gtknv_redraw(e);
}
@@ -87,7 +87,7 @@ static void set_horizontal_params(GtkNarrativeView *e)
static void vertical_adjust(GtkAdjustment *adj, GtkNarrativeView *e)
{
e->scroll_pos = gtk_adjustment_get_value(adj);
- redraw(e);
+ gtknv_redraw(e);
}
@@ -151,8 +151,8 @@ static void update_size(GtkNarrativeView *e)
}
-static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event,
- GtkNarrativeView *e)
+static gboolean gtknv_resize_sig(GtkWidget *widget, GdkEventConfigure *event,
+ GtkNarrativeView *e)
{
e->visible_height = event->height;
e->visible_width = event->width;
@@ -166,7 +166,7 @@ static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event,
}
-static void emit_change_sig(GtkNarrativeView *e)
+static void gtknv_emit_change_sig(GtkNarrativeView *e)
{
g_signal_emit_by_name(e, "changed");
}
@@ -463,13 +463,13 @@ static void copy_selection(GtkNarrativeView *e)
}
-static gint destroy_sig(GtkWidget *window, GtkNarrativeView *e)
+static gint gtknv_destroy_sig(GtkWidget *window, GtkNarrativeView *e)
{
return 0;
}
-static double para_top(Narrative *n, int pnum)
+static double gtknv_para_top(Narrative *n, int pnum)
{
int i;
double py = 0.0;
@@ -486,7 +486,7 @@ static void draw_para_highlight(cairo_t *cr, Narrative *n, int cursor_para,
item = &n->items[cursor_para];
cx = item->space_l;
- cy = para_top(n, cursor_para) + item->space_t;
+ cy = gtknv_para_top(n, cursor_para) + item->space_t;
cairo_new_path(cr);
cairo_rectangle(cr, cx-5.0, cy-5.0, item->obj_w+10.0, item->obj_h+10.0);
@@ -496,8 +496,8 @@ static void draw_para_highlight(cairo_t *cr, Narrative *n, int cursor_para,
}
-static void get_cursor_pos(Narrative *n, struct edit_pos cpos,
- double *x, double *y, double *h)
+static void gtknv_get_cursor_pos(Narrative *n, struct edit_pos cpos,
+ double *x, double *y, double *h)
{
size_t offs;
PangoRectangle rect;
@@ -506,7 +506,7 @@ static void get_cursor_pos(Narrative *n, struct edit_pos cpos,
item = &n->items[cpos.para];
if ( !narrative_item_is_text(n, cpos.para) ) {
*x = item->space_l;
- *y = para_top(n, cpos.para) + item->space_t;
+ *y = gtknv_para_top(n, cpos.para) + item->space_t;
*h = item->obj_h + item->space_t + item->space_b;
return;
}
@@ -519,12 +519,12 @@ static void get_cursor_pos(Narrative *n, struct edit_pos cpos,
offs = narrative_pos_trail_to_offset(n, cpos.para, cpos.pos, cpos.trail);
pango_layout_get_cursor_pos(item->layout, offs, &rect, NULL);
*x = pango_units_to_double(rect.x) + item->space_l;
- *y = pango_units_to_double(rect.y) + para_top(n, cpos.para) + item->space_t;
+ *y = pango_units_to_double(rect.y) + gtknv_para_top(n, cpos.para) + item->space_t;
*h = pango_units_to_double(rect.height);
}
-static void draw_caret(cairo_t *cr, Narrative *n, struct edit_pos cpos, double ww)
+static void gtknv_draw_caret(cairo_t *cr, Narrative *n, struct edit_pos cpos, double ww)
{
assert(n != NULL);
@@ -535,7 +535,7 @@ static void draw_caret(cairo_t *cr, Narrative *n, struct edit_pos cpos, double w
double cx, clow, chigh, h;
const double t = 1.8;
- get_cursor_pos(n, cpos, &cx, &clow, &h);
+ gtknv_get_cursor_pos(n, cpos, &cx, &clow, &h);
chigh = clow+h;
@@ -566,7 +566,7 @@ static void draw_caret(cairo_t *cr, Narrative *n, struct edit_pos cpos, double w
item = &n->items[cpos.para];
cx = item->space_l - 5.5;
- cy = para_top(n, cpos.para) + item->space_t - 5.5;
+ cy = gtknv_para_top(n, cpos.para) + item->space_t - 5.5;
cw = item->obj_w + 11.0;
ch = item->obj_h + 11.0;
@@ -580,17 +580,17 @@ static void draw_caret(cairo_t *cr, Narrative *n, struct edit_pos cpos, double w
}
-static void draw_overlay(cairo_t *cr, GtkNarrativeView *e)
+static void gtknv_draw_overlay(cairo_t *cr, GtkNarrativeView *e)
{
if ( e->para_highlight ) {
draw_para_highlight(cr, e->n, e->cpos.para, e->w);
} else {
- draw_caret(cr, e->n, e->cpos, e->w);
+ gtknv_draw_caret(cr, e->n, e->cpos, e->w);
}
}
-static gboolean draw_sig(GtkWidget *da, cairo_t *cr, GtkNarrativeView *e)
+static gboolean gtknv_draw_sig(GtkWidget *da, cairo_t *cr, GtkNarrativeView *e)
{
if ( e->rewrap_needed ) {
rewrap_range(e, 0, e->n->n_items);
@@ -613,7 +613,7 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, GtkNarrativeView *e)
/* Editing overlay */
cairo_translate(cr, e->n->space_l, e->n->space_t);
- draw_overlay(cr, e);
+ gtknv_draw_overlay(cr, e);
return FALSE;
}
@@ -623,7 +623,7 @@ static void check_cursor_visible(GtkNarrativeView *e)
{
double x, y, h;
- get_cursor_pos(e->n, e->cpos, &x, &y, &h);
+ gtknv_get_cursor_pos(e->n, e->cpos, &x, &y, &h);
/* Off the bottom? */
if ( y - e->scroll_pos + h > e->visible_height ) {
@@ -638,7 +638,7 @@ static void check_cursor_visible(GtkNarrativeView *e)
}
-static size_t end_offset_of_para(Narrative *n, int pnum)
+static size_t gtknv_end_offset_of_para(Narrative *n, int pnum)
{
int i;
size_t len;
@@ -671,7 +671,7 @@ static void sort_positions(struct edit_pos *a, struct edit_pos *b)
}
-static void cursor_moveh(Narrative *n, struct edit_pos *cp, signed int dir)
+static void gtknv_cursor_moveh(Narrative *n, struct edit_pos *cp, signed int dir)
{
struct narrative_item *item = &n->items[cp->para];
int np = cp->pos;
@@ -696,7 +696,7 @@ static void cursor_moveh(Narrative *n, struct edit_pos *cp, signed int dir)
if ( cp->para > 0 ) {
size_t end_offs;
cp->para--;
- end_offs = end_offset_of_para(n, cp->para);
+ end_offs = gtknv_end_offset_of_para(n, cp->para);
if ( end_offs > 0 ) {
cp->pos = end_offs - 1;
cp->trail = 1;
@@ -729,7 +729,7 @@ static void cursor_moveh(Narrative *n, struct edit_pos *cp, signed int dir)
}
-static void unset_selection(GtkNarrativeView *e)
+static void gtknv_unset_selection(GtkNarrativeView *e)
{
int a, b;
@@ -758,7 +758,7 @@ static int positions_equal(struct edit_pos a, struct edit_pos b)
}
-static void do_backspace(GtkNarrativeView *e, signed int dir)
+static void gtknv_do_backspace(GtkNarrativeView *e, signed int dir)
{
struct edit_pos p1, p2;
size_t o1, o2;
@@ -774,7 +774,7 @@ static void do_backspace(GtkNarrativeView *e, signed int dir)
/* Delete one character, as represented visually */
p2 = e->cpos;
p1 = p2;
- cursor_moveh(e->n, &p1, dir);
+ gtknv_cursor_moveh(e->n, &p1, dir);
}
sort_positions(&p1, &p2);
@@ -782,7 +782,7 @@ static void do_backspace(GtkNarrativeView *e, signed int dir)
o2 = narrative_pos_trail_to_offset(e->n, p2.para, p2.pos, p2.trail);
narrative_delete_block(e->n, p1.para, o1, p2.para, o2);
e->cpos = p1;
- unset_selection(e);
+ gtknv_unset_selection(e);
/* The only paragraphs which still exist and might have been
* affected by the deletion are sel_start.para and the one
@@ -790,19 +790,19 @@ static void do_backspace(GtkNarrativeView *e, signed int dir)
rewrap_range(e, p1.para, p1.para+1);
update_size(e);
check_cursor_visible(e);
- emit_change_sig(e);
- redraw(e);
+ gtknv_emit_change_sig(e);
+ gtknv_redraw(e);
}
-static void insert_text_in_paragraph(struct narrative_item *item, size_t offs,
- char *t)
+static void gtknv_insert_text_in_paragraph(struct narrative_item *item, size_t offs,
+ char *t)
{
char *n;
int run;
size_t run_offs;
- run = which_run(item, offs, &run_offs);
+ run = narrative_which_run(item, offs, &run_offs);
n = malloc(strlen(t) + strlen(item->runs[run].text) + 1);
if ( n == NULL ) return;
@@ -815,10 +815,10 @@ static void insert_text_in_paragraph(struct narrative_item *item, size_t offs,
}
-static void insert_text(char *t, GtkNarrativeView *e)
+static void gtknv_insert_text(char *t, GtkNarrativeView *e)
{
if ( !positions_equal(e->sel_start, e->sel_end) ) {
- do_backspace(e, 0);
+ gtknv_do_backspace(e, 0);
}
if ( narrative_item_is_text(e->n, e->cpos.para) ) {
@@ -833,30 +833,30 @@ static void insert_text(char *t, GtkNarrativeView *e)
e->cpos.pos = 0;
e->cpos.trail = 0;
} else {
- insert_text_in_paragraph(&e->n->items[e->cpos.para], off, t);
+ gtknv_insert_text_in_paragraph(&e->n->items[e->cpos.para], off, t);
rewrap_range(e, e->cpos.para, e->cpos.para);
- cursor_moveh(e->n, &e->cpos, +1);
+ gtknv_cursor_moveh(e->n, &e->cpos, +1);
}
update_size(e);
} /* else do nothing */
- emit_change_sig(e);
+ gtknv_emit_change_sig(e);
check_cursor_visible(e);
- redraw(e);
+ gtknv_redraw(e);
}
-static gboolean im_commit_sig(GtkIMContext *im, gchar *str,
- GtkNarrativeView *e)
+static gboolean gtknv_im_commit_sig(GtkIMContext *im, gchar *str,
+ GtkNarrativeView *e)
{
- insert_text(str, e);
+ gtknv_insert_text(str, e);
return FALSE;
}
-static int find_cursor(Narrative *n, double x, double y, struct edit_pos *pos)
+static int gtknv_find_cursor(Narrative *n, double x, double y, struct edit_pos *pos)
{
double cur_y;
struct narrative_item *item;
@@ -877,15 +877,15 @@ static int find_cursor(Narrative *n, double x, double y, struct edit_pos *pos)
pango_layout_xy_to_index(item->layout,
pango_units_from_double(x - n->space_l - item->space_l),
- pango_units_from_double(y - n->space_t - para_top(n, pos->para)),
+ pango_units_from_double(y - n->space_t - gtknv_para_top(n, pos->para)),
&pos->pos, &pos->trail);
return 0;
}
-static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event,
- GtkNarrativeView *e)
+static gboolean gtknv_button_press_sig(GtkWidget *da, GdkEventButton *event,
+ GtkNarrativeView *e)
{
gdouble x, y;
@@ -893,9 +893,9 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event,
y = event->y + e->scroll_pos;
/* Clicked an existing frame, no immediate dragging */
- e->drag_status = DRAG_STATUS_COULD_DRAG;
- unset_selection(e);
- find_cursor(e->n, x, y, &e->sel_start);
+ e->drag_status = NARRATIVE_DRAG_STATUS_COULD_DRAG;
+ gtknv_unset_selection(e);
+ gtknv_find_cursor(e->n, x, y, &e->sel_start);
e->sel_end = e->sel_start;
e->cpos = e->sel_start;
@@ -908,7 +908,7 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event,
}
gtk_widget_grab_focus(GTK_WIDGET(da));
- redraw(e);
+ gtknv_redraw(e);
return FALSE;
}
@@ -923,8 +923,8 @@ static void sorti(int *a, int *b)
}
-static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event,
- GtkNarrativeView *e)
+static gboolean gtknv_motion_sig(GtkWidget *da, GdkEventMotion *event,
+ GtkNarrativeView *e)
{
gdouble x, y;
struct edit_pos old_sel_end;
@@ -933,14 +933,14 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event,
x = event->x;
y = event->y + e->scroll_pos;
- if ( e->drag_status == DRAG_STATUS_COULD_DRAG ) {
+ if ( e->drag_status == NARRATIVE_DRAG_STATUS_COULD_DRAG ) {
/* We just got a motion signal, and the status was "could drag",
* therefore the drag has started. */
- e->drag_status = DRAG_STATUS_DRAGGING;
+ e->drag_status = NARRATIVE_DRAG_STATUS_DRAGGING;
}
old_sel_end = e->sel_end;
- find_cursor(e->n, x, y, &e->sel_end);
+ gtknv_find_cursor(e->n, x, y, &e->sel_end);
minp = e->sel_start.para;
maxp = e->sel_end.para;
@@ -951,16 +951,16 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event,
}
rewrap_range(e, minp, maxp);
- find_cursor(e->n, x, y, &e->cpos);
- redraw(e);
+ gtknv_find_cursor(e->n, x, y, &e->cpos);
+ gtknv_redraw(e);
gdk_event_request_motions(event);
return FALSE;
}
-static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event,
- GtkNarrativeView *e)
+static gboolean gtknv_key_press_sig(GtkWidget *da, GdkEventKey *event,
+ GtkNarrativeView *e)
{
gboolean r;
int claim = 0;
@@ -973,45 +973,45 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event,
switch ( event->keyval ) {
case GDK_KEY_Left :
- cursor_moveh(e->n, &e->cpos, -1);
+ gtknv_cursor_moveh(e->n, &e->cpos, -1);
check_cursor_visible(e);
- redraw(e);
+ gtknv_redraw(e);
claim = 1;
break;
case GDK_KEY_Right :
- cursor_moveh(e->n, &e->cpos, +1);
+ gtknv_cursor_moveh(e->n, &e->cpos, +1);
check_cursor_visible(e);
- redraw(e);
+ gtknv_redraw(e);
claim = 1;
break;
case GDK_KEY_Up :
- cursor_moveh(e->n, &e->cpos, -1);
+ gtknv_cursor_moveh(e->n, &e->cpos, -1);
check_cursor_visible(e);
- redraw(e);
+ gtknv_redraw(e);
claim = 1;
break;
case GDK_KEY_Down :
- cursor_moveh(e->n, &e->cpos, +1);
+ gtknv_cursor_moveh(e->n, &e->cpos, +1);
check_cursor_visible(e);
- redraw(e);
+ gtknv_redraw(e);
claim = 1;
break;
case GDK_KEY_Return :
- im_commit_sig(NULL, "\n", e);
+ gtknv_im_commit_sig(NULL, "\n", e);
claim = 1;
break;
case GDK_KEY_BackSpace :
- do_backspace(e, -1);
+ gtknv_do_backspace(e, -1);
claim = 1;
break;
case GDK_KEY_Delete :
- do_backspace(e, +1);
+ gtknv_do_backspace(e, +1);
claim = 1;
break;
@@ -1037,15 +1037,15 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event,
}
-static gboolean dnd_motion(GtkWidget *widget, GdkDragContext *drag_context,
- gint x, gint y, guint time, GtkNarrativeView *e)
+static gboolean gtknv_dnd_motion(GtkWidget *widget, GdkDragContext *drag_context,
+ gint x, gint y, guint time, GtkNarrativeView *e)
{
return TRUE;
}
-static gboolean dnd_drop(GtkWidget *widget, GdkDragContext *drag_context,
- gint x, gint y, guint time, GtkNarrativeView *e)
+static gboolean gtknv_dnd_drop(GtkWidget *widget, GdkDragContext *drag_context,
+ gint x, gint y, guint time, GtkNarrativeView *e)
{
GdkAtom target;
@@ -1061,21 +1061,21 @@ static gboolean dnd_drop(GtkWidget *widget, GdkDragContext *drag_context,
}
-static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context,
- gint x, gint y, GtkSelectionData *seldata,
- guint info, guint time, GtkNarrativeView *e)
+static void gtknv_dnd_receive(GtkWidget *widget, GdkDragContext *drag_context,
+ gint x, gint y, GtkSelectionData *seldata,
+ guint info, guint time, GtkNarrativeView *e)
{
}
-static void dnd_leave(GtkWidget *widget, GdkDragContext *drag_context,
- guint time, GtkNarrativeView *nview)
+static void gtknv_dnd_leave(GtkWidget *widget, GdkDragContext *drag_context,
+ guint time, GtkNarrativeView *nview)
{
- nview->drag_status = DRAG_STATUS_NONE;
+ nview->drag_status = NARRATIVE_DRAG_STATUS_NONE;
}
-static gint realise_sig(GtkWidget *da, GtkNarrativeView *e)
+static gint gtknv_realise_sig(GtkWidget *da, GtkNarrativeView *e)
{
GdkWindow *win;
@@ -1084,8 +1084,8 @@ static gint realise_sig(GtkWidget *da, GtkNarrativeView *e)
win = gtk_widget_get_window(GTK_WIDGET(e));
gtk_im_context_set_client_window(GTK_IM_CONTEXT(e->im_context), win);
gdk_window_set_accept_focus(win, TRUE);
- g_signal_connect(G_OBJECT(e->im_context), "commit", G_CALLBACK(im_commit_sig), e);
- g_signal_connect(G_OBJECT(e), "key-press-event", G_CALLBACK(key_press_sig), e);
+ g_signal_connect(G_OBJECT(e->im_context), "commit", G_CALLBACK(gtknv_im_commit_sig), e);
+ g_signal_connect(G_OBJECT(e), "key-press-event", G_CALLBACK(gtknv_key_press_sig), e);
return FALSE;
}
@@ -1109,15 +1109,15 @@ GtkWidget *gtk_narrative_view_new(Narrative *n)
nview->w, nview->h);
g_signal_connect(G_OBJECT(nview), "destroy",
- G_CALLBACK(destroy_sig), nview);
+ G_CALLBACK(gtknv_destroy_sig), nview);
g_signal_connect(G_OBJECT(nview), "realize",
- G_CALLBACK(realise_sig), nview);
+ G_CALLBACK(gtknv_realise_sig), nview);
g_signal_connect(G_OBJECT(nview), "button-press-event",
- G_CALLBACK(button_press_sig), nview);
+ G_CALLBACK(gtknv_button_press_sig), nview);
g_signal_connect(G_OBJECT(nview), "motion-notify-event",
- G_CALLBACK(motion_sig), nview);
+ G_CALLBACK(gtknv_motion_sig), nview);
g_signal_connect(G_OBJECT(nview), "configure-event",
- G_CALLBACK(resize_sig), nview);
+ G_CALLBACK(gtknv_resize_sig), nview);
/* Drag and drop */
targets[0].target = "text/uri-list";
@@ -1126,13 +1126,13 @@ GtkWidget *gtk_narrative_view_new(Narrative *n)
gtk_drag_dest_set(GTK_WIDGET(nview), 0, targets, 1,
GDK_ACTION_PRIVATE);
g_signal_connect(nview, "drag-data-received",
- G_CALLBACK(dnd_receive), nview);
+ G_CALLBACK(gtknv_dnd_receive), nview);
g_signal_connect(nview, "drag-motion",
- G_CALLBACK(dnd_motion), nview);
+ G_CALLBACK(gtknv_dnd_motion), nview);
g_signal_connect(nview, "drag-drop",
- G_CALLBACK(dnd_drop), nview);
+ G_CALLBACK(gtknv_dnd_drop), nview);
g_signal_connect(nview, "drag-leave",
- G_CALLBACK(dnd_leave), nview);
+ G_CALLBACK(gtknv_dnd_leave), nview);
gtk_widget_set_can_focus(GTK_WIDGET(nview), TRUE);
gtk_widget_add_events(GTK_WIDGET(nview),
@@ -1143,7 +1143,7 @@ GtkWidget *gtk_narrative_view_new(Narrative *n)
| GDK_SCROLL_MASK);
g_signal_connect(G_OBJECT(nview), "draw",
- G_CALLBACK(draw_sig), nview);
+ G_CALLBACK(gtknv_draw_sig), nview);
gtk_widget_grab_focus(GTK_WIDGET(nview));
@@ -1156,7 +1156,7 @@ GtkWidget *gtk_narrative_view_new(Narrative *n)
void gtk_narrative_view_set_para_highlight(GtkNarrativeView *e, int para_highlight)
{
e->para_highlight = para_highlight;
- redraw(e);
+ gtknv_redraw(e);
}
@@ -1184,7 +1184,7 @@ void gtk_narrative_view_set_cursor_para(GtkNarrativeView *e, signed int pos)
e->scroll_pos = h - (e->visible_height/2);
set_vertical_params(e);
- redraw(e);
+ gtknv_redraw(e);
}
@@ -1198,7 +1198,7 @@ void gtk_narrative_view_add_slide_at_cursor(GtkNarrativeView *e)
if ( narrative_item_is_text(e->n, e->cpos.para) ) {
size_t off = narrative_pos_trail_to_offset(e->n, e->cpos.para,
e->cpos.pos, e->cpos.trail);
- if ( (off > 0) && (off < end_offset_of_para(e->n, e->cpos.para)) ) {
+ if ( (off > 0) && (off < gtknv_end_offset_of_para(e->n, e->cpos.para)) ) {
narrative_split_item(e->n, e->cpos.para, off);
narrative_insert_slide(e->n, s, e->cpos.para+1);
} else if ( off == 0 ) {
@@ -1216,14 +1216,14 @@ void gtk_narrative_view_add_slide_at_cursor(GtkNarrativeView *e)
e->cpos.trail = 0;
update_size(e);
check_cursor_visible(e);
- emit_change_sig(e);
- redraw(e);
+ gtknv_emit_change_sig(e);
+ gtknv_redraw(e);
}
extern void gtk_narrative_view_redraw(GtkNarrativeView *e)
{
e->rewrap_needed = 1;
- emit_change_sig(e);
- redraw(e);
+ gtknv_emit_change_sig(e);
+ gtknv_redraw(e);
}
diff --git a/libstorycode/gtk/gtknarrativeview.h b/libstorycode/gtk/gtknarrativeview.h
index 910c60f..18c97bb 100644
--- a/libstorycode/gtk/gtknarrativeview.h
+++ b/libstorycode/gtk/gtknarrativeview.h
@@ -52,11 +52,11 @@
#define GTK_NARRATIVE_VIEW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), \
GTK_TYPE_NARRATIVE_VIEW, GtkNarrativeViewClass))
-enum drag_status
+enum narrative_drag_status
{
- DRAG_STATUS_NONE,
- DRAG_STATUS_COULD_DRAG,
- DRAG_STATUS_DRAGGING,
+ NARRATIVE_DRAG_STATUS_NONE,
+ NARRATIVE_DRAG_STATUS_COULD_DRAG,
+ NARRATIVE_DRAG_STATUS_DRAGGING,
};
@@ -87,7 +87,7 @@ struct _gtknarrativeview
struct edit_pos cpos;
/* Rubber band boxes and related stuff */
- enum drag_status drag_status;
+ enum narrative_drag_status drag_status;
struct edit_pos sel_start; /* Where the user dragged from */
struct edit_pos sel_end;
};
diff --git a/libstorycode/gtk/gtkslideview.c b/libstorycode/gtk/gtkslideview.c
index 6cf0ec5..6c23cad 100644
--- a/libstorycode/gtk/gtkslideview.c
+++ b/libstorycode/gtk/gtkslideview.c
@@ -53,8 +53,8 @@ static int resizable(SlideItem *item)
return 0;
}
-static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event,
- GtkSlideView *e)
+static gboolean gtksv_resize_sig(GtkWidget *widget, GdkEventConfigure *event,
+ GtkSlideView *e)
{
double sx, sy;
double aw, ah;
@@ -89,7 +89,7 @@ static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event,
}
-static void emit_change_sig(GtkSlideView *e)
+static void gtksv_emit_change_sig(GtkSlideView *e)
{
g_signal_emit_by_name(e, "changed");
}
@@ -107,7 +107,7 @@ static void gtk_slide_view_init(GtkSlideView *e)
}
-static void redraw(GtkSlideView *e)
+static void gtksv_redraw(GtkSlideView *e)
{
gint w, h;
w = gtk_widget_get_allocated_width(GTK_WIDGET(e));
@@ -116,7 +116,7 @@ static void redraw(GtkSlideView *e)
}
-static gint destroy_sig(GtkWidget *window, GtkSlideView *e)
+static gint gtksv_destroy_sig(GtkWidget *window, GtkSlideView *e)
{
return 0;
}
@@ -161,21 +161,7 @@ static void draw_resize_handle(cairo_t *cr, double x, double y)
}
-static size_t pos_trail_to_offset(SlideItem *item, int para, int run,
- size_t offs, int trail)
-{
- glong char_offs;
- char *ptr;
-
- char_offs = g_utf8_pointer_to_offset(item->paras[para].runs[run].text,
- item->paras[para].runs[run].text+offs);
- char_offs += trail;
- ptr = g_utf8_offset_to_pointer(item->paras[para].runs[run].text, char_offs);
- return ptr - item->paras[para].runs[run].text;
-}
-
-
-static double para_top(SlideItem *item, int pnum)
+static double gtksv_para_top(SlideItem *item, int pnum)
{
int i;
double py = 0.0;
@@ -188,9 +174,9 @@ static double para_top(SlideItem *item, int pnum)
}
-static int get_cursor_pos(SlideItem *item, Stylesheet *stylesheet,
- struct slide_pos cpos, double slide_w, double slide_h,
- double *x, double *y, double *h)
+static int gtksv_get_cursor_pos(SlideItem *item, Stylesheet *stylesheet,
+ struct slide_pos cpos, double slide_w, double slide_h,
+ double *x, double *y, double *h)
{
size_t offs;
PangoRectangle rect;
@@ -206,24 +192,24 @@ static int get_cursor_pos(SlideItem *item, Stylesheet *stylesheet,
slide_item_get_padding(item, stylesheet, &padl, &padr, &padt, &padb,
slide_w, slide_h);
- offs = pos_trail_to_offset(item, cpos.para, cpos.run, cpos.pos, cpos.trail);
+ offs = slide_pos_trail_to_offset(item, cpos.para, cpos.run, cpos.pos, cpos.trail);
pango_layout_get_cursor_pos(item->paras[cpos.para].layout, offs, &rect, NULL);
*x = pango_units_to_double(rect.x) + padl;
- *y = pango_units_to_double(rect.y) + para_top(item, cpos.para) + padt;
+ *y = pango_units_to_double(rect.y) + gtksv_para_top(item, cpos.para) + padt;
*h = pango_units_to_double(rect.height);
return 0;
}
-static void draw_caret(cairo_t *cr, Stylesheet *stylesheet,
- SlideItem *item, struct slide_pos cpos,
- double frx, double fry, double slide_w, double slide_h)
+static void gtksv_draw_caret(cairo_t *cr, Stylesheet *stylesheet,
+ SlideItem *item, struct slide_pos cpos,
+ double frx, double fry, double slide_w, double slide_h)
{
double cx, clow, chigh, h;
const double t = 1.8;
- if ( get_cursor_pos(item, stylesheet, cpos, slide_w, slide_h,
- &cx, &clow, &h) ) return;
+ if ( gtksv_get_cursor_pos(item, stylesheet, cpos, slide_w, slide_h,
+ &cx, &clow, &h) ) return;
cx += frx;
clow += fry;
@@ -248,7 +234,7 @@ static void draw_caret(cairo_t *cr, Stylesheet *stylesheet,
}
-static void draw_overlay(cairo_t *cr, GtkSlideView *e)
+static void gtksv_draw_overlay(cairo_t *cr, GtkSlideView *e)
{
if ( e->cursor_frame != NULL ) {
@@ -272,13 +258,13 @@ static void draw_overlay(cairo_t *cr, GtkSlideView *e)
}
if ( e->cursor_frame->type != SLIDE_ITEM_IMAGE ) {
- draw_caret(cr, stylesheet, e->cursor_frame, e->cpos, x, y,
- slide_w, slide_h);
+ gtksv_draw_caret(cr, stylesheet, e->cursor_frame, e->cpos, x, y,
+ slide_w, slide_h);
}
}
- if ( e->drag_status == DRAG_STATUS_DRAGGING ) {
+ if ( e->drag_status == SLIDE_DRAG_STATUS_DRAGGING ) {
if ( (e->drag_reason == DRAG_REASON_CREATE)
|| (e->drag_reason == DRAG_REASON_IMPORT) )
@@ -307,7 +293,7 @@ static void draw_overlay(cairo_t *cr, GtkSlideView *e)
}
-static gboolean draw_sig(GtkWidget *da, cairo_t *cr, GtkSlideView *e)
+static gboolean gtksv_draw_sig(GtkWidget *da, cairo_t *cr, GtkSlideView *e)
{
PangoContext *pc;
@@ -336,7 +322,7 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, GtkSlideView *e)
g_object_unref(pc);
/* Editing overlay */
- draw_overlay(cr, e);
+ gtksv_draw_overlay(cr, e);
return FALSE;
}
@@ -531,9 +517,9 @@ static int is_text(enum slide_item_type type)
}
-static int find_cursor(SlideItem *item, Stylesheet *stylesheet,
- double x, double y, struct slide_pos *pos,
- double slide_w, double slide_h)
+static int gtksv_find_cursor(SlideItem *item, Stylesheet *stylesheet,
+ double x, double y, struct slide_pos *pos,
+ double slide_w, double slide_h)
{
double cur_y = 0.0;
double top;
@@ -577,7 +563,7 @@ static int find_cursor(SlideItem *item, Stylesheet *stylesheet,
}
-static void unset_selection(GtkSlideView *e)
+static void gtksv_unset_selection(GtkSlideView *e)
{
e->sel_start.para = 0;
e->sel_start.pos = 0;
@@ -634,12 +620,12 @@ static void do_resize(GtkSlideView *e, double x, double y, double w, double h)
e->cursor_frame->geom.h.len = h;
}
- redraw(e);
+ gtksv_redraw(e);
}
-static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event,
- GtkSlideView *e)
+static gboolean gtksv_button_press_sig(GtkWidget *da, GdkEventButton *event,
+ GtkSlideView *e)
{
enum drag_corner c;
gdouble x, y;
@@ -687,27 +673,27 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event,
(e->cursor_frame->type == SLIDE_ITEM_IMAGE),
x, y);
- e->drag_status = DRAG_STATUS_COULD_DRAG;
+ e->drag_status = SLIDE_DRAG_STATUS_COULD_DRAG;
e->drag_reason = DRAG_REASON_RESIZE;
} else {
/* Position cursor and prepare for possible drag */
e->cursor_frame = clicked;
- find_cursor(clicked, stylesheet, x-frx, y-fry, &e->cpos,
- slide_w, slide_h);
+ gtksv_find_cursor(clicked, stylesheet, x-frx, y-fry, &e->cpos,
+ slide_w, slide_h);
e->start_corner_x = x;
e->start_corner_y = y;
if ( resizable(clicked) && shift ) {
- e->drag_status = DRAG_STATUS_COULD_DRAG;
+ e->drag_status = SLIDE_DRAG_STATUS_COULD_DRAG;
e->drag_reason = DRAG_REASON_MOVE;
} else {
- e->drag_status = DRAG_STATUS_COULD_DRAG;
+ e->drag_status = SLIDE_DRAG_STATUS_COULD_DRAG;
e->drag_reason = DRAG_REASON_TEXTSEL;
- find_cursor(clicked, stylesheet, x-frx, y-fry,
- &e->sel_start, slide_w, slide_h);
+ gtksv_find_cursor(clicked, stylesheet, x-frx, y-fry,
+ &e->sel_start, slide_w, slide_h);
e->sel_end = e->sel_start;
}
@@ -718,41 +704,41 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event,
/* Clicked no object. Deselect old object.
* If shift held, set up for creating a new one. */
e->cursor_frame = NULL;
- unset_selection(e);
+ gtksv_unset_selection(e);
if ( shift ) {
e->start_corner_x = x;
e->start_corner_y = y;
- e->drag_status = DRAG_STATUS_COULD_DRAG;
+ e->drag_status = SLIDE_DRAG_STATUS_COULD_DRAG;
e->drag_reason = DRAG_REASON_CREATE;
} else {
- e->drag_status = DRAG_STATUS_NONE;
+ e->drag_status = SLIDE_DRAG_STATUS_NONE;
e->drag_reason = DRAG_REASON_NONE;
}
} else {
/* Clicked an existing frame, no immediate dragging */
- e->drag_status = DRAG_STATUS_COULD_DRAG;
+ e->drag_status = SLIDE_DRAG_STATUS_COULD_DRAG;
e->drag_reason = DRAG_REASON_TEXTSEL;
- unset_selection(e);
- find_cursor(clicked, stylesheet, x-frx, y-fry, &e->sel_start,
- slide_w, slide_h);
- find_cursor(clicked, stylesheet, x-frx, y-fry, &e->sel_end,
- slide_w, slide_h);
+ gtksv_unset_selection(e);
+ gtksv_find_cursor(clicked, stylesheet, x-frx, y-fry, &e->sel_start,
+ slide_w, slide_h);
+ gtksv_find_cursor(clicked, stylesheet, x-frx, y-fry, &e->sel_end,
+ slide_w, slide_h);
e->cursor_frame = clicked;
- find_cursor(clicked, stylesheet, x-frx, y-fry, &e->cpos,
- slide_w, slide_h);
+ gtksv_find_cursor(clicked, stylesheet, x-frx, y-fry, &e->cpos,
+ slide_w, slide_h);
}
gtk_widget_grab_focus(GTK_WIDGET(da));
- redraw(e);
+ gtksv_redraw(e);
return FALSE;
}
-static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, GtkSlideView *e)
+static gboolean gtksv_motion_sig(GtkWidget *da, GdkEventMotion *event, GtkSlideView *e)
{
gdouble x, y;
double frx, fry, frw, frh;
@@ -767,11 +753,11 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, GtkSlideView *e
stylesheet = narrative_get_stylesheet(e->n);
slide_get_logical_size(e->slide, stylesheet, &slide_w, &slide_h);
- if ( e->drag_status == DRAG_STATUS_COULD_DRAG ) {
+ if ( e->drag_status == SLIDE_DRAG_STATUS_COULD_DRAG ) {
/* We just got a motion signal, and the status was "could drag",
* therefore the drag has started. */
- e->drag_status = DRAG_STATUS_DRAGGING;
+ e->drag_status = SLIDE_DRAG_STATUS_DRAGGING;
}
@@ -788,7 +774,7 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, GtkSlideView *e
case DRAG_REASON_CREATE :
e->drag_corner_x = x;
e->drag_corner_y = y;
- redraw(e);
+ gtksv_redraw(e);
break;
case DRAG_REASON_IMPORT :
@@ -799,7 +785,7 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, GtkSlideView *e
calculate_box_size(frx, fry, frw, frh, e,
(e->cursor_frame->type == SLIDE_ITEM_IMAGE),
x, y);
- redraw(e);
+ gtksv_redraw(e);
break;
case DRAG_REASON_MOVE :
@@ -807,13 +793,14 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, GtkSlideView *e
e->box_y = (fry - e->start_corner_y) + y;
e->box_width = frw;
e->box_height = frh;
- redraw(e);
+ gtksv_redraw(e);
break;
case DRAG_REASON_TEXTSEL :
- find_cursor(e->cursor_frame, stylesheet, x-frx, y-fry, &e->sel_end, slide_w, slide_h);
+ gtksv_find_cursor(e->cursor_frame, stylesheet, x-frx, y-fry,
+ &e->sel_end, slide_w, slide_h);
e->cpos = e->sel_end;
- redraw(e);
+ gtksv_redraw(e);
break;
}
@@ -875,8 +862,8 @@ static SlideItem *create_frame(GtkSlideView *e, double cx, double cy,
}
-static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event,
- GtkSlideView *e)
+static gboolean gtksv_button_release_sig(GtkWidget *da, GdkEventButton *event,
+ GtkSlideView *e)
{
gdouble x, y;
SlideItem *fr;
@@ -887,11 +874,11 @@ static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event,
y /= e->view_scale;
/* Not dragging? Then I don't care. */
- if ( e->drag_status != DRAG_STATUS_DRAGGING ) return FALSE;
+ if ( e->drag_status != SLIDE_DRAG_STATUS_DRAGGING ) return FALSE;
e->drag_corner_x = x;
e->drag_corner_y = y;
- e->drag_status = DRAG_STATUS_NONE;
+ e->drag_status = SLIDE_DRAG_STATUS_NONE;
switch ( e->drag_reason )
{
@@ -909,7 +896,7 @@ static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event,
e->cpos.para = 0;
e->cpos.pos = 0;
e->cpos.trail = 0;
- unset_selection(e);
+ gtksv_unset_selection(e);
} else {
fprintf(stderr, _("Failed to create frame!\n"));
}
@@ -936,12 +923,12 @@ static gboolean button_release_sig(GtkWidget *da, GdkEventButton *event,
e->drag_reason = DRAG_REASON_NONE;
gtk_widget_grab_focus(GTK_WIDGET(da));
- redraw(e);
+ gtksv_redraw(e);
return FALSE;
}
-static size_t end_offset_of_para(SlideItem *item, int pnum)
+static size_t gtksv_end_offset_of_para(SlideItem *item, int pnum)
{
struct slide_text_paragraph *para;
assert(pnum >= 0);
@@ -951,13 +938,13 @@ static size_t end_offset_of_para(SlideItem *item, int pnum)
}
-static void cursor_moveh(GtkSlideView *e, struct slide_pos *cp, signed int dir)
+static void gtksv_cursor_moveh(GtkSlideView *e, struct slide_pos *cp, signed int dir)
{
int np = cp->pos;
if ( !is_text(e->cursor_frame->type) ) return;
if ( e->cursor_frame->paras[e->cpos.para].layout == NULL ) return;
- unset_selection(e);
+ gtksv_unset_selection(e);
pango_layout_move_cursor_visually(e->cursor_frame->paras[e->cpos.para].layout,
1, cp->pos, cp->trail, dir,
@@ -967,7 +954,7 @@ static void cursor_moveh(GtkSlideView *e, struct slide_pos *cp, signed int dir)
if ( cp->para > 0 ) {
size_t end_offs;
cp->para--;
- end_offs = end_offset_of_para(e->cursor_frame, cp->para);
+ end_offs = gtksv_end_offset_of_para(e->cursor_frame, cp->para);
if ( end_offs > 0 ) {
cp->pos = end_offs - 1;
cp->trail = 1;
@@ -1029,7 +1016,7 @@ static void sort_slide_positions(struct slide_pos *a, struct slide_pos *b)
}
-static void do_backspace(GtkSlideView *e, signed int dir)
+static void gtksv_do_backspace(GtkSlideView *e, signed int dir)
{
/* FIXME! */
#if 0
@@ -1052,7 +1039,7 @@ static void do_backspace(GtkSlideView *e, signed int dir)
/* Delete one character, as represented visually */
p2 = e->cpos;
p1 = p2;
- cursor_moveh(e, &p1, dir);
+ gtksv_cursor_moveh(e, &p1, dir);
}
sort_slide_positions(&p1, &p2);
@@ -1060,19 +1047,19 @@ static void do_backspace(GtkSlideView *e, signed int dir)
o2 = pos_trail_to_offset(e->cursor_frame, p2.para, p1.run, p2.pos, p2.trail);
slide_item_delete_text(e->cursor_frame, p1.para, o1, p2.para, o2);
e->cpos = p1;
- unset_selection(e);
+ gtksv_unset_selection(e);
pango_layout_set_text(e->cursor_frame->paras[e->cpos.para].layout,
e->cursor_frame->paras[e->cpos.para].text, -1);
- emit_change_sig(e);
- redraw(e);
+ gtksv_emit_change_sig(e);
+ gtksv_redraw(e);
#endif
}
-static void insert_text_in_paragraph(SlideItem *item, int para,
- size_t offs, char *t)
+static void gtksv_insert_text_in_paragraph(SlideItem *item, int para,
+ size_t offs, char *t)
{
/* FIXME! */
#if 0
@@ -1088,7 +1075,7 @@ static void insert_text_in_paragraph(SlideItem *item, int para,
}
-static void insert_text(char *t, GtkSlideView *e)
+static void gtksv_insert_text(char *t, GtkSlideView *e)
{
/* FIXME! */
#if 0
@@ -1098,9 +1085,9 @@ static void insert_text(char *t, GtkSlideView *e)
if ( !is_text(e->cursor_frame->type) ) return;
if ( !slide_positions_equal(e->sel_start, e->sel_end) ) {
- do_backspace(e, 0);
+ gtksv_do_backspace(e, 0);
}
- unset_selection(e);
+ gtksv_unset_selection(e);
if ( strcmp(t, "\n") == 0 ) {
off = pos_trail_to_offset(e->cursor_frame, e->cpos.para,
@@ -1109,33 +1096,33 @@ static void insert_text(char *t, GtkSlideView *e)
e->cpos.para++;
e->cpos.pos = 0;
e->cpos.trail = 0;
- emit_change_sig(e);
- redraw(e);
+ gtksv_emit_change_sig(e);
+ gtksv_redraw(e);
return;
}
off = pos_trail_to_offset(e->cursor_frame, e->cpos.para,
e->cpos.pos, e->cpos.trail);
- insert_text_in_paragraph(e->cursor_frame, e->cpos.para, off, t);
+ gtksv_insert_text_in_paragraph(e->cursor_frame, e->cpos.para, off, t);
pango_layout_set_text(e->cursor_frame->paras[e->cpos.para].layout,
e->cursor_frame->paras[e->cpos.para].text, -1);
- cursor_moveh(e, &e->cpos, +1);
- emit_change_sig(e);
- redraw(e);
+ gtksv_cursor_moveh(e, &e->cpos, +1);
+ gtksv_emit_change_sig(e);
+ gtksv_redraw(e);
#endif
}
-static gboolean im_commit_sig(GtkIMContext *im, gchar *str,
- GtkSlideView *e)
+static gboolean gtksv_im_commit_sig(GtkIMContext *im, gchar *str,
+ GtkSlideView *e)
{
- insert_text(str, e);
+ gtksv_insert_text(str, e);
return FALSE;
}
-static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event,
- GtkSlideView *e)
+static gboolean gtksv_key_press_sig(GtkWidget *da, GdkEventKey *event,
+ GtkSlideView *e)
{
gboolean r;
int claim = 0;
@@ -1150,41 +1137,41 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event,
switch ( event->keyval ) {
case GDK_KEY_Left :
- cursor_moveh(e, &e->cpos, -1);
- redraw(e);
+ gtksv_cursor_moveh(e, &e->cpos, -1);
+ gtksv_redraw(e);
claim = 1;
break;
case GDK_KEY_Right :
- cursor_moveh(e, &e->cpos, +1);
- redraw(e);
+ gtksv_cursor_moveh(e, &e->cpos, +1);
+ gtksv_redraw(e);
claim = 1;
break;
case GDK_KEY_Up :
- cursor_moveh(e, &e->cpos, -1);
- redraw(e);
+ gtksv_cursor_moveh(e, &e->cpos, -1);
+ gtksv_redraw(e);
claim = 1;
break;
case GDK_KEY_Down :
- cursor_moveh(e, &e->cpos, +1);
- redraw(e);
+ gtksv_cursor_moveh(e, &e->cpos, +1);
+ gtksv_redraw(e);
claim = 1;
break;
case GDK_KEY_Return :
- im_commit_sig(NULL, "\n", e);
+ gtksv_im_commit_sig(NULL, "\n", e);
claim = 1;
break;
case GDK_KEY_BackSpace :
- do_backspace(e, -1);
+ gtksv_do_backspace(e, -1);
claim = 1;
break;
case GDK_KEY_Delete :
- do_backspace(e, +1);
+ gtksv_do_backspace(e, +1);
claim = 1;
break;
@@ -1199,10 +1186,10 @@ void gtk_slide_view_delete_selected_frame(GtkSlideView *e)
{
if ( e->cursor_frame == NULL ) return;
slide_delete_item(e->slide, e->cursor_frame);
- unset_selection(e);
+ gtksv_unset_selection(e);
e->cursor_frame = NULL;
- emit_change_sig(e);
- redraw(e);
+ gtksv_emit_change_sig(e);
+ gtksv_redraw(e);
}
@@ -1234,7 +1221,7 @@ static gboolean dnd_motion(GtkWidget *widget, GdkDragContext *drag_context,
e->drag_corner_x = x + e->import_width/2.0;
e->drag_corner_y = y + e->import_height/2.0;
- redraw(e);
+ gtksv_redraw(e);
}
@@ -1348,7 +1335,7 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context,
gtk_drag_unhighlight(widget);
e->drag_highlight = 0;
}
- e->drag_status = DRAG_STATUS_NONE;
+ e->drag_status = SLIDE_DRAG_STATUS_NONE;
e->drag_reason = DRAG_REASON_NONE;
e->import_acceptable = 0;
@@ -1365,7 +1352,7 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context,
check_import_size(e);
e->drag_reason = DRAG_REASON_IMPORT;
- e->drag_status = DRAG_STATUS_DRAGGING;
+ e->drag_status = SLIDE_DRAG_STATUS_DRAGGING;
}
@@ -1394,7 +1381,7 @@ static void dnd_receive(GtkWidget *widget, GdkDragContext *drag_context,
e->start_corner_x, e->start_corner_y,
w, h);
free(filename);
- redraw(e);
+ gtksv_redraw(e);
} else {
@@ -1414,12 +1401,12 @@ static void dnd_leave(GtkWidget *widget, GdkDragContext *drag_context,
}
e->have_drag_data = 0;
e->drag_highlight = 0;
- e->drag_status = DRAG_STATUS_NONE;
+ e->drag_status = SLIDE_DRAG_STATUS_NONE;
e->drag_reason = DRAG_REASON_NONE;
}
-static gint realise_sig(GtkWidget *da, GtkSlideView *e)
+static gint gtksv_realise_sig(GtkWidget *da, GtkSlideView *e)
{
GdkWindow *win;
@@ -1428,8 +1415,8 @@ static gint realise_sig(GtkWidget *da, GtkSlideView *e)
win = gtk_widget_get_window(GTK_WIDGET(e));
gtk_im_context_set_client_window(GTK_IM_CONTEXT(e->im_context), win);
gdk_window_set_accept_focus(win, TRUE);
- g_signal_connect(G_OBJECT(e->im_context), "commit", G_CALLBACK(im_commit_sig), e);
- g_signal_connect(G_OBJECT(e), "key-press-event", G_CALLBACK(key_press_sig), e);
+ g_signal_connect(G_OBJECT(e->im_context), "commit", G_CALLBACK(gtksv_im_commit_sig), e);
+ g_signal_connect(G_OBJECT(e), "key-press-event", G_CALLBACK(gtksv_key_press_sig), e);
return FALSE;
}
@@ -1445,9 +1432,9 @@ void gtk_slide_view_set_slide(GtkWidget *widget, Slide *slide)
{
GtkSlideView *e = GTK_SLIDE_VIEW(widget);
e->slide = slide;
- unset_selection(e);
+ gtksv_unset_selection(e);
e->cursor_frame = NULL;
- redraw(e);
+ gtksv_redraw(e);
}
@@ -1482,17 +1469,17 @@ GtkWidget *gtk_slide_view_new(Narrative *n, Slide *slide)
sv->w, sv->h);
g_signal_connect(G_OBJECT(sv), "destroy",
- G_CALLBACK(destroy_sig), sv);
+ G_CALLBACK(gtksv_destroy_sig), sv);
g_signal_connect(G_OBJECT(sv), "realize",
- G_CALLBACK(realise_sig), sv);
+ G_CALLBACK(gtksv_realise_sig), sv);
g_signal_connect(G_OBJECT(sv), "button-press-event",
- G_CALLBACK(button_press_sig), sv);
+ G_CALLBACK(gtksv_button_press_sig), sv);
g_signal_connect(G_OBJECT(sv), "button-release-event",
- G_CALLBACK(button_release_sig), sv);
+ G_CALLBACK(gtksv_button_release_sig), sv);
g_signal_connect(G_OBJECT(sv), "motion-notify-event",
- G_CALLBACK(motion_sig), sv);
+ G_CALLBACK(gtksv_motion_sig), sv);
g_signal_connect(G_OBJECT(sv), "configure-event",
- G_CALLBACK(resize_sig), sv);
+ G_CALLBACK(gtksv_resize_sig), sv);
/* Drag and drop */
targets[0].target = "text/uri-list";
@@ -1518,7 +1505,7 @@ GtkWidget *gtk_slide_view_new(Narrative *n, Slide *slide)
| GDK_SCROLL_MASK);
g_signal_connect(G_OBJECT(sv), "draw",
- G_CALLBACK(draw_sig), sv);
+ G_CALLBACK(gtksv_draw_sig), sv);
gtk_widget_grab_focus(GTK_WIDGET(sv));
diff --git a/libstorycode/gtk/gtkslideview.h b/libstorycode/gtk/gtkslideview.h
index 4b891a7..a3dadff 100644
--- a/libstorycode/gtk/gtkslideview.h
+++ b/libstorycode/gtk/gtkslideview.h
@@ -76,11 +76,11 @@ enum drag_corner
};
-enum drag_status
+enum slide_drag_status
{
- DRAG_STATUS_NONE,
- DRAG_STATUS_COULD_DRAG,
- DRAG_STATUS_DRAGGING,
+ SLIDE_DRAG_STATUS_NONE,
+ SLIDE_DRAG_STATUS_COULD_DRAG,
+ SLIDE_DRAG_STATUS_DRAGGING,
};
@@ -125,7 +125,7 @@ struct _gtkslideview
double box_width;
double box_height;
enum drag_reason drag_reason;
- enum drag_status drag_status;
+ enum slide_drag_status drag_status;
enum drag_corner drag_corner;
struct slide_pos sel_start; /* Where the user dragged from */
struct slide_pos sel_end;
diff --git a/libstorycode/narrative.c b/libstorycode/narrative.c
index fe74288..303e31a 100644
--- a/libstorycode/narrative.c
+++ b/libstorycode/narrative.c
@@ -342,7 +342,7 @@ static void delete_text(struct narrative_item *item, size_t o1, ssize_t o2)
int r1, r2;
size_t roffs1, roffs2;
- r1 = which_run(item, o1, &roffs1);
+ r1 = narrative_which_run(item, o1, &roffs1);
/* This means 'delete to end' */
if ( o2 == -1 ) {
@@ -353,7 +353,7 @@ static void delete_text(struct narrative_item *item, size_t o1, ssize_t o2)
}
}
- r2 = which_run(item, o2, &roffs2);
+ r2 = narrative_which_run(item, o2, &roffs2);
if ( r1 == r2 ) {
@@ -459,7 +459,7 @@ void narrative_delete_block(Narrative *n, int i1, size_t o1, int i2, size_t o2)
}
-int which_run(struct narrative_item *item, size_t item_offs, size_t *run_offs)
+int narrative_which_run(struct narrative_item *item, size_t item_offs, size_t *run_offs)
{
int run;
size_t pos = 0;
@@ -487,7 +487,7 @@ void narrative_split_item(Narrative *n, int i1, size_t o1)
if ( narrative_item_is_text(n, i1) ) {
size_t run_offs;
- int run = which_run(item1, o1, &run_offs);
+ int run = narrative_which_run(item1, o1, &run_offs);
int j;
item2->n_runs = item1->n_runs - run;
diff --git a/libstorycode/narrative_priv.h b/libstorycode/narrative_priv.h
index dcf8831..fafaa59 100644
--- a/libstorycode/narrative_priv.h
+++ b/libstorycode/narrative_priv.h
@@ -97,7 +97,7 @@ struct _narrative
double space_b;
};
-extern int which_run(struct narrative_item *item, size_t item_offs, size_t *run_offs);
+extern int narrative_which_run(struct narrative_item *item, size_t item_offs, size_t *run_offs);
#endif /* NARRATIVE_PRIV_H */
diff --git a/libstorycode/narrative_render_cairo.c b/libstorycode/narrative_render_cairo.c
index 894c730..63f0865 100644
--- a/libstorycode/narrative_render_cairo.c
+++ b/libstorycode/narrative_render_cairo.c
@@ -49,7 +49,7 @@
const double dummy_h_val = 1024.0;
-static double lcalc(struct length l, double pd)
+static double narrative_lcalc(struct length l, double pd)
{
if ( l.unit == LENGTH_UNIT ) {
return l.len;
@@ -59,17 +59,6 @@ static double lcalc(struct length l, double pd)
}
-static PangoAlignment to_pangoalignment(enum alignment align)
-{
- switch ( align ) {
- case ALIGN_LEFT : return PANGO_ALIGN_LEFT;
- case ALIGN_RIGHT : return PANGO_ALIGN_RIGHT;
- case ALIGN_CENTER : return PANGO_ALIGN_CENTER;
- default: return PANGO_ALIGN_LEFT;
- }
-}
-
-
static void wrap_text(struct narrative_item *item, PangoContext *pc,
Stylesheet *ss, const char *stn, double w,
size_t sel_start, size_t sel_end)
@@ -207,7 +196,7 @@ size_t narrative_pos_trail_to_offset(Narrative *n, int i, int offs, int trail)
if ( !narrative_item_is_text(n, i) ) return offs;
- run = which_run(item, offs, &run_offs);
+ run = narrative_which_run(item, offs, &run_offs);
char_offs = g_utf8_pointer_to_offset(item->runs[run].text,
item->runs[run].text+run_offs);
@@ -270,10 +259,10 @@ int narrative_wrap_range(Narrative *n, Stylesheet *stylesheet, PangoLanguage *la
struct length paraspace[4];
if ( stylesheet_get_padding(stylesheet, "NARRATIVE", pad) ) return 1;
- n->space_l = lcalc(pad[0], w);
- n->space_r = lcalc(pad[1], w);
- n->space_t = lcalc(pad[2], dummy_h_val);
- n->space_b = lcalc(pad[3], dummy_h_val);
+ n->space_l = narrative_lcalc(pad[0], w);
+ n->space_r = narrative_lcalc(pad[1], w);
+ n->space_t = narrative_lcalc(pad[2], dummy_h_val);
+ n->space_b = narrative_lcalc(pad[3], dummy_h_val);
n->w = w;
w -= n->space_l + n->space_r;
@@ -345,10 +334,10 @@ int narrative_wrap_range(Narrative *n, Stylesheet *stylesheet, PangoLanguage *la
}
if ( stylesheet_get_paraspace(stylesheet, stn, paraspace) == 0 ) {
- n->items[i].space_l = lcalc(paraspace[0], w);
- n->items[i].space_r = lcalc(paraspace[1], w);
- n->items[i].space_t = lcalc(paraspace[2], dummy_h_val);
- n->items[i].space_b = lcalc(paraspace[3], dummy_h_val);
+ n->items[i].space_l = narrative_lcalc(paraspace[0], w);
+ n->items[i].space_r = narrative_lcalc(paraspace[1], w);
+ n->items[i].space_t = narrative_lcalc(paraspace[2], dummy_h_val);
+ n->items[i].space_b = narrative_lcalc(paraspace[3], dummy_h_val);
}
switch ( n->items[i].type ) {
diff --git a/libstorycode/render_cairo_common.c b/libstorycode/render_cairo_common.c
index b3883c9..d2b3338 100644
--- a/libstorycode/render_cairo_common.c
+++ b/libstorycode/render_cairo_common.c
@@ -95,3 +95,14 @@ int runs_to_pangolayout(PangoLayout *layout, struct text_run *runs, int n_runs)
return 0;
}
+
+
+PangoAlignment to_pangoalignment(enum alignment align)
+{
+ switch ( align ) {
+ case ALIGN_LEFT : return PANGO_ALIGN_LEFT;
+ case ALIGN_RIGHT : return PANGO_ALIGN_RIGHT;
+ case ALIGN_CENTER : return PANGO_ALIGN_CENTER;
+ default: return PANGO_ALIGN_LEFT;
+ }
+}
diff --git a/libstorycode/render_cairo_common.h b/libstorycode/render_cairo_common.h
index 69272ef..5a415a6 100644
--- a/libstorycode/render_cairo_common.h
+++ b/libstorycode/render_cairo_common.h
@@ -32,5 +32,6 @@
#include "storycode.h"
extern int runs_to_pangolayout(PangoLayout *layout, struct text_run *runs, int n_runs);
+extern PangoAlignment to_pangoalignment(enum alignment align);
#endif /* RENDER_CAIRO_COMMON_H */
diff --git a/libstorycode/slide_render_cairo.c b/libstorycode/slide_render_cairo.c
index 6a27787..e68e51e 100644
--- a/libstorycode/slide_render_cairo.c
+++ b/libstorycode/slide_render_cairo.c
@@ -46,7 +46,7 @@
#include "slide_priv.h"
-static double lcalc(struct length l, double pd)
+static double slide_lcalc(struct length l, double pd)
{
if ( l.unit == LENGTH_UNIT ) {
return l.len;
@@ -56,17 +56,6 @@ static double lcalc(struct length l, double pd)
}
-static PangoAlignment to_pangoalignment(enum alignment align)
-{
- switch ( align ) {
- case ALIGN_LEFT : return PANGO_ALIGN_LEFT;
- case ALIGN_RIGHT : return PANGO_ALIGN_RIGHT;
- case ALIGN_CENTER : return PANGO_ALIGN_CENTER;
- default: return PANGO_ALIGN_LEFT;
- }
-}
-
-
static int slide_positions_equal(struct slide_pos a, struct slide_pos b)
{
if ( a.para != b.para ) return 0;
@@ -76,8 +65,8 @@ static int slide_positions_equal(struct slide_pos a, struct slide_pos b)
}
-static size_t pos_trail_to_offset(SlideItem *item, int para, int run,
- size_t offs, int trail)
+size_t slide_pos_trail_to_offset(SlideItem *item, int para, int run,
+ size_t offs, int trail)
{
glong char_offs;
char *ptr;
@@ -168,15 +157,15 @@ static void render_text(SlideItem *item, cairo_t *cr, PangoContext *pc,
} else {
stylesheet_get_geometry(ss, stn, &geom);
}
- x = lcalc(geom.x, parent_w);
- y = lcalc(geom.y, parent_h);
- w = lcalc(geom.w, parent_w);
- h = lcalc(geom.h, parent_h);
+ x = slide_lcalc(geom.x, parent_w);
+ y = slide_lcalc(geom.y, parent_h);
+ w = slide_lcalc(geom.w, parent_w);
+ h = slide_lcalc(geom.h, parent_h);
if ( stylesheet_get_padding(ss, stn, pad) ) return;
- pad_l = lcalc(pad[0], parent_w);
- pad_r = lcalc(pad[1], parent_w);
- pad_t = lcalc(pad[2], parent_h);
+ pad_l = slide_lcalc(pad[0], parent_w);
+ pad_r = slide_lcalc(pad[1], parent_w);
+ pad_t = slide_lcalc(pad[2], parent_h);
font = stylesheet_get_font(ss, stn, &fgcol, &align);
if ( font == NULL ) return;
@@ -192,10 +181,10 @@ static void render_text(SlideItem *item, cairo_t *cr, PangoContext *pc,
}
if ( !slide_positions_equal(sel_start, sel_end) ) {
- sel_s = pos_trail_to_offset(item, sel_start.para, sel_start.run,
- sel_start.pos, sel_start.trail);
- sel_e = pos_trail_to_offset(item, sel_end.para, sel_end.run,
- sel_end.pos, sel_end.trail);
+ sel_s = slide_pos_trail_to_offset(item, sel_start.para, sel_start.run,
+ sel_start.pos, sel_start.trail);
+ sel_e = slide_pos_trail_to_offset(item, sel_end.para, sel_end.run,
+ sel_end.pos, sel_end.trail);
} else {
sel_s = 0;
sel_e = 0;
@@ -204,10 +193,10 @@ static void render_text(SlideItem *item, cairo_t *cr, PangoContext *pc,
do_background(ss, stn, cr, x, y, w, h);
if ( stylesheet_get_paraspace(ss, stn, paraspacel) == 0 ) {
- paraspace[0] = lcalc(paraspacel[0], w);
- paraspace[1] = lcalc(paraspacel[1], w);
- paraspace[2] = lcalc(paraspacel[2], h);
- paraspace[3] = lcalc(paraspacel[3], h);
+ paraspace[0] = slide_lcalc(paraspacel[0], w);
+ paraspace[1] = slide_lcalc(paraspacel[1], w);
+ paraspace[2] = slide_lcalc(paraspacel[2], h);
+ paraspace[3] = slide_lcalc(paraspacel[3], h);
} else {
paraspace[0] = 0.0;
paraspace[1] = 0.0;
@@ -293,10 +282,10 @@ static void render_image(SlideItem *item, cairo_t *cr,
double wd, hd;
cairo_surface_t *surf;
- x = lcalc(item->geom.x, parent_w);
- y = lcalc(item->geom.y, parent_h);
- w = lcalc(item->geom.w, parent_w);
- h = lcalc(item->geom.h, parent_h);
+ x = slide_lcalc(item->geom.x, parent_w);
+ y = slide_lcalc(item->geom.y, parent_h);
+ w = slide_lcalc(item->geom.w, parent_w);
+ h = slide_lcalc(item->geom.h, parent_h);
wd = w; hd = h;
cairo_user_to_device_distance(cr, &wd, &hd);
diff --git a/libstorycode/slide_render_cairo.h b/libstorycode/slide_render_cairo.h
index 9587007..f90a27c 100644
--- a/libstorycode/slide_render_cairo.h
+++ b/libstorycode/slide_render_cairo.h
@@ -45,4 +45,6 @@ extern int slide_render_cairo(Slide *s, cairo_t *cr, ImageStore *is, Stylesheet
extern int render_slides_to_pdf(Narrative *n, ImageStore *is, const char *filename);
+extern size_t slide_pos_trail_to_offset(SlideItem *item, int para_num, int run, size_t offs, int trail);
+
#endif /* RENDER_H */
diff --git a/libstorycode/storycode.l b/libstorycode/storycode.l
index 2e063f8..e7c4d15 100644
--- a/libstorycode/storycode.l
+++ b/libstorycode/storycode.l
@@ -35,19 +35,19 @@
%option prefix="sc"
%option noyywrap nounput noinput
-%s geom
-%s font
-%s filename
-%s paraspace
-%s pad
-%s align
-%s col
-%s sqb
-%x stringesc
-%x runtext
-%x prerun
-%s image
-%s image_filename
+%s cond_geom
+%s cond_font
+%s cond_filename
+%s cond_paraspace
+%s cond_pad
+%s cond_align
+%s cond_col
+%s cond_sqb
+%x cond_stringesc
+%x cond_runtext
+%x cond_prerun
+%s cond_image
+%s cond_image_filename
%%
@@ -58,51 +58,51 @@ NARRATIVE { return SC_NARRATIVE; }
SLIDE { return SC_SLIDE; }
ENDOFPRESENTATION { return SC_EOP; }
BP { return SC_BP; }
-GEOMETRY { BEGIN(geom); return SC_GEOMETRY; }
+GEOMETRY { BEGIN(cond_geom); return SC_GEOMETRY; }
TEXT { return SC_TEXTFRAME; }
FOOTER { return SC_FOOTER; }
-FONT[ ] { BEGIN(font); return SC_FONT; }
-PAD { BEGIN(pad); return SC_PAD; }
-PARASPACE { BEGIN(paraspace); return SC_PARASPACE; }
-ALIGN { BEGIN(align); return SC_ALIGN; }
-FGCOL { BEGIN(col); return SC_FGCOL; }
-BGCOL { BEGIN(col); return SC_BGCOL; }
-<col>VERT { return SC_VERT; }
-<col>VERTICAL { return SC_VERT; }
-<col>HORIZ { return SC_HORIZ; }
-<col>HORIZONTAL { return SC_HORIZ; }
-<align,sqb>(?i:left) { return SC_LEFT; }
-<align,sqb>(?i:center) { return SC_CENTER; }
-<align,sqb>(?i:right) { return SC_RIGHT; }
+FONT[ ] { BEGIN(cond_font); return SC_FONT; }
+PAD { BEGIN(cond_pad); return SC_PAD; }
+PARASPACE { BEGIN(cond_paraspace); return SC_PARASPACE; }
+ALIGN { BEGIN(cond_align); return SC_ALIGN; }
+FGCOL { BEGIN(cond_col); return SC_FGCOL; }
+BGCOL { BEGIN(cond_col); return SC_BGCOL; }
+<cond_col>VERT { return SC_VERT; }
+<cond_col>VERTICAL { return SC_VERT; }
+<cond_col>HORIZ { return SC_HORIZ; }
+<cond_col>HORIZONTAL { return SC_HORIZ; }
+<cond_align,cond_sqb>(?i:left) { return SC_LEFT; }
+<cond_align,cond_sqb>(?i:center) { return SC_CENTER; }
+<cond_align,cond_sqb>(?i:right) { return SC_RIGHT; }
-<font>.*\n { sclval.str = strdup(yytext);
+<cond_font>.*\n { sclval.str = strdup(yytext);
sclval.str[yyleng-1] = '\0';
BEGIN(0);
lineno++;
return SC_FONTNAME; }
-<INITIAL>IMAGE { BEGIN(image); return SC_IMAGEFRAME; }
-<image>:[ ] { BEGIN(image_filename); return SC_TEXT_START; }
-<image_filename>[^\n]* { sclval.str = strdup(yytext);
+<INITIAL>IMAGE { BEGIN(cond_image); return SC_IMAGEFRAME; }
+<cond_image>:[ ] { BEGIN(cond_image_filename); return SC_TEXT_START; }
+<cond_image_filename>[^\n]* { sclval.str = strdup(yytext);
lineno++;
return SC_FILENAME; }
-<INITIAL>: { BEGIN(prerun); return SC_TEXT_START; }
-<prerun>[ ] { BEGIN(runtext); }
-<runtext>[\\] { BEGIN(stringesc); }
-<stringesc>. { sclval.str = strdup(yytext); BEGIN(runtext); return SC_RUN_TEXT; }
-<runtext>[\*] { return '*'; }
-<runtext>[/] { return '/'; }
-<runtext>[_] { return '_'; }
-<runtext>[^\\\*/_\n]* { sclval.str = strdup(yytext);
+<INITIAL>: { BEGIN(cond_prerun); return SC_TEXT_START; }
+<cond_prerun>[ ] { BEGIN(cond_runtext); }
+<cond_runtext>[\\] { BEGIN(cond_stringesc); }
+<cond_stringesc>. { sclval.str = strdup(yytext); BEGIN(cond_runtext); return SC_RUN_TEXT; }
+<cond_runtext>[\*] { return '*'; }
+<cond_runtext>[/] { return '/'; }
+<cond_runtext>[_] { return '_'; }
+<cond_runtext>[^\\\*/_\n]* { sclval.str = strdup(yytext);
sclval.str[yyleng] = '\0';
return SC_RUN_TEXT; }
-<runtext>\n { BEGIN(0); lineno++; }
-<prerun>\n { BEGIN(0); lineno++; }
+<cond_runtext>\n { BEGIN(0); lineno++; }
+<cond_prerun>\n { BEGIN(0); lineno++; }
\n { BEGIN(0); lineno++; }
-"[" { sqb_caller = YY_START; BEGIN(sqb); return '['; }
+"[" { sqb_caller = YY_START; BEGIN(cond_sqb); return '['; }
"]" { BEGIN(sqb_caller); return ']'; }
[{] { return '{'; }
[}] { return '}'; }
@@ -112,7 +112,7 @@ BGCOL { BEGIN(col); return SC_BGCOL; }
[+] { return '+'; }
[x] { return 'x'; }
[,] { return ','; }
-<col>#[[:xdigit:]]{6} { sclval.str = strdup(yytext); return SC_HEXCOL; }
+<cond_col>#[[:xdigit:]]{6} { sclval.str = strdup(yytext); return SC_HEXCOL; }
%%
diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y
index fe14ed2..587db4a 100644
--- a/libstorycode/storycode.y
+++ b/libstorycode/storycode.y
@@ -31,7 +31,10 @@
#include "slide.h"
#include "stylesheet.h"
- enum style_mask
+ /* NB These structures look very similar to ones in stylesheet.c.
+ * However, those structures are not exposed in the API, since there's no
+ * need other than re-using them for a slightly different purpose here. */
+ enum parse_style_mask
{
STYMASK_GEOM = 1<<0,
STYMASK_FONT = 1<<1,
@@ -42,9 +45,9 @@
STYMASK_BGCOL = 1<<6,
};
- struct style
+ struct parse_style
{
- enum style_mask mask;
+ enum parse_style_mask mask;
struct frame_geom geom;
char *font;
enum alignment alignment;
@@ -56,14 +59,14 @@
struct colour bgcol2;
};
- struct paragraph {
+ struct parse_paragraph {
struct text_run *runs;
int n_runs;
int max_runs;
};
- struct many_paragraphs {
- struct paragraph *paras;
+ struct parse_many_paragraphs {
+ struct parse_paragraph *paras;
int n_paras;
int max_paras;
};
@@ -79,10 +82,10 @@
char *str;
struct text_run run;
- struct paragraph para;
- struct many_paragraphs many_paragraphs;
+ struct parse_paragraph para;
+ struct parse_many_paragraphs many_paragraphs;
- struct style style;
+ struct parse_style style;
struct length len;
struct length lenquad[4];
@@ -174,15 +177,7 @@
%{
-static void copy_col(struct colour *to, struct colour from)
-{
- int i;
- for ( i=0; i<4; i++ ) to->rgba[i] = from.rgba[i];
- to->hexcode = from.hexcode;
-}
-
-
-static void merge_style(struct style *combined, struct style inp)
+static void merge_style(struct parse_style *combined, struct parse_style inp)
{
int i;
@@ -250,11 +245,11 @@ static int hex_to_double(const char *v, double *r)
}
-void push_paragraph(struct many_paragraphs *mp, struct paragraph p)
+void push_paragraph(struct parse_many_paragraphs *mp, struct parse_paragraph p)
{
if ( mp->n_paras == mp->max_paras ) {
- struct paragraph *nparas;
- nparas = realloc(mp->paras, (mp->max_paras+8)*sizeof(struct paragraph));
+ struct parse_paragraph *nparas;
+ nparas = realloc(mp->paras, (mp->max_paras+8)*sizeof(struct parse_paragraph));
if ( nparas == NULL ) return;
mp->max_paras += 8;
mp->paras = nparas;
@@ -264,7 +259,7 @@ void push_paragraph(struct many_paragraphs *mp, struct paragraph p)
}
-struct text_run **combine_paras(struct many_paragraphs mp, int **pn_runs)
+struct text_run **combine_paras(struct parse_many_paragraphs mp, int **pn_runs)
{
struct text_run **combined_paras;
int *n_runs;
@@ -284,7 +279,7 @@ struct text_run **combine_paras(struct many_paragraphs mp, int **pn_runs)
}
-void set_stylesheet(Narrative *n, struct style *style, const char *element)
+void set_stylesheet(Narrative *n, struct parse_style *style, const char *element)
{
Stylesheet *ss = narrative_get_stylesheet(n);
if ( style->mask & STYMASK_GEOM ) stylesheet_set_geometry(ss, element, style->geom);
diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c
index be4db9b..d649d48 100644
--- a/libstorycode/stylesheet.c
+++ b/libstorycode/stylesheet.c
@@ -71,7 +71,7 @@ struct _stylesheet
};
-static void copy_col(struct colour *to, struct colour from)
+void copy_col(struct colour *to, struct colour from)
{
int i;
for ( i=0; i<4; i++ ) to->rgba[i] = from.rgba[i];
diff --git a/libstorycode/stylesheet.h b/libstorycode/stylesheet.h
index 0b994da..e5b4d62 100644
--- a/libstorycode/stylesheet.h
+++ b/libstorycode/stylesheet.h
@@ -111,4 +111,6 @@ extern char *stylesheet_serialise(Stylesheet *s);
extern const char *stylesheet_get_friendly_name(const char *in);
+extern void copy_col(struct colour *to, struct colour from);
+
#endif /* STYLESHEET_H */
diff --git a/src/narrative_window.c b/src/narrative_window.c
index 6c952f9..9a06a07 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -211,7 +211,7 @@ static void saveas_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
}
-static void about_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+static void nw_about_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
{
NarrativeWindow *nw = vp;
open_about_dialog(nw->window);
@@ -666,7 +666,7 @@ static void start_slideshow_sig(GSimpleAction *action, GVariant *parameter,
GActionEntry nw_entries[] = {
- { "about", about_sig, NULL, NULL, NULL },
+ { "about", nw_about_sig, NULL, NULL, NULL },
{ "save", save_sig, NULL, NULL, NULL },
{ "saveas", saveas_sig, NULL, NULL, NULL },
{ "slide", add_slide_sig, NULL, NULL, NULL },
diff --git a/src/slide_window.c b/src/slide_window.c
index 8a0db2c..75d40d2 100644
--- a/src/slide_window.c
+++ b/src/slide_window.c
@@ -285,7 +285,7 @@ static gboolean sw_key_press_sig(GtkWidget *da, GdkEventKey *event,
}
-static void about_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
+static void sw_about_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
{
SlideWindow *sw = vp;
open_about_dialog(sw->window);
@@ -294,7 +294,7 @@ static void about_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
GActionEntry sw_entries[] = {
- { "about", about_sig, NULL, NULL, NULL },
+ { "about", sw_about_sig, NULL, NULL, NULL },
{ "paste", paste_sig, NULL, NULL, NULL },
{ "copyframe", copy_frame_sig, NULL, NULL, NULL },
{ "deleteframe", delete_frame_sig, NULL, NULL, NULL },