summaryrefslogtreecommitdiffstats
path: root/src/utils
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-11-04 12:45:17 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-11-04 12:45:17 (EDT)
commitbac3792a28a03289c32fde5458921ce06d986545 (patch)
treee345c856f00aeacddcb98d8ef17119876896d5aa /src/utils
parent9c9f466c17e227796c556b651c5ab71068b90db6 (diff)
downloadmarquee-bac3792a28a03289c32fde5458921ce06d986545.zip
marquee-bac3792a28a03289c32fde5458921ce06d986545.tar.gz
marquee-bac3792a28a03289c32fde5458921ce06d986545.tar.bz2
mq_html_container_v(): New function
Diffstat (limited to 'src/utils')
-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;