summaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
authorJaakko Keränen <jaakko.keranen@iki.fi>2021-02-16 08:50:37 +0200
committerJaakko Keränen <jaakko.keranen@iki.fi>2021-02-16 08:50:37 +0200
commit902ccb3d65db97ad4f8d17279806b0290d7ca332 (patch)
tree97ef9f469a2812e11ac44722e3b78da1f15dd6a1 /src/ui
parent180e0add685b16a916292d775b7497e8443048e7 (diff)
Search engine queries via the navbar
Any text that doesn't look like a URL is passed onto the configured search URL as a query string. IssueID #157
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/util.c7
-rw-r--r--src/ui/window.c14
2 files changed, 15 insertions, 6 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index 9a98d07b..553d9078 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -1175,6 +1175,10 @@ iWidget *makePreferences_Widget(void) {
1175 } 1175 }
1176 /* Network. */ { 1176 /* Network. */ {
1177 appendTwoColumnPage_(tabs, "Network", '5', &headings, &values); 1177 appendTwoColumnPage_(tabs, "Network", '5', &headings, &values);
1178 addChild_Widget(headings, iClob(makeHeading_Widget("Search URL:")));
1179 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.searchurl");
1180 addChild_Widget(headings, iClob(makeHeading_Widget("Decode URLs:")));
1181 addChild_Widget(values, iClob(makeToggle_Widget("prefs.decodeurls")));
1178 addChild_Widget(headings, iClob(makeHeading_Widget("Cache size:"))); 1182 addChild_Widget(headings, iClob(makeHeading_Widget("Cache size:")));
1179 iWidget *cacheGroup = new_Widget(); { 1183 iWidget *cacheGroup = new_Widget(); {
1180 iInputWidget *cache = new_InputWidget(4); 1184 iInputWidget *cache = new_InputWidget(4);
@@ -1183,8 +1187,6 @@ iWidget *makePreferences_Widget(void) {
1183 addChildFlags_Widget(cacheGroup, iClob(new_LabelWidget("MB", NULL)), frameless_WidgetFlag); 1187 addChildFlags_Widget(cacheGroup, iClob(new_LabelWidget("MB", NULL)), frameless_WidgetFlag);
1184 } 1188 }
1185 addChildFlags_Widget(values, iClob(cacheGroup), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag); 1189 addChildFlags_Widget(values, iClob(cacheGroup), arrangeHorizontal_WidgetFlag | arrangeSize_WidgetFlag);
1186 addChild_Widget(headings, iClob(makeHeading_Widget("Decode URLs:")));
1187 addChild_Widget(values, iClob(makeToggle_Widget("prefs.decodeurls")));
1188 makeTwoColumnHeading_("PROXIES", headings, values); 1190 makeTwoColumnHeading_("PROXIES", headings, values);
1189 addChild_Widget(headings, iClob(makeHeading_Widget("Gemini proxy:"))); 1191 addChild_Widget(headings, iClob(makeHeading_Widget("Gemini proxy:")));
1190 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.proxy.gemini"); 1192 setId_Widget(addChild_Widget(values, iClob(new_InputWidget(0))), "prefs.proxy.gemini");
@@ -1201,6 +1203,7 @@ iWidget *makePreferences_Widget(void) {
1201 resizeToLargestPage_Widget(tabs); 1203 resizeToLargestPage_Widget(tabs);
1202 arrange_Widget(dlg); 1204 arrange_Widget(dlg);
1203 /* Set input field sizes. */ { 1205 /* Set input field sizes. */ {
1206 expandInputFieldWidth_(findChild_Widget(tabs, "prefs.searchurl"));
1204 expandInputFieldWidth_(findChild_Widget(tabs, "prefs.downloads")); 1207 expandInputFieldWidth_(findChild_Widget(tabs, "prefs.downloads"));
1205 expandInputFieldWidth_(findChild_Widget(tabs, "prefs.proxy.gemini")); 1208 expandInputFieldWidth_(findChild_Widget(tabs, "prefs.proxy.gemini"));
1206 expandInputFieldWidth_(findChild_Widget(tabs, "prefs.proxy.gopher")); 1209 expandInputFieldWidth_(findChild_Widget(tabs, "prefs.proxy.gopher"));
diff --git a/src/ui/window.c b/src/ui/window.c
index cd813acb..563d57ae 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -47,6 +47,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
47 47
48#include <the_Foundation/file.h> 48#include <the_Foundation/file.h>
49#include <the_Foundation/path.h> 49#include <the_Foundation/path.h>
50#include <the_Foundation/regexp.h>
50#include <SDL_hints.h> 51#include <SDL_hints.h>
51#include <SDL_timer.h> 52#include <SDL_timer.h>
52#include <SDL_syswm.h> 53#include <SDL_syswm.h>
@@ -419,9 +420,14 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
419 !isFocused_Widget(findWidget_App("lookup"))) { 420 !isFocused_Widget(findWidget_App("lookup"))) {
420 iString *newUrl = copy_String(text_InputWidget(url)); 421 iString *newUrl = copy_String(text_InputWidget(url));
421 trim_String(newUrl); 422 trim_String(newUrl);
422 postCommandf_App( 423 if (!isEmpty_String(&prefs_App()->searchUrl) && !isLikelyUrl_String(newUrl)) {
423 "open url:%s", 424 postCommandf_App("open url:%s", cstr_String(searchQueryUrl_App(newUrl)));
424 cstr_String(absoluteUrl_String(&iStringLiteral(""), collect_String(newUrl)))); 425 }
426 else {
427 postCommandf_App(
428 "open url:%s",
429 cstr_String(absoluteUrl_String(&iStringLiteral(""), collect_String(newUrl))));
430 }
425 return iTrue; 431 return iTrue;
426 } 432 }
427 } 433 }
@@ -1168,7 +1174,7 @@ static iBool handleWindowEvent_Window_(iWindow *d, const SDL_WindowEvent *ev) {
1168 //updateRootSize_Window_(d, iTrue); 1174 //updateRootSize_Window_(d, iTrue);
1169 invalidate_Window_(d); 1175 invalidate_Window_(d);
1170 d->isMinimized = iFalse; 1176 d->isMinimized = iFalse;
1171 //printf("restored %d\n", snap_Window(d)); fflush(stdout); 1177 printf("restored %d\n", snap_Window(d)); fflush(stdout);
1172 return iTrue; 1178 return iTrue;
1173 case SDL_WINDOWEVENT_MINIMIZED: 1179 case SDL_WINDOWEVENT_MINIMIZED:
1174 d->isMinimized = iTrue; 1180 d->isMinimized = iTrue;