diff options
author | Thomas White <taw@bitwiz.me.uk> | 2018-11-01 23:11:19 +0100 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2018-11-01 23:22:13 +0100 |
commit | ac114445ed6e5c8722a9eec0fe934df00c615f2d (patch) | |
tree | f4e5599d4afd4a35efb1b48bdec06660d8d44e2d /src/stylesheet_editor.c | |
parent | 983e03f02bd948083bf4c57b7eabf19674f743a4 (diff) |
Implement "revert" in stylesheet editor
Diffstat (limited to 'src/stylesheet_editor.c')
-rw-r--r-- | src/stylesheet_editor.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/stylesheet_editor.c b/src/stylesheet_editor.c index 55ac3a9..0f5b908 100644 --- a/src/stylesheet_editor.c +++ b/src/stylesheet_editor.c @@ -44,6 +44,7 @@ G_DEFINE_TYPE_WITH_CODE(StylesheetEditor, stylesheet_editor, struct _sspriv { struct presentation *p; + char *ssdata; }; @@ -315,9 +316,12 @@ static void update_spacing(struct presentation *p, const char *style_name, } -static void revert_sig(GtkButton *button, StylesheetEditor *widget) +static void revert_sig(GtkButton *button, StylesheetEditor *se) { - printf("click revert!\n"); + stylesheet_set_data(se->priv->p->stylesheet, + se->priv->ssdata); + set_values_from_presentation(se); + g_signal_emit_by_name(se, "changed"); } @@ -491,6 +495,14 @@ static void narrative_paraspace_sig(GtkSpinButton *widget, StylesheetEditor *se) } +static void stylesheet_editor_finalize(GObject *obj) +{ + StylesheetEditor *se = COLLOQUIUM_STYLESHEET_EDITOR(obj); + free(se->priv->ssdata); + G_OBJECT_CLASS(stylesheet_editor_parent_class)->finalize(obj); +} + + static void stylesheet_editor_init(StylesheetEditor *se) { se->priv = G_TYPE_INSTANCE_GET_PRIVATE(se, COLLOQUIUM_TYPE_STYLESHEET_EDITOR, @@ -512,7 +524,7 @@ void stylesheet_editor_class_init(StylesheetEditorClass *klass) "/uk/me/bitwiz/Colloquium/stylesheeteditor.ui"); g_type_class_add_private(gobject_class, sizeof(StylesheetEditorPrivate)); - + gobject_class->finalize = stylesheet_editor_finalize; /* Narrative style */ SE_BIND_CHILD(narrative_style_font, narrative_font_sig); @@ -570,6 +582,8 @@ StylesheetEditor *stylesheet_editor_new(struct presentation *p) se->priv->p = p; set_values_from_presentation(se); + se->priv->ssdata = stylesheet_data(p->stylesheet); + return se; } |