From 3547a37fbf25cd775e12fc55a8692f94b358128f Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Wed, 04 Oct 2017 13:12:35 -0400 Subject: mq_html_input_checkbox(): Enable "off" values --- (limited to 'src') diff --git a/src/html.c b/src/html.c index cc83874..ede51f7 100644 --- a/src/html.c +++ b/src/html.c @@ -552,7 +552,30 @@ mq_html_input_radio(const gchar *name, const gchar *label, gboolean 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, checked ? " checked=\"checked\"" : ""); + name, label, name, name, name, + checked ? " checked=\"checked\"" : ""); } -- cgit v0.9.1