aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2018-04-29 21:40:21 +0200
committerThomas White <taw@bitwiz.me.uk>2018-04-29 21:40:21 +0200
commit992cf2451ad3720466fb8957e1296d3468dab17e (patch)
treec223d03d5d529cb51c66f988da2fb1c87f6a5d10
parent507581ce62ee42a09a3cf57d9d13654edfee659f (diff)
Implement setting default font
-rw-r--r--data/stylesheeteditor.ui1
-rw-r--r--src/stylesheet_editor.c41
2 files changed, 42 insertions, 0 deletions
diff --git a/data/stylesheeteditor.ui b/data/stylesheeteditor.ui
index 3e1bba3..5dd473d 100644
--- a/data/stylesheeteditor.ui
+++ b/data/stylesheeteditor.ui
@@ -109,6 +109,7 @@
<property name="receives_default">True</property>
<property name="font">Sans 12</property>
<property name="preview_text">Preview text</property>
+ <signal name="font-set" handler="default_font_sig" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
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);
}