aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/stylesheeteditor.ui27
-rw-r--r--src/stylesheet_editor.c126
2 files changed, 129 insertions, 24 deletions
diff --git a/data/stylesheeteditor.ui b/data/stylesheeteditor.ui
index e02a8e8..626d3a5 100644
--- a/data/stylesheeteditor.ui
+++ b/data/stylesheeteditor.ui
@@ -53,7 +53,7 @@
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment19">
- <property name="upper">100</property>
+ <property name="upper">5000</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
@@ -63,17 +63,17 @@
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment20">
- <property name="upper">100</property>
+ <property name="upper">5000</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment21">
- <property name="upper">100</property>
+ <property name="upper">5000</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
<object class="GtkAdjustment" id="adjustment22">
- <property name="upper">100</property>
+ <property name="upper">5000</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
@@ -1463,6 +1463,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment19</property>
+ <signal name="value-changed" handler="furniture_dims_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1475,6 +1476,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment20</property>
+ <signal name="value-changed" handler="furniture_dims_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1487,6 +1489,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment21</property>
+ <signal name="value-changed" handler="furniture_dims_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">4</property>
@@ -1499,6 +1502,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment22</property>
+ <signal name="value-changed" handler="furniture_dims_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">4</property>
@@ -1515,6 +1519,7 @@
<item id="percent" translatable="yes">% slide</item>
<item id="units" translatable="yes">units</item>
</items>
+ <signal name="changed" handler="furniture_dims_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">5</property>
@@ -1530,6 +1535,7 @@
<item id="percent" translatable="yes">% slide</item>
<item id="units" translatable="yes">units</item>
</items>
+ <signal name="changed" handler="furniture_dims_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">2</property>
@@ -1599,6 +1605,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
+ <signal name="color-set" handler="furniture_fgcol_sig" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@@ -1640,6 +1647,7 @@
<item id="horiz" translatable="yes">Horizontal gradient</item>
<item id="vert" translatable="yes">Vertical gradient</item>
</items>
+ <signal name="changed" handler="furniture_bg_sig" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
@@ -1653,6 +1661,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
+ <signal name="color-set" handler="furniture_bg_sig" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@@ -1666,6 +1675,7 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_alpha">True</property>
+ <signal name="color-set" handler="furniture_bg_sig" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@@ -1709,6 +1719,7 @@
<item id="center" translatable="yes">Center</item>
<item id="right" translatable="yes">Right</item>
</items>
+ <signal name="changed" handler="furniture_alignment_sig" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
@@ -1802,6 +1813,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment23</property>
+ <signal name="value-changed" handler="furniture_padding_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1814,6 +1826,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment24</property>
+ <signal name="value-changed" handler="furniture_padding_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1826,6 +1839,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment25</property>
+ <signal name="value-changed" handler="furniture_padding_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">3</property>
@@ -1838,6 +1852,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment26</property>
+ <signal name="value-changed" handler="furniture_padding_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">3</property>
@@ -1936,6 +1951,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment27</property>
+ <signal name="value-changed" handler="furniture_paraspace_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1948,6 +1964,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment28</property>
+ <signal name="value-changed" handler="furniture_paraspace_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1960,6 +1977,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment29</property>
+ <signal name="value-changed" handler="furniture_paraspace_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">3</property>
@@ -1972,6 +1990,7 @@
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adjustment30</property>
+ <signal name="value-changed" handler="furniture_paraspace_sig" swapped="no"/>
</object>
<packing>
<property name="left_attach">3</property>
diff --git a/src/stylesheet_editor.c b/src/stylesheet_editor.c
index 0eb7fde..292bbf1 100644
--- a/src/stylesheet_editor.c
+++ b/src/stylesheet_editor.c
@@ -254,8 +254,6 @@ static void set_furniture(StylesheetEditor *se, const char *furniture)
}
-
-
static void set_values_from_presentation(StylesheetEditor *se)
{
Stylesheet *ss = se->priv->p->stylesheet;
@@ -386,6 +384,46 @@ static void update_spacing(struct presentation *p, const char *style_name,
}
+static char units_id_to_char(const char *id)
+{
+ if ( strcmp(id, "units") == 0 ) return 'u';
+ if ( strcmp(id, "percent") == 0 ) return 'f';
+ return 'u';
+}
+
+
+static void update_ss_dims(struct presentation *p, const char *style_name,
+ const char *key, GtkWidget *ww, GtkWidget *wh,
+ GtkWidget *wx, GtkWidget *wy,
+ GtkWidget *wwu, GtkWidget *whu)
+{
+ float w, h, x, y;
+ char w_units, h_units;
+ const gchar *uid;
+ char tmp[256];
+
+ w = gtk_spin_button_get_value(GTK_SPIN_BUTTON(ww));
+ h = gtk_spin_button_get_value(GTK_SPIN_BUTTON(wh));
+ x = gtk_spin_button_get_value(GTK_SPIN_BUTTON(wx));
+ y = gtk_spin_button_get_value(GTK_SPIN_BUTTON(wy));
+ uid = gtk_combo_box_get_active_id(GTK_COMBO_BOX(wwu));
+ w_units = units_id_to_char(uid);
+ uid = gtk_combo_box_get_active_id(GTK_COMBO_BOX(whu));
+ h_units = units_id_to_char(uid);
+
+ if ( w_units == 'f' ) w /= 100.0;
+ if ( h_units == 'f' ) h /= 100.0;
+
+ if ( snprintf(tmp, 256, "%.2f%cx%.2f%c+%.0f+%0.f",
+ w, w_units, h, h_units, x, y) >= 256 )
+ {
+ fprintf(stderr, "Spacing too long\n");
+ } else {
+ stylesheet_set(p->stylesheet, style_name, key, tmp);
+ }
+}
+
+
static void revert_sig(GtkButton *button, StylesheetEditor *se)
{
stylesheet_set_data(se->priv->p->stylesheet,
@@ -402,7 +440,6 @@ static void set_font(GtkFontButton *widget, StylesheetEditor *se,
font = gtk_font_button_get_font_name(GTK_FONT_BUTTON(widget));
stylesheet_set(se->priv->p->stylesheet, style_name, "font", font);
- printf("setting %s . %s to %s\n", style_name, "font", font);
set_values_from_presentation(se);
g_signal_emit_by_name(se, "changed");
}
@@ -566,30 +603,79 @@ static void narrative_paraspace_sig(GtkSpinButton *widget, StylesheetEditor *se)
}
+static void furniture_selector_change_sig(GtkComboBoxText *widget, StylesheetEditor *se)
+{
+ se->priv->furniture = gtk_combo_box_get_active_id(GTK_COMBO_BOX(widget));
+ set_furniture(se, se->priv->furniture);
+}
+
+
+static void furniture_font_sig(GtkFontButton *widget, StylesheetEditor *se)
+{
+ set_font(widget, se, se->priv->furniture);
+}
+
+
+static void furniture_fgcol_sig(GtkColorButton *widget, StylesheetEditor *se)
+{
+ set_col(widget, se,se->priv->furniture, "fgcol");
+}
+
+
+static void furniture_bg_sig(GtkColorButton *widget, StylesheetEditor *se)
+{
+ update_bg(se->priv->p, se->priv->furniture, se->furniture_bggrad,
+ se->furniture_bgcol, se->furniture_bgcol2);
+ set_values_from_presentation(se);
+ g_signal_emit_by_name(se, "changed");
+}
+
+
static void furniture_paraspace_sig(GtkSpinButton *widget, StylesheetEditor *se)
{
+ update_spacing(se->priv->p, se->priv->furniture, "pad",
+ se->furniture_padding_l,
+ se->furniture_padding_r,
+ se->furniture_padding_t,
+ se->furniture_padding_b);
+ set_values_from_presentation(se);
+ g_signal_emit_by_name(se, "changed");
}
static void furniture_padding_sig(GtkSpinButton *widget, StylesheetEditor *se)
{
+ update_spacing(se->priv->p, se->priv->furniture, "pad",
+ se->furniture_padding_l,
+ se->furniture_padding_r,
+ se->furniture_padding_t,
+ se->furniture_padding_b);
+ set_values_from_presentation(se);
+ g_signal_emit_by_name(se, "changed");
}
-static void furniture_selector_change_sig(GtkComboBoxText *widget, StylesheetEditor *se)
+static void furniture_alignment_sig(GtkComboBoxText *widget, StylesheetEditor *se)
{
- se->priv->furniture = gtk_combo_box_get_active_id(GTK_COMBO_BOX(widget));
- set_furniture(se, se->priv->furniture);
+ const gchar *id = gtk_combo_box_get_active_id(GTK_COMBO_BOX(widget));
+ stylesheet_set(se->priv->p->stylesheet, se->priv->furniture,
+ "alignment", id);
+ set_values_from_presentation(se);
+ g_signal_emit_by_name(se, "changed");
}
-static void furniture_font_sig(GtkFontButton *widget, StylesheetEditor *se)
+static void furniture_dims_sig(GtkSpinButton *widget, StylesheetEditor *se)
{
- set_font(widget, se, se->priv->furniture);
+ update_ss_dims(se->priv->p, se->priv->furniture, "geometry",
+ se->furniture_w, se->furniture_h,
+ se->furniture_x, se->furniture_y,
+ se->furniture_w_units, se->furniture_h_units);
+ set_values_from_presentation(se);
+ g_signal_emit_by_name(se, "changed");
}
-
static void stylesheet_editor_finalize(GObject *obj)
{
StylesheetEditor *se = COLLOQUIUM_STYLESHEET_EDITOR(obj);
@@ -671,17 +757,17 @@ void stylesheet_editor_class_init(StylesheetEditorClass *klass)
SE_BIND_CHILD(furniture_padding_t, furniture_padding_sig);
SE_BIND_CHILD(furniture_padding_b, furniture_padding_sig);
SE_BIND_CHILD(furniture_font, furniture_font_sig);
- SE_BIND_CHILD(furniture_fgcol, NULL);
- SE_BIND_CHILD(furniture_bgcol, NULL);
- SE_BIND_CHILD(furniture_bgcol2, NULL);
- SE_BIND_CHILD(furniture_bggrad, NULL);
- SE_BIND_CHILD(furniture_alignment, NULL);
- SE_BIND_CHILD(furniture_w, NULL);
- SE_BIND_CHILD(furniture_h, NULL);
- SE_BIND_CHILD(furniture_x, NULL);
- SE_BIND_CHILD(furniture_y, NULL);
- SE_BIND_CHILD(furniture_w_units, NULL);
- SE_BIND_CHILD(furniture_h_units, NULL);
+ SE_BIND_CHILD(furniture_fgcol, furniture_fgcol_sig);
+ SE_BIND_CHILD(furniture_bgcol, furniture_bg_sig);
+ SE_BIND_CHILD(furniture_bgcol2, furniture_bg_sig);
+ SE_BIND_CHILD(furniture_bggrad, furniture_bg_sig);
+ SE_BIND_CHILD(furniture_alignment, furniture_alignment_sig);
+ SE_BIND_CHILD(furniture_w, furniture_dims_sig);
+ SE_BIND_CHILD(furniture_h, furniture_dims_sig);
+ SE_BIND_CHILD(furniture_x, furniture_dims_sig);
+ SE_BIND_CHILD(furniture_y, furniture_dims_sig);
+ SE_BIND_CHILD(furniture_w_units, furniture_dims_sig);
+ SE_BIND_CHILD(furniture_h_units, furniture_dims_sig);
gtk_widget_class_bind_template_callback(widget_class, revert_sig);