summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ui/documentwidget.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/ui/documentwidget.c b/src/ui/documentwidget.c
index 271ad274..079f08f4 100644
--- a/src/ui/documentwidget.c
+++ b/src/ui/documentwidget.c
@@ -30,6 +30,7 @@ struct Impl_DocumentWidget {
30 iWidget widget; 30 iWidget widget;
31 enum iDocumentState state; 31 enum iDocumentState state;
32 iString *url; 32 iString *url;
33 iString *titleUser;
33 iGmRequest *request; 34 iGmRequest *request;
34 iAtomicInt isSourcePending; /* request has new content, need to parse it */ 35 iAtomicInt isSourcePending; /* request has new content, need to parse it */
35 iGmDocument *doc; 36 iGmDocument *doc;
@@ -56,6 +57,7 @@ void init_DocumentWidget(iDocumentWidget *d) {
56 setId_Widget(w, "document"); 57 setId_Widget(w, "document");
57 d->state = blank_DocumentState; 58 d->state = blank_DocumentState;
58 d->url = new_String(); 59 d->url = new_String();
60 d->titleUser = new_String();
59 d->request = NULL; 61 d->request = NULL;
60 d->isSourcePending = iFalse; 62 d->isSourcePending = iFalse;
61 d->doc = new_GmDocument(); 63 d->doc = new_GmDocument();
@@ -85,6 +87,7 @@ void init_DocumentWidget(iDocumentWidget *d) {
85void deinit_DocumentWidget(iDocumentWidget *d) { 87void deinit_DocumentWidget(iDocumentWidget *d) {
86 deinit_PtrArray(&d->visibleLinks); 88 deinit_PtrArray(&d->visibleLinks);
87 delete_String(d->url); 89 delete_String(d->url);
90 delete_String(d->titleUser);
88 iRelease(d->request); 91 iRelease(d->request);
89 iRelease(d->doc); 92 iRelease(d->doc);
90 SDL_FreeCursor(d->arrowCursor); 93 SDL_FreeCursor(d->arrowCursor);
@@ -163,9 +166,16 @@ static void updateVisible_DocumentWidget_(iDocumentWidget *d) {
163} 166}
164 167
165static void updateWindowTitle_DocumentWidget_(const iDocumentWidget *d) { 168static void updateWindowTitle_DocumentWidget_(const iDocumentWidget *d) {
166 setTitle_Window(get_Window(), 169 const char *titleSep = " \u2013 ";
167 !isEmpty_String(title_GmDocument(d->doc)) ? title_GmDocument(d->doc) 170 iString *title = collect_String(copy_String(title_GmDocument(d->doc)));
168 : collectNewCStr_String("Lagrange")); 171 if (!isEmpty_String(d->titleUser)) {
172 if (!isEmpty_String(title)) appendCStr_String(title, titleSep);
173 append_String(title, d->titleUser);
174 }
175 if (isEmpty_String(title)) {
176 setCStr_String(title, "Lagrange");
177 }
178 setTitle_Window(get_Window(), title);
169} 179}
170 180
171static void setSource_DocumentWidget_(iDocumentWidget *d, const iString *source) { 181static void setSource_DocumentWidget_(iDocumentWidget *d, const iString *source) {
@@ -217,6 +227,12 @@ void setUrl_DocumentWidget(iDocumentWidget *d, const iString *url) {
217 set_String(d->url, newUrl); 227 set_String(d->url, newUrl);
218 fetch_DocumentWidget_(d); 228 fetch_DocumentWidget_(d);
219 } 229 }
230 iRegExp *userPat = new_RegExp("~([^/?]+)", 0);
231 iRegExpMatch m;
232 if (matchString_RegExp(userPat, d->url, &m)) {
233 setRange_String(d->titleUser, capturedRange_RegExpMatch(&m, 1));
234 }
235 iRelease(userPat);
220 delete_String(newUrl); 236 delete_String(newUrl);
221} 237}
222 238