# HG changeset patch # User Olaf Wintermann # Date 1706602205 -3600 # Node ID 26acbfa75c1f239ae2dc03eb6b28225aee175b17 # Parent f8dfc57055169a1cb2b5e41df0f3bafaa56855db add handler for the path bar activate events diff -r f8dfc5705516 -r 26acbfa75c1f application/davcontroller.c --- 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: +} diff -r f8dfc5705516 -r 26acbfa75c1f application/davcontroller.h --- 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 diff -r f8dfc5705516 -r 26acbfa75c1f application/window.c --- 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); +} diff -r f8dfc5705516 -r 26acbfa75c1f application/window.h --- a/application/window.h Tue Jan 30 08:49:35 2024 +0100 +++ b/application/window.h Tue Jan 30 09:10:05 2024 +0100 @@ -54,6 +54,7 @@ void window_progress(MainWindow *win, int on); +void action_path_selected(UiEvent *event, void *data); #ifdef __cplusplus }