From 6c1edf4ec1cf1ddab82b597867d9c846267b97ca Mon Sep 17 00:00:00 2001 From: Patrick McDermott Date: Thu, 26 Oct 2017 22:20:09 -0400 Subject: mq_html_h*(), mq_html_p(): Split out *_free() variants And update calls. --- (limited to 'src') diff --git a/src/about/preferences.c b/src/about/preferences.c index 64633a7..8a51d98 100644 --- a/src/about/preferences.c +++ b/src/about/preferences.c @@ -53,7 +53,7 @@ static gchar * gen_page_general(MqConfig *config) { return mq_html_container("div", - mq_html_h3(NULL, "Web Browsing"), + mq_html_h3("Web Browsing"), GEN_SLCT("tabs.new", "New Tab Page", "home", "Home Page", @@ -65,7 +65,7 @@ gen_page_general(MqConfig *config) GEN_BOOL("tabs.warn-on-close", "Warn When Closing Multiple Tabs or Windows"), - mq_html_h3(NULL, "Navigation and Accessibility"), + mq_html_h3("Navigation and Accessibility"), GEN_BOOL("navigation.smooth-scrolling", "Enable Smooth Scrolling"), GEN_BOOL("navigation.tabbing", @@ -76,19 +76,19 @@ gen_page_general(MqConfig *config) "Enable Spatial Navigation Between Elements By Arrow " "Keys"), - mq_html_h3(NULL, "Spell Checking"), + mq_html_h3("Spell Checking"), GEN_BOOL("spell.enable", "Enable Spell Checking"), GEN_STRL("spell.langs", "Spell Checking Languages"), - mq_html_h3(NULL, "Miscellaneous"), + mq_html_h3("Miscellaneous"), GEN_BOOL("display.textarea.resize.enable", "Enable Resizable Text Areas"), GEN_BOOL("devtools.enable", "Enable Developer Tools"), - mq_html_h3(NULL, "Compatibility"), + mq_html_h3("Compatibility"), GEN_STR ("compatibility.user-agent", "User Agent Identity"), GEN_BOOL("compatibility.quirks", @@ -100,7 +100,7 @@ static gchar * gen_page_display(MqConfig *config) { return mq_html_container("div", - mq_html_h3(NULL, "Fonts"), + mq_html_h3("Fonts"), GEN_STR ("font.family.default", "Default Font Family"), GEN_STR ("font.family.monospace", @@ -122,13 +122,13 @@ gen_page_display(MqConfig *config) GEN_INT ("font.size.minimum", "Minimum Font Size", 0, 1, 72), - mq_html_h3(NULL, "Languages"), + mq_html_h3("Languages"), GEN_STRL("intl.accept-languages", "Preferred Web Site Languages"), GEN_STR ("intl.default-charset", "Default Character Set"), - mq_html_h3(NULL, "Zoom"), + mq_html_h3("Zoom"), GEN_DBL ("zoom.default", "Default Zoom Level", 0.00, 0.10, 10.00), GEN_BOOL("zoom.text-only", @@ -140,7 +140,7 @@ static gchar * gen_page_permissions(MqConfig *config) { return mq_html_container("div", - mq_html_h3(NULL, "General"), + mq_html_h3("General"), GEN_BOOL("permissions.images.auto-load", "Automatically Load Images"), GEN_BOOL("permissions.images.favicons.override", @@ -153,7 +153,7 @@ gen_page_permissions(MqConfig *config) GEN_BOOL("permissions.plugins.enable", "Enable Plugins"), - mq_html_h3(NULL, "JavaScript"), + mq_html_h3("JavaScript"), GEN_BOOL("permissions.javascript.open-windows", "Enable JavaScript to Open Windows"), GEN_BOOL("permissions.javascript.fullscreen", @@ -163,7 +163,7 @@ gen_page_permissions(MqConfig *config) GEN_BOOL("permissions.javascript.clipboard", "Enable JavaScript to Access the Clipboard"), - mq_html_h3(NULL, "Data Storage"), + mq_html_h3("Data Storage"), GEN_BOOL("permissions.javascript.database", "Enable Web Database"), GEN_BOOL("permissions.javascript.storage", @@ -171,7 +171,7 @@ gen_page_permissions(MqConfig *config) GEN_BOOL("permissions.appcache", "Enable Application Cache"), - mq_html_h3(NULL, "Graphics and Multimedia"), + mq_html_h3("Graphics and Multimedia"), GEN_BOOL("canvas.acceleration.enable", "Enable Hardware-Accelerated 2-D Canvas Drawing"), GEN_BOOL("permissions.javascript.webgl", @@ -193,7 +193,7 @@ static gchar * gen_page_sec_and_priv(MqConfig *config) { return mq_html_container("div", - mq_html_h3(NULL, "History"), + mq_html_h3("History"), GEN_BOOL("privacy.private-browsing.enabled", "Enable Private Prowsing (Disables History, Cache, and " "Form Auto-Filling)"), @@ -202,19 +202,19 @@ gen_page_sec_and_priv(MqConfig *config) GEN_BOOL("privacy.remember.downloads", "Remember Download History"), - mq_html_h3(NULL, "Cookies"), + mq_html_h3("Cookies"), GEN_SLCT("cookies.accept", "Accept Cookies", "always", "Always", "never", "Never", "no-third-party", "No Third-Party"), - mq_html_h3(NULL, "Security"), + mq_html_h3("Security"), GEN_BOOL("security.xss-auditor.enable", "Attempt to Detect and Block Cross-Site Scripting " "Attacks"), - mq_html_h3(NULL, "Network"), + mq_html_h3("Network"), GEN_BOOL("dns.prefetch.enable", "Prefetch Domain Name Resolutions for Better " "Performance"), diff --git a/src/about/version.c b/src/about/version.c index ff1a375..c589d6e 100644 --- a/src/about/version.c +++ b/src/about/version.c @@ -46,17 +46,15 @@ mq_about_version_response(MqApplication G_GNUC_UNUSED *application, document = mq_html_document(title, mq_html_notebook(FALSE, "notebook1", 0, mq_html_container("div", - mq_html_h3(NULL, PACKAGE_NAME), - mq_html_p(NULL, PACKAGE_VERSION_GIT), - mq_html_p(NULL, - "© 2017 Patrick McDermott"), + mq_html_h3(PACKAGE_NAME), + mq_html_p(PACKAGE_VERSION_GIT), + mq_html_p("© 2017 Patrick McDermott"), NULL), "About", mq_html_container("div", - mq_html_h3(NULL, "Authors"), - mq_html_p(NULL, - "Patrick McDermott " - "<pj@pehjota.net>"), + mq_html_h3("Authors"), + mq_html_p("Patrick McDermott " + "<pj@pehjota.net>"), NULL), "Credits", g_strdup(mq_gpl_3_0_html()), diff --git a/src/html.c b/src/html.c index 71cdd8e..382d616 100644 --- a/src/html.c +++ b/src/html.c @@ -231,13 +231,16 @@ mq_html_document(const gchar *title, ...) #define TEXT_ELEMENT(ELEM) \ gchar * \ - mq_html_##ELEM(GDestroyNotify destroy, gchar *text) \ + mq_html_##ELEM(const gchar *text) \ + { \ + return g_strconcat("<" #ELEM ">", text, "", NULL); \ + } \ + gchar * \ + mq_html_##ELEM##_free(gchar *text) \ { \ gchar *e; \ e = g_strconcat("<" #ELEM ">", text, "", NULL); \ - if (destroy) { \ - destroy(text); \ - } \ + g_free(text); \ return e; \ } TEXT_ELEMENT(h1) diff --git a/src/html.h b/src/html.h index 8f5eada..6184683 100644 --- a/src/html.h +++ b/src/html.h @@ -29,7 +29,9 @@ mq_html_document(const gchar *title, ...) G_GNUC_NULL_TERMINATED; #define TEXT_ELEMENT(ELEM) \ gchar * \ - mq_html_##ELEM(GDestroyNotify destroy, gchar *text); + mq_html_##ELEM(const gchar *text); \ + gchar * \ + mq_html_##ELEM##_free(gchar *text); TEXT_ELEMENT(h1) TEXT_ELEMENT(h2) TEXT_ELEMENT(h3) -- cgit v0.9.1