aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--data/stylesheeteditor.ui164
-rw-r--r--src/frame.h7
-rw-r--r--src/sc_interp.c56
-rw-r--r--src/stylesheet.c10
-rw-r--r--src/stylesheet_editor.c119
-rw-r--r--src/stylesheet_editor.h20
-rw-r--r--src/utils.c54
-rw-r--r--src/utils.h8
8 files changed, 342 insertions, 96 deletions
diff --git a/data/stylesheeteditor.ui b/data/stylesheeteditor.ui
index 05aa5ae..e02a8e8 100644
--- a/data/stylesheeteditor.ui
+++ b/data/stylesheeteditor.ui
@@ -52,16 +52,76 @@
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkAdjustment" id="adjustment19">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkAdjustment" id="adjustment2">
<property name="upper">2000</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkAdjustment" id="adjustment20">
+ <property name="upper">100</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="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment22">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment23">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment24">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment25">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment26">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment27">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment28">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="adjustment29">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkAdjustment" id="adjustment3">
<property name="upper">2000</property>
<property name="step_increment">1</property>
<property name="page_increment">10</property>
</object>
+ <object class="GtkAdjustment" id="adjustment30">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkAdjustment" id="adjustment4">
<property name="upper">2000</property>
<property name="step_increment">1</property>
@@ -1310,13 +1370,13 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="active">0</property>
- <property name="active_id">slidetitle</property>
+ <property name="active_id">$.slide.slidetitle</property>
<items>
- <item id="prestitle" translatable="yes">Presentation title</item>
- <item id="presauthor" translatable="yes">Presentation author</item>
- <item id="slidetitle" translatable="yes">Slide title</item>
- <item id="slidefooter" translatable="yes">Slide footer</item>
- <item id="slidecredit" translatable="yes">Slide credit</item>
+ <item id="$.slide.prestitle" translatable="yes">Presentation title</item>
+ <item id="$.slide.author" translatable="yes">Presentation author</item>
+ <item id="$.slide.slidetitle" translatable="yes">Slide title</item>
+ <item id="$.slide.footer" translatable="yes">Slide footer</item>
+ <item id="$.slide.credit" translatable="yes">Slide credit</item>
</items>
<signal name="changed" handler="furniture_selector_change_sig" swapped="no"/>
</object>
@@ -1359,7 +1419,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="furniture_h">
+ <object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Height:</property>
@@ -1367,12 +1427,12 @@
<property name="xalign">1</property>
</object>
<packing>
- <property name="left_attach">2</property>
+ <property name="left_attach">3</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
- <object class="GtkLabel" id="furniture_x">
+ <object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Corner x:</property>
@@ -1385,7 +1445,7 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="furniture_y">
+ <object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Corner y:</property>
@@ -1393,7 +1453,7 @@
<property name="xalign">1</property>
</object>
<packing>
- <property name="left_attach">2</property>
+ <property name="left_attach">3</property>
<property name="top_attach">1</property>
</packing>
</child>
@@ -1402,7 +1462,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
- <property name="adjustment">adjustment13</property>
+ <property name="adjustment">adjustment19</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1410,11 +1470,11 @@
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="furniture_padding_t1">
+ <object class="GtkSpinButton" id="furniture_x">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
- <property name="adjustment">adjustment14</property>
+ <property name="adjustment">adjustment20</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1422,29 +1482,66 @@
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="furniture_padding_r1">
+ <object class="GtkSpinButton" id="furniture_h">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
- <property name="adjustment">adjustment15</property>
+ <property name="adjustment">adjustment21</property>
</object>
<packing>
- <property name="left_attach">3</property>
+ <property name="left_attach">4</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
- <object class="GtkSpinButton" id="furniture_padding_b1">
+ <object class="GtkSpinButton" id="furniture_y">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
- <property name="adjustment">adjustment16</property>
+ <property name="adjustment">adjustment22</property>
</object>
<packing>
- <property name="left_attach">3</property>
+ <property name="left_attach">4</property>
<property name="top_attach">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkComboBoxText" id="furniture_h_units">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_right">8</property>
+ <property name="active">0</property>
+ <items>
+ <item id="percent" translatable="yes">% slide</item>
+ <item id="units" translatable="yes">units</item>
+ </items>
+ </object>
+ <packing>
+ <property name="left_attach">5</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="furniture_w_units">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="active">0</property>
+ <items>
+ <item id="percent" translatable="yes">% slide</item>
+ <item id="units" translatable="yes">units</item>
+ </items>
+ </object>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="top_attach">0</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
</object>
</child>
</object>
@@ -1482,12 +1579,13 @@
</packing>
</child>
<child>
- <object class="GtkFontButton" id="furniture_font1">
+ <object class="GtkFontButton" id="furniture_font">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="font">Sans 12</property>
<property name="preview_text">Preview text</property>
+ <signal name="font-set" handler="furniture_font_sig" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
@@ -1496,7 +1594,7 @@
</packing>
</child>
<child>
- <object class="GtkColorButton" id="furniture_fgcol1">
+ <object class="GtkColorButton" id="furniture_fgcol">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@@ -1534,7 +1632,7 @@
</packing>
</child>
<child>
- <object class="GtkComboBoxText" id="furniture_bggrad1">
+ <object class="GtkComboBoxText" id="furniture_bggrad">
<property name="visible">True</property>
<property name="can_focus">False</property>
<items>
@@ -1550,7 +1648,7 @@
</packing>
</child>
<child>
- <object class="GtkColorButton" id="furniture_bgcol1">
+ <object class="GtkColorButton" id="furniture_bgcol">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@@ -1563,7 +1661,7 @@
</packing>
</child>
<child>
- <object class="GtkColorButton" id="furniture_bgcol3">
+ <object class="GtkColorButton" id="furniture_bgcol2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@@ -1703,7 +1801,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
- <property name="adjustment">adjustment13</property>
+ <property name="adjustment">adjustment23</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1715,7 +1813,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
- <property name="adjustment">adjustment14</property>
+ <property name="adjustment">adjustment24</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1727,7 +1825,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
- <property name="adjustment">adjustment15</property>
+ <property name="adjustment">adjustment25</property>
</object>
<packing>
<property name="left_attach">3</property>
@@ -1739,7 +1837,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
- <property name="adjustment">adjustment16</property>
+ <property name="adjustment">adjustment26</property>
</object>
<packing>
<property name="left_attach">3</property>
@@ -1837,7 +1935,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
- <property name="adjustment">adjustment1</property>
+ <property name="adjustment">adjustment27</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1849,7 +1947,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
- <property name="adjustment">adjustment2</property>
+ <property name="adjustment">adjustment28</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -1861,7 +1959,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
- <property name="adjustment">adjustment3</property>
+ <property name="adjustment">adjustment29</property>
</object>
<packing>
<property name="left_attach">3</property>
@@ -1873,7 +1971,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="text" translatable="yes">0</property>
- <property name="adjustment">adjustment4</property>
+ <property name="adjustment">adjustment30</property>
</object>
<packing>
<property name="left_attach">3</property>
diff --git a/src/frame.h b/src/frame.h
index 2a15209..d0525f8 100644
--- a/src/frame.h
+++ b/src/frame.h
@@ -33,13 +33,6 @@
typedef enum
{
- UNITS_SLIDE,
- UNITS_FRAC
-} LengthUnits;
-
-
-typedef enum
-{
GRAD_NONE,
GRAD_HORIZ,
GRAD_VERT
diff --git a/src/sc_interp.c b/src/sc_interp.c
index 73135af..86084b0 100644
--- a/src/sc_interp.c
+++ b/src/sc_interp.c
@@ -676,44 +676,15 @@ void update_geom(struct frame *fr)
}
-static LengthUnits get_units(const char *t)
+static int calculate_dims(const char *opt, struct frame *parent,
+ double *wp, double *hp, double *xp, double *yp)
{
- size_t len = strlen(t);
-
- if ( t[len-1] == 'f' ) return UNITS_FRAC;
- if ( t[len-1] == 'u' ) return UNITS_SLIDE;
-
- fprintf(stderr, _("Invalid units in '%s'\n"), t);
- return UNITS_SLIDE;
-}
-
-
-static int parse_dims(const char *opt, struct frame *parent,
- double *wp, double *hp, double *xp, double *yp)
-{
- char *w;
- char *h;
- char *x;
- char *y;
- char *check;
LengthUnits h_units, w_units;
- /* Looks like a dimension/position thing */
- w = strdup(opt);
- h = index(w, 'x');
- h[0] = '\0'; h++;
-
- x = index(h, '+');
- if ( x == NULL ) goto invalid;
- x[0] = '\0'; x++;
-
- y = index(x, '+');
- if ( x == NULL ) goto invalid;
- y[0] = '\0'; y++;
+ if ( parse_dims(opt, wp, hp, &w_units, &h_units, xp, yp) ) {
+ return 1;
+ }
- *wp = strtod(w, &check);
- if ( check == w ) goto invalid;
- w_units = get_units(w);
if ( w_units == UNITS_FRAC ) {
if ( parent != NULL ) {
double pw = parent->w;
@@ -725,10 +696,6 @@ static int parse_dims(const char *opt, struct frame *parent,
}
}
-
- *hp = strtod(h, &check);
- if ( check == h ) goto invalid;
- h_units = get_units(h);
if ( h_units == UNITS_FRAC ) {
if ( parent != NULL ) {
double ph = parent->h;
@@ -740,16 +707,7 @@ static int parse_dims(const char *opt, struct frame *parent,
}
}
- *xp= strtod(x, &check);
- if ( check == x ) goto invalid;
- *yp = strtod(y, &check);
- if ( check == y ) goto invalid;
-
return 0;
-
-invalid:
- fprintf(stderr, _("Invalid dimensions '%s'\n"), opt);
- return 1;
}
@@ -758,7 +716,7 @@ static int parse_frame_option(const char *opt, struct frame *fr,
{
if ( (index(opt, 'x') != NULL) && (index(opt, '+') != NULL)
&& (index(opt, '+') != rindex(opt, '+')) ) {
- return parse_dims(opt, parent, &fr->w, &fr->h, &fr->x, &fr->y);
+ return calculate_dims(opt, parent, &fr->w, &fr->h, &fr->x, &fr->y);
}
fprintf(stderr, _("Unrecognised frame option '%s'\n"), opt);
@@ -811,7 +769,7 @@ static int parse_image_option(const char *opt, struct frame *parent,
if ( (index(opt, 'x') != NULL) && (index(opt, '+') != NULL)
&& (index(opt, '+') != rindex(opt, '+')) ) {
double dum;
- return parse_dims(opt, NULL, wp, hp, &dum, &dum);
+ return calculate_dims(opt, NULL, wp, hp, &dum, &dum);
}
if ( strncmp(opt, "filename=\"", 10) == 0 ) {
diff --git a/src/stylesheet.c b/src/stylesheet.c
index 52bc4ff..51e8bd4 100644
--- a/src/stylesheet.c
+++ b/src/stylesheet.c
@@ -133,7 +133,12 @@ static JsonObject *find_stylesheet_object(Stylesheet *ss, const char *path,
node = json_path_query(path, ss->root, &err);
array = json_node_get_array(node);
- if ( json_array_get_length(array) != 1 ) {
+ if ( json_array_get_length(array) == 0 ) {
+ json_node_unref(node);
+ return NULL;
+ }
+
+ if ( json_array_get_length(array) > 1 ) {
json_node_unref(node);
fprintf(stderr, "More than one result in SS lookup (%s)!\n", path);
return NULL;
@@ -158,11 +163,12 @@ char *stylesheet_lookup(Stylesheet *ss, const char *path, const char *key)
JsonNode *node = NULL;
if ( ss == NULL ) {
- fprintf(stderr, _("No stylesheet!\n"));
+ fprintf(stderr, "No stylesheet!\n");
return NULL;
}
obj = find_stylesheet_object(ss, path, &node);
+ if ( obj == NULL ) return NULL;
if ( json_object_has_member(obj, key) ) {
diff --git a/src/stylesheet_editor.c b/src/stylesheet_editor.c
index 1d899c7..0eb7fde 100644
--- a/src/stylesheet_editor.c
+++ b/src/stylesheet_editor.c
@@ -44,6 +44,7 @@ G_DEFINE_TYPE_WITH_CODE(StylesheetEditor, stylesheet_editor,
struct _sspriv
{
struct presentation *p;
+ const gchar *furniture;
char *ssdata;
};
@@ -85,11 +86,45 @@ static void set_vals_from_ss(Stylesheet *ss, const char *path, const char *key,
fprintf(stderr, _("Failed to parse quad: %s\n"), result);
}
} else {
- printf("Not found %s\n", path);
+ printf("Not found %s.%s\n", path, key);
}
}
+static void set_geom_from_ss(Stylesheet *ss, const char *path, const char *key,
+ GtkWidget *ww, GtkWidget *wh,
+ GtkWidget *wx, GtkWidget *wy,
+ GtkWidget *wwu, GtkWidget *whu)
+{
+ char *result = stylesheet_lookup(ss, path, key);
+ if ( result != NULL ) {
+ double x, y, w, h;
+ LengthUnits wu, hu;
+ if ( parse_dims(result, &w, &h, &wu, &hu, &x, &y) == 0 ) {
+ if ( wu == UNITS_FRAC ) {
+ w *= 100;
+ gtk_combo_box_set_active_id(GTK_COMBO_BOX(wwu), "percent");
+ } else {
+ gtk_combo_box_set_active_id(GTK_COMBO_BOX(wwu), "units");
+ }
+ if ( hu == UNITS_FRAC ) {
+ h *= 100;
+ gtk_combo_box_set_active_id(GTK_COMBO_BOX(whu), "percent");
+ } else {
+ gtk_combo_box_set_active_id(GTK_COMBO_BOX(whu), "units");
+ }
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(ww), w);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(wh), h);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(wx), x);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(wy), y);
+ } else {
+ fprintf(stderr, _("Failed to parse dims: %s\n"), result);
+ }
+ } else {
+ printf("Not found %s.%s\n", path, key);
+ }
+}
+
static void set_size_from_ss(Stylesheet *ss, const char *path,
GtkWidget *ww, GtkWidget *wh)
{
@@ -103,7 +138,7 @@ static void set_size_from_ss(Stylesheet *ss, const char *path,
fprintf(stderr, _("Failed to parse double: %s\n"), result);
}
} else {
- printf("Not found %s\n", path);
+ printf("Not found %s.size\n", path);
}
}
@@ -188,6 +223,39 @@ static void set_bg_from_ss(Stylesheet *ss, const char *path, GtkWidget *wcol,
}
+static void set_furniture(StylesheetEditor *se, const char *furniture)
+{
+ set_geom_from_ss(se->priv->p->stylesheet, furniture, "geometry",
+ se->furniture_w,
+ se->furniture_h,
+ se->furniture_x,
+ se->furniture_y,
+ se->furniture_w_units,
+ se->furniture_h_units);
+
+ set_vals_from_ss(se->priv->p->stylesheet, furniture, "pad",
+ se->furniture_padding_l,
+ se->furniture_padding_r,
+ se->furniture_padding_t,
+ se->furniture_padding_b);
+
+ set_vals_from_ss(se->priv->p->stylesheet, furniture, "paraspace",
+ se->furniture_paraspace_l,
+ se->furniture_paraspace_r,
+ se->furniture_paraspace_t,
+ se->furniture_paraspace_b);
+
+ set_font_from_ss(se->priv->p->stylesheet, furniture, se->furniture_font);
+ set_col_from_ss(se->priv->p->stylesheet, furniture, se->furniture_fgcol);
+ set_alignment_from_ss(se->priv->p->stylesheet, furniture,
+ se->furniture_alignment);
+ set_bg_from_ss(se->priv->p->stylesheet, furniture, se->furniture_bgcol,
+ se->furniture_bgcol2, se->furniture_bggrad);
+}
+
+
+
+
static void set_values_from_presentation(StylesheetEditor *se)
{
Stylesheet *ss = se->priv->p->stylesheet;
@@ -230,6 +298,8 @@ static void set_values_from_presentation(StylesheetEditor *se)
se->frame_style_paraspace_r,
se->frame_style_paraspace_t,
se->frame_style_paraspace_b);
+
+ set_furniture(se, se->priv->furniture);
}
@@ -309,7 +379,7 @@ static void update_spacing(struct presentation *p, const char *style_name,
v[3] = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(wb));
if ( snprintf(tmp, 256, "%i,%i,%i,%i", v[0], v[1], v[2], v[3]) >= 256 ) {
- fprintf(stderr, _("Spacing too long\n"));
+ fprintf(stderr, "Spacing too long\n");
} else {
stylesheet_set(p->stylesheet, style_name, key, tmp);
}
@@ -332,6 +402,7 @@ 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");
}
@@ -495,13 +566,30 @@ static void narrative_paraspace_sig(GtkSpinButton *widget, StylesheetEditor *se)
}
+static void furniture_paraspace_sig(GtkSpinButton *widget, StylesheetEditor *se)
+{
+}
+
+
+static void furniture_padding_sig(GtkSpinButton *widget, StylesheetEditor *se)
+{
+}
+
+
static void furniture_selector_change_sig(GtkComboBoxText *widget, StylesheetEditor *se)
{
- const gchar *id = gtk_combo_box_get_active_id(GTK_COMBO_BOX(widget));
- printf("furniture %s\n", id);
+ 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 stylesheet_editor_finalize(GObject *obj)
{
StylesheetEditor *se = COLLOQUIUM_STYLESHEET_EDITOR(obj);
@@ -574,6 +662,26 @@ void stylesheet_editor_class_init(StylesheetEditorClass *klass)
/* Furniture */
SE_BIND_CHILD(furniture_selector, furniture_selector_change_sig);
+ SE_BIND_CHILD(furniture_paraspace_l, furniture_paraspace_sig);
+ SE_BIND_CHILD(furniture_paraspace_r, furniture_paraspace_sig);
+ SE_BIND_CHILD(furniture_paraspace_t, furniture_paraspace_sig);
+ SE_BIND_CHILD(furniture_paraspace_b, furniture_paraspace_sig);
+ SE_BIND_CHILD(furniture_padding_l, furniture_padding_sig);
+ SE_BIND_CHILD(furniture_padding_r, furniture_padding_sig);
+ 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);
gtk_widget_class_bind_template_callback(widget_class, revert_sig);
@@ -590,6 +698,7 @@ StylesheetEditor *stylesheet_editor_new(struct presentation *p)
if ( se == NULL ) return NULL;
se->priv->p = p;
+ se->priv->furniture = gtk_combo_box_get_active_id(GTK_COMBO_BOX(se->furniture_selector));
set_values_from_presentation(se);
se->priv->ssdata = stylesheet_data(p->stylesheet);
diff --git a/src/stylesheet_editor.h b/src/stylesheet_editor.h
index f9e5f65..a7c77b6 100644
--- a/src/stylesheet_editor.h
+++ b/src/stylesheet_editor.h
@@ -92,6 +92,26 @@ struct _stylesheeteditor
GtkWidget *frame_style_padding_b;
GtkWidget *frame_style_alignment;
GtkWidget *furniture_selector;
+ GtkWidget *furniture_paraspace_l;
+ GtkWidget *furniture_paraspace_r;
+ GtkWidget *furniture_paraspace_t;
+ GtkWidget *furniture_paraspace_b;
+ GtkWidget *furniture_padding_l;
+ GtkWidget *furniture_padding_r;
+ GtkWidget *furniture_padding_t;
+ GtkWidget *furniture_padding_b;
+ GtkWidget *furniture_font;
+ GtkWidget *furniture_fgcol;
+ GtkWidget *furniture_bgcol;
+ GtkWidget *furniture_bgcol2;
+ GtkWidget *furniture_bggrad;
+ GtkWidget *furniture_alignment;
+ GtkWidget *furniture_w;
+ GtkWidget *furniture_h;
+ GtkWidget *furniture_x;
+ GtkWidget *furniture_y;
+ GtkWidget *furniture_w_units;
+ GtkWidget *furniture_h_units;
StylesheetEditorPrivate *priv;
};
diff --git a/src/utils.c b/src/utils.c
index 277b3f1..b41f344 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -81,3 +81,57 @@ int parse_tuple(const char *a, float v[4])
return 0;
}
+
+static LengthUnits get_units(const char *t)
+{
+ size_t len = strlen(t);
+
+ if ( t[len-1] == 'f' ) return UNITS_FRAC;
+ if ( t[len-1] == 'u' ) return UNITS_SLIDE;
+
+ fprintf(stderr, _("Invalid units in '%s'\n"), t);
+ return UNITS_SLIDE;
+}
+
+
+int parse_dims(const char *opt, double *wp, double *hp,
+ LengthUnits *wup, LengthUnits *hup,
+ double *xp, double *yp)
+{
+ char *w;
+ char *h;
+ char *x;
+ char *y;
+ char *check;
+
+ w = strdup(opt);
+ h = index(w, 'x');
+ h[0] = '\0'; h++;
+
+ x = index(h, '+');
+ if ( x == NULL ) goto invalid;
+ x[0] = '\0'; x++;
+
+ y = index(x, '+');
+ if ( x == NULL ) goto invalid;
+ y[0] = '\0'; y++;
+
+ *wp = strtod(w, &check);
+ if ( check == w ) goto invalid;
+ *wup = get_units(w);
+
+ *hp = strtod(h, &check);
+ if ( check == h ) goto invalid;
+ *hup = get_units(h);
+
+ *xp= strtod(x, &check);
+ if ( check == x ) goto invalid;
+ *yp = strtod(y, &check);
+ if ( check == y ) goto invalid;
+
+ return 0;
+
+invalid:
+ fprintf(stderr, _("Invalid dimensions '%s'\n"), opt);
+ return 1;
+}
diff --git a/src/utils.h b/src/utils.h
index fc843c3..af3c7b8 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -27,11 +27,19 @@
#include <config.h>
#endif
+typedef enum
+{
+ UNITS_SLIDE,
+ UNITS_FRAC
+} LengthUnits;
extern void chomp(char *s);
extern int safe_strcmp(const char *a, const char *b);
extern int parse_double(const char *a, float v[2]);
extern int parse_tuple(const char *a, float v[4]);
+extern int parse_dims(const char *opt, double *wp, double *hp,
+ LengthUnits *wup, LengthUnits *hup,
+ double *xp, double *yp);
#include <libintl.h>
#define _(x) gettext(x)