diff options
author | Thomas White <taw@bitwiz.me.uk> | 2018-04-29 21:40:21 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.me.uk> | 2018-04-29 21:40:21 +0200 |
commit | 992cf2451ad3720466fb8957e1296d3468dab17e (patch) | |
tree | c223d03d5d529cb51c66f988da2fb1c87f6a5d10 /src/stylesheet_editor.c | |
parent | 507581ce62ee42a09a3cf57d9d13654edfee659f (diff) |
Implement setting default font
Diffstat (limited to 'src/stylesheet_editor.c')
-rw-r--r-- | src/stylesheet_editor.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/stylesheet_editor.c b/src/stylesheet_editor.c index 5699385..bb65be7 100644 --- a/src/stylesheet_editor.c +++ b/src/stylesheet_editor.c @@ -38,18 +38,58 @@ G_DEFINE_TYPE_WITH_CODE(StylesheetEditor, stylesheet_editor, GTK_TYPE_DIALOG, NULL) +static void set_values_from_presentation(StylesheetEditor *se); + struct _sspriv { struct presentation *p; }; +static void set_ss(SCBlock *bl, const char *find, const char *seti) +{ + char *set; + const char *name; + + set = strdup(seti); + if ( set == NULL ) return; + + name = sc_block_name(bl); + if ( (name != NULL) && (strcmp(name, "stylesheet")==0) ) { + bl = sc_block_child(bl); + } + + while ( bl != NULL ) { + + const char *name = sc_block_name(bl); + if ( (name != NULL) && (strcmp(name, find)==0) ) { + sc_block_set_options(bl, set); + return; + } + + bl = sc_block_next(bl); + + } + + fprintf(stderr, "WARNING: Didn't find block in stylesheet to set.\n"); +} + + static void revert_sig(GtkButton *button, StylesheetEditor *widget) { printf("click revert!\n"); } +static void default_font_sig(GtkFontButton *widget, StylesheetEditor *se) +{ + const gchar *font; + font = gtk_font_button_get_font_name(GTK_FONT_BUTTON(widget)); + set_ss(se->priv->p->stylesheet, "font", font); + set_values_from_presentation(se); +} + + static void stylesheet_editor_init(StylesheetEditor *se) { se->priv = G_TYPE_INSTANCE_GET_PRIVATE(se, COLLOQUIUM_TYPE_STYLESHEET_EDITOR, @@ -76,6 +116,7 @@ void stylesheet_editor_class_init(StylesheetEditorClass *klass) default_style_fgcol); gtk_widget_class_bind_template_callback(widget_class, revert_sig); + gtk_widget_class_bind_template_callback(widget_class, default_font_sig); } |