/*
* 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
#include
#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)
{
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))
#define GEN_STRL(NAME, LABEL) mq_html_input_text(NAME, LABEL, \
mq_config_get_string(config, NAME))
#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_fieldset(
mq_html_h3(NULL, "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(NULL, "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(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_fieldset(
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);
}
static gchar *
gen_page_permissions(MqConfig *config)
{
return mq_html_fieldset(
mq_html_h3(NULL, "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(NULL, "JavaScript"),
GEN_BOOL("permissions.javascript.open-windows",
"Enable JavaScript to Open Windows"),
GEN_BOOL("permissions.javascript.fullscreen",
"Enable JavaScript to Display Elements Fullscreen"),
GEN_BOOL("permissions.javascript.modal-dialogs",
"Enable JavaScript to Show Modal Dialogs"),
GEN_BOOL("permissions.javascript.clipboard",
"Enable JavaScript to Access the Clipboard"),
mq_html_h3(NULL, "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(NULL, "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",
"Enable 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",
"Enable JavaScript to Access Audio and Video Devices"),
GEN_BOOL("permissions.javascript.mediasource.enable",
"Enable JavaScript to Generate Media Streams"),
NULL);
}
static gchar *
gen_page_sec_and_priv(MqConfig *config)
{
return mq_html_fieldset(
mq_html_h3(NULL, "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(NULL, "Cookies"),
GEN_SLCT("cookies.accept",
"Accept Cookies",
"always", "Always",
"never", "Never",
"no-third-party", "No Third-Party"),
mq_html_h3(NULL, "Security"),
GEN_BOOL("security.xss-auditor.enable",
"Attempt to Detect and Block Cross-Site Scripting "
"Attacks"),
mq_html_h3(NULL, "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",
mq_html_form("Save", "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);
}
}