diff options
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/documentwidget.c | 17 | ||||
-rw-r--r-- | src/ui/documentwidget.h | 3 | ||||
-rw-r--r-- | src/ui/labelwidget.c | 2 | ||||
-rw-r--r-- | src/ui/window.c | 26 |
4 files changed, 46 insertions, 2 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c index 4cd0ac18..030a323b 100644 --- a/src/ui/documentwidget.c +++ b/src/ui/documentwidget.c | |||
@@ -148,6 +148,7 @@ static void fetch_DocumentWidget_(iDocumentWidget *d) { | |||
148 | iRelease(d->request); | 148 | iRelease(d->request); |
149 | d->request = NULL; | 149 | d->request = NULL; |
150 | } | 150 | } |
151 | postCommand_Widget(as_Widget(d), "document.request.started"); | ||
151 | d->state = fetching_DocumentState; | 152 | d->state = fetching_DocumentState; |
152 | set_Atomic(&d->isSourcePending, iFalse); | 153 | set_Atomic(&d->isSourcePending, iFalse); |
153 | d->request = new_GmRequest(); | 154 | d->request = new_GmRequest(); |
@@ -171,6 +172,10 @@ void setUrl_DocumentWidget(iDocumentWidget *d, const iString *url) { | |||
171 | delete_String(newUrl); | 172 | delete_String(newUrl); |
172 | } | 173 | } |
173 | 174 | ||
175 | iBool isRequestOngoing_DocumentWidget(const iDocumentWidget *d) { | ||
176 | return d->state == fetching_DocumentState || d->state == receivedPartialResponse_DocumentState; | ||
177 | } | ||
178 | |||
174 | static void scroll_DocumentWidget_(iDocumentWidget *d, int offset) { | 179 | static void scroll_DocumentWidget_(iDocumentWidget *d, int offset) { |
175 | d->scrollY += offset; | 180 | d->scrollY += offset; |
176 | if (d->scrollY < 0) { | 181 | if (d->scrollY < 0) { |
@@ -278,6 +283,18 @@ static iBool processEvent_DocumentWidget_(iDocumentWidget *d, const SDL_Event *e | |||
278 | postCommandf_App("document.changed url:%s", cstr_String(d->url)); | 283 | postCommandf_App("document.changed url:%s", cstr_String(d->url)); |
279 | return iTrue; | 284 | return iTrue; |
280 | } | 285 | } |
286 | else if (isCommand_UserEvent(ev, "document.stop")) { | ||
287 | if (d->request) { | ||
288 | postCommandf_App("document.request.cancelled url:%s", cstr_String(d->url)); | ||
289 | iReleasePtr(&d->request); | ||
290 | d->state = ready_DocumentState; | ||
291 | } | ||
292 | return iTrue; | ||
293 | } | ||
294 | else if (isCommand_UserEvent(ev, "document.reload")) { | ||
295 | fetch_DocumentWidget_(d); | ||
296 | return iTrue; | ||
297 | } | ||
281 | else if (isCommand_Widget(w, ev, "scroll.moved")) { | 298 | else if (isCommand_Widget(w, ev, "scroll.moved")) { |
282 | d->scrollY = arg_Command(command_UserEvent(ev)); | 299 | d->scrollY = arg_Command(command_UserEvent(ev)); |
283 | updateVisible_DocumentWidget_(d); | 300 | updateVisible_DocumentWidget_(d); |
diff --git a/src/ui/documentwidget.h b/src/ui/documentwidget.h index 02b75e69..dfd342af 100644 --- a/src/ui/documentwidget.h +++ b/src/ui/documentwidget.h | |||
@@ -5,4 +5,5 @@ | |||
5 | iDeclareWidgetClass(DocumentWidget) | 5 | iDeclareWidgetClass(DocumentWidget) |
6 | iDeclareObjectConstruction(DocumentWidget) | 6 | iDeclareObjectConstruction(DocumentWidget) |
7 | 7 | ||
8 | void setUrl_DocumentWidget (iDocumentWidget *d, const iString *url); | 8 | void setUrl_DocumentWidget (iDocumentWidget *, const iString *url); |
9 | iBool isRequestOngoing_DocumentWidget (const iDocumentWidget *); | ||
diff --git a/src/ui/labelwidget.c b/src/ui/labelwidget.c index 341c2f0e..f24e2573 100644 --- a/src/ui/labelwidget.c +++ b/src/ui/labelwidget.c | |||
@@ -264,10 +264,12 @@ void setText_LabelWidget(iLabelWidget *d, const iString *text) { | |||
264 | 264 | ||
265 | void updateText_LabelWidget(iLabelWidget *d, const iString *text) { | 265 | void updateText_LabelWidget(iLabelWidget *d, const iString *text) { |
266 | set_String(&d->label, text); | 266 | set_String(&d->label, text); |
267 | refresh_Widget(&d->widget); | ||
267 | } | 268 | } |
268 | 269 | ||
269 | void updateTextCStr_LabelWidget(iLabelWidget *d, const char *text) { | 270 | void updateTextCStr_LabelWidget(iLabelWidget *d, const char *text) { |
270 | setCStr_String(&d->label, text); | 271 | setCStr_String(&d->label, text); |
272 | refresh_Widget(&d->widget); | ||
271 | } | 273 | } |
272 | 274 | ||
273 | void setTextCStr_LabelWidget(iLabelWidget *d, const char *text) { | 275 | void setTextCStr_LabelWidget(iLabelWidget *d, const char *text) { |
diff --git a/src/ui/window.c b/src/ui/window.c index 8236b9e6..6196a638 100644 --- a/src/ui/window.c +++ b/src/ui/window.c | |||
@@ -74,6 +74,9 @@ static const iMenuItem editMenuItems[] = { | |||
74 | static const iMenuItem viewMenuItems[] = { | 74 | static const iMenuItem viewMenuItems[] = { |
75 | }; | 75 | }; |
76 | 76 | ||
77 | static const char *reloadCStr_ = "\u25cb"; | ||
78 | static const char *stopCStr_ = orange_ColorEscape "\u00d7"; | ||
79 | |||
77 | static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | 80 | static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { |
78 | if (equal_Command(cmd, "input.ended")) { | 81 | if (equal_Command(cmd, "input.ended")) { |
79 | iInputWidget *url = findChild_Widget(navBar, "url"); | 82 | iInputWidget *url = findChild_Widget(navBar, "url"); |
@@ -88,8 +91,27 @@ static iBool handleNavBarCommands_(iWidget *navBar, const char *cmd) { | |||
88 | iInputWidget *url = findWidget_App("url"); | 91 | iInputWidget *url = findWidget_App("url"); |
89 | setTextCStr_InputWidget(url, valuePtr_Command(cmd, "url")); | 92 | setTextCStr_InputWidget(url, valuePtr_Command(cmd, "url")); |
90 | setTitle_Window(get_Window(), text_InputWidget(url)); | 93 | setTitle_Window(get_Window(), text_InputWidget(url)); |
94 | updateTextCStr_LabelWidget(findChild_Widget(navBar, "reload"), reloadCStr_); | ||
95 | return iFalse; | ||
96 | } | ||
97 | else if (equal_Command(cmd, "document.request.cancelled")) { | ||
98 | updateTextCStr_LabelWidget(findChild_Widget(navBar, "reload"), reloadCStr_); | ||
91 | return iFalse; | 99 | return iFalse; |
92 | } | 100 | } |
101 | else if (equal_Command(cmd, "document.request.started")) { | ||
102 | updateTextCStr_LabelWidget(findChild_Widget(navBar, "reload"), stopCStr_); | ||
103 | return iFalse; | ||
104 | } | ||
105 | else if (equal_Command(cmd, "navigate.reload")) { | ||
106 | iDocumentWidget *doc = findWidget_App("document"); | ||
107 | if (isRequestOngoing_DocumentWidget(doc)) { | ||
108 | postCommand_App("document.stop"); | ||
109 | } | ||
110 | else { | ||
111 | postCommand_App("document.reload"); | ||
112 | } | ||
113 | return iTrue; | ||
114 | } | ||
93 | return iFalse; | 115 | return iFalse; |
94 | } | 116 | } |
95 | 117 | ||
@@ -120,7 +142,9 @@ static void setupUserInterface_Window(iWindow *d) { | |||
120 | setId_Widget(as_Widget(url), "url"); | 142 | setId_Widget(as_Widget(url), "url"); |
121 | setTextCStr_InputWidget(url, "gemini://"); | 143 | setTextCStr_InputWidget(url, "gemini://"); |
122 | addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag); | 144 | addChildFlags_Widget(navBar, iClob(url), expand_WidgetFlag); |
123 | addChild_Widget(navBar, iClob(new_LabelWidget("x", 0, 0, "navigate.reload"))); | 145 | setId_Widget( |
146 | addChild_Widget(navBar, iClob(new_LabelWidget(reloadCStr_, 0, 0, "navigate.reload"))), | ||
147 | "reload"); | ||
124 | } | 148 | } |
125 | 149 | ||
126 | addChildFlags_Widget(div, iClob(new_DocumentWidget()), expand_WidgetFlag); | 150 | addChildFlags_Widget(div, iClob(new_DocumentWidget()), expand_WidgetFlag); |