From 89f9769dd414de3ae090b30dda04cb01cb9034b0 Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Sat, 30 Sep 2017 19:23:24 -0400 Subject: mq_html_notebook(): New function --- (limited to 'src') diff --git a/src/html.c b/src/html.c index 9380068..0e3ee36 100644 --- a/src/html.c +++ b/src/html.c @@ -27,6 +27,95 @@ #include "html.h" gchar * +mq_html_notebook(gboolean vertical, const gchar *name, ...) +{ + gsize name_len; + gsize len; + va_list ap; + gsize i; + gchar *child; + gchar *tab_label; + gchar *i_str; + gchar *notebook; + gchar *ptr; + + /* Calculate length. */ + name_len = strlen(name); + len = strlen("
\n"); + va_start(ap, name); + i = 0; + while ((child = va_arg(ap, gchar *)) && + (tab_label = va_arg(ap, gchar *))) { + i_str = g_strdup_printf("%zu", i); + len += strlen("\n"); + len += strlen("\n"); + ++i; + } + va_end(ap); + va_start(ap, name); + while ((child = va_arg(ap, gchar *)) && + (tab_label = va_arg(ap, gchar *))) { + /* TODO: Page ID and control CSS */ + len += strlen(child); + } + va_end(ap); + len += strlen("
\n"); + ++len; /* NUL byte */ + + /* Build string. */ + notebook = g_new(gchar, len); + ptr = g_stpcpy(notebook, "
\n"); + va_start(ap, name); + i = 0; + while ((child = va_arg(ap, gchar *)) && + (tab_label = va_arg(ap, gchar *))) { + i_str = g_strdup_printf("%zu", i); + ptr = g_stpcpy(ptr, "\n"); + ptr = g_stpcpy(ptr, "\n"); + g_free(i_str); + ++i; + } + va_end(ap); + va_start(ap, name); + while ((child = va_arg(ap, gchar *)) && + (tab_label = va_arg(ap, gchar *))) { + /* TODO: Page ID and control CSS */ + ptr = g_stpcpy(ptr, child); + g_free(child); + } + va_end(ap); + ptr = g_stpcpy(ptr, "
\n"); /* g_stpcpy() adds the NUL. */ + + return notebook; +} + +gchar * mq_html_form(const gchar *submit_label, const gchar *reset_label, ...) { gsize len; diff --git a/src/html.h b/src/html.h index 84a133a..f80f897 100644 --- a/src/html.h +++ b/src/html.h @@ -25,6 +25,9 @@ #include gchar * +mq_html_notebook(gboolean vertical, const gchar *name, ...); + +gchar * mq_html_form(const gchar *submit_label, const gchar *reset_label, ...); gchar * -- cgit v0.9.1