diff options
-rw-r--r-- | libstorycode/stylesheet.c | 20 | ||||
-rw-r--r-- | libstorycode/stylesheet.h | 1 | ||||
-rw-r--r-- | src/stylesheet_editor.c | 5 |
3 files changed, 25 insertions, 1 deletions
diff --git a/libstorycode/stylesheet.c b/libstorycode/stylesheet.c index 3bbddb3..be4db9b 100644 --- a/libstorycode/stylesheet.c +++ b/libstorycode/stylesheet.c @@ -568,3 +568,23 @@ const char *stylesheet_get_friendly_name(const char *in) if ( strcmp(in, "FOOTER") == 0 ) return "Footer"; return in; } + + +int stylesheet_set_from_storycode(Stylesheet *ss, const char *sc) +{ + Stylesheet *ssnew; + Narrative *n; + + n = storycode_parse_presentation(sc); + if ( n == NULL ) return 1; + + ssnew = narrative_get_stylesheet(n); + if ( ssnew == NULL ) return 1; + + narrative_free(n); + + free_style_contents(&ss->top); + ss->top = ssnew->top; + + return 0; +} diff --git a/libstorycode/stylesheet.h b/libstorycode/stylesheet.h index 0a38477..0b994da 100644 --- a/libstorycode/stylesheet.h +++ b/libstorycode/stylesheet.h @@ -79,6 +79,7 @@ enum gradient extern Stylesheet *stylesheet_new(void); extern void stylesheet_free(Stylesheet *s); +extern int stylesheet_set_from_storycode(Stylesheet *ss, const char *sc); extern int stylesheet_get_slide_default_size(Stylesheet *s, double *w, double *h); diff --git a/src/stylesheet_editor.c b/src/stylesheet_editor.c index c70b678..1cff58a 100644 --- a/src/stylesheet_editor.c +++ b/src/stylesheet_editor.c @@ -38,6 +38,7 @@ struct _sspriv { Stylesheet *stylesheet; + char *orig_ss; char *style_name; }; @@ -379,7 +380,7 @@ static void element_changed(GtkTreeSelection *sel, StylesheetEditor *se) static void revert_sig(GtkButton *button, StylesheetEditor *se) { - /* FIXME: implement */ + stylesheet_set_from_storycode(se->priv->stylesheet, se->priv->orig_ss); set_values_from_presentation(se); g_signal_emit_by_name(se, "changed"); } @@ -545,6 +546,7 @@ static void bg_sig(GtkColorButton *widget, StylesheetEditor *se) static void stylesheet_editor_finalize(GObject *obj) { + free(COLLOQUIUM_STYLESHEET_EDITOR(obj)->priv->orig_ss); G_OBJECT_CLASS(stylesheet_editor_parent_class)->finalize(obj); } @@ -614,6 +616,7 @@ StylesheetEditor *stylesheet_editor_new(Stylesheet *ss) se->priv->stylesheet = ss; se->priv->style_name = NULL; + se->priv->orig_ss = stylesheet_serialise(ss); renderer = gtk_cell_renderer_text_new(); column = gtk_tree_view_column_new_with_attributes("Element", renderer, |