/*
* about:preferences
*
* Copyright (C) 2017 Patrick McDermott
*
* This file is part of Marquee.
*
* Marquee is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Marquee is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Marquee. If not, see .
*/
#include "paths.h"
#include
#include
#include "../../application.h"
#include "../../config/config.h"
#include "../../utils/html.h"
#include "../about.h"
static void
save_pref(gchar *key, gchar *value, MqConfig *config)
{
if (key[0] != '_') {
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, \
mq_config_get_string(config, NAME), FALSE)
#define GEN_STRL(NAME, LABEL) mq_html_input_text(NAME, LABEL, \
mq_config_get_string(config, NAME), FALSE)
#define GEN_SLCT(NAME, LABEL, ...) mq_html_input_select(NAME, LABEL, \
mq_config_get_string(config, NAME), NULL, NULL, __VA_ARGS__, NULL)
static gchar *
gen_page_general(MqConfig *config)
{
return mq_html_container("div", NULL,
mq_html_h3("Web Browsing"),
GEN_SLCT("tabs.new",
"New tab page",
"home", "Home page",
"blank", "Blank 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("Navigation and Accessibility"),
GEN_BOOL("navigation.smooth-scrolling",
"Enable 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("Spell Checking"),
GEN_BOOL("spell.enable",
"Enable spell checking"),
GEN_STRL("spell.langs",
"Spell checking languages"),
mq_html_h3("Miscellaneous"),
GEN_BOOL("display.textarea.resize.enable",
"Enable resizable text areas"),
GEN_BOOL("devtools.enable",
"Enable developer tools"),
mq_html_h3("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", NULL,
mq_html_h3("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("Languages"),
GEN_STRL("intl.accept-languages",
"Preferred Web site languages"),
GEN_STR ("intl.default-charset",
"Default character set"),
mq_html_h3("Zoom"),
GEN_DBL ("zoom.default",
"Default zoom level", 0.00, 0.10, 10.00),
GEN_BOOL("zoom.text-only",
"Zoom text only"),
NULL);
}
static gchar *
gen_page_permissions(MqConfig *config)
{
return mq_html_container("div", NULL,
mq_html_h3("General"),
GEN_BOOL("permissions.images.auto-load",
"Automatically load images"),
GEN_BOOL("permissions.images.favicons.override",
"Always load icons irrespective of automatic image "
"Loading"),
GEN_BOOL("permissions.java.enable",
"Enable Java"),
GEN_BOOL("permissions.javascript.enable",
"Enable JavaScript"),
GEN_BOOL("permissions.plugins.enable",
"Enable plugins"),
mq_html_h3("JavaScript"),
GEN_BOOL("permissions.javascript.open-windows",
"Allow JavaScript to open windows"),
GEN_BOOL("permissions.javascript.fullscreen",
"Allow JavaScript to display elements fullscreen"),
GEN_BOOL("permissions.javascript.modal-dialogs",
"Allow JavaScript to show modal dialogs"),
GEN_BOOL("permissions.javascript.clipboard",
"Allow JavaScript to access the clipboard"),
mq_html_h3("Data Storage"),
GEN_BOOL("permissions.javascript.database",
"Enable Web database"),
GEN_BOOL("permissions.javascript.storage",
"Enable Web storage"),
GEN_BOOL("permissions.appcache",
"Enable application cache"),
mq_html_h3("Graphics and Multimedia"),
GEN_BOOL("canvas.acceleration.enable",
"Enable hardware-accelerated 2-D canvas drawing"),
GEN_BOOL("permissions.javascript.webgl",
"Enable JavaScript WebGL 3-D graphics rendering"),
GEN_BOOL("permissions.javascript.audio",
"Allow JavaScript to process and synthesize audio"),
GEN_BOOL("media.autoplay",
"Enable automatic media playback and loading"),
GEN_BOOL("media.force-fullscreen",
"Force media to play fullscreen"),
GEN_BOOL("permissions.javascript.mediastream.enable",
"Allow JavaScript to access audio and video devices"),
GEN_BOOL("permissions.javascript.mediasource.enable",
"Allow JavaScript to generate media streams"),
NULL);
}
static gchar *
gen_page_sec_and_priv(MqConfig *config)
{
return mq_html_container("div", NULL,
mq_html_h3("History"),
GEN_BOOL("privacy.private-browsing.enabled",
"Enable private prowsing (disables history, cache, and "
"form auto-filling)"),
GEN_BOOL("privacy.remember.history",
"Remember browsing history"),
GEN_BOOL("privacy.remember.downloads",
"Remember download history"),
mq_html_h3("Cookies"),
GEN_SLCT("cookies.accept",
"Accept cookies",
"always", "Always",
"never", "Never",
"no-third-party", "No third-party"),
mq_html_h3("Security"),
GEN_BOOL("security.xss-auditor.enable",
"Attempt to detect and block cross-site scripting "
"attacks"),
mq_html_h3("Network"),
GEN_BOOL("dns.prefetch.enable",
"Prefetch domain name resolutions for better "
"performance"),
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)
{
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", NULL, NULL,
mq_html_form(NULL, "Save", NULL, "Cancel",
mq_html_notebook(FALSE, "notebook1", 0,
gen_page_general(config),
"General",
gen_page_display(config),
"Display",
gen_page_permissions(config),
"Permissions",
gen_page_sec_and_priv(config),
"Security and Privacy",
NULL),
NULL),
NULL);
mq_about_response(request, document);
}
}