\n"); /* g_stpcpy() adds the NUL. */
return notebook;
}
gchar *
mq_html_form(const gchar *submit_label, const gchar *reset_label, ...)
{
gsize len;
va_list ap;
gchar *child;
gchar *form;
gchar *ptr;
/* Calculate length. */
len = strlen("\n");
++len; /* NUL byte */
/* Build string. */
form = g_new(gchar, len);
ptr = g_stpcpy(form, "\n"); /* g_stpcpy() adds the NUL. */
return form;
}
gchar *
mq_html_input_text(const gchar *name, const gchar *label, const gchar *value)
{
if (label && label[0]) {
return g_strdup_printf(
"\n",
name, label, name, name, value ? value : "");
} else {
return g_strdup_printf(
"\n",
name, name, value ? value : "");
}
}
gchar *
mq_html_input_number_i(const gchar *name, const gchar *label,
gint min, gint step, gint max, gint value)
{
if (label && label[0]) {
return g_strdup_printf(
"\n",
name, label, name, name, min, step, max, value);
} else {
return g_strdup_printf(
"\n",
name, name, min, step, max, value);
}
}
gchar *
mq_html_input_number_d(const gchar *name, const gchar *label,
gdouble min, gdouble step, gdouble max, gdouble value)
{
if (label && label[0]) {
return g_strdup_printf(
"\n",
name, label, name, name, min, step, max, value);
} else {
return g_strdup_printf(
"\n",
name, name, min, step, max, value);
}
}
gchar *
mq_html_input_radio(const gchar *name, const gchar *label, gboolean checked)
{
return g_strdup_printf("\n",
name, label, name, name, checked ? " checked=\"checked\"" : "");
}
gchar *
mq_html_input_checkbox(const gchar *name, const gchar *label, gboolean checked)
{
/*
* Values of "checkbox"-type s that are not checked are not sent
* in queries with form submissions. The "about:preferences"
* query-handling code doesn't handle any preferences that aren't
* submitted in the query, so values need to be submitted for unchecked
* "checkbox"-type s in order for unchecking to have any effect.
*
* This function returns two s: one of type "hidden" with a value
* of "off" and one of type "checkbox". If the "checkbox"-type
* is checked, both values will be submitted in the query, with
* the value of the "checkbox"-type last. Otherwise, only the
* "off" value of the "hidden"-type will be submitted.
*
* The query-parsing code for "about"-scheme resources iterates through
* each "key=value" pair in order, inserting each pair into a
* GHashTable. When keys collide, g_hash_table_insert() replaces the
* previous value with the new value. Thus, the value of the
* "checkbox"-type will override that of the "hidden"-type
* when the former is checked.
*/
return g_strdup_printf("\n",
name, label, name, name, name,
checked ? " checked=\"checked\"" : "");
}
gchar *
mq_html_input_select(const gchar *name, const gchar *label,
const gchar *selected,
GDestroyNotify destroy_value, GDestroyNotify destroy_label, ...)
{
gsize len;
va_list ap;
gchar *option_value;
gchar *option_label;
gchar *select;
gchar *ptr;
g_assert(selected && selected[0]); /* Would cause buffer overflow */
/* Calculate length. */
len = strlen("\n");
++len; /* NUL byte */
/* Build string. */
select = g_new(gchar, len);
ptr = g_stpcpy(select, "\n"); /* g_stpcpy() adds NUL */
return select;
}
gchar *
mq_html_input_iframe(const gchar *src)
{
return g_strdup_printf("", src);
}