diff options
author | baskerville <nihilhill@gmail.com> | 2012-07-26 11:00:27 +0200 |
---|---|---|
committer | baskerville <nihilhill@gmail.com> | 2012-07-26 11:00:27 +0200 |
commit | af1b907c931bfa22aa9425ca01c5994cd4d68fb7 (patch) | |
tree | 3daecd3078bc2b9128f7ee1f2352cb29b2c00e38 /src | |
parent | 728a5b9b7e8591741b786f8a682b237e0b403482 (diff) | |
download | dwb-af1b907c931bfa22aa9425ca01c5994cd4d68fb7.zip |
Added a 'searchengine-submit-pattern'
Diffstat (limited to 'src')
-rw-r--r-- | src/config.h | 2 | ||||
-rw-r--r-- | src/dwb.c | 12 | ||||
-rw-r--r-- | src/view.c | 8 |
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 }, }, };/*}}}*/ @@ -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; } @@ -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); |