diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/documentwidget.c | 23 | ||||
-rw-r--r-- | src/ui/documentwidget.h | 5 | ||||
-rw-r--r-- | src/ui/window.c | 5 |
3 files changed, 28 insertions, 5 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 661a9d46..a1299727 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -76,6 +76,7 @@ iDefineClass(MediaRequest) | |||
76 | 76 | ||
77 | struct Impl_DocumentWidget { | 77 | struct Impl_DocumentWidget { |
78 | iWidget widget; | 78 | iWidget widget; |
79 | iHistory *history; | ||
79 | enum iDocumentState state; | 80 | enum iDocumentState state; |
80 | iString *url; | 81 | iString *url; |
81 | iString *titleUser; | 82 | iString *titleUser; |
@@ -98,7 +99,7 @@ struct Impl_DocumentWidget { | |||
98 | int initialScrollY; | 99 | int initialScrollY; |
99 | iScrollWidget *scroll; | 100 | iScrollWidget *scroll; |
100 | iWidget *menu; | 101 | iWidget *menu; |
101 | SDL_Cursor *arrowCursor; | 102 | SDL_Cursor *arrowCursor; /* TODO: cursors belong in Window */ |
102 | SDL_Cursor *beamCursor; | 103 | SDL_Cursor *beamCursor; |
103 | SDL_Cursor *handCursor; | 104 | SDL_Cursor *handCursor; |
104 | }; | 105 | }; |
@@ -110,6 +111,7 @@ void init_DocumentWidget(iDocumentWidget *d) { | |||
110 | init_Widget(w); | 111 | init_Widget(w); |
111 | setId_Widget(w, "document"); | 112 | setId_Widget(w, "document"); |
112 | iZap(d->certExpiry); | 113 | iZap(d->certExpiry); |
114 | d->history = new_History(); | ||
113 | d->state = blank_DocumentState; | 115 | d->state = blank_DocumentState; |
114 | d->url = new_String(); | 116 | d->url = new_String(); |
115 | d->titleUser = new_String(); | 117 | d->titleUser = new_String(); |
@@ -153,6 +155,7 @@ void deinit_DocumentWidget(iDocumentWidget *d) { | |||
153 | SDL_FreeCursor(d->arrowCursor); | 155 | SDL_FreeCursor(d->arrowCursor); |
154 | SDL_FreeCursor(d->beamCursor); | 156 | SDL_FreeCursor(d->beamCursor); |
155 | SDL_FreeCursor(d->handCursor); | 157 | SDL_FreeCursor(d->handCursor); |
158 | delete_History(d->history); | ||
156 | } | 159 | } |
157 | 160 | ||
158 | static int documentWidth_DocumentWidget_(const iDocumentWidget *d) { | 161 | static int documentWidth_DocumentWidget_(const iDocumentWidget *d) { |
@@ -258,7 +261,7 @@ static void updateVisible_DocumentWidget_(iDocumentWidget *d) { | |||
258 | render_GmDocument(d->doc, visRange, addVisibleLink_DocumentWidget_, d); | 261 | render_GmDocument(d->doc, visRange, addVisibleLink_DocumentWidget_, d); |
259 | updateHover_DocumentWidget_(d, mouseCoord_Window(get_Window())); | 262 | updateHover_DocumentWidget_(d, mouseCoord_Window(get_Window())); |
260 | /* Remember scroll positions of recently visited pages. */ { | 263 | /* Remember scroll positions of recently visited pages. */ { |
261 | iRecentUrl *recent = mostRecentUrl_History(history_App()); | 264 | iRecentUrl *recent = mostRecentUrl_History(d->history); |
262 | if (recent) { | 265 | if (recent) { |
263 | recent->scrollY = d->scrollY / gap_UI; | 266 | recent->scrollY = d->scrollY / gap_UI; |
264 | } | 267 | } |
@@ -424,6 +427,10 @@ static void updateTrust_DocumentWidget_(iDocumentWidget *d, const iGmResponse *r | |||
424 | } | 427 | } |
425 | } | 428 | } |
426 | 429 | ||
430 | iHistory *history_DocumentWidget(iDocumentWidget *d) { | ||
431 | return d->history; | ||
432 | } | ||
433 | |||
427 | void setUrlFromCache_DocumentWidget(iDocumentWidget *d, const iString *url, iBool isFromCache) { | 434 | void setUrlFromCache_DocumentWidget(iDocumentWidget *d, const iString *url, iBool isFromCache) { |
428 | if (cmpStringSc_String(d->url, url, &iCaseInsensitive)) { | 435 | if (cmpStringSc_String(d->url, url, &iCaseInsensitive)) { |
429 | set_String(d->url, url); | 436 | set_String(d->url, url); |
@@ -439,7 +446,7 @@ void setUrlFromCache_DocumentWidget(iDocumentWidget *d, const iString *url, iBoo | |||
439 | iRelease(userPats[i]); | 446 | iRelease(userPats[i]); |
440 | } | 447 | } |
441 | } | 448 | } |
442 | const iRecentUrl *recent = mostRecentUrl_History(history_App()); | 449 | const iRecentUrl *recent = mostRecentUrl_History(d->history); |
443 | if (isFromCache && recent && recent->cachedResponse) { | 450 | if (isFromCache && recent && recent->cachedResponse) { |
444 | const iGmResponse *resp = recent->cachedResponse; | 451 | const iGmResponse *resp = recent->cachedResponse; |
445 | d->state = fetching_DocumentState; | 452 | d->state = fetching_DocumentState; |
@@ -764,7 +771,7 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
764 | pointerLabel_Command(command_UserEvent(ev), "request") == d->request) { | 771 | pointerLabel_Command(command_UserEvent(ev), "request") == d->request) { |
765 | checkResponse_DocumentWidget_(d); | 772 | checkResponse_DocumentWidget_(d); |
766 | d->state = ready_DocumentState; | 773 | d->state = ready_DocumentState; |
767 | setCachedResponse_History(history_App(), response_GmRequest(d->request)); | 774 | setCachedResponse_History(d->history, response_GmRequest(d->request)); |
768 | iReleasePtr(&d->request); | 775 | iReleasePtr(&d->request); |
769 | postCommandf_App("document.changed url:%s", cstr_String(d->url)); | 776 | postCommandf_App("document.changed url:%s", cstr_String(d->url)); |
770 | return iFalse; | 777 | return iFalse; |
@@ -788,6 +795,14 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
788 | fetch_DocumentWidget_(d); | 795 | fetch_DocumentWidget_(d); |
789 | return iTrue; | 796 | return iTrue; |
790 | } | 797 | } |
798 | else if (isCommand_UserEvent(ev, "navigate.back")) { | ||
799 | goBack_History(d->history); | ||
800 | return iTrue; | ||
801 | } | ||
802 | else if (isCommand_UserEvent(ev, "navigate.forward")) { | ||
803 | goForward_History(d->history); | ||
804 | return iTrue; | ||
805 | } | ||
791 | else if (isCommand_Widget(w, ev, "scroll.moved")) { | 806 | else if (isCommand_Widget(w, ev, "scroll.moved")) { |
792 | d->scrollY = arg_Command(command_UserEvent(ev)); | 807 | d->scrollY = arg_Command(command_UserEvent(ev)); |
793 | updateVisible_DocumentWidget_(d); | 808 | updateVisible_DocumentWidget_(d); |
diff --git a/src/ui/documentwidget.h b/src/ui/documentwidget.h index 7064d0d7..5ce28f4e 100644 --- a/src/ui/documentwidget.h +++ b/src/ui/documentwidget.h | |||
@@ -2,10 +2,15 @@ | |||
2 | 2 | ||
3 | #include "widget.h" | 3 | #include "widget.h" |
4 | 4 | ||
5 | iDeclareType(History) | ||
6 | |||
5 | iDeclareWidgetClass(DocumentWidget) | 7 | iDeclareWidgetClass(DocumentWidget) |
6 | iDeclareObjectConstruction(DocumentWidget) | 8 | iDeclareObjectConstruction(DocumentWidget) |
7 | 9 | ||
10 | iHistory * history_DocumentWidget (iDocumentWidget *); | ||
11 | |||
8 | void setUrl_DocumentWidget (iDocumentWidget *, const iString *url); | 12 | void setUrl_DocumentWidget (iDocumentWidget *, const iString *url); |
9 | void setUrlFromCache_DocumentWidget (iDocumentWidget *d, const iString *url, iBool isFromCache); | 13 | void setUrlFromCache_DocumentWidget (iDocumentWidget *d, const iString *url, iBool isFromCache); |
10 | void setInitialScroll_DocumentWidget (iDocumentWidget *, int scrollY); /* set after content received */ | 14 | void setInitialScroll_DocumentWidget (iDocumentWidget *, int scrollY); /* set after content received */ |
15 | |||
11 | iBool isRequestOngoing_DocumentWidget (const iDocumentWidget *); | 16 | iBool isRequestOngoing_DocumentWidget (const iDocumentWidget *); |
diff --git a/src/ui/window.c b/src/ui/window.c index 2661fd3f..defe998f 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include "paint.h" | 6 | #include "paint.h" |
7 | #include "text.h" | 7 | #include "text.h" |
8 | #include "util.h" | 8 | #include "util.h" |
9 | #include "../visited.h" | ||
9 | #include "labelwidget.h" | 10 | #include "labelwidget.h" |
10 | #include "inputwidget.h" | 11 | #include "inputwidget.h" |
11 | #include "documentwidget.h" | 12 | #include "documentwidget.h" |
@@ -108,7 +109,9 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | |||
108 | } | 109 | } |
109 | else if (equal_Command(cmd, "document.changed")) { | 110 | else if (equal_Command(cmd, "document.changed")) { |
110 | iInputWidget *url = findWidget_App("url"); | 111 | iInputWidget *url = findWidget_App("url"); |
111 | setTextCStr_InputWidget(url, suffixPtr_Command(cmd, "url")); | 112 | const iString *urlStr = collect_String(suffix_Command(cmd, "url")); |
113 | visitUrl_Visited(visited_App(), urlStr); | ||
114 | setText_InputWidget(url, urlStr); | ||
112 | updateTextCStr_LabelWidget(findChild_Widget(navBar, "reload"), reloadCStr_); | 115 | updateTextCStr_LabelWidget(findChild_Widget(navBar, "reload"), reloadCStr_); |
113 | return iFalse; | 116 | return iFalse; |
114 | } | 117 | } |