summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/utils/html.c46
-rw-r--r--src/utils/html.h4
2 files changed, 50 insertions, 0 deletions
diff --git a/src/utils/html.c b/src/utils/html.c
index 5716c07..d377046 100644
--- a/src/utils/html.c
+++ b/src/utils/html.c
@@ -391,6 +391,52 @@ mq_html_container(const gchar *element, const gchar *classes, ...)
}
gchar *
+mq_html_container_v(const gchar *element, const gchar *classes,
+ gchar **children)
+{
+ gsize len;
+ gsize i;
+ gchar *container;
+ gchar *ptr;
+
+ /* Calculate length. */
+ len = strlen("<");
+ len += strlen(element);
+ if (classes && classes[0]) {
+ len += strlen(" class=\"");
+ len += strlen(classes);
+ len += strlen("\"");
+ }
+ len += strlen(">\n");
+ for (i = 0; children && children[i]; ++i) {
+ len += strlen(children[i]);
+ }
+ len += strlen("</");
+ len += strlen(element);
+ len += strlen(">\n");
+ ++len; /* NUL byte */
+
+ /* Build string. */
+ container = g_new(gchar, len);
+ ptr = g_stpcpy(container, "<");
+ ptr = g_stpcpy(ptr, element);
+ if (classes && classes[0]) {
+ ptr = g_stpcpy(ptr, " class=\"");
+ ptr = g_stpcpy(ptr, classes);
+ ptr = g_stpcpy(ptr, "\"");
+ }
+ ptr = g_stpcpy(ptr, ">\n");
+ for (i = 0; children && children[i]; ++i) {
+ ptr = g_stpcpy(ptr, children[i]);
+ }
+ ptr = g_stpcpy(ptr, "</");
+ ptr = g_stpcpy(ptr, element);
+ ptr = g_stpcpy(ptr, ">\n"); /* g_stpcpy() adds the NUL. */
+
+ return container;
+}
+
+gchar *
mq_html_notebook(gboolean vertical, const gchar *name, guint current_page, ...)
{
gsize name_len;
diff --git a/src/utils/html.h b/src/utils/html.h
index 3cff076..023edb2 100644
--- a/src/utils/html.h
+++ b/src/utils/html.h
@@ -48,6 +48,10 @@ mq_html_container(const gchar *element, const gchar *classes, ...)
G_GNUC_NULL_TERMINATED;
gchar *
+mq_html_container_v(const gchar *element, const gchar *classes,
+ gchar **children);
+
+gchar *
mq_html_list(const gchar *type, GDestroyNotify destroy, ...)
G_GNUC_NULL_TERMINATED;