summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-26 18:22:46 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-26 18:22:46 (EDT)
commit8f26235740667d84cc0528a1edc6213c073bd13d (patch)
tree4c883c17e29f5cfd6c860919c772f8c246f35022
parent5e4efa97e3aebb80e3fc2e560e19e5e9577c05fa (diff)
downloadmarquee-8f26235740667d84cc0528a1edc6213c073bd13d.zip
marquee-8f26235740667d84cc0528a1edc6213c073bd13d.tar.gz
marquee-8f26235740667d84cc0528a1edc6213c073bd13d.tar.bz2
mq_html_input_*(): Enclose labels and inputs in <tr>s and <td>s
-rw-r--r--src/html.c82
1 files changed, 64 insertions, 18 deletions
diff --git a/src/html.c b/src/html.c
index 14d6661..f6f3223 100644
--- a/src/html.c
+++ b/src/html.c
@@ -578,9 +578,15 @@ mq_html_fieldset(gchar *first_child, ...)
gchar *
mq_html_input_text(const gchar *name, const gchar *label, const gchar *value)
{
- return g_strdup_printf("<label for=\"%s\">\n<span>%s</span>\n"
+ return g_strdup_printf(
+ "<tr>\n"
+ "<td>\n"
+ "<label for=\"%s\">%s</label>\n"
+ "</td>\n"
+ "<td>\n"
"<input type=\"text\" name=\"%s\" id=\"%s\" value=\"%s\">\n"
- "</label>\n",
+ "</td>\n"
+ "</tr>\n",
name, label, name, name, value ? value : "");
}
@@ -588,10 +594,16 @@ gchar *
mq_html_input_number_i(const gchar *name, const gchar *label,
gint min, gint step, gint max, gint value)
{
- return g_strdup_printf("<label for=\"%s\">\n<span>%s</span>\n"
+ return g_strdup_printf(
+ "<tr>\n"
+ "<td>\n"
+ "<label for=\"%s\">%s</label>\n"
+ "</td>\n"
+ "<td>\n"
"<input type=\"number\" name=\"%s\" id=\"%s\""
" min=\"%d\" step=\"%d\" max=\"%d\" value=\"%d\">\n"
- "</label>\n",
+ "</td>\n"
+ "</tr>\n",
name, label, name, name, min, step, max, value);
}
@@ -599,18 +611,31 @@ gchar *
mq_html_input_number_d(const gchar *name, const gchar *label,
gdouble min, gdouble step, gdouble max, gdouble value)
{
- return g_strdup_printf("<label for=\"%s\">\n<span>%s</span>\n"
+ return g_strdup_printf(
+ "<tr>\n"
+ "<td>\n"
+ "<label for=\"%s\">%s</label>\n"
+ "</td>\n"
+ "<td>\n"
"<input type=\"number\" name=\"%s\" id=\"%s\""
" min=\"%f\" step=\"%f\" max=\"%f\" value=\"%f\">\n"
- "</label>\n",
+ "</td>\n"
+ "</tr>\n",
name, label, name, name, min, step, max, value);
}
gchar *
mq_html_input_radio(const gchar *name, const gchar *label, gboolean checked)
{
- return g_strdup_printf("<label for=\"%s\">\n<span>%s</span>\n"
- "<input type=\"radio\" name=\"%s\" id=\"%s\"%s>\n</label>\n",
+ return g_strdup_printf(
+ "<tr>\n"
+ "<td>\n"
+ "<label for=\"%s\">%s</label>\n"
+ "</td>\n"
+ "<td>\n"
+ "<input type=\"radio\" name=\"%s\" id=\"%s\"%s>\n"
+ "</td>\n"
+ "</tr>\n",
name, label, name, name, checked ? " checked=\"checked\"" : "");
}
@@ -638,9 +663,16 @@ mq_html_input_checkbox(const gchar *name, const gchar *label, gboolean checked)
* <input> when the former <input> is checked.
*/
- return g_strdup_printf("<label for=\"%s\">\n<span>%s</span>\n"
+ return g_strdup_printf(
+ "<tr>\n"
+ "<td>\n"
+ "<label for=\"%s\">%s</label>\n"
+ "</td>\n"
+ "<td>\n"
"<input type=\"hidden\" name=\"%s\" value=\"off\">\n"
- "<input type=\"checkbox\" name=\"%s\" id=\"%s\"%s>\n</label>\n",
+ "<input type=\"checkbox\" name=\"%s\" id=\"%s\"%s>\n"
+ "</td>\n"
+ "</tr>\n",
name, label, name, name, name,
checked ? " checked=\"checked\"" : "");
}
@@ -660,11 +692,16 @@ mq_html_input_select(const gchar *name, const gchar *label,
g_assert(selected && selected[0]); /* Would cause buffer overflow */
/* Calculate length. */
- len = strlen("<label for=\"");
+ len = strlen("<tr>\n");
+ len += strlen("<td>\n");
+ len += strlen("<label for=\"");
len += strlen(name);
- len += strlen("\">\n<span>");
+ len += strlen("\">");
len += strlen(label);
- len += strlen("</span>\n<select name=\"");
+ len += strlen("</label>\n");
+ len += strlen("</td>\n");
+ len += strlen("<td>\n");
+ len += strlen("<select name=\"");
len += strlen(name);
len += strlen("\" id=\"");
len += strlen(name);
@@ -681,16 +718,23 @@ mq_html_input_select(const gchar *name, const gchar *label,
}
va_end(ap);
len += strlen(" selected=\"selected\"");
- len += strlen("</select>\n</label>\n");
+ len += strlen("</select>\n");
+ len += strlen("</td>\n");
+ len += strlen("</tr>\n");
++len; /* NUL byte */
/* Build string. */
select = g_new(gchar, len);
- ptr = g_stpcpy(select, "<label for=\"");
+ ptr = g_stpcpy(select, "<tr>\n");
+ ptr = g_stpcpy(ptr, "<td>\n");
+ ptr = g_stpcpy(ptr, "<label for=\"");
ptr = g_stpcpy(ptr, name);
- ptr = g_stpcpy(ptr, "\">\n<span>");
+ ptr = g_stpcpy(ptr, "\">");
ptr = g_stpcpy(ptr, label);
- ptr = g_stpcpy(ptr, "</span>\n<select name=\"");
+ ptr = g_stpcpy(ptr, "</label>\n");
+ ptr = g_stpcpy(ptr, "</td>\n");
+ ptr = g_stpcpy(ptr, "<td>\n");
+ ptr = g_stpcpy(ptr, "<select name=\"");
ptr = g_stpcpy(ptr, name);
ptr = g_stpcpy(ptr, "\" id=\"");
ptr = g_stpcpy(ptr, name);
@@ -715,7 +759,9 @@ mq_html_input_select(const gchar *name, const gchar *label,
ptr = g_stpcpy(ptr, "</option>\n");
}
va_end(ap);
- ptr = g_stpcpy(ptr, "</select>\n</label>\n"); /* g_stpcpy() adds NUL */
+ ptr = g_stpcpy(ptr, "</select>\n");
+ ptr = g_stpcpy(ptr, "</td>\n");
+ ptr = g_stpcpy(ptr, "</tr>\n"); /* g_stpcpy() adds NUL */
return select;
}