summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-01 14:24:17 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-01 15:09:29 (EDT)
commit8dd98917acb6ee2078c6d4a9e176a016b2648695 (patch)
tree7c3ab96070269d634a0dd367afaea1f8ba4ba80f
parent41a2147edfb2d7bc893ecc5a830143ebfd2d6dd9 (diff)
downloadmarquee-8dd98917acb6ee2078c6d4a9e176a016b2648695.zip
marquee-8dd98917acb6ee2078c6d4a9e176a016b2648695.tar.gz
marquee-8dd98917acb6ee2078c6d4a9e176a016b2648695.tar.bz2
mq_html_list(): New function
-rw-r--r--src/html.c43
-rw-r--r--src/html.h3
2 files changed, 46 insertions, 0 deletions
diff --git a/src/html.c b/src/html.c
index 8b93448..16882f6 100644
--- a/src/html.c
+++ b/src/html.c
@@ -186,6 +186,49 @@ TEXT_ELEMENT(p)
#undef TEXT_ELEMENT
gchar *
+mq_html_list(const gchar *type, ...)
+{
+ gsize len;
+ va_list ap;
+ gchar *child;
+ gchar *form;
+ gchar *ptr;
+
+ /* TODO: Doesn't support specification of <ol> list types. */
+
+ /* Calculate length. */
+ len = strlen("<ul>\n");
+ va_start(ap, type);
+ while ((child = va_arg(ap, gchar *))) {
+ len += strlen("<li>\n");
+ len += strlen(child);
+ len += strlen("</li>\n");
+ }
+ va_end(ap);
+ len += strlen("</ul>\n");
+ ++len; /* NUL byte */
+
+ /* Build string. */
+ form = g_new(gchar, len);
+ if (type && type[0]) {
+ ptr = g_stpcpy(form, "<ol>\n");
+ } else {
+ ptr = g_stpcpy(form, "<ul>\n");
+ }
+ va_start(ap, type);
+ while ((child = va_arg(ap, gchar *))) {
+ ptr = g_stpcpy(ptr, "<li>\n");
+ ptr = g_stpcpy(ptr, child);
+ g_free(child);
+ ptr = g_stpcpy(ptr, "</li>\n");
+ }
+ va_end(ap);
+ ptr = g_stpcpy(ptr, "</ul>\n"); /* g_stpcpy() adds the NUL. */
+
+ return form;
+}
+
+gchar *
mq_html_container(const gchar *element, ...)
{
gsize len;
diff --git a/src/html.h b/src/html.h
index 8c6c5e4..82ab94f 100644
--- a/src/html.h
+++ b/src/html.h
@@ -45,6 +45,9 @@ gchar *
mq_html_container(const gchar *element, ...);
gchar *
+mq_html_list(const gchar *type, ...);
+
+gchar *
mq_html_notebook(gboolean vertical, const gchar *name, guint current_page, ...);
gchar *