summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-04 13:12:35 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-04 13:12:35 (EDT)
commit3547a37fbf25cd775e12fc55a8692f94b358128f (patch)
treeadd63debdaad1b0d3e9b70bc8cd1880daee2b44f
parentae43c369a94016091f168b60a9f0ce7ece8f208d (diff)
downloadmarquee-3547a37fbf25cd775e12fc55a8692f94b358128f.zip
marquee-3547a37fbf25cd775e12fc55a8692f94b358128f.tar.gz
marquee-3547a37fbf25cd775e12fc55a8692f94b358128f.tar.bz2
mq_html_input_checkbox(): Enable "off" values
-rw-r--r--src/html.c25
1 files changed, 24 insertions, 1 deletions
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 <input>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 <input>s in order for unchecking to have any effect.
+ *
+ * This function returns two <input>s: one of type "hidden" with a value
+ * of "off" and one of type "checkbox". If the "checkbox"-type <input>
+ * is checked, both <input> values will be submitted in the query, with
+ * the value of the "checkbox"-type <input> last. Otherwise, only the
+ * "off" value of the "hidden"-type <input> 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 <input> will override that of the "hidden"-type
+ * <input> when the former <input> is checked.
+ */
+
return g_strdup_printf("<label for=\"%s\"><span>%s</span>"
+ "<input type=\"hidden\" name=\"%s\" value=\"off\">"
"<input type=\"checkbox\" name=\"%s\" id=\"%s\"%s></label>\n",
- name, label, name, name, checked ? " checked=\"checked\"" : "");
+ name, label, name, name, name,
+ checked ? " checked=\"checked\"" : "");
}