diff options
-rw-r--r-- | src/about/preferences.c | 40 | ||||
-rw-r--r-- | src/html.c | 149 | ||||
-rw-r--r-- | src/html.h | 6 |
3 files changed, 38 insertions, 157 deletions
diff --git a/src/about/preferences.c b/src/about/preferences.c index 3a16895..64633a7 100644 --- a/src/about/preferences.c +++ b/src/about/preferences.c @@ -52,8 +52,8 @@ save_pref(gchar *key, gchar *value, MqConfig *config) static gchar * gen_page_general(MqConfig *config) { - return mq_html_fieldset( - mq_html_th(NULL, "Web Browsing"), + return mq_html_container("div", + mq_html_h3(NULL, "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_th(NULL, "Navigation and Accessibility"), + mq_html_h3(NULL, "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_th(NULL, "Spell Checking"), + mq_html_h3(NULL, "Spell Checking"), GEN_BOOL("spell.enable", "Enable Spell Checking"), GEN_STRL("spell.langs", "Spell Checking Languages"), - mq_html_th(NULL, "Miscellaneous"), + mq_html_h3(NULL, "Miscellaneous"), GEN_BOOL("display.textarea.resize.enable", "Enable Resizable Text Areas"), GEN_BOOL("devtools.enable", "Enable Developer Tools"), - mq_html_th(NULL, "Compatibility"), + mq_html_h3(NULL, "Compatibility"), GEN_STR ("compatibility.user-agent", "User Agent Identity"), GEN_BOOL("compatibility.quirks", @@ -99,8 +99,8 @@ gen_page_general(MqConfig *config) static gchar * gen_page_display(MqConfig *config) { - return mq_html_fieldset( - mq_html_th(NULL, "Fonts"), + return mq_html_container("div", + mq_html_h3(NULL, "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_th(NULL, "Languages"), + mq_html_h3(NULL, "Languages"), GEN_STRL("intl.accept-languages", "Preferred Web Site Languages"), GEN_STR ("intl.default-charset", "Default Character Set"), - mq_html_th(NULL, "Zoom"), + mq_html_h3(NULL, "Zoom"), GEN_DBL ("zoom.default", "Default Zoom Level", 0.00, 0.10, 10.00), GEN_BOOL("zoom.text-only", @@ -139,8 +139,8 @@ gen_page_display(MqConfig *config) static gchar * gen_page_permissions(MqConfig *config) { - return mq_html_fieldset( - mq_html_th(NULL, "General"), + return mq_html_container("div", + mq_html_h3(NULL, "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_th(NULL, "JavaScript"), + mq_html_h3(NULL, "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_th(NULL, "Data Storage"), + mq_html_h3(NULL, "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_th(NULL, "Graphics and Multimedia"), + mq_html_h3(NULL, "Graphics and Multimedia"), GEN_BOOL("canvas.acceleration.enable", "Enable Hardware-Accelerated 2-D Canvas Drawing"), GEN_BOOL("permissions.javascript.webgl", @@ -192,8 +192,8 @@ gen_page_permissions(MqConfig *config) static gchar * gen_page_sec_and_priv(MqConfig *config) { - return mq_html_fieldset( - mq_html_th(NULL, "History"), + return mq_html_container("div", + mq_html_h3(NULL, "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_th(NULL, "Cookies"), + mq_html_h3(NULL, "Cookies"), GEN_SLCT("cookies.accept", "Accept Cookies", "always", "Always", "never", "Never", "no-third-party", "No Third-Party"), - mq_html_th(NULL, "Security"), + mq_html_h3(NULL, "Security"), GEN_BOOL("security.xss-auditor.enable", "Attempt to Detect and Block Cross-Site Scripting " "Attacks"), - mq_html_th(NULL, "Network"), + mq_html_h3(NULL, "Network"), GEN_BOOL("dns.prefetch.enable", "Prefetch Domain Name Resolutions for Better " "Performance"), @@ -143,13 +143,6 @@ static const gchar *styles = "form {\n" "margin: 0;\n" "}" - "table {\n" - "border-collapse: collapse;\n" - "}\n" - "table th {\n" - "padding: 6px 0;\n" - "text-align: left;\n" - "}\n" "form input, form select {\n" "border: 1px solid #9F9F9F;\n" "border-radius: 3px;\n" @@ -165,14 +158,6 @@ static const gchar *styles = "margin: 0;\n" "float: right;\n" "}\n" - "form table label {\n" - "margin: 6px 0;\n" - "padding: 0 6px 0 0;\n" - "text-align: right;\n" - "}\n" - "form table input, form table select {\n" - "margin: 6px 0;\n" - "}\n" "form label {\n" "display: block;\n" "}\n" @@ -551,69 +536,11 @@ mq_html_form(const gchar *submit_label, const gchar *reset_label, ...) } gchar * -mq_html_fieldset(gchar *first_child, ...) -{ - gsize len; - va_list ap; - gchar *child; - gchar *fieldset; - gchar *ptr; - - /* Calculate length. */ - len = strlen("<fieldset>\n"); - len += strlen("<table>\n"); - len += strlen(first_child); - va_start(ap, first_child); - while ((child = va_arg(ap, gchar *))) { - len += strlen(child); - } - va_end(ap); - len += strlen("</table>\n"); - len += strlen("</fieldset>\n"); - ++len; /* NUL byte */ - - /* Build string. */ - fieldset = g_new(gchar, len); - ptr = g_stpcpy(fieldset, "<fieldset>\n"); - ptr = g_stpcpy(ptr, "<table>\n"); - ptr = g_stpcpy(ptr, first_child); - g_free(first_child); - va_start(ap, first_child); - while ((child = va_arg(ap, gchar *))) { - ptr = g_stpcpy(ptr, child); - g_free(child); - } - va_end(ap); - ptr = g_stpcpy(ptr, "</table>\n"); - ptr = g_stpcpy(ptr, "</fieldset>\n"); /* g_stpcpy() adds the NUL. */ - - return fieldset; -} - -gchar * -mq_html_th(GDestroyNotify destroy, gchar *text) -{ - gchar *e; - e = g_strconcat("<tr>\n<th colspan=\"2\">", text, "</th>\n</tr>\n", - NULL); - if (destroy) { - destroy(text); - } - return e; -} - -gchar * mq_html_input_text(const gchar *name, const gchar *label, const gchar *value) { - return g_strdup_printf( - "<tr>\n" - "<td>\n" - "<label for=\"%s\">%s</label>\n" - "</td>\n" - "<td>\n" + return g_strdup_printf("<label for=\"%s\">\n<span>%s</span>\n" "<input type=\"text\" name=\"%s\" id=\"%s\" value=\"%s\">\n" - "</td>\n" - "</tr>\n", + "</label>\n", name, label, name, name, value ? value : ""); } @@ -621,16 +548,10 @@ gchar * mq_html_input_number_i(const gchar *name, const gchar *label, gint min, gint step, gint max, gint value) { - return g_strdup_printf( - "<tr>\n" - "<td>\n" - "<label for=\"%s\">%s</label>\n" - "</td>\n" - "<td>\n" + return g_strdup_printf("<label for=\"%s\">\n<span>%s</span>\n" "<input type=\"number\" name=\"%s\" id=\"%s\"" " min=\"%d\" step=\"%d\" max=\"%d\" value=\"%d\">\n" - "</td>\n" - "</tr>\n", + "</label>\n", name, label, name, name, min, step, max, value); } @@ -638,31 +559,18 @@ gchar * mq_html_input_number_d(const gchar *name, const gchar *label, gdouble min, gdouble step, gdouble max, gdouble value) { - return g_strdup_printf( - "<tr>\n" - "<td>\n" - "<label for=\"%s\">%s</label>\n" - "</td>\n" - "<td>\n" + return g_strdup_printf("<label for=\"%s\">\n<span>%s</span>\n" "<input type=\"number\" name=\"%s\" id=\"%s\"" " min=\"%f\" step=\"%f\" max=\"%f\" value=\"%f\">\n" - "</td>\n" - "</tr>\n", + "</label>\n", name, label, name, name, min, step, max, value); } gchar * mq_html_input_radio(const gchar *name, const gchar *label, gboolean checked) { - return g_strdup_printf( - "<tr>\n" - "<td>\n" - "<label for=\"%s\">%s</label>\n" - "</td>\n" - "<td>\n" - "<input type=\"radio\" name=\"%s\" id=\"%s\"%s>\n" - "</td>\n" - "</tr>\n", + return g_strdup_printf("<label for=\"%s\">\n<span>%s</span>\n" + "<input type=\"radio\" name=\"%s\" id=\"%s\"%s>\n</label>\n", name, label, name, name, checked ? " checked=\"checked\"" : ""); } @@ -690,16 +598,9 @@ mq_html_input_checkbox(const gchar *name, const gchar *label, gboolean checked) * <input> when the former <input> is checked. */ - return g_strdup_printf( - "<tr>\n" - "<td>\n" - "<label for=\"%s\">%s</label>\n" - "</td>\n" - "<td>\n" + return g_strdup_printf("<label for=\"%s\">\n<span>%s</span>\n" "<input type=\"hidden\" name=\"%s\" value=\"off\">\n" - "<input type=\"checkbox\" name=\"%s\" id=\"%s\"%s>\n" - "</td>\n" - "</tr>\n", + "<input type=\"checkbox\" name=\"%s\" id=\"%s\"%s>\n</label>\n", name, label, name, name, name, checked ? " checked=\"checked\"" : ""); } @@ -719,16 +620,11 @@ mq_html_input_select(const gchar *name, const gchar *label, g_assert(selected && selected[0]); /* Would cause buffer overflow */ /* Calculate length. */ - len = strlen("<tr>\n"); - len += strlen("<td>\n"); - len += strlen("<label for=\""); + len = strlen("<label for=\""); len += strlen(name); - len += strlen("\">"); + len += strlen("\">\n<span>"); len += strlen(label); - len += strlen("</label>\n"); - len += strlen("</td>\n"); - len += strlen("<td>\n"); - len += strlen("<select name=\""); + len += strlen("</span>\n<select name=\""); len += strlen(name); len += strlen("\" id=\""); len += strlen(name); @@ -745,23 +641,16 @@ mq_html_input_select(const gchar *name, const gchar *label, } va_end(ap); len += strlen(" selected=\"selected\""); - len += strlen("</select>\n"); - len += strlen("</td>\n"); - len += strlen("</tr>\n"); + len += strlen("</select>\n</label>\n"); ++len; /* NUL byte */ /* Build string. */ select = g_new(gchar, len); - ptr = g_stpcpy(select, "<tr>\n"); - ptr = g_stpcpy(ptr, "<td>\n"); - ptr = g_stpcpy(ptr, "<label for=\""); + ptr = g_stpcpy(select, "<label for=\""); ptr = g_stpcpy(ptr, name); - ptr = g_stpcpy(ptr, "\">"); + ptr = g_stpcpy(ptr, "\">\n<span>"); ptr = g_stpcpy(ptr, label); - ptr = g_stpcpy(ptr, "</label>\n"); - ptr = g_stpcpy(ptr, "</td>\n"); - ptr = g_stpcpy(ptr, "<td>\n"); - ptr = g_stpcpy(ptr, "<select name=\""); + ptr = g_stpcpy(ptr, "</span>\n<select name=\""); ptr = g_stpcpy(ptr, name); ptr = g_stpcpy(ptr, "\" id=\""); ptr = g_stpcpy(ptr, name); @@ -786,9 +675,7 @@ mq_html_input_select(const gchar *name, const gchar *label, ptr = g_stpcpy(ptr, "</option>\n"); } va_end(ap); - ptr = g_stpcpy(ptr, "</select>\n"); - ptr = g_stpcpy(ptr, "</td>\n"); - ptr = g_stpcpy(ptr, "</tr>\n"); /* g_stpcpy() adds NUL */ + ptr = g_stpcpy(ptr, "</select>\n</label>\n"); /* g_stpcpy() adds NUL */ return select; } @@ -58,12 +58,6 @@ mq_html_form(const gchar *submit_label, const gchar *reset_label, ...) G_GNUC_NULL_TERMINATED; gchar * -mq_html_fieldset(gchar *first_child, ...); - -gchar * -mq_html_th(GDestroyNotify destroy, gchar *text); - -gchar * mq_html_input_text(const gchar *name, const gchar *label, const gchar *value); gchar * |