aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2018-10-30 21:35:10 +0100
committerThomas White <taw@bitwiz.me.uk>2018-10-30 21:35:10 +0100
commit471310e27efc55b3410f3380c60acdc498e21c38 (patch)
treeec51b08dd32e542a6201412834b94503b0515a12 /src
parent4571fe902303b707b4cf4491f3caff653edc4934 (diff)
Add alignment to stylesheet editor
Diffstat (limited to 'src')
-rw-r--r--src/stylesheet_editor.c43
-rw-r--r--src/stylesheet_editor.h2
2 files changed, 45 insertions, 0 deletions
diff --git a/src/stylesheet_editor.c b/src/stylesheet_editor.c
index 8100472..55ac3a9 100644
--- a/src/stylesheet_editor.c
+++ b/src/stylesheet_editor.c
@@ -106,6 +106,27 @@ static void set_size_from_ss(Stylesheet *ss, const char *path,
}
}
+
+static int alignment_ok(const char *a)
+{
+ if ( a == NULL ) return 0;
+ if ( strcmp(a, "left") == 0 ) return 1;
+ if ( strcmp(a, "center") == 0 ) return 1;
+ if ( strcmp(a, "right") == 0 ) return 1;
+ return 0;
+}
+
+
+static void set_alignment_from_ss(Stylesheet *ss, const char *path,
+ GtkWidget *d)
+{
+ char *result = stylesheet_lookup(ss, path, "alignment");
+ if ( alignment_ok(result) ) {
+ gtk_combo_box_set_active_id(GTK_COMBO_BOX(d), result);
+ }
+}
+
+
static void set_bg_from_ss(Stylesheet *ss, const char *path, GtkWidget *wcol,
GtkWidget *wcol2, GtkWidget *wgrad)
{
@@ -173,6 +194,7 @@ static void set_values_from_presentation(StylesheetEditor *se)
/* Narrative */
set_font_from_ss(ss, "$.narrative", se->narrative_style_font);
set_col_from_ss(ss, "$.narrative", se->narrative_style_fgcol);
+ set_alignment_from_ss(ss, "$.narrative", se->narrative_style_alignment);
set_bg_from_ss(ss, "$.narrative", se->narrative_style_bgcol,
se->narrative_style_bgcol2,
se->narrative_style_bggrad);
@@ -195,6 +217,7 @@ static void set_values_from_presentation(StylesheetEditor *se)
/* Frames */
set_font_from_ss(ss, "$.slide.frame", se->frame_style_font);
set_col_from_ss(ss, "$.slide.frame", se->frame_style_fgcol);
+ set_alignment_from_ss(ss, "$.slide.frame", se->frame_style_alignment);
set_bg_from_ss(ss, "$.slide.frame", se->frame_style_bgcol,
se->frame_style_bgcol2,
se->frame_style_bggrad);
@@ -347,6 +370,15 @@ static void narrative_bg_sig(GtkColorButton *widget, StylesheetEditor *se)
}
+static void narrative_alignment_sig(GtkComboBoxText *widget, StylesheetEditor *se)
+{
+ const gchar *id = gtk_combo_box_get_active_id(GTK_COMBO_BOX(widget));
+ stylesheet_set(se->priv->p->stylesheet, "$.narrative", "alignment", id);
+ set_values_from_presentation(se);
+ g_signal_emit_by_name(se, "changed");
+}
+
+
static void slide_size_sig(GtkSpinButton *widget, StylesheetEditor *se)
{
int w, h;
@@ -426,6 +458,15 @@ static void frame_paraspace_sig(GtkSpinButton *widget, StylesheetEditor *se)
}
+static void frame_alignment_sig(GtkComboBoxText *widget, StylesheetEditor *se)
+{
+ const gchar *id = gtk_combo_box_get_active_id(GTK_COMBO_BOX(widget));
+ stylesheet_set(se->priv->p->stylesheet, "$.slide.frame", "alignment", id);
+ set_values_from_presentation(se);
+ g_signal_emit_by_name(se, "changed");
+}
+
+
static void narrative_padding_sig(GtkSpinButton *widget, StylesheetEditor *se)
{
update_spacing(se->priv->p, "$.narrative", "pad",
@@ -487,6 +528,7 @@ void stylesheet_editor_class_init(StylesheetEditorClass *klass)
SE_BIND_CHILD(narrative_style_padding_r, narrative_padding_sig);
SE_BIND_CHILD(narrative_style_padding_t, narrative_padding_sig);
SE_BIND_CHILD(narrative_style_padding_b, narrative_padding_sig);
+ SE_BIND_CHILD(narrative_style_alignment, narrative_alignment_sig);
/* Slide style */
SE_BIND_CHILD(slide_size_w, slide_size_sig);
@@ -509,6 +551,7 @@ void stylesheet_editor_class_init(StylesheetEditorClass *klass)
SE_BIND_CHILD(frame_style_padding_r, frame_padding_sig);
SE_BIND_CHILD(frame_style_padding_t, frame_padding_sig);
SE_BIND_CHILD(frame_style_padding_b, frame_padding_sig);
+ SE_BIND_CHILD(frame_style_alignment, frame_alignment_sig);
gtk_widget_class_bind_template_callback(widget_class, revert_sig);
diff --git a/src/stylesheet_editor.h b/src/stylesheet_editor.h
index 22856da..0dea6d5 100644
--- a/src/stylesheet_editor.h
+++ b/src/stylesheet_editor.h
@@ -71,6 +71,7 @@ struct _stylesheeteditor
GtkWidget *narrative_style_padding_r;
GtkWidget *narrative_style_padding_t;
GtkWidget *narrative_style_padding_b;
+ GtkWidget *narrative_style_alignment;
GtkWidget *slide_size_w;
GtkWidget *slide_size_h;
GtkWidget *slide_style_bgcol;
@@ -89,6 +90,7 @@ struct _stylesheeteditor
GtkWidget *frame_style_padding_r;
GtkWidget *frame_style_padding_t;
GtkWidget *frame_style_padding_b;
+ GtkWidget *frame_style_alignment;
StylesheetEditorPrivate *priv;
};