summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/utils/html.c65
-rw-r--r--src/utils/html.h4
2 files changed, 69 insertions, 0 deletions
diff --git a/src/utils/html.c b/src/utils/html.c
index 7f10a51..5c4b216 100644
--- a/src/utils/html.c
+++ b/src/utils/html.c
@@ -1038,6 +1038,71 @@ mq_html_submit(const gchar *name, const gchar *label, gboolean disabled)
}
gchar *
+mq_html_buttonbox(const gchar *submit_name, const gchar *submit_label,
+ const gchar *reset_name, const gchar *reset_label)
+{
+ gsize len;
+ gchar *buttonbox;
+ gchar *ptr;
+
+ /* Calculate length. */
+ len = strlen("<div class=\"dialog-buttonbox\">\n");
+ if (reset_label && reset_label[0]) {
+ 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\" ");
+ 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");
+ }
+ len += strlen("</div>\n");
+ ++len; /* NUL byte */
+
+ /* Build string. */
+ ptr = buttonbox = g_new(gchar, len);
+ ptr = g_stpcpy(ptr, "<div class=\"dialog-buttonbox\">\n");
+ if (reset_label && reset_label[0]) {
+ 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\" ");
+ 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");
+ }
+ ptr = g_stpcpy(ptr, "</div>\n"); /* g_stpcpy() adds the NUL. */
+
+ return buttonbox;
+}
+
+gchar *
mq_html_input_iframe(const gchar *src)
{
return g_strdup_printf("<iframe src=\"%s\"></iframe>", src);
diff --git a/src/utils/html.h b/src/utils/html.h
index ec9b659..7e8002c 100644
--- a/src/utils/html.h
+++ b/src/utils/html.h
@@ -110,6 +110,10 @@ gchar *
mq_html_submit(const gchar *name, const gchar *label, gboolean disabled);
gchar *
+mq_html_buttonbox(const gchar *submit_name, const gchar *submit_label,
+ const gchar *reset_name, const gchar *reset_label);
+
+gchar *
mq_html_input_iframe(const gchar *src);
G_END_DECLS