diff options
author | Patrick McDermott <pj@pehjota.net> | 2017-11-04 12:57:21 (EDT) |
---|---|---|
committer | Patrick McDermott <pj@pehjota.net> | 2017-11-04 12:57:21 (EDT) |
commit | c5c1b87571674a74db3697ec24c17fae09dedd7d (patch) | |
tree | 7878c70b0a533bef9dae000ff6a68f0268ed5336 | |
parent | 86945e9ab330160562ca194bc0d845d84ca97062 (diff) | |
download | marquee-c5c1b87571674a74db3697ec24c17fae09dedd7d.zip marquee-c5c1b87571674a74db3697ec24c17fae09dedd7d.tar.gz marquee-c5c1b87571674a74db3697ec24c17fae09dedd7d.tar.bz2 |
mq_html_form(): Allow buttons to be individually disabled
-rw-r--r-- | src/utils/html.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/src/utils/html.c b/src/utils/html.c index c1075e8..7c105d0 100644 --- a/src/utils/html.c +++ b/src/utils/html.c @@ -581,12 +581,16 @@ mq_html_form(const gchar *submit_label, const gchar *reset_label, ...) } va_end(ap); len += strlen("<div class=\"dialog-buttonbox\">\n"); - len += strlen("<input type=\"reset\" value=\""); - len += strlen(reset_label); - len += strlen("\">\n"); - len += strlen("<input type=\"submit\" value=\""); - len += strlen(submit_label); - len += strlen("\">\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 */ @@ -601,12 +605,16 @@ mq_html_form(const gchar *submit_label, const gchar *reset_label, ...) } va_end(ap); ptr = g_stpcpy(ptr, "<div class=\"dialog-buttonbox\">\n"); - ptr = g_stpcpy(ptr, "<input type=\"reset\" value=\""); - ptr = g_stpcpy(ptr, reset_label); - ptr = g_stpcpy(ptr, "\">\n"); - ptr = g_stpcpy(ptr, "<input type=\"submit\" value=\""); - ptr = g_stpcpy(ptr, submit_label); - ptr = g_stpcpy(ptr, "\">\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. */ |