aboutsummaryrefslogtreecommitdiff
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
parent4571fe902303b707b4cf4491f3caff653edc4934 (diff)
Add alignment to stylesheet editor
-rw-r--r--data/stylesheeteditor.ui96
-rw-r--r--src/stylesheet_editor.c43
-rw-r--r--src/stylesheet_editor.h2
3 files changed, 137 insertions, 4 deletions
diff --git a/data/stylesheeteditor.ui b/data/stylesheeteditor.ui
index 19723bb..0e806be 100644
--- a/data/stylesheeteditor.ui
+++ b/data/stylesheeteditor.ui
@@ -298,6 +298,50 @@
</packing>
</child>
<child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">8</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Alignment:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="narrative_style_alignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="active">0</property>
+ <property name="active_id">left</property>
+ <items>
+ <item id="left" translatable="yes">Left</item>
+ <item id="center" translatable="yes">Center</item>
+ <item id="right" translatable="yes">Right</item>
+ </items>
+ <signal name="changed" handler="narrative_alignment_sig" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">2</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -433,7 +477,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">4</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -572,7 +616,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">4</property>
- <property name="position">4</property>
+ <property name="position">5</property>
</packing>
</child>
</object>
@@ -914,6 +958,50 @@
</packing>
</child>
<child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">8</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Alignment:</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="frame_style_alignment">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="active">0</property>
+ <property name="active_id">left</property>
+ <items>
+ <item id="left" translatable="yes">Left</item>
+ <item id="center" translatable="yes">Center</item>
+ <item id="right" translatable="yes">Right</item>
+ </items>
+ <signal name="changed" handler="frame_alignment_sig" swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">2</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
+ <child>
<object class="GtkFrame">
<property name="visible">True</property>
<property name="can_focus">False</property>
@@ -1049,7 +1137,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">4</property>
- <property name="position">3</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -1188,7 +1276,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">4</property>
- <property name="position">4</property>
+ <property name="position">5</property>
</packing>
</child>
</object>
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;
};