summaryrefslogtreecommitdiff
path: root/src/ui/window.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/window.c')
-rw-r--r--src/ui/window.c37
1 files changed, 34 insertions, 3 deletions
diff --git a/src/ui/window.c b/src/ui/window.c
index 510fe2fe..b545cc10 100644
--- a/src/ui/window.c
+++ b/src/ui/window.c
@@ -480,6 +480,21 @@ static void dismissPortraitPhoneSidebars_(void) {
480 } 480 }
481} 481}
482 482
483static iBool willPerformSearchQuery_(const iString *userInput) {
484 const iString *clean = collect_String(trimmed_String(userInput));
485 if (isEmpty_String(clean)) {
486 return iFalse;
487 }
488 return !isEmpty_String(&prefs_App()->searchUrl) && !isLikelyUrl_String(userInput);
489}
490
491static void showSearchQueryIndicator_(iBool show) {
492 iWidget *indicator = findWidget_App("input.indicator.search");
493 setFlags_Widget(indicator, hidden_WidgetFlag, !show);
494 setContentPadding_InputWidget(
495 (iInputWidget *) parent_Widget(indicator), 0, show ? width_Widget(indicator) : 0);
496}
497
483static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { 498static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
484 if (equal_Command(cmd, "window.resized")) { 499 if (equal_Command(cmd, "window.resized")) {
485 const iBool isPhone = deviceType_App() == phone_AppDeviceType; 500 const iBool isPhone = deviceType_App() == phone_AppDeviceType;
@@ -534,14 +549,18 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
534 return iTrue; 549 return iTrue;
535 } 550 }
536 else if (equal_Command(cmd, "input.edited")) { 551 else if (equal_Command(cmd, "input.edited")) {
537 iAnyObject *url = findChild_Widget(navBar, "url"); 552 iAnyObject * url = findChild_Widget(navBar, "url");
553 const iString *text = text_InputWidget(url);
554 const iBool show = willPerformSearchQuery_(text);
555 showSearchQueryIndicator_(show);
538 if (pointer_Command(cmd) == url) { 556 if (pointer_Command(cmd) == url) {
539 submit_LookupWidget(findWidget_App("lookup"), text_InputWidget(url)); 557 submit_LookupWidget(findWidget_App("lookup"), text);
540 return iTrue; 558 return iTrue;
541 } 559 }
542 } 560 }
543 else if (startsWith_CStr(cmd, "input.ended id:url ")) { 561 else if (startsWith_CStr(cmd, "input.ended id:url ")) {
544 iInputWidget *url = findChild_Widget(navBar, "url"); 562 iInputWidget *url = findChild_Widget(navBar, "url");
563 showSearchQueryIndicator_(iFalse);
545 if (isEmpty_String(text_InputWidget(url))) { 564 if (isEmpty_String(text_InputWidget(url))) {
546 /* User entered nothing; restore the current URL. */ 565 /* User entered nothing; restore the current URL. */
547 setText_InputWidget(url, url_DocumentWidget(document_App())); 566 setText_InputWidget(url, url_DocumentWidget(document_App()));
@@ -551,7 +570,7 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) {
551 !isFocused_Widget(findWidget_App("lookup"))) { 570 !isFocused_Widget(findWidget_App("lookup"))) {
552 iString *newUrl = copy_String(text_InputWidget(url)); 571 iString *newUrl = copy_String(text_InputWidget(url));
553 trim_String(newUrl); 572 trim_String(newUrl);
554 if (!isEmpty_String(&prefs_App()->searchUrl) && !isLikelyUrl_String(newUrl)) { 573 if (willPerformSearchQuery_(newUrl)) {
555 postCommandf_App("open url:%s", cstr_String(searchQueryUrl_App(newUrl))); 574 postCommandf_App("open url:%s", cstr_String(searchQueryUrl_App(newUrl)));
556 } 575 }
557 else { 576 else {
@@ -886,6 +905,18 @@ static void setupUserInterface_Window(iWindow *d) {
886 iClob(progress), 905 iClob(progress),
887 moveToParentRightEdge_WidgetFlag); 906 moveToParentRightEdge_WidgetFlag);
888 } 907 }
908 /* Feeds refresh indicator is inside the input field. */ {
909 iLabelWidget *queryInd =
910 new_LabelWidget(uiTextAction_ColorEscape "\u21d2 Search Query", NULL);
911 setId_Widget(as_Widget(queryInd), "input.indicator.search");
912 setBackgroundColor_Widget(as_Widget(queryInd), uiBackground_ColorId);
913 setFrameColor_Widget(as_Widget(queryInd), uiTextAction_ColorId);
914 setAlignVisually_LabelWidget(queryInd, iTrue);
915 shrink_Rect(&as_Widget(queryInd)->rect, init_I2(0, gap_UI));
916 addChildFlags_Widget(as_Widget(url),
917 iClob(queryInd),
918 moveToParentRightEdge_WidgetFlag | hidden_WidgetFlag);
919 }
889 } 920 }
890 setId_Widget(addChild_Widget( 921 setId_Widget(addChild_Widget(
891 navBar, iClob(newIcon_LabelWidget(reloadCStr_, 0, 0, "navigate.reload"))), 922 navBar, iClob(newIcon_LabelWidget(reloadCStr_, 0, 0, "navigate.reload"))),