summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-11-04 15:08:15 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-11-04 15:08:15 (EDT)
commitebd2cbbf04d57e07e3f3c5ac361996746601479c (patch)
tree934b4245de45e0cbc843b5ac11cb816c7c0b345f /src
parentb70243d38d68c5eaf7643b492e9d5e38e8a35301 (diff)
downloadmarquee-ebd2cbbf04d57e07e3f3c5ac361996746601479c.zip
marquee-ebd2cbbf04d57e07e3f3c5ac361996746601479c.tar.gz
marquee-ebd2cbbf04d57e07e3f3c5ac361996746601479c.tar.bz2
mq_html_form_v(): New function
Diffstat (limited to 'src')
-rw-r--r--src/utils/html.c52
-rw-r--r--src/utils/html.h4
2 files changed, 56 insertions, 0 deletions
diff --git a/src/utils/html.c b/src/utils/html.c
index fdaa96a..0f44a44 100644
--- a/src/utils/html.c
+++ b/src/utils/html.c
@@ -729,6 +729,58 @@ mq_html_form(const gchar *submit_label, const gchar *reset_label, ...)
}
gchar *
+mq_html_form_v(const gchar *submit_label, const gchar *reset_label,
+ gchar **children)
+{
+ gsize len;
+ gsize i;
+ gchar *form;
+ gchar *ptr;
+
+ /* Calculate length. */
+ len = strlen("<form>\n");
+ for (i = 0; children && children[i]; ++i) {
+ len += strlen(children[i]);
+ }
+ len += strlen("<div class=\"dialog-buttonbox\">\n");
+ if (reset_label && reset_label[0]) {
+ len += strlen("<input type=\"reset\" value=\"");
+ len += strlen(reset_label);
+ len += strlen("\">\n");
+ }
+ if (submit_label && submit_label[0]) {
+ len += strlen("<input type=\"submit\" value=\"");
+ len += strlen(submit_label);
+ len += strlen("\">\n");
+ }
+ len += strlen("</div>\n");
+ len += strlen("</form>\n");
+ ++len; /* NUL byte */
+
+ /* Build string. */
+ form = g_new(gchar, len);
+ ptr = g_stpcpy(form, "<form>\n");
+ for (i = 0; children && children[i]; ++i) {
+ ptr = g_stpcpy(ptr, children[i]);
+ }
+ ptr = g_stpcpy(ptr, "<div class=\"dialog-buttonbox\">\n");
+ if (reset_label && reset_label[0]) {
+ ptr = g_stpcpy(ptr, "<input type=\"reset\" value=\"");
+ ptr = g_stpcpy(ptr, reset_label);
+ ptr = g_stpcpy(ptr, "\">\n");
+ }
+ if (submit_label && submit_label[0]) {
+ ptr = g_stpcpy(ptr, "<input type=\"submit\" value=\"");
+ ptr = g_stpcpy(ptr, submit_label);
+ ptr = g_stpcpy(ptr, "\">\n");
+ }
+ ptr = g_stpcpy(ptr, "</div>\n");
+ ptr = g_stpcpy(ptr, "</form>\n"); /* g_stpcpy() adds the NUL. */
+
+ return form;
+}
+
+gchar *
mq_html_input_text(const gchar *name, const gchar *label, const gchar *value)
{
if (label && label[0]) {
diff --git a/src/utils/html.h b/src/utils/html.h
index 10588f7..86067a9 100644
--- a/src/utils/html.h
+++ b/src/utils/html.h
@@ -70,6 +70,10 @@ mq_html_form(const gchar *submit_label, const gchar *reset_label, ...)
G_GNUC_NULL_TERMINATED;
gchar *
+mq_html_form_v(const gchar *submit_label, const gchar *reset_label,
+ gchar **children);
+
+gchar *
mq_html_input_text(const gchar *name, const gchar *label, const gchar *value);
gchar *