aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2018-10-20 10:02:31 +0200
committerThomas White <taw@bitwiz.me.uk>2018-10-20 10:02:31 +0200
commitae183124e9317f3d183da746b93d75909c7b89b5 (patch)
tree99f5589cd20743333a6def64b27d36d265207a0e
parent6f4dfee487a912ad8db247ca57cd0dc87488cdee (diff)
Remove template stuff
-rw-r--r--src/narrative_window.c59
-rw-r--r--src/sc_interp.c84
-rw-r--r--src/sc_interp.h11
3 files changed, 2 insertions, 152 deletions
diff --git a/src/narrative_window.c b/src/narrative_window.c
index 7a19562..ead78bd 100644
--- a/src/narrative_window.c
+++ b/src/narrative_window.c
@@ -185,59 +185,6 @@ static void delete_slide_sig(GSimpleAction *action, GVariant *parameter,
}
-static struct template_id *get_templates(Stylesheet *ss, int *n)
-{
- /* FIXME: From JSON stylesheet */
- *n = 0;
- return NULL;
-}
-
-
-static void update_template_menus(NarrativeWindow *nw)
-{
- struct template_id *templates;
- int i, n_templates;
-
- templates = get_templates(nw->p->stylesheet, &n_templates);
-
- for ( i=0; i<n_templates; i++ ) {
- free(templates[i].name);
- free(templates[i].friendlyname);
- sc_block_free(templates[i].scblock);
- }
-
- free(templates);
-}
-
-
-static SCBlock *get_slide_template(Stylesheet *ss)
-{
- struct template_id *templates;
- int i, n_templates;
- SCBlock *ret = NULL;
-
- templates = get_templates(ss, &n_templates);
-
- for ( i=0; i<n_templates; i++ ) {
- if ( strcmp(templates[i].name, "slide") == 0 ) {
- ret = templates[i].scblock;
- } else {
- sc_block_free(templates[i].scblock);
- }
- free(templates[i].name);
- free(templates[i].friendlyname);
- }
- free(templates);
-
- /* No template? */
- if ( ret == NULL ) {
- ret = sc_parse("\\slide{}");
- }
-
- return ret; /* NB this is a copy of the one owned by the interpreter */
-}
-
-
static gint load_ss_response_sig(GtkWidget *d, gint response,
NarrativeWindow *nw)
{
@@ -330,9 +277,8 @@ static void add_slide_sig(GSimpleAction *action, GVariant *parameter,
/* Split the current paragraph */
nsblock = split_paragraph_at_cursor(nw->sceditor);
- /* Get the template */
- templ = get_slide_template(nw->p->stylesheet); /* our copy */
- show_sc_blocks(templ);
+ /* FIXME: Template from JSON */
+ templ = sc_parse("\\slide{}");
/* Link the new SCBlock in */
if ( nsblock != NULL ) {
@@ -865,7 +811,6 @@ NarrativeWindow *narrative_window_new(struct presentation *p, GApplication *papp
"win.last");
update_toolbar(nw);
- update_template_menus(nw);
scroll = gtk_scrolled_window_new(NULL, NULL);
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll),
diff --git a/src/sc_interp.c b/src/sc_interp.c
index 7b996f6..05e9325 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -38,13 +38,6 @@
#include "utils.h"
-struct template
-{
- char *name;
- SCBlock *bl;
-};
-
-
struct sc_state
{
PangoFontDescription *fontdesc;
@@ -63,10 +56,6 @@ struct sc_state
double slide_height;
struct frame *fr; /* The current frame */
-
- int n_templates;
- int max_templates;
- struct template *templates;
};
struct _scinterp
@@ -615,14 +604,6 @@ SCInterpreter *sc_interp_new(PangoContext *pc, PangoLanguage *lang,
scin->cbl = NULL;
st = &scin->state[0];
- st->n_templates = 0;
- st->max_templates = 16;
- st->templates = malloc(16*sizeof(struct template));
- if ( st->templates == NULL ) {
- free(scin->state);
- free(scin);
- return NULL;
- }
st->fr = NULL;
st->paraspace[0] = 0.0;
st->paraspace[1] = 0.0;
@@ -660,8 +641,6 @@ SCInterpreter *sc_interp_new(PangoContext *pc, PangoLanguage *lang,
void sc_interp_destroy(SCInterpreter *scin)
{
- /* FIXME: Free all templates */
-
/* Empty the stack */
while ( scin->j > 0 ) {
sc_interp_restore(scin);
@@ -1265,66 +1244,3 @@ int sc_interp_add_blocks(SCInterpreter *scin, SCBlock *bl, Stylesheet *ss)
return 0;
}
-
-static int try_add_template(SCInterpreter *scin, const char *options, SCBlock *bl)
-{
- struct sc_state *st = &scin->state[scin->j];
- char *nn;
- char *comma;
- int i;
-
- nn = strdup(options);
- comma = strchr(nn, ',');
- if ( comma != NULL ) {
- comma[0] = '\0';
- }
-
- for ( i=0; i<st->n_templates; i++ ) {
- if ( strcmp(st->templates[i].name, nn) == 0 ) {
- fprintf(stderr, _("Duplicate template '%s'\n"), nn);
- return 0;
- }
- }
-
- if ( st->max_templates == st->n_templates ) {
-
- struct template *templates_new;
-
- templates_new = realloc(st->templates, sizeof(struct template)
- * (st->max_templates+16));
- if ( templates_new == NULL ) {
- fprintf(stderr, _("Failed to add templates\n"));
- return 1;
- }
-
- st->templates = templates_new;
- st->max_templates += 16;
-
- }
-
- i = st->n_templates++;
-
- st->templates[i].name = nn;
- st->templates[i].bl = bl;
-
- return 0;
-}
-
-
-struct template_id *sc_interp_get_templates(SCInterpreter *scin, int *np)
-{
- struct template_id *list;
- int i;
-
- list = malloc(sizeof(struct template_id)*scin->state->n_templates);
- if ( list == NULL ) return NULL;
-
- for ( i=0; i<scin->state->n_templates; i++ ) {
- list[i].name = strdup(scin->state->templates[i].name);
- list[i].friendlyname = strdup(scin->state->templates[i].name);
- list[i].scblock = sc_block_copy(scin->state->templates[i].bl);
- }
-
- *np = scin->state->n_templates;
- return list;
-}
diff --git a/src/sc_interp.h b/src/sc_interp.h
index b0bd689..7593226 100644
--- a/src/sc_interp.h
+++ b/src/sc_interp.h
@@ -87,15 +87,4 @@ extern int sc_interp_get_height(SCInterpreter *scin);
extern void update_geom(struct frame *fr);
-struct template_id
-{
- char *name;
- char *friendlyname;
- SCBlock *scblock;
-};
-
-extern struct template_id *sc_interp_get_templates(SCInterpreter *scin,
- int *np);
-
-
#endif /* SC_INTERP_H */