summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/html.c24
-rw-r--r--src/html.h2
2 files changed, 16 insertions, 10 deletions
diff --git a/src/html.c b/src/html.c
index 914a051..bf4f18c 100644
--- a/src/html.c
+++ b/src/html.c
@@ -68,7 +68,7 @@ mq_html_container(const gchar *element, ...)
}
gchar *
-mq_html_notebook(gboolean vertical, const gchar *name, ...)
+mq_html_notebook(gboolean vertical, const gchar *name, guint current_page, ...)
{
gsize name_len;
gsize len;
@@ -83,7 +83,7 @@ mq_html_notebook(gboolean vertical, const gchar *name, ...)
/* Calculate length. */
name_len = strlen(name);
len = strlen("<div class=\"notebook-") + 1 + strlen("\">\n");
- va_start(ap, name);
+ va_start(ap, current_page);
i = 0;
while ((child = va_arg(ap, gchar *)) &&
(tab_label = va_arg(ap, gchar *))) {
@@ -93,8 +93,11 @@ mq_html_notebook(gboolean vertical, const gchar *name, ...)
len += strlen("_");
len += strlen(i_str);
/* len += (gsize) log10(i) + 1; */
- len += strlen("\" type=\"radio\" checked=\"checked\" "
- "name=\"_tabs\"></input>\n");
+ len += strlen("\" type=\"radio\"");
+ if (i == current_page) {
+ len += strlen(" checked=\"checked\"");
+ }
+ len += strlen(" name=\"_tabs\"></input>\n");
len += strlen("<label for=\"_tab_");
len += name_len;
len += strlen("_");
@@ -106,7 +109,7 @@ mq_html_notebook(gboolean vertical, const gchar *name, ...)
++i;
}
va_end(ap);
- va_start(ap, name);
+ va_start(ap, current_page);
while ((child = va_arg(ap, gchar *)) &&
(tab_label = va_arg(ap, gchar *))) {
/* TODO: Page ID and control CSS */
@@ -121,7 +124,7 @@ mq_html_notebook(gboolean vertical, const gchar *name, ...)
ptr = g_stpcpy(notebook, "<div class=\"notebook-");
ptr = g_stpcpy(ptr, vertical ? "v" : "h");
ptr = g_stpcpy(ptr, "\">\n");
- va_start(ap, name);
+ va_start(ap, current_page);
i = 0;
while ((child = va_arg(ap, gchar *)) &&
(tab_label = va_arg(ap, gchar *))) {
@@ -130,8 +133,11 @@ mq_html_notebook(gboolean vertical, const gchar *name, ...)
ptr = g_stpcpy(ptr, name);
ptr = g_stpcpy(ptr, "_");
ptr = g_stpcpy(ptr, i_str);
- ptr = g_stpcpy(ptr, "\" type=\"radio\" checked=\"checked\" "
- "name=\"_tabs\"></input>\n");
+ ptr = g_stpcpy(ptr, "\" type=\"radio\"");
+ if (i == current_page) {
+ ptr = g_stpcpy(ptr, " checked=\"checked\"");
+ }
+ ptr = g_stpcpy(ptr, " name=\"_tabs\"></input>\n");
ptr = g_stpcpy(ptr, "<label for=\"_tab_");
ptr = g_stpcpy(ptr, name);
ptr = g_stpcpy(ptr, "_");
@@ -143,7 +149,7 @@ mq_html_notebook(gboolean vertical, const gchar *name, ...)
++i;
}
va_end(ap);
- va_start(ap, name);
+ va_start(ap, current_page);
while ((child = va_arg(ap, gchar *)) &&
(tab_label = va_arg(ap, gchar *))) {
/* TODO: Page ID and control CSS */
diff --git a/src/html.h b/src/html.h
index db738e9..b31179d 100644
--- a/src/html.h
+++ b/src/html.h
@@ -28,7 +28,7 @@ gchar *
mq_html_container(const gchar *element, ...);
gchar *
-mq_html_notebook(gboolean vertical, const gchar *name, ...);
+mq_html_notebook(gboolean vertical, const gchar *name, guint current_page, ...);
gchar *
mq_html_form(const gchar *submit_label, const gchar *reset_label, ...);