summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-11-04 21:20:58 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-11-04 21:36:38 (EDT)
commit2c96093cd1622e22c11b50d939cce33d752ce3ee (patch)
tree3054b237182e5fc0aafce2348bca0061edd72577 /src/utils
parent18bb954f220d97cf5d26a4a89088b6556b427563 (diff)
downloadmarquee-2c96093cd1622e22c11b50d939cce33d752ce3ee.zip
marquee-2c96093cd1622e22c11b50d939cce33d752ce3ee.tar.gz
marquee-2c96093cd1622e22c11b50d939cce33d752ce3ee.tar.bz2
mq_html_form*(): Add optional button names
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/html.c71
-rw-r--r--src/utils/html.h7
2 files changed, 64 insertions, 14 deletions
diff --git a/src/utils/html.c b/src/utils/html.c
index 0549457..35e6e65 100644
--- a/src/utils/html.c
+++ b/src/utils/html.c
@@ -673,7 +673,8 @@ mq_html_notebook(gboolean vertical, const gchar *name, guint current_page, ...)
}
gchar *
-mq_html_form(const gchar *submit_label, const gchar *reset_label, ...)
+mq_html_form(const gchar *submit_name, const gchar *submit_label,
+ const gchar *reset_name, const gchar *reset_label, ...)
{
gsize len;
va_list ap;
@@ -690,12 +691,24 @@ mq_html_form(const gchar *submit_label, const gchar *reset_label, ...)
va_end(ap);
len += strlen("<div class=\"dialog-buttonbox\">\n");
if (reset_label && reset_label[0]) {
- len += strlen("<input type=\"reset\" value=\"");
+ len += strlen("<input type=\"reset\" ");
+ if (reset_name && reset_name[0]) {
+ len += strlen("name=\"");
+ len += strlen(reset_name);
+ len += strlen("\" ");
+ }
+ len += strlen("value=\"");
len += strlen(reset_label);
len += strlen("\">\n");
}
if (submit_label && submit_label[0]) {
- len += strlen("<input type=\"submit\" value=\"");
+ len += strlen("<input type=\"submit\" ");
+ if (submit_name && submit_name[0]) {
+ len += strlen("name=\"");
+ len += strlen(submit_name);
+ len += strlen("\" ");
+ }
+ len += strlen("value=\"");
len += strlen(submit_label);
len += strlen("\">\n");
}
@@ -714,12 +727,24 @@ mq_html_form(const gchar *submit_label, const gchar *reset_label, ...)
va_end(ap);
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, "<input type=\"reset\" ");
+ if (reset_name && reset_name[0]) {
+ ptr = g_stpcpy(ptr, "name=\"");
+ ptr = g_stpcpy(ptr, reset_name);
+ ptr = g_stpcpy(ptr, "\" ");
+ }
+ ptr = g_stpcpy(ptr, "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, "<input type=\"submit\" ");
+ if (submit_name && submit_name[0]) {
+ ptr = g_stpcpy(ptr, "name=\"");
+ ptr = g_stpcpy(ptr, submit_name);
+ ptr = g_stpcpy(ptr, "\" ");
+ }
+ ptr = g_stpcpy(ptr, "value=\"");
ptr = g_stpcpy(ptr, submit_label);
ptr = g_stpcpy(ptr, "\">\n");
}
@@ -730,8 +755,8 @@ 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)
+mq_html_form_v(const gchar *submit_name, const gchar *submit_label,
+ const gchar *reset_name, const gchar *reset_label, gchar **children)
{
gsize len;
gsize i;
@@ -745,12 +770,24 @@ mq_html_form_v(const gchar *submit_label, const gchar *reset_label,
}
len += strlen("<div class=\"dialog-buttonbox\">\n");
if (reset_label && reset_label[0]) {
- len += strlen("<input type=\"reset\" value=\"");
+ len += strlen("<input type=\"reset\" ");
+ if (reset_name && reset_name[0]) {
+ len += strlen("name=\"");
+ len += strlen(reset_name);
+ len += strlen("\" ");
+ }
+ len += strlen("value=\"");
len += strlen(reset_label);
len += strlen("\">\n");
}
if (submit_label && submit_label[0]) {
- len += strlen("<input type=\"submit\" value=\"");
+ len += strlen("<input type=\"submit\" ");
+ if (submit_name && submit_name[0]) {
+ len += strlen("name=\"");
+ len += strlen(submit_name);
+ len += strlen("\" ");
+ }
+ len += strlen("value=\"");
len += strlen(submit_label);
len += strlen("\">\n");
}
@@ -766,12 +803,24 @@ mq_html_form_v(const gchar *submit_label, const gchar *reset_label,
}
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, "<input type=\"reset\" ");
+ if (reset_name && reset_name[0]) {
+ ptr = g_stpcpy(ptr, "name=\"");
+ ptr = g_stpcpy(ptr, reset_name);
+ ptr = g_stpcpy(ptr, "\" ");
+ }
+ ptr = g_stpcpy(ptr, "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, "<input type=\"submit\" ");
+ if (submit_name && submit_name[0]) {
+ ptr = g_stpcpy(ptr, "name=\"");
+ ptr = g_stpcpy(ptr, submit_name);
+ ptr = g_stpcpy(ptr, "\" ");
+ }
+ ptr = g_stpcpy(ptr, "value=\"");
ptr = g_stpcpy(ptr, submit_label);
ptr = g_stpcpy(ptr, "\">\n");
}
diff --git a/src/utils/html.h b/src/utils/html.h
index 53d4216..16129be 100644
--- a/src/utils/html.h
+++ b/src/utils/html.h
@@ -66,12 +66,13 @@ mq_html_notebook(gboolean vertical, const gchar *name, guint current_page, ...)
G_GNUC_NULL_TERMINATED;
gchar *
-mq_html_form(const gchar *submit_label, const gchar *reset_label, ...)
+mq_html_form(const gchar *submit_name, const gchar *submit_label,
+ const gchar *reset_name, const gchar *reset_label, ...)
G_GNUC_NULL_TERMINATED;
gchar *
-mq_html_form_v(const gchar *submit_label, const gchar *reset_label,
- gchar **children);
+mq_html_form_v(const gchar *submit_name, const gchar *submit_label,
+ const gchar *reset_name, const gchar *reset_label, gchar **children);
gchar *
mq_html_input_text(const gchar *name, const gchar *label, const gchar *value);