Tue, 30 Jan 2024 09:10:05 +0100
add handler for the path bar activate events
--- a/application/davcontroller.c Tue Jan 30 08:49:35 2024 +0100 +++ b/application/davcontroller.c Tue Jan 30 09:10:05 2024 +0100 @@ -78,6 +78,7 @@ // ------------------------------ davbrowser_query_path ------------------------------ typedef struct DavBrowserQueryPath { + UiThreadpool *pool; DavBrowser *browser; char *path; DavResource *result; @@ -97,16 +98,23 @@ DavBrowserQueryPath *query = data; DavBrowser *browser = event->document; - if (query->result) { - davbrowser_set_collection(event->obj, browser, query->result); + if (query->pool == browser->dav_queue) { + if (query->result) { + davbrowser_set_collection(event->obj, browser, query->result); + } else { + // TODO: error + } + + window_progress(event->window, 0); } else { - // TODO: error + // operation aborted + if (query->result) { + dav_resource_free_all(query->result); + } } free(query->path); free(query); - - window_progress(event->window, 0); } void davbrowser_query_path(UiObject *ui, DavBrowser *browser, const char *path) { @@ -125,6 +133,7 @@ free(full_path); DavBrowserQueryPath *query = malloc(sizeof(DavBrowserQueryPath)); + query->pool = browser->dav_queue; query->browser = browser; query->path = strdup(path); query->result = NULL; @@ -132,3 +141,18 @@ window_progress(ui->window, 1); } + +void davbrowser_query_url(UiObject *ui, DavBrowser *browser, const char *url) { + if (browser->repo_base) { + cxstring base = cx_str(browser->repo_base); + cxstring newurl = cx_str(url); + + if (cx_strprefix(newurl, base)) { + const char *path = url + base.length; + davbrowser_query_path(ui, browser, path); + return; + } + } + + // TODO: +}
--- a/application/davcontroller.h Tue Jan 30 08:49:35 2024 +0100 +++ b/application/davcontroller.h Tue Jan 30 09:10:05 2024 +0100 @@ -47,7 +47,7 @@ void davbrowser_query_path(UiObject *ui, DavBrowser *browser, const char *path); - +void davbrowser_query_url(UiObject *ui, DavBrowser *browser, const char *url); #ifdef __cplusplus
--- a/application/window.c Tue Jan 30 08:49:35 2024 +0100 +++ b/application/window.c Tue Jan 30 09:10:05 2024 +0100 @@ -56,7 +56,7 @@ ui_button(obj, .icon = "Back"); ui_button(obj, .icon = "Forward"); - ui_path_textfield(obj, .fill = UI_ON, .getpathelm = dav_get_pathelm, .varname = "path"); + ui_path_textfield(obj, .fill = UI_ON, .getpathelm = dav_get_pathelm, .onactivate = action_path_selected ,.varname = "path"); ui_progressspinner(obj, .value = wdata->progress); } @@ -177,3 +177,11 @@ return elms; } + + + +void action_path_selected(UiEvent *event, void *data) { + DavBrowser *browser = event->document; + char *path = event->eventdata; + davbrowser_query_url(event->obj, browser, path); +}