summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <pj@pehjota.net>2017-10-05 00:44:25 (EDT)
committer Patrick McDermott <pj@pehjota.net>2017-10-05 00:44:25 (EDT)
commit4a4888710f3e77c6f218336beef9cd23ffb41d5e (patch)
treeb180f88b5b1ca61e4e52c4b561a1daa1cdfcc727
parenta3d10a4c448cd2f62dec97427520516c7605b0d0 (diff)
downloadmarquee-4a4888710f3e77c6f218336beef9cd23ffb41d5e.zip
marquee-4a4888710f3e77c6f218336beef9cd23ffb41d5e.tar.gz
marquee-4a4888710f3e77c6f218336beef9cd23ffb41d5e.tar.bz2
about:preferences: Display and save some preferences
-rw-r--r--src/about/preferences.c136
1 files changed, 120 insertions, 16 deletions
diff --git a/src/about/preferences.c b/src/about/preferences.c
index 7bdc48d..8b5c2e0 100644
--- a/src/about/preferences.c
+++ b/src/about/preferences.c
@@ -24,35 +24,139 @@
#include "paths.h"
#include "../application.h"
+#include "../config.h"
#include "../about.h"
#include "../html.h"
+static void
+save_pref(gchar *key, gchar *value, MqConfig *config)
+{
+ mq_config_set(config, key, value);
+}
+
+#define GEN_BOOL(NAME, LABEL) mq_html_input_checkbox(NAME, LABEL, \
+ mq_config_get_boolean(config, NAME))
+#define GEN_INT( NAME, LABEL, MIN, STEP, MAX) mq_html_input_number_i( \
+ NAME, LABEL, MIN, STEP, MAX, mq_config_get_integer(config, NAME))
+#define GEN_DBL( NAME, LABEL, MIN, STEP, MAX) mq_html_input_number_d( \
+ NAME, LABEL, MIN, STEP, MAX, mq_config_get_double(config, NAME))
+#define GEN_STR( NAME, LABEL) mq_html_input_text(NAME, LABEL, \
+ "") /* TODO */
+#define GEN_STRL(NAME, LABEL) mq_html_input_text(NAME, LABEL, \
+ "") /* TODO */
+
+static gchar *
+gen_page_general(MqConfig *config)
+{
+ return mq_html_container("div",
+ mq_html_h3(NULL, "Web Browsing"),
+ GEN_STR ("tabs.new",
+ "New Tab Page"),
+ GEN_STR ("tabs.home",
+ "Home Page"),
+ GEN_BOOL("tabs.background",
+ "Open New Tabs in the Background"),
+ GEN_BOOL("tabs.warn-on-close",
+ "Warn When Closing Multiple Tabs or Windows"),
+
+ mq_html_h3(NULL, "Navigation and Accessibility"),
+ GEN_BOOL("navigation.smooth-scrolling",
+ "Smooth Scrolling"),
+ GEN_BOOL("navigation.tabbing",
+ "Enable Tabbing Navigation (Cycling Focus by Tab Key)"),
+ GEN_BOOL("navigation.caret",
+ "Enable Caret (Text Cursor) Navigation"),
+ GEN_BOOL("navigation.spatial",
+ "Enable Spatial Navigation Between Elements By Arrow "
+ "Keys"),
+
+ mq_html_h3(NULL, "Spell Checking"),
+ GEN_BOOL("spell.enable",
+ "Enable Spell Checking"),
+ GEN_STRL("spell.langs",
+ "Spell Checking Languages"),
+
+ mq_html_h3(NULL, "Miscellaneous"),
+ GEN_BOOL("display.textarea.resize.enable",
+ "Enable Resizable Text Areas"),
+ GEN_BOOL("devtools.enable",
+ "Enable Developer Tools"),
+
+ mq_html_h3(NULL, "Compatibility"),
+ GEN_STR ("compatibility.user-agent",
+ "User Agent Identity"),
+ GEN_BOOL("compatibility.quirks",
+ "Enable Site-Specific Quirks"),
+ NULL);
+}
+
+static gchar *
+gen_page_display(MqConfig *config)
+{
+ return mq_html_container("div",
+ mq_html_h3(NULL, "Fonts"),
+ GEN_STR ("font.family.default",
+ "Default Font Family"),
+ GEN_STR ("font.family.monospace",
+ "Default Monospace Font Family"),
+ GEN_STR ("font.family.serif",
+ "Default Serif Font Family"),
+ GEN_STR ("font.family.sans-serif",
+ "Default Sans-serif Font Family"),
+ GEN_STR ("font.family.cursive",
+ "Cursive Font Family"),
+ GEN_STR ("font.family.fantasy",
+ "Fantasy Font Family"),
+ GEN_STR ("font.family.pictograph",
+ "Pictograph Font Family"),
+ GEN_INT ("font.size.default",
+ "Default Font Size", 5, 1, 72),
+ GEN_INT ("font.size.monospace-default",
+ "Default Monospace Font Size", 5, 1, 72),
+ GEN_INT ("font.size.minimum",
+ "Minimum Font Size", 0, 1, 72),
+
+ mq_html_h3(NULL, "Languages"),
+ GEN_STRL("intl.accept-languages",
+ "Preferred Web Site Languages"),
+ GEN_STR ("intl.default-charset",
+ "Default Character Set"),
+
+ mq_html_h3(NULL, "Zoom"),
+ GEN_DBL ("zoom.default",
+ "Default Zoom Level", 0.00, 0.10, 10.00),
+ GEN_BOOL("zoom.text-only",
+ "Zoom Text Only"),
+ NULL);
+}
+
+#undef GEN_BOOL
+#undef GEN_INT
+#undef GEN_DBL
+#undef GEN_STR
+#undef GEN_STRL
+
void
mq_about_preferences_response(MqApplication *application, GHashTable *query,
WebKitURISchemeRequest *request)
{
- gchar *document;
+ MqConfig *config;
+ gchar *document;
+
+ config = mq_application_get_config(application);
if (query) {
+ g_hash_table_foreach(query, (GHFunc) save_pref, config);
+ mq_config_save(config);
mq_about_redirect(request, "mq-about:preferences");
} else {
document = mq_html_document("Preferences",
mq_html_form("Save", "Cancel",
- mq_html_notebook(TRUE, "notebook1", 0,
- mq_html_container("div",
- mq_html_input_text("text1",
- "Text 1", ""),
- mq_html_input_text("text2",
- "Text 2", ""),
- NULL),
- "Tab 1",
- mq_html_container("div",
- mq_html_input_text("text3",
- "Text 3", ""),
- mq_html_input_text("text4",
- "Text 4", ""),
- NULL),
- "Tab 2",
+ mq_html_notebook(FALSE, "notebook1", 0,
+ gen_page_general(config),
+ "General",
+ gen_page_display(config),
+ "Display",
NULL),
NULL),
NULL);