summaryrefslogtreecommitdiffstats
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
parent18bb954f220d97cf5d26a4a89088b6556b427563 (diff)
downloadmarquee-2c96093cd1622e22c11b50d939cce33d752ce3ee.zip
marquee-2c96093cd1622e22c11b50d939cce33d752ce3ee.tar.gz
marquee-2c96093cd1622e22c11b50d939cce33d752ce3ee.tar.bz2
mq_html_form*(): Add optional button names
-rw-r--r--src/schemes/about/preferences.c2
-rw-r--r--src/schemes/about/profiles.c2
-rw-r--r--src/utils/html.c71
-rw-r--r--src/utils/html.h7
4 files changed, 66 insertions, 16 deletions
diff --git a/src/schemes/about/preferences.c b/src/schemes/about/preferences.c
index 6e65c3c..59ac9c6 100644
--- a/src/schemes/about/preferences.c
+++ b/src/schemes/about/preferences.c
@@ -243,7 +243,7 @@ mq_about_preferences_response(MqApplication *application, GHashTable *query,
mq_about_redirect(request, "mq-about:preferences");
} else {
document = mq_html_document("Preferences",
- mq_html_form("Save", "Cancel",
+ mq_html_form(NULL, "Save", NULL, "Cancel",
mq_html_notebook(FALSE, "notebook1", 0,
gen_page_general(config),
"General",
diff --git a/src/schemes/about/profiles.c b/src/schemes/about/profiles.c
index 3fc5fd9..c1e3d09 100644
--- a/src/schemes/about/profiles.c
+++ b/src/schemes/about/profiles.c
@@ -89,7 +89,7 @@ generate_document(MqProfiles *profiles)
g_strfreev(ids);
return mq_html_document("Profiles",
- mq_html_form_v("Add Profile", NULL, divs),
+ mq_html_form_v("add", "Add Profile", NULL, NULL, divs),
NULL);
}
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);