summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbaskerville <nihilhill@gmail.com>2012-07-26 11:00:27 +0200
committerbaskerville <nihilhill@gmail.com>2012-07-26 11:00:27 +0200
commitaf1b907c931bfa22aa9425ca01c5994cd4d68fb7 (patch)
tree3daecd3078bc2b9128f7ee1f2352cb29b2c00e38 /src
parent728a5b9b7e8591741b786f8a682b237e0b403482 (diff)
downloaddwb-af1b907c931bfa22aa9425ca01c5994cd4d68fb7.zip
Added a 'searchengine-submit-pattern'
Diffstat (limited to 'src')
-rw-r--r--src/config.h2
-rw-r--r--src/dwb.c12
-rw-r--r--src/view.c8
3 files changed, 18 insertions, 4 deletions
diff --git a/src/config.h b/src/config.h
index 1065f71e..2911d204 100644
--- a/src/config.h
+++ b/src/config.h
@@ -1138,4 +1138,6 @@ static WebSettings DWB_SETTINGS[] = {
SETTING_GLOBAL, BOOLEAN, { .b = false }, NULL, { 0 }, },
{ { "bars-padding", "Padding of the status, download, completion and tab bars", },
SETTING_GLOBAL, INTEGER, { .i = 0 }, NULL, { 0 }, },
+ { { "searchengine-submit-pattern", "The pattern which will be replaced with the search terms", },
+ SETTING_GLOBAL, CHAR, { .p = NULL }, NULL, { 0 }, },
};/*}}}*/
diff --git a/src/dwb.c b/src/dwb.c
index 015dd188..4b72c792 100644
--- a/src/dwb.c
+++ b/src/dwb.c
@@ -1517,7 +1517,11 @@ static char *
dwb_get_search_engine_uri(const char *uri, const char *text) {
char *ret = NULL;
if (uri != NULL && text != NULL) {
- GRegex *regex = g_regex_new(HINT_SEARCH_SUBMIT, 0, 0, NULL);
+ char *hint_search_submit = GET_CHAR("searchengine-submit-pattern");
+ if (hint_search_submit == NULL) {
+ hint_search_submit = HINT_SEARCH_SUBMIT;
+ }
+ GRegex *regex = g_regex_new(hint_search_submit, 0, 0, NULL);
char *escaped = g_uri_escape_string(text, NULL, true);
ret = g_regex_replace(regex, uri, -1, 0, escaped, 0, NULL);
g_free(escaped);
@@ -1568,7 +1572,11 @@ void
dwb_submit_searchengine(void) {
char buffer[64];
char *value;
- snprintf(buffer, 64, "{ \"searchString\" : \"%s\" }", HINT_SEARCH_SUBMIT);
+ char *hint_search_submit = GET_CHAR("searchengine-submit-pattern");
+ if (hint_search_submit == NULL) {
+ hint_search_submit = HINT_SEARCH_SUBMIT;
+ }
+ snprintf(buffer, 64, "{ \"searchString\" : \"%s\" }", hint_search_submit);
if ( (value = js_call_as_function(MAIN_FRAME(), CURRENT_VIEW()->hint_object, "submitSearchEngine", buffer, &value)) ) {
dwb.state.form_name = value;
}
diff --git a/src/view.c b/src/view.c
index ff871006..f2c03a76 100644
--- a/src/view.c
+++ b/src/view.c
@@ -484,8 +484,12 @@ view_navigation_policy_cb(WebKitWebView *web, WebKitWebFrame *frame, WebKitNetwo
case WEBKIT_WEB_NAVIGATION_REASON_FORM_SUBMITTED:
if (dwb.state.mode == SEARCH_FIELD_MODE) {
webkit_web_policy_decision_ignore(policy);
- dwb.state.search_engine = dwb.state.form_name && !g_strrstr(uri, HINT_SEARCH_SUBMIT)
- ? g_strdup_printf("%s?%s=%s", uri, dwb.state.form_name, HINT_SEARCH_SUBMIT)
+ char *hint_search_submit = GET_CHAR("searchengine-submit-pattern");
+ if (hint_search_submit == NULL) {
+ hint_search_submit = HINT_SEARCH_SUBMIT;
+ }
+ dwb.state.search_engine = dwb.state.form_name && !g_strrstr(uri, hint_search_submit)
+ ? g_strdup_printf("%s?%s=%s", uri, dwb.state.form_name, hint_search_submit)
: g_strdup(uri);
dwb_save_searchengine();
webkit_web_policy_decision_ignore(policy);