aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libstorycode/gtk/gtknarrativeview.c99
-rw-r--r--libstorycode/gtk/gtknarrativeview.h5
-rw-r--r--libstorycode/gtk/gtkslideview.c22
-rw-r--r--libstorycode/gtk/gtkslideview.h5
-rw-r--r--libstorycode/narrative.c133
-rw-r--r--libstorycode/narrative.h20
-rw-r--r--libstorycode/narrative_priv.h7
-rw-r--r--libstorycode/narrative_render_cairo.h2
-rw-r--r--libstorycode/presentation.c220
-rw-r--r--libstorycode/presentation.h59
-rw-r--r--libstorycode/scparse_priv.h2
-rw-r--r--libstorycode/slide.h2
-rw-r--r--libstorycode/slide_render_cairo.c1
-rw-r--r--libstorycode/slide_render_cairo.h2
-rw-r--r--libstorycode/storycode.c5
-rw-r--r--libstorycode/storycode.h4
-rw-r--r--libstorycode/storycode.l1
-rw-r--r--libstorycode/storycode.y18
-rw-r--r--meson.build1
-rw-r--r--src/colloquium.c17
-rw-r--r--src/narrative_window.c74
-rw-r--r--src/narrative_window.h3
-rw-r--r--src/pdfstorycode.c18
-rw-r--r--src/pr_clock.c3
-rw-r--r--src/slide_window.c28
-rw-r--r--src/slide_window.h2
-rw-r--r--src/slideshow.c14
-rw-r--r--src/slideshow.h4
-rw-r--r--src/testcard.c6
-rw-r--r--src/testcard.h4
30 files changed, 302 insertions, 479 deletions
diff --git a/libstorycode/gtk/gtknarrativeview.c b/libstorycode/gtk/gtknarrativeview.c
index 66ed570..2e50065 100644
--- a/libstorycode/gtk/gtknarrativeview.c
+++ b/libstorycode/gtk/gtknarrativeview.c
@@ -33,7 +33,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <math.h>
-#include <presentation.h>
+#include <narrative.h>
#include <narrative_render_cairo.h>
//#include "slide_window.h"
@@ -131,14 +131,14 @@ static void rewrap_range(GtkNarrativeView *e, int min, int max)
pc = gtk_widget_get_pango_context(GTK_WIDGET(e));
- langname = presentation_get_language(e->p);
+ langname = narrative_get_language(e->n);
lang = pango_language_from_string(langname);
/* Wrap everything with the current width, to get the total height */
- narrative_wrap_range(presentation_get_narrative(e->p),
- presentation_get_stylesheet(e->p),
+ narrative_wrap_range(e->n,
+ narrative_get_stylesheet(e->n),
lang, pc, e->w,
- presentation_get_imagestore(e->p),
+ narrative_get_imagestore(e->n),
min, max, e->sel_start, e->sel_end);
}
@@ -146,7 +146,7 @@ static void rewrap_range(GtkNarrativeView *e, int min, int max)
static void update_size(GtkNarrativeView *e)
{
e->w = e->visible_width;
- e->h = narrative_get_height(presentation_get_narrative(e->p));
+ e->h = narrative_get_height(e->n);
set_vertical_params(e);
set_horizontal_params(e);
@@ -156,15 +156,11 @@ static void update_size(GtkNarrativeView *e)
static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event,
GtkNarrativeView *e)
{
- Narrative *n;
-
- n = presentation_get_narrative(e->p);
-
e->visible_height = event->height;
e->visible_width = event->width;
e->w = e->visible_width;
- rewrap_range(e, 0, n->n_items-1);
+ rewrap_range(e, 0, e->n->n_items-1);
update_size(e);
@@ -604,8 +600,7 @@ static void draw_caret(cairo_t *cr, Narrative *n, struct edit_pos cpos,
static void draw_overlay(cairo_t *cr, GtkNarrativeView *e)
{
- draw_caret(cr, presentation_get_narrative(e->p),
- e->cpos, e->para_highlight, e->w);
+ draw_caret(cr, e->n, e->cpos, e->para_highlight, e->w);
}
@@ -623,8 +618,7 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, GtkNarrativeView *e)
cairo_fill(cr);
/* Contents */
- narrative_render_cairo(presentation_get_narrative(e->p), cr,
- presentation_get_stylesheet(e->p));
+ narrative_render_cairo(e->n, cr, narrative_get_stylesheet(e->n));
/* Editing overlay */
draw_overlay(cr, e);
@@ -635,34 +629,23 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, GtkNarrativeView *e)
static void check_cursor_visible(GtkNarrativeView *e)
{
- Narrative *n;
double x, y, h;
- n = presentation_get_narrative(e->p);
- get_cursor_pos(n, e->cpos, &x, &y, &h);
+ get_cursor_pos(e->n, e->cpos, &x, &y, &h);
/* Off the bottom? */
if ( y - e->scroll_pos + h > e->visible_height ) {
e->scroll_pos = y + h - e->visible_height;
- e->scroll_pos += n->space_b;
+ e->scroll_pos += e->n->space_b;
}
/* Off the top? */
if ( y < e->scroll_pos ) {
- e->scroll_pos = y - n->space_t;
+ e->scroll_pos = y - e->n->space_t;
}
}
-static struct narrative_item *get_current_item(GtkNarrativeView *e,
- Narrative **pn)
-{
- Narrative *n = presentation_get_narrative(e->p);
- if ( pn != NULL ) *pn = n;
- return &n->items[e->cpos.para];
-}
-
-
static size_t end_offset_of_para(Narrative *n, int pnum)
{
assert(pnum >= 0);
@@ -780,12 +763,9 @@ static int positions_equal(struct edit_pos a, struct edit_pos b)
static void do_backspace(GtkNarrativeView *e, signed int dir)
{
- Narrative *n;
struct edit_pos p1, p2;
size_t o1, o2;
- n = presentation_get_narrative(e->p);
-
if ( !positions_equal(e->sel_start, e->sel_end) ) {
/* Block delete */
@@ -797,13 +777,13 @@ static void do_backspace(GtkNarrativeView *e, signed int dir)
/* Delete one character, as represented visually */
p2 = e->cpos;
p1 = p2;
- cursor_moveh(n, &p1, dir);
+ cursor_moveh(e->n, &p1, dir);
}
sort_positions(&p1, &p2);
- o1 = pos_trail_to_offset(&n->items[p1.para], p1.pos, p1.trail);
- o2 = pos_trail_to_offset(&n->items[p2.para], p2.pos, p2.trail);
- narrative_delete_block(n, p1.para, o1, p2.para, o2);
+ o1 = pos_trail_to_offset(&e->n->items[p1.para], p1.pos, p1.trail);
+ o2 = pos_trail_to_offset(&e->n->items[p2.para], p2.pos, p2.trail);
+ narrative_delete_block(e->n, p1.para, o1, p2.para, o2);
e->cpos = p1;
unset_selection(e);
@@ -848,20 +828,19 @@ static void split_paragraph_at_cursor(Narrative *n, struct edit_pos pos)
static void insert_text(char *t, GtkNarrativeView *e)
{
- Narrative *n;
struct narrative_item *item;
if ( !positions_equal(e->sel_start, e->sel_end) ) {
do_backspace(e, 0);
}
- item = get_current_item(e, &n);
+ item = &e->n->items[e->cpos.para];
if ( strcmp(t, "\n") == 0 ) {
- split_paragraph_at_cursor(n, e->cpos);
+ split_paragraph_at_cursor(e->n, e->cpos);
rewrap_range(e, e->cpos.para, e->cpos.para+1);
update_size(e);
- cursor_moveh(n, &e->cpos, +1);
+ cursor_moveh(e->n, &e->cpos, +1);
check_cursor_visible(e);
emit_change_sig(e);
redraw(e);
@@ -876,7 +855,7 @@ static void insert_text(char *t, GtkNarrativeView *e)
insert_text_in_paragraph(item, off, t);
rewrap_range(e, e->cpos.para, e->cpos.para);
update_size(e);
- cursor_moveh(n, &e->cpos, +1);
+ cursor_moveh(e->n, &e->cpos, +1);
} /* else do nothing: pressing enter is OK, though */
@@ -926,21 +905,19 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event,
GtkNarrativeView *e)
{
gdouble x, y;
- Narrative *n;
- n = presentation_get_narrative(e->p);
x = event->x;
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(n, x, y, &e->sel_start);
+ find_cursor(e->n, x, y, &e->sel_start);
e->sel_end = e->sel_start;
e->cpos = e->sel_start;
if ( event->type == GDK_2BUTTON_PRESS ) {
- struct narrative_item *item = &n->items[e->cpos.para];
+ struct narrative_item *item = &e->n->items[e->cpos.para];
if ( item->type == NARRATIVE_ITEM_SLIDE ) {
g_signal_emit_by_name(e, "slide-double-clicked",
item->slide);
@@ -966,7 +943,6 @@ static void sorti(int *a, int *b)
static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event,
GtkNarrativeView *e)
{
- Narrative *n;
gdouble x, y;
struct edit_pos old_sel_end;
int minp, maxp;
@@ -981,8 +957,7 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event,
}
old_sel_end = e->sel_end;
- n = presentation_get_narrative(e->p);
- find_cursor(n, x, y, &e->sel_end);
+ find_cursor(e->n, x, y, &e->sel_end);
minp = e->sel_start.para;
maxp = e->sel_end.para;
@@ -993,7 +968,7 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event,
}
rewrap_range(e, minp, maxp);
- find_cursor(n, x, y, &e->cpos);
+ find_cursor(e->n, x, y, &e->cpos);
redraw(e);
gdk_event_request_motions(event);
@@ -1005,7 +980,6 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event,
GtkNarrativeView *e)
{
gboolean r;
- Narrative *n;
int claim = 0;
/* Throw the event to the IM context and let it sort things out */
@@ -1013,30 +987,28 @@ static gboolean key_press_sig(GtkWidget *da, GdkEventKey *event,
event);
if ( r ) return FALSE; /* IM ate it */
- n = presentation_get_narrative(e->p);
-
switch ( event->keyval ) {
case GDK_KEY_Left :
- cursor_moveh(n, &e->cpos, -1);
+ cursor_moveh(e->n, &e->cpos, -1);
redraw(e);
claim = 1;
break;
case GDK_KEY_Right :
- cursor_moveh(n, &e->cpos, +1);
+ cursor_moveh(e->n, &e->cpos, +1);
redraw(e);
claim = 1;
break;
case GDK_KEY_Up :
- cursor_moveh(n, &e->cpos, -1);
+ cursor_moveh(e->n, &e->cpos, -1);
redraw(e);
claim = 1;
break;
case GDK_KEY_Down :
- cursor_moveh(n, &e->cpos, +1);
+ cursor_moveh(e->n, &e->cpos, +1);
redraw(e);
claim = 1;
break;
@@ -1132,7 +1104,7 @@ static gint realise_sig(GtkWidget *da, GtkNarrativeView *e)
}
-GtkWidget *gtk_narrative_view_new(Presentation *p)
+GtkWidget *gtk_narrative_view_new(Narrative *n)
{
GtkNarrativeView *nview;
GtkTargetEntry targets[1];
@@ -1142,7 +1114,7 @@ GtkWidget *gtk_narrative_view_new(Presentation *p)
nview->w = 100;
nview->h = 100;
nview->scroll_pos = 0;
- nview->p = p;
+ nview->n = n;
nview->para_highlight = 0;
@@ -1215,21 +1187,16 @@ void gtk_narrative_view_set_cursor_para(GtkNarrativeView *e, signed int pos)
redraw(e);
}
+
void gtk_narrative_view_add_slide_at_cursor(GtkNarrativeView *e)
{
- Narrative *n;
Slide *s;
- int pos;
-
- n = presentation_get_narrative(e->p);
s = slide_new();
if ( s == NULL ) return;
- split_paragraph_at_cursor(n, e->cpos);
- pos = narrative_get_slide_number(n, e->cpos.para);
- presentation_insert_slide(e->p, s, pos);
- narrative_insert_slide(n, s, e->cpos.para+1);
+ split_paragraph_at_cursor(e->n, e->cpos);
+ narrative_insert_slide(e->n, s, e->cpos.para+1);
rewrap_range(e, e->cpos.para, e->cpos.para+2);
e->cpos.para++;
diff --git a/libstorycode/gtk/gtknarrativeview.h b/libstorycode/gtk/gtknarrativeview.h
index c85ca1f..82fd215 100644
--- a/libstorycode/gtk/gtknarrativeview.h
+++ b/libstorycode/gtk/gtknarrativeview.h
@@ -32,7 +32,6 @@
#include <stylesheet.h>
#include <narrative.h>
-#include <presentation.h>
#include <imagestore.h>
#include <narrative_render_cairo.h>
@@ -66,7 +65,7 @@ struct _gtknarrativeview
GtkDrawingArea parent_instance;
/*< private >*/
- Presentation *p;
+ Narrative *n;
GtkIMContext *im_context;
int w; /* Surface size in pixels */
@@ -101,7 +100,7 @@ typedef struct _gtknarrativeview GtkNarrativeView;
typedef struct _gtknarrativeviewclass GtkNarrativeViewClass;
extern GType gtk_narrative_view_get_type(void);
-extern GtkWidget *gtk_narrative_view_new(Presentation *p);
+extern GtkWidget *gtk_narrative_view_new(Narrative *n);
extern void gtk_narrative_view_set_logical_size(GtkNarrativeView *e, double w, double h);
diff --git a/libstorycode/gtk/gtkslideview.c b/libstorycode/gtk/gtkslideview.c
index 91bc1c7..c98fe5b 100644
--- a/libstorycode/gtk/gtkslideview.c
+++ b/libstorycode/gtk/gtkslideview.c
@@ -35,7 +35,7 @@
#include <libintl.h>
#define _(x) gettext(x)
-#include <presentation.h>
+#include <narrative.h>
#include <slide_render_cairo.h>
#include <stylesheet.h>
@@ -57,7 +57,7 @@ static gboolean resize_sig(GtkWidget *widget, GdkEventConfigure *event,
double log_w, log_h;
Stylesheet *ss;
- ss = presentation_get_stylesheet(e->p);
+ ss = narrative_get_stylesheet(e->n);
if ( slide_get_logical_size(e->slide, ss, &log_w, &log_h) ) {
fprintf(stderr, "Failed to get logical size\n");
return FALSE;
@@ -250,7 +250,7 @@ static void draw_overlay(cairo_t *cr, GtkSlideView *e)
double slide_w, slide_h;
Stylesheet *stylesheet;
- stylesheet = presentation_get_stylesheet(e->p);
+ stylesheet = narrative_get_stylesheet(e->n);
slide_get_logical_size(e->slide, stylesheet, &slide_w, &slide_h);
slide_item_get_geom(e->cursor_frame, stylesheet, &x, &y, &w, &h,
slide_w, slide_h);
@@ -322,9 +322,9 @@ static gboolean draw_sig(GtkWidget *da, cairo_t *cr, GtkSlideView *e)
/* Contents */
pc = pango_cairo_create_context(cr);
- slide_render_cairo(e->slide, cr, presentation_get_imagestore(e->p),
- presentation_get_stylesheet(e->p),
- presentation_get_slide_number(e->p, e->slide),
+ slide_render_cairo(e->slide, cr, narrative_get_imagestore(e->n),
+ narrative_get_stylesheet(e->n),
+ narrative_get_slide_number_for_slide(e->n, e->slide),
pango_language_get_default(), pc,
e->cursor_frame, e->sel_start, e->sel_end);
g_object_unref(pc);
@@ -581,7 +581,7 @@ static void do_resize(GtkSlideView *e, double x, double y, double w, double h)
assert(e->cursor_frame != NULL);
- stylesheet = presentation_get_stylesheet(e->p);
+ stylesheet = narrative_get_stylesheet(e->n);
slide_get_logical_size(e->slide, stylesheet, &slide_w, &slide_h);
if ( w < 0.0 ) {
@@ -635,7 +635,7 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event,
double slide_w, slide_h;
double frx, fry, frw, frh;
- stylesheet = presentation_get_stylesheet(e->p);
+ stylesheet = narrative_get_stylesheet(e->n);
slide_get_logical_size(e->slide, stylesheet, &slide_w, &slide_h);
x = event->x - e->border_offs_x + e->h_scroll_pos;
@@ -750,7 +750,7 @@ static gboolean motion_sig(GtkWidget *da, GdkEventMotion *event, GtkSlideView *e
x /= e->view_scale;
y /= e->view_scale;
- stylesheet = presentation_get_stylesheet(e->p);
+ 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 ) {
@@ -1397,7 +1397,7 @@ void gtk_slide_view_set_slide(GtkWidget *widget, Slide *slide)
}
-GtkWidget *gtk_slide_view_new(Presentation *p, Slide *slide)
+GtkWidget *gtk_slide_view_new(Narrative *n, Slide *slide)
{
GtkSlideView *sv;
GtkTargetEntry targets[1];
@@ -1405,7 +1405,7 @@ GtkWidget *gtk_slide_view_new(Presentation *p, Slide *slide)
sv = g_object_new(GTK_TYPE_SLIDE_VIEW, NULL);
- sv->p = p;
+ sv->n = n;
sv->slide = slide;
sv->w = 100;
sv->h = 100;
diff --git a/libstorycode/gtk/gtkslideview.h b/libstorycode/gtk/gtkslideview.h
index 0221fca..59b9ad4 100644
--- a/libstorycode/gtk/gtkslideview.h
+++ b/libstorycode/gtk/gtkslideview.h
@@ -33,7 +33,6 @@
#include <stylesheet.h>
#include <narrative.h>
-#include <presentation.h>
#include <imagestore.h>
#include <slide_render_cairo.h>
@@ -90,7 +89,7 @@ struct _gtkslideview
GtkDrawingArea parent_instance;
/*< private >*/
- Presentation *p;
+ Narrative *n;
Slide *slide;
GtkIMContext *im_context;
@@ -148,7 +147,7 @@ struct _gtkslideviewclass
typedef struct _gtkslideview GtkSlideView;
typedef struct _gtkslideviewclass GtkSlideViewClass;
-extern GtkWidget *gtk_slide_view_new(Presentation *p, Slide *slide);
+extern GtkWidget *gtk_slide_view_new(Narrative *n, Slide *slide);
extern void gtk_slide_view_set_slide(GtkWidget *sv, Slide *slide);
#endif /* GTK_SLIDE_VIEW_H */
diff --git a/libstorycode/narrative.c b/libstorycode/narrative.c
index 5dfe117..19797e3 100644
--- a/libstorycode/narrative.c
+++ b/libstorycode/narrative.c
@@ -28,9 +28,23 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
+#include <stdio.h>
+#include <gio/gio.h>
+#ifdef HAVE_PANGO
+#include <pango/pango.h>
+#endif
+
+#ifdef HAVE_CAIRO
+#include <cairo.h>
+#endif
+
+#include "stylesheet.h"
+#include "slide.h"
#include "narrative.h"
#include "narrative_priv.h"
+#include "imagestore.h"
+#include "storycode.h"
Narrative *narrative_new()
{
@@ -39,6 +53,14 @@ Narrative *narrative_new()
if ( n == NULL ) return NULL;
n->n_items = 0;
n->items = NULL;
+ n->stylesheet = NULL;
+ n->imagestore = NULL;
+ n->saved = 1;
+#ifdef HAVE_PANGO
+ n->language = pango_language_to_string(pango_language_get_default());
+#else
+ n->language = NULL;
+#endif
return n;
}
@@ -70,6 +92,74 @@ void narrative_free(Narrative *n)
}
+Narrative *narrative_load(GFile *file)
+{
+ GBytes *bytes;
+ const char *text;
+ size_t len;
+ Narrative *n;
+
+ bytes = g_file_load_bytes(file, NULL, NULL, NULL);
+ if ( bytes == NULL ) return NULL;
+
+ text = g_bytes_get_data(bytes, &len);
+ n = storycode_parse_presentation(text);
+ g_bytes_unref(bytes);
+ if ( n == NULL ) return NULL;
+
+ n->imagestore = imagestore_new("."); /* FIXME: From app config */
+ imagestore_set_parent(n->imagestore, g_file_get_parent(file));
+ return n;
+}
+
+
+int narrative_save(Narrative *n, GFile *file)
+{
+ /* FIXME: Implementation */
+ return 1;
+}
+
+
+void narrative_set_unsaved(Narrative *n)
+{
+ n->saved = 0;
+}
+
+
+int narrative_get_unsaved(Narrative *n)
+{
+ return !n->saved;
+}
+
+
+void narrative_add_stylesheet(Narrative *n, Stylesheet *ss)
+{
+ assert(n->stylesheet == NULL);
+ n->stylesheet = ss;
+}
+
+
+Stylesheet *narrative_get_stylesheet(Narrative *n)
+{
+ if ( n == NULL ) return NULL;
+ return n->stylesheet;
+}
+
+
+const char *narrative_get_language(Narrative *n)
+{
+ if ( n == NULL ) return NULL;
+ return n->language;
+}
+
+
+ImageStore *narrative_get_imagestore(Narrative *n)
+{
+ if ( n == NULL ) return NULL;
+ return n->imagestore;
+}
+
+
static void init_item(struct narrative_item *item)
{
item->layout = NULL;
@@ -265,6 +355,17 @@ int narrative_get_num_items(Narrative *n)
}
+int narrative_get_num_slides(Narrative *n)
+{
+ int i;
+ int ns = 0;
+ for ( i=0; i<n->n_items; i++ ) {
+ if ( n->items[i].type == NARRATIVE_ITEM_SLIDE ) ns++;
+ }
+ return ns;
+}
+
+
Slide *narrative_get_slide(Narrative *n, int para)
{
if ( para >= n->n_items ) return NULL;
@@ -273,12 +374,40 @@ Slide *narrative_get_slide(Narrative *n, int para)
}
-int narrative_get_slide_number(Narrative *n, int para)
+int narrative_get_slide_number_for_para(Narrative *n, int para)
{
int i;
int ns = 0;
- for ( i=0; i<n->n_items; i++ ) {
+ for ( i=0; i<para; i++ ) {
if ( n->items[i].type == NARRATIVE_ITEM_SLIDE ) ns++;
}
return ns;
}
+
+
+int narrative_get_slide_number_for_slide(Narrative *n, Slide *s)
+{
+ int i;
+ int ns = 0;
+ for ( i=0; i<n->n_items; i++ ) {
+ if ( n->items[i].type == NARRATIVE_ITEM_SLIDE ) {
+ if ( n->items[i].slide == s ) return ns;
+ ns++;
+ }
+ }
+ return n->n_items;
+}
+
+
+Slide *narrative_get_slide_by_number(Narrative *n, int pos)
+{
+ int i;
+ int ns = 0;
+ for ( i=0; i<n->n_items; i++ ) {
+ if ( n->items[i].type == NARRATIVE_ITEM_SLIDE ) {
+ if ( ns == pos ) return n->items[i].slide;
+ ns++;
+ }
+ }
+ return NULL;
+}
diff --git a/libstorycode/narrative.h b/libstorycode/narrative.h
index 193339d..22918e1 100644
--- a/libstorycode/narrative.h
+++ b/libstorycode/narrative.h
@@ -27,13 +27,28 @@
#include <config.h>
#endif
+#include <gio/gio.h>
+
typedef struct _narrative Narrative;
#include "slide.h"
+#include "imagestore.h"
extern Narrative *narrative_new(void);
extern void narrative_free(Narrative *n);
+extern void narrative_add_stylesheet(Narrative *n, Stylesheet *ss);
+extern Stylesheet *narrative_get_stylesheet(Narrative *n);
+
+extern const char *narrative_get_language(Narrative *n);
+extern ImageStore *narrative_get_imagestore(Narrative *n);
+
+extern Narrative *narrative_load(GFile *file);
+extern int narrative_save(Narrative *n, GFile *file);
+
+extern void narrative_set_unsaved(Narrative *n);
+extern int narrative_get_unsaved(Narrative *n);
+
extern void narrative_add_prestitle(Narrative *n, char *text);
extern void narrative_add_bp(Narrative *n, char *text);
extern void narrative_add_text(Narrative *n, char *text);
@@ -43,8 +58,11 @@ extern void narrative_delete_block(Narrative *n, int i1, size_t o1,
int i2, size_t o2);
extern void narrative_split_item(Narrative *n, int i1, size_t o1);
extern int narrative_get_num_items(Narrative *n);
+extern int narrative_get_num_slides(Narrative *n);
extern Slide *narrative_get_slide(Narrative *n, int para);
-extern int narrative_get_slide_number(Narrative *n, int para);
+extern Slide *narrative_get_slide_by_number(Narrative *n, int pos);
+extern int narrative_get_slide_number_for_para(Narrative *n, int para);
+extern int narrative_get_slide_number_for_slide(Narrative *n, Slide *s);
#endif /* NARRATIVE_H */
diff --git a/libstorycode/narrative_priv.h b/libstorycode/narrative_priv.h
index 1a461c4..065b416 100644
--- a/libstorycode/narrative_priv.h
+++ b/libstorycode/narrative_priv.h
@@ -27,6 +27,7 @@
#include <pango/pangocairo.h>
#endif
+#include "imagestore.h"
#include "storycode.h"
#include "slide.h"
@@ -72,8 +73,14 @@ struct narrative_item
struct _narrative
{
+ Stylesheet *stylesheet;
+ ImageStore *imagestore;
+ int saved;
+ const char *language;
+
int n_items;
struct narrative_item *items;
+
double w;
double space_l;
double space_r;
diff --git a/libstorycode/narrative_render_cairo.h b/libstorycode/narrative_render_cairo.h
index 690517d..fe3680a 100644
--- a/libstorycode/narrative_render_cairo.h
+++ b/libstorycode/narrative_render_cairo.h
@@ -27,7 +27,7 @@
#include <config.h>
#endif
-#include "presentation.h"
+#include "narrative.h"
#include "imagestore.h"
struct edit_pos
diff --git a/libstorycode/presentation.c b/libstorycode/presentation.c
deleted file mode 100644
index 925f011..0000000
--- a/libstorycode/presentation.c
+++ /dev/null
@@ -1,220 +0,0 @@
-/*
- * presentation.c
- *
- * Copyright © 2019 Thomas White <taw@bitwiz.org.uk>
- *
- * This file is part of Colloquium.
- *
- * Colloquium is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <stdio.h>
-#include <gio/gio.h>
-
-#ifdef HAVE_PANGO
-#include <pango/pango.h>
-#endif
-
-#include "presentation.h"
-#include "stylesheet.h"
-#include "slide.h"
-#include "narrative.h"
-#include "imagestore.h"
-#include "storycode.h"
-
-struct _presentation
-{
- Stylesheet *stylesheet;
- Narrative *narrative;
- ImageStore *imagestore;
- int n_slides;
- Slide **slides;
- int max_slides;
- int saved;
- const char *language;
-};
-
-
-Presentation *presentation_new()
-{
- Presentation *p;
- p = malloc(sizeof(*p));
- if ( p == NULL ) return NULL;
- p->stylesheet = NULL;
- p->narrative = NULL;
- p->slides = NULL;
- p->n_slides = 0;
- p->max_slides = 0;
- p->imagestore = NULL;
- p->saved = 1;
-#ifdef HAVE_PANGO
- p->language = pango_language_to_string(pango_language_get_default());
-#else
- p->language = NULL;
-#endif
- return p;
-}
-
-
-Presentation *presentation_load(GFile *file)
-{
- GBytes *bytes;
- const char *text;
- size_t len;
- Presentation *p;
-
- bytes = g_file_load_bytes(file, NULL, NULL, NULL);
- if ( bytes == NULL ) return NULL;
-
- text = g_bytes_get_data(bytes, &len);
- p = storycode_parse_presentation(text);
- g_bytes_unref(bytes);
- if ( p == NULL ) return NULL;
-
- p->imagestore = imagestore_new("."); /* FIXME: From app config */
- imagestore_set_parent(p->imagestore, g_file_get_parent(file));
- return p;
-}
-
-
-int presentation_save(Presentation *p, GFile *file)
-{
- /* FIXME: Implementation */
- return 1;
-}
-
-
-void presentation_set_unsaved(Presentation *p)
-{
- p->saved = 0;
-}
-
-
-int presentation_get_unsaved(Presentation *p)
-{
- return !p->saved;
-}
-
-
-void presentation_free(Presentation *p)
-{
- /* FIXME: Free narrative, slides, imagestore */
- free(p);
-}
-
-
-void presentation_add_stylesheet(Presentation *p, Stylesheet *ss)
-{
- assert(p->stylesheet == NULL);
- p->stylesheet = ss;
-}
-
-
-void presentation_add_narrative(Presentation *p, Narrative *n)
-{
- assert(p->narrative == NULL);
- p->narrative = n;
-}
-
-
-void presentation_add_slide(Presentation *p, Slide *s)
-{
- assert(p->n_slides <= p->max_slides);
- if ( p->n_slides == p->max_slides ) {
- Slide **nslides = realloc(p->slides,
- (p->max_slides+8)*sizeof(Slide *));
- if ( nslides == NULL ) {
- fprintf(stderr, "Failed to allocate memory for slide\n");
- return;
- }
- p->slides = nslides;
- p->max_slides += 8;
- }
-
- p->slides[p->n_slides++] = s;
-}
-
-
-void presentation_insert_slide(Presentation *p, Slide *s, int pos)
-{
- int i;
- presentation_add_slide(p, NULL);
- assert(pos < p->n_slides);
- for ( i=p->n_slides-1; i>pos+1; i-- ) {
- p->slides[i] = p->slides[i-1];
- }
- p->slides[pos] = s;
-}
-
-
-int presentation_get_num_slides(Presentation *p)
-{
- return p->n_slides;
-}
-
-
-Slide *presentation_get_slide_by_number(Presentation *p, int i)
-{
- if ( i >= p->n_slides ) return NULL;
- if ( i < 0 ) return NULL;
- return p->slides[i];
-}
-
-
-signed int presentation_get_slide_number(Presentation *p, Slide *s)
-{
- int i;
- if ( p == NULL ) return -1;
- for ( i=0; i<p->n_slides; i++ ) {
- if ( s == p->slides[i] ) return i;
- }
- return -1;
-}
-
-
-Stylesheet *presentation_get_stylesheet(Presentation *p)
-{
- if ( p == NULL ) return NULL;
- return p->stylesheet;
-}
-
-
-Narrative *presentation_get_narrative(Presentation *p)
-{
- if ( p == NULL ) return NULL;
- return p->narrative;
-}
-
-
-const char *presentation_get_language(Presentation *p)
-{
- if ( p == NULL ) return NULL;
- return p->language;
-}
-
-
-ImageStore *presentation_get_imagestore(Presentation *p)
-{
- if ( p == NULL ) return NULL;
- return p->imagestore;
-}
diff --git a/libstorycode/presentation.h b/libstorycode/presentation.h
deleted file mode 100644
index f2f22f4..0000000
--- a/libstorycode/presentation.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * presentation.h
- *
- * Copyright © 2019 Thomas White <taw@bitwiz.org.uk>
- *
- * This file is part of Colloquium.
- *
- * Colloquium is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-
-#ifndef PRESENTATION_H
-#define PRESENTATION_H
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <gio/gio.h>
-
-typedef struct _presentation Presentation;
-
-#include "stylesheet.h"
-#include "narrative.h"
-#include "imagestore.h"
-
-extern Presentation *presentation_new(void);
-extern Presentation *presentation_load(GFile *file);
-extern int presentation_save(Presentation *p, GFile *file);
-extern void presentation_free(Presentation *p);
-extern void presentation_set_unsaved(Presentation *p);
-extern int presentation_get_unsaved(Presentation *p);
-
-extern void presentation_add_stylesheet(Presentation *p, Stylesheet *ss);
-extern void presentation_add_narrative(Presentation *p, Narrative *n);
-extern void presentation_add_slide(Presentation *p, Slide *s);
-extern void presentation_insert_slide(Presentation *p, Slide *s, int pos);
-
-extern int presentation_get_num_slides(Presentation *p);
-extern Slide *presentation_get_slide_by_number(Presentation *p, int i);
-extern signed int presentation_get_slide_number(Presentation *p, Slide *s);
-extern Stylesheet *presentation_get_stylesheet(Presentation *p);
-extern Narrative *presentation_get_narrative(Presentation *p);
-extern const char *presentation_get_language(Presentation *p);
-extern ImageStore *presentation_get_imagestore(Presentation *p);
-
-
-#endif /* PRESENTATION_H */
diff --git a/libstorycode/scparse_priv.h b/libstorycode/scparse_priv.h
index 47edbf8..c327b1a 100644
--- a/libstorycode/scparse_priv.h
+++ b/libstorycode/scparse_priv.h
@@ -23,7 +23,6 @@
#ifndef SCPARSE_PRIV_H
#define SCPARSE_PRIV_H
-#include "presentation.h"
#include "narrative.h"
#include "slide.h"
@@ -40,7 +39,6 @@ enum style_mask
struct scpctx
{
- Presentation *p;
Narrative *n;
Stylesheet *ss;
Slide *s;
diff --git a/libstorycode/slide.h b/libstorycode/slide.h
index b4510ec..3957f9e 100644
--- a/libstorycode/slide.h
+++ b/libstorycode/slide.h
@@ -27,6 +27,8 @@
#include <config.h>
#endif
+#include <stddef.h>
+
typedef struct _slide Slide;
typedef struct _slideitem SlideItem;
diff --git a/libstorycode/slide_render_cairo.c b/libstorycode/slide_render_cairo.c
index c428fad..03df9c6 100644
--- a/libstorycode/slide_render_cairo.c
+++ b/libstorycode/slide_render_cairo.c
@@ -33,7 +33,6 @@
#include <stdlib.h>
#include <math.h>
-#include "presentation.h"
#include "slide.h"
#include "narrative.h"
#include "stylesheet.h"
diff --git a/libstorycode/slide_render_cairo.h b/libstorycode/slide_render_cairo.h
index cd6e03b..bb7ad84 100644
--- a/libstorycode/slide_render_cairo.h
+++ b/libstorycode/slide_render_cairo.h
@@ -27,7 +27,7 @@
#include <config.h>
#endif
-#include "presentation.h"
+#include "slide.h"
#include "imagestore.h"
struct slide_pos
diff --git a/libstorycode/storycode.c b/libstorycode/storycode.c
index edfe580..b34785d 100644
--- a/libstorycode/storycode.c
+++ b/libstorycode/storycode.c
@@ -28,7 +28,6 @@
#include <stdlib.h>
#include <string.h>
-#include "presentation.h"
#include "narrative.h"
#include "slide.h"
#include "stylesheet.h"
@@ -38,7 +37,7 @@
#include "scparse_priv.h"
-Presentation *storycode_parse_presentation(const char *sc)
+Narrative *storycode_parse_presentation(const char *sc)
{
YY_BUFFER_STATE b;
struct scpctx parse_ctx;
@@ -47,5 +46,5 @@ Presentation *storycode_parse_presentation(const char *sc)
scparse(&parse_ctx);
sc_delete_buffer(b);
- return parse_ctx.p;
+ return parse_ctx.n;
}
diff --git a/libstorycode/storycode.h b/libstorycode/storycode.h
index 476941e..f941493 100644
--- a/libstorycode/storycode.h
+++ b/libstorycode/storycode.h
@@ -27,9 +27,9 @@
#include <config.h>
#endif
-#include "presentation.h"
+#include "narrative.h"
-extern Presentation *storycode_parse_presentation(const char *sc);
+extern Narrative *storycode_parse_presentation(const char *sc);
#endif /* STORYCODE_H */
diff --git a/libstorycode/storycode.l b/libstorycode/storycode.l
index d64b8c0..e7f3961 100644
--- a/libstorycode/storycode.l
+++ b/libstorycode/storycode.l
@@ -23,7 +23,6 @@
%{
#define YYDEBUG 1
- #include "presentation.h"
#include "narrative.h"
#include "slide.h"
#include "stylesheet.h"
diff --git a/libstorycode/storycode.y b/libstorycode/storycode.y
index f549525..d2508e2 100644
--- a/libstorycode/storycode.y
+++ b/libstorycode/storycode.y
@@ -26,7 +26,6 @@
%code requires {
- #include "presentation.h"
#include "narrative.h"
#include "slide.h"
#include "stylesheet.h"
@@ -35,7 +34,6 @@
}
%union {
- Presentation *p;
Stylesheet *ss;
Narrative *n;
Slide *s;
@@ -77,7 +75,6 @@
%token SQOPEN SQCLOSE
%token UNIT VALUE SIZE HEXCOL
-%type <p> presentation
%type <n> narrative
%type <s> slide
%type <ss> stylesheet
@@ -102,11 +99,10 @@
%parse-param { struct scpctx *ctx };
%initial-action
{
- ctx->p = presentation_new();
+ ctx->n = narrative_new();
/* These are the objects currently being created. They will be
- * added to the presentation when they're complete */
- ctx->n = narrative_new();
+ * added to the narrative when they're complete */
ctx->ss = stylesheet_new();
ctx->s = slide_new();
@@ -179,9 +175,8 @@ void set_style(struct scpctx *ctx, enum style_element element)
/* The only thing a "presentation" really needs is narrative */
presentation:
- stylesheet narrative { presentation_add_stylesheet(ctx->p, ctx->ss);
- presentation_add_narrative(ctx->p, ctx->n); }
-| narrative { presentation_add_narrative(ctx->p, ctx->n); }
+ stylesheet narrative
+| narrative
;
@@ -211,8 +206,7 @@ narrative_bulletpoint:
/* -------- Slide -------- */
slide:
- SLIDE '{' slide_parts '}' { presentation_add_slide(ctx->p, ctx->s);
- narrative_add_slide(ctx->n, ctx->s);
+ SLIDE '{' slide_parts '}' { narrative_add_slide(ctx->n, ctx->s);
/* New work in progress object */
ctx->s = slide_new(); }
;
@@ -326,7 +320,7 @@ stylesheet:
STYLES '{'
style_narrative
style_slide
- '}' { }
+ '}' { narrative_add_stylesheet(ctx->n, ctx->ss); }
;
style_narrative:
diff --git a/meson.build b/meson.build
index 569b8bb..07626cc 100644
--- a/meson.build
+++ b/meson.build
@@ -65,7 +65,6 @@ storycode_lex_ch = flex_gen.process('libstorycode/storycode.l')
libstorycode = library('storycode',
['libstorycode/narrative.c',
'libstorycode/slide.c',
- 'libstorycode/presentation.c',
'libstorycode/stylesheet.c',
'libstorycode/storycode.c',
'libstorycode/slide_render_cairo.c',
diff --git a/src/colloquium.c b/src/colloquium.c
index ac60a63..65647ad 100644
--- a/src/colloquium.c
+++ b/src/colloquium.c
@@ -35,7 +35,7 @@
#include <libintl.h>
#define _(x) gettext(x)
-#include <presentation.h>
+#include <narrative.h>
#include "colloquium.h"
#include "narrative_window.h"
@@ -61,16 +61,13 @@ static void colloquium_activate(GApplication *papp)
{
Colloquium *app = COLLOQUIUM(papp);
if ( !app->first_run ) {
- Presentation *p;
Narrative *n;
Stylesheet *ss;
- p = presentation_new();
n = narrative_new();
ss = stylesheet_new();
narrative_add_text(n, strdup(""));
- presentation_add_narrative(p, n);
- presentation_add_stylesheet(p, ss);
- narrative_window_new(p, papp);
+ narrative_add_stylesheet(n, ss);
+ narrative_window_new(n, papp);
}
}
@@ -231,10 +228,10 @@ static void colloquium_open(GApplication *papp, GFile **files, gint n_files,
int i;
for ( i=0; i<n_files; i++ ) {
- Presentation *p;
- p = presentation_load(files[i]);
- if ( p != NULL ) {
- narrative_window_new(p, papp);
+ Narrative *n;
+ n = narrative_load(files[i]);
+ if ( n != NULL ) {
+ narrative_window_new(n, papp);
} else {
char *uri = g_file_get_uri(files[i]);
fprintf(stderr, _("Failed to load presentation '%s'\n"),
diff --git a/src/narrative_window.c b/src/narrative_window.c
index 94515df..772c886 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -33,7 +33,7 @@
#include <libintl.h>
#define _(x) gettext(x)
-#include <presentation.h>
+#include <narrative.h>
#include <gtk/gtknarrativeview.h>
#include "colloquium.h"
@@ -54,7 +54,7 @@ struct _narrative_window
GtkToolItem *blast;
GtkWidget *nv;
GApplication *app;
- Presentation *p;
+ Narrative *n;
GFile *file;
SCSlideshow *show;
int show_no_slides;
@@ -95,7 +95,7 @@ static void update_titlebar(NarrativeWindow *nw)
}
strcat(title, " - Colloquium");
- if ( presentation_get_unsaved(nw->p) ) {
+ if ( narrative_get_unsaved(nw->n) ) {
strcat(title, " *");
}
gtk_window_set_title(GTK_WINDOW(nw->window), title);
@@ -119,7 +119,7 @@ static void update_toolbar(NarrativeWindow *nw)
gtk_widget_set_sensitive(GTK_WIDGET(nw->bprev), TRUE);
}
- n_para = narrative_get_num_items(presentation_get_narrative(nw->p));
+ n_para = narrative_get_num_items(nw->n);
if ( cur_para == n_para - 1 ) {
gtk_widget_set_sensitive(GTK_WIDGET(nw->bnext), FALSE);
gtk_widget_set_sensitive(GTK_WIDGET(nw->blast), FALSE);
@@ -137,11 +137,11 @@ static gint saveas_response_sig(GtkWidget *d, gint response,
GFile *file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(d));
- if ( presentation_save(nw->p, file) ) {
+ if ( narrative_save(nw->n, file) ) {
show_error(nw, _("Failed to save presentation"));
}
- /* save_presentation keeps a reference to both of these */
+ /* save_narrative keeps a reference to both of these */
g_object_unref(file);
}
@@ -190,7 +190,7 @@ static void save_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
return saveas_sig(NULL, NULL, nw);
}
- presentation_save(nw->p, nw->file);
+ narrative_save(nw->n, nw->file);
}
@@ -212,7 +212,7 @@ static void delete_slide_sig(GSimpleAction *action, GVariant *parameter,
//
// /* Full rerender */
// sc_editor_set_scblock(nw->nv, nw->dummy_top);
-// nw->p->saved = 0;
+// nw->n->saved = 0;
// update_titlebar(nw);
}
@@ -231,7 +231,7 @@ static gint load_ss_response_sig(GtkWidget *d, gint response,
// if ( new_ss != NULL ) {
//
// stylesheet_free(nw->p->stylesheet);
-// nw->p->stylesheet = new_ss;
+// nw->n->stylesheet = new_ss;
// sc_editor_set_stylesheet(nw->nv, new_ss);
//
// /* Full rerender */
@@ -256,7 +256,7 @@ static void stylesheet_changed_sig(GtkWidget *da, NarrativeWindow *nw)
// int i;
//
// /* It might have changed (been created) since last time */
-// sc_editor_set_stylesheet(nw->nv, nw->p->stylesheet);
+// sc_editor_set_stylesheet(nw->nv, nwn>p->stylesheet);
//
// /* Full rerender, first block may have changed */
// sc_editor_set_scblock(nw->nv, nw->dummy_top);
@@ -274,7 +274,7 @@ static void edit_ss_sig(GSimpleAction *action, GVariant *parameter,
// NarrativeWindow *nw = vp;
// StylesheetEditor *se;
//
-// se = stylesheet_editor_new(nw->p);
+// se = stylesheet_editor_new(nw->n);
// gtk_window_set_transient_for(GTK_WINDOW(se), GTK_WINDOW(nw->window));
// g_signal_connect(G_OBJECT(se), "changed",
// G_CALLBACK(stylesheet_changed_sig), nw);
@@ -309,7 +309,7 @@ static void add_slide_sig(GSimpleAction *action, GVariant *parameter,
{
NarrativeWindow *nw = vp;
gtk_narrative_view_add_slide_at_cursor(GTK_NARRATIVE_VIEW(nw->nv));
- presentation_set_unsaved(nw->p);
+ narrative_set_unsaved(nw->n);
update_titlebar(nw);
}
@@ -318,7 +318,7 @@ static void first_para_sig(GSimpleAction *action, GVariant *parameter,
gpointer vp)
{
NarrativeWindow *nw = vp;
- int n_paras = narrative_get_num_items(presentation_get_narrative(nw->p));
+ int n_paras = narrative_get_num_items(nw->n);
gtk_narrative_view_set_cursor_para(GTK_NARRATIVE_VIEW(nw->nv), 0);
pr_clock_set_pos(nw->pr_clock,
gtk_narrative_view_get_cursor_para(GTK_NARRATIVE_VIEW(nw->nv)),
@@ -330,7 +330,7 @@ static void first_para_sig(GSimpleAction *action, GVariant *parameter,
static void ss_prev_para(SCSlideshow *ss, void *vp)
{
NarrativeWindow *nw = vp;
- int n_paras = narrative_get_num_items(presentation_get_narrative(nw->p));
+ int n_paras = narrative_get_num_items(nw->n);
if ( gtk_narrative_view_get_cursor_para(GTK_NARRATIVE_VIEW(nw->nv)) == 0 ) return;
gtk_narrative_view_set_cursor_para(GTK_NARRATIVE_VIEW(nw->nv),
gtk_narrative_view_get_cursor_para(GTK_NARRATIVE_VIEW(nw->nv))-1);
@@ -353,12 +353,10 @@ static void ss_next_para(SCSlideshow *ss, void *vp)
{
NarrativeWindow *nw = vp;
Slide *ns;
- Narrative *narr;
GtkNarrativeView *nv;
int n_paras;
- narr = presentation_get_narrative(nw->p);
- n_paras = narrative_get_num_items(narr);
+ n_paras = narrative_get_num_items(nw->n);
nv = GTK_NARRATIVE_VIEW(nw->nv);
if ( gtk_narrative_view_get_cursor_para(nv) == n_paras - 1 ) return;
@@ -371,13 +369,13 @@ static void ss_next_para(SCSlideshow *ss, void *vp)
{
Slide *ns;
gtk_narrative_view_set_cursor_para(nv, i);
- ns = narrative_get_slide(narr, i);
+ ns = narrative_get_slide(nw->n, i);
if ( ns != NULL ) break;
}
}
pr_clock_set_pos(nw->pr_clock, gtk_narrative_view_get_cursor_para(nv), n_paras);
- ns = narrative_get_slide(narr, gtk_narrative_view_get_cursor_para(nv));
+ ns = narrative_get_slide(nw->n, gtk_narrative_view_get_cursor_para(nv));
if ( ns != NULL ) {
sc_slideshow_set_slide(nw->show, ns);
}
@@ -397,7 +395,7 @@ static void last_para_sig(GSimpleAction *action, GVariant *parameter,
gpointer vp)
{
NarrativeWindow *nw = vp;
- int n_paras = narrative_get_num_items(presentation_get_narrative(nw->p));
+ int n_paras = narrative_get_num_items(nw->n);
gtk_narrative_view_set_cursor_para(GTK_NARRATIVE_VIEW(nw->nv), -1);
pr_clock_set_pos(nw->pr_clock,
gtk_narrative_view_get_cursor_para(GTK_NARRATIVE_VIEW(nw->nv)),
@@ -417,12 +415,12 @@ static void testcard_sig(GSimpleAction *action, GVariant *parameter,
gpointer vp)
{
NarrativeWindow *nw = vp;
- show_testcard(nw->p);
+ show_testcard(nw->n);
}
static gint export_pdf_response_sig(GtkWidget *d, gint response,
- Presentation *p)
+ Narrative *n)
{
// if ( response == GTK_RESPONSE_ACCEPT ) {
// char *filename;
@@ -440,7 +438,7 @@ static gint export_pdf_response_sig(GtkWidget *d, gint response,
static void print_sig(GSimpleAction *action, GVariant *parameter, gpointer vp)
{
//NarrativeWindow *nw = vp;
-// run_printing(nw->p, nw->window);
+// run_printing(nw->n, nw->window);
}
@@ -460,7 +458,7 @@ static void exportpdf_sig(GSimpleAction *action, GVariant *parameter,
// TRUE);
//
// g_signal_connect(G_OBJECT(d), "response",
-// G_CALLBACK(export_pdf_response_sig), nw->p);
+// G_CALLBACK(export_pdf_response_sig), nw->n);
//
// gtk_widget_show_all(d);
}
@@ -476,7 +474,7 @@ static gboolean nw_button_press_sig(GtkWidget *da, GdkEventButton *event,
static void changed_sig(GtkWidget *da, NarrativeWindow *nw)
{
- presentation_set_unsaved(nw->p);
+ narrative_set_unsaved(nw->n);
update_titlebar(nw);
}
@@ -504,7 +502,7 @@ static gboolean nw_double_click_sig(GtkWidget *da, gpointer *pslide,
NarrativeWindow *nw)
{
Slide *slide = (Slide *)pslide;
- slide_window_open(nw->p, slide, nw->app);
+ slide_window_open(nw->n, slide, nw->app);
return FALSE;
}
@@ -575,13 +573,13 @@ static void start_slideshow_here_sig(GSimpleAction *action, GVariant *parameter,
NarrativeWindow *nw = vp;
Slide *slide;
- if ( presentation_get_num_slides(nw->p) == 0 ) return;
+ if ( narrative_get_num_slides(nw->n) == 0 ) return;
- slide = narrative_get_slide(presentation_get_narrative(nw->p),
+ slide = narrative_get_slide(nw->n,
gtk_narrative_view_get_cursor_para(GTK_NARRATIVE_VIEW(nw->nv)));
if ( slide == NULL ) return;
- nw->show = sc_slideshow_new(nw->p, GTK_APPLICATION(nw->app));
+ nw->show = sc_slideshow_new(nw->n, GTK_APPLICATION(nw->app));
if ( nw->show == NULL ) return;
nw->show_no_slides = 0;
@@ -602,9 +600,9 @@ static void start_slideshow_noslides_sig(GSimpleAction *action, GVariant *parame
{
NarrativeWindow *nw = vp;
- if ( presentation_get_num_slides(nw->p) == 0 ) return;
+ if ( narrative_get_num_slides(nw->n) == 0 ) return;
- nw->show = sc_slideshow_new(nw->p, GTK_APPLICATION(nw->app));
+ nw->show = sc_slideshow_new(nw->n, GTK_APPLICATION(nw->app));
if ( nw->show == NULL ) return;
nw->show_no_slides = 1;
@@ -613,7 +611,7 @@ static void start_slideshow_noslides_sig(GSimpleAction *action, GVariant *parame
G_CALLBACK(nw_key_press_sig), nw);
g_signal_connect(G_OBJECT(nw->show), "destroy",
G_CALLBACK(ss_destroy_sig), nw);
- sc_slideshow_set_slide(nw->show, presentation_get_slide_by_number(nw->p, 0));
+ sc_slideshow_set_slide(nw->show, narrative_get_slide_by_number(nw->n, 0));
gtk_narrative_view_set_para_highlight(GTK_NARRATIVE_VIEW(nw->nv), 1);
gtk_narrative_view_set_cursor_para(GTK_NARRATIVE_VIEW(nw->nv), 0);
update_toolbar(nw);
@@ -625,9 +623,9 @@ static void start_slideshow_sig(GSimpleAction *action, GVariant *parameter,
{
NarrativeWindow *nw = vp;
- if ( presentation_get_num_slides(nw->p) == 0 ) return;
+ if ( narrative_get_num_slides(nw->n) == 0 ) return;
- nw->show = sc_slideshow_new(nw->p, GTK_APPLICATION(nw->app));
+ nw->show = sc_slideshow_new(nw->n, GTK_APPLICATION(nw->app));
if ( nw->show == NULL ) return;
nw->show_no_slides = 0;
@@ -636,7 +634,7 @@ static void start_slideshow_sig(GSimpleAction *action, GVariant *parameter,
G_CALLBACK(nw_key_press_sig), nw);
g_signal_connect(G_OBJECT(nw->show), "destroy",
G_CALLBACK(ss_destroy_sig), nw);
- sc_slideshow_set_slide(nw->show, presentation_get_slide_by_number(nw->p, 0));
+ sc_slideshow_set_slide(nw->show, narrative_get_slide_by_number(nw->n, 0));
gtk_narrative_view_set_para_highlight(GTK_NARRATIVE_VIEW(nw->nv), 1);
gtk_narrative_view_set_cursor_para(GTK_NARRATIVE_VIEW(nw->nv), 0);
gtk_widget_show_all(GTK_WIDGET(nw->show));
@@ -690,7 +688,7 @@ GActionEntry nw_entries[] = {
//}
-NarrativeWindow *narrative_window_new(Presentation *p, GApplication *papp)
+NarrativeWindow *narrative_window_new(Narrative *n, GApplication *papp)
{
NarrativeWindow *nw;
GtkWidget *vbox;
@@ -704,7 +702,7 @@ NarrativeWindow *narrative_window_new(Presentation *p, GApplication *papp)
if ( nw == NULL ) return NULL;
nw->app = papp;
- nw->p = p;
+ nw->n = n;
nw->n_slidewindows = 0;
nw->window = gtk_application_window_new(GTK_APPLICATION(app));
@@ -716,7 +714,7 @@ NarrativeWindow *narrative_window_new(Presentation *p, GApplication *papp)
vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
gtk_container_add(GTK_CONTAINER(nw->window), vbox);
- nw->nv = gtk_narrative_view_new(p);
+ nw->nv = gtk_narrative_view_new(n);
toolbar = gtk_toolbar_new();
gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), GTK_TOOLBAR_ICONS);
diff --git a/src/narrative_window.h b/src/narrative_window.h
index 51c7dcc..a2c769c 100644
--- a/src/narrative_window.h
+++ b/src/narrative_window.h
@@ -29,7 +29,6 @@
typedef struct _narrative_window NarrativeWindow;
-extern NarrativeWindow *narrative_window_new(Presentation *p,
- GApplication *app);
+extern NarrativeWindow *narrative_window_new(Narrative *n, GApplication *app);
#endif /* NARRATIVE_WINDOW_H */
diff --git a/src/pdfstorycode.c b/src/pdfstorycode.c
index 421839d..d09fb47 100644
--- a/src/pdfstorycode.c
+++ b/src/pdfstorycode.c
@@ -35,7 +35,7 @@
#include <pango/pangocairo.h>
#include "storycode.h"
-#include "presentation.h"
+#include "narrative.h"
#include "slide.h"
#include "imagestore.h"
#include "slide_render_cairo.h"
@@ -44,7 +44,7 @@
#define _(x) gettext(x)
-static int render_slides_to_pdf(Presentation *p, ImageStore *is, const char *filename)
+static int render_slides_to_pdf(Narrative *n, ImageStore *is, const char *filename)
{
double w = 2048.0;
cairo_surface_t *surf;
@@ -64,20 +64,20 @@ static int render_slides_to_pdf(Presentation *p, ImageStore *is, const char *fil
sel.para = 0; sel.pos = 0; sel.trail = 0;
- for ( i=0; i<presentation_get_num_slides(p); i++ )
+ for ( i=0; i<narrative_get_num_slides(n); i++ )
{
Slide *s;
double log_w, log_h;
- s = presentation_get_slide_by_number(p, i);
- slide_get_logical_size(s, presentation_get_stylesheet(p),
+ s = narrative_get_slide_by_number(n, i);
+ slide_get_logical_size(s, narrative_get_stylesheet(n),
&log_w, &log_h);
cairo_pdf_surface_set_size(surf, w, w*(log_h/log_w));
cairo_save(cr);
cairo_scale(cr, w/log_w, w/log_w);
- slide_render_cairo(s, cr, is, presentation_get_stylesheet(p),
+ slide_render_cairo(s, cr, is, narrative_get_stylesheet(n),
i, pango_language_get_default(), pc,
NULL, sel, sel);
cairo_show_page(cr);
@@ -98,20 +98,20 @@ int main(int argc, char *argv[])
GBytes *bytes;
const char *text;
size_t len;
- Presentation *p;
+ Narrative *n;
ImageStore *is;
file = g_file_new_for_commandline_arg(argv[1]);
bytes = g_file_load_bytes(file, NULL, NULL, NULL);
text = g_bytes_get_data(bytes, &len);
- p = storycode_parse_presentation(text);
+ n = storycode_parse_presentation(text);
g_bytes_unref(bytes);
is = imagestore_new(".");
imagestore_set_parent(is, g_file_get_parent(file));
/* Render each slide to PDF */
- render_slides_to_pdf(p, is, "slides.pdf");
+ render_slides_to_pdf(n, is, "slides.pdf");
return 0;
}
diff --git a/src/pr_clock.c b/src/pr_clock.c
index aa1348e..ce20153 100644
--- a/src/pr_clock.c
+++ b/src/pr_clock.c
@@ -1,7 +1,7 @@
/*
* pr_clock.c
*
- * Copyright © 2013-2018 Thomas White <taw@bitwiz.org.uk>
+ * Copyright © 2013-2019 Thomas White <taw@bitwiz.org.uk>
*
* This file is part of Colloquium.
*
@@ -32,7 +32,6 @@
#include <libintl.h>
#define _(x) gettext(x)
-#include "presentation.h"
#include "pr_clock.h"
diff --git a/src/slide_window.c b/src/slide_window.c
index 854c1d5..24b91a0 100644
--- a/src/slide_window.c
+++ b/src/slide_window.c
@@ -33,7 +33,7 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <math.h>
-#include <presentation.h>
+#include <narrative.h>
#include <slide.h>
#include <gtkslideview.h>
@@ -44,7 +44,7 @@
struct _slidewindow
{
GtkWidget *window;
- Presentation *p;
+ Narrative *n;
Slide *slide;
GtkWidget *sv;
};
@@ -94,16 +94,16 @@ static void change_edit_slide(SlideWindow *sw, Slide *np)
static void change_slide_first(SlideWindow *sw)
{
- Slide *s = presentation_get_slide_by_number(sw->p, 0);
+ Slide *s = narrative_get_slide_by_number(sw->n, 0);
if ( s != NULL ) change_edit_slide(sw, s);
}
static void change_slide_backwards(SlideWindow *sw)
{
- int slide_n = presentation_get_slide_number(sw->p, sw->slide);
+ int slide_n = narrative_get_slide_number_for_slide(sw->n, sw->slide);
if ( slide_n > 0 ) {
- Slide *s = presentation_get_slide_by_number(sw->p, slide_n-1);
+ Slide *s = narrative_get_slide_by_number(sw->n, slide_n-1);
change_edit_slide(sw, s);
}
}
@@ -111,16 +111,16 @@ static void change_slide_backwards(SlideWindow *sw)
static void change_slide_forwards(SlideWindow *sw)
{
- int slide_n = presentation_get_slide_number(sw->p, sw->slide);
- Slide *s = presentation_get_slide_by_number(sw->p, slide_n+1);
+ int slide_n = narrative_get_slide_number_for_slide(sw->n, sw->slide);
+ Slide *s = narrative_get_slide_by_number(sw->n, slide_n+1);
if ( s != NULL ) change_edit_slide(sw, s);
}
static void change_slide_last(SlideWindow *sw)
{
- int slide_n = presentation_get_num_slides(sw->p);
- Slide *s = presentation_get_slide_by_number(sw->p, slide_n);
+ int slide_n = narrative_get_num_slides(sw->n);
+ Slide *s = narrative_get_slide_by_number(sw->n, slide_n);
if ( s != NULL ) change_edit_slide(sw, s);
}
@@ -159,7 +159,7 @@ static void last_slide_sig(GSimpleAction *action, GVariant *parameter,
static gboolean sw_close_sig(GtkWidget *w, SlideWindow *sw)
{
- //narrative_window_sw_closed(sw->p->narrative_window, sw);
+ //narrative_window_sw_closed(sw->n->narrative_window, sw);
return FALSE;
}
@@ -204,7 +204,7 @@ GActionEntry sw_entries[] = {
};
-extern SlideWindow *slide_window_open(Presentation *p, Slide *slide,
+extern SlideWindow *slide_window_open(Narrative *n, Slide *slide,
GApplication *papp)
{
GtkWidget *window;
@@ -218,7 +218,7 @@ extern SlideWindow *slide_window_open(Presentation *p, Slide *slide,
window = gtk_application_window_new(GTK_APPLICATION(app));
gtk_window_set_role(GTK_WINDOW(window), "slide");
sw->window = window;
- sw->p = p;
+ sw->n = n;
sw->slide = slide;
g_action_map_add_action_entries(G_ACTION_MAP(window), sw_entries,
@@ -227,12 +227,12 @@ extern SlideWindow *slide_window_open(Presentation *p, Slide *slide,
g_signal_connect(G_OBJECT(window), "destroy",
G_CALLBACK(sw_close_sig), sw);
- sw->sv = gtk_slide_view_new(p, slide);
+ sw->sv = gtk_slide_view_new(n, slide);
g_signal_connect(G_OBJECT(sw->sv), "key-press-event",
G_CALLBACK(sw_key_press_sig), sw);
- slide_get_logical_size(slide, presentation_get_stylesheet(p), &w, &h);
+ slide_get_logical_size(slide, narrative_get_stylesheet(n), &w, &h);
gtk_window_set_default_size(GTK_WINDOW(window), w, h);
gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(sw->sv));
diff --git a/src/slide_window.h b/src/slide_window.h
index f59fad1..50a93c4 100644
--- a/src/slide_window.h
+++ b/src/slide_window.h
@@ -29,7 +29,7 @@
typedef struct _slidewindow SlideWindow;
-extern SlideWindow *slide_window_open(Presentation *p, Slide *slide,
+extern SlideWindow *slide_window_open(Narrative *n, Slide *slide,
GApplication *papp);
#endif /* SLIDEWINDOW_H */
diff --git a/src/slideshow.c b/src/slideshow.c
index 1bd1930..692509f 100644
--- a/src/slideshow.c
+++ b/src/slideshow.c
@@ -33,7 +33,7 @@
#include <libintl.h>
#define _(x) gettext(x)
-#include <presentation.h>
+#include <narrative.h>
#include "slide_render_cairo.h"
#include "slideshow.h"
@@ -90,7 +90,7 @@ static gboolean ss_draw_sig(GtkWidget *da, cairo_t *cr, SCSlideshow *ss)
cairo_fill(cr);
slide_get_logical_size(ss->cur_slide,
- presentation_get_stylesheet(ss->p), &lw, &lh);
+ narrative_get_stylesheet(ss->n), &lw, &lh);
if ( lw/lh > (double)dw/dh ) {
/* Slide is too wide. Letterboxing top/bottom */
@@ -116,12 +116,12 @@ static gboolean ss_draw_sig(GtkWidget *da, cairo_t *cr, SCSlideshow *ss)
cairo_scale(cr, sw/lw, sh/lh);
sel.para = 0; sel.pos = 0; sel.trail = 0;
- n = presentation_get_slide_number(ss->p, ss->cur_slide);
+ n = narrative_get_slide_number_for_slide(ss->n, ss->cur_slide);
pc = pango_cairo_create_context(cr);
slide_render_cairo(ss->cur_slide, cr,
- presentation_get_imagestore(ss->p),
- presentation_get_stylesheet(ss->p),
+ narrative_get_imagestore(ss->n),
+ narrative_get_stylesheet(ss->n),
n, pango_language_get_default(), pc,
NULL, sel, sel);
@@ -160,7 +160,7 @@ void sc_slideshow_set_slide(SCSlideshow *ss, Slide *ns)
}
-SCSlideshow *sc_slideshow_new(Presentation *p, GtkApplication *app)
+SCSlideshow *sc_slideshow_new(Narrative *n, GtkApplication *app)
{
GdkDisplay *display;
int n_monitors;
@@ -170,7 +170,7 @@ SCSlideshow *sc_slideshow_new(Presentation *p, GtkApplication *app)
if ( ss == NULL ) return NULL;
ss->blank = 0;
- ss->p = p;
+ ss->n = n;
ss->cur_slide = NULL;
ss->blank_cursor = NULL;
ss->app = app;
diff --git a/src/slideshow.h b/src/slideshow.h
index 777b9f2..07fc542 100644
--- a/src/slideshow.h
+++ b/src/slideshow.h
@@ -51,7 +51,7 @@ struct _scslideshow
GtkWindow parent_instance;
/* <private> */
- Presentation *p;
+ Narrative *n;
Slide *cur_slide;
GtkWidget *drawingarea;
GdkCursor *blank_cursor;
@@ -72,7 +72,7 @@ struct _scslideshowclass
typedef struct _scslideshow SCSlideshow;
typedef struct _scslideshowclass SCSlideshowClass;
-extern SCSlideshow *sc_slideshow_new(Presentation *p, GtkApplication *app);
+extern SCSlideshow *sc_slideshow_new(Narrative *n, GtkApplication *app);
extern void sc_slideshow_set_slide(SCSlideshow *ss, Slide *ns);
extern Slide *sc_slideshow_get_slide(SCSlideshow *ss);
diff --git a/src/testcard.c b/src/testcard.c
index 2975187..9febf90 100644
--- a/src/testcard.c
+++ b/src/testcard.c
@@ -33,7 +33,7 @@
#include <libintl.h>
#define _(x) gettext(x)
-#include <presentation.h>
+#include <narrative.h>
struct testcard
@@ -236,7 +236,7 @@ static gboolean tc_key_press_sig(GtkWidget *da, GdkEventKey *event,
}
-void show_testcard(Presentation *p)
+void show_testcard(Narrative *n)
{
GdkDisplay *display;
int n_monitors;
@@ -246,7 +246,7 @@ void show_testcard(Presentation *p)
if ( tc == NULL ) return;
tc->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
- stylesheet_get_slide_default_size(presentation_get_stylesheet(p),
+ stylesheet_get_slide_default_size(narrative_get_stylesheet(n),
&tc->slide_width, &tc->slide_height);
tc->drawingarea = gtk_drawing_area_new();
diff --git a/src/testcard.h b/src/testcard.h
index da8315f..8e9a4ca 100644
--- a/src/testcard.h
+++ b/src/testcard.h
@@ -27,8 +27,8 @@
#include <config.h>
#endif
-#include <presentation.h>
+#include <narrative.h>
-extern void show_testcard(Presentation *p);
+extern void show_testcard(Narrative *n);
#endif /* TESTCARD_H */