Wed, 31 Jan 2024 12:55:11 +0100
add refresh button
--- a/application/application.c Tue Jan 30 16:58:03 2024 +0100 +++ b/application/application.c Wed Jan 31 12:55:11 2024 +0100 @@ -80,10 +80,10 @@ // toolbar ui_toolbar_item("Home", .icon = "Home"); ui_toolbar_item("NewWindow", .icon = "NewWindow", .onclick = action_window_new); + ui_toolbar_item("Refresh", .icon = "Refresh", .onclick = action_refresh); ui_toolbar_menu("Repo", .label = "Repository") { ui_menu_itemlist(.varname = "repolist", .getvalue = davrepo_getname, .onselect = action_repo_selected); } - ui_toolbar_item("Refresh", .icon = "Refresh"); ui_toolbar_item("NewFolder", .icon = "NewFolder"); ui_toolbar_item("NewFile", .icon = "Add"); ui_toolbar_item("Upload", .label = "Upload", .icon = "Upload"); @@ -99,6 +99,7 @@ ui_toolbar_add_default("Home", UI_TOOLBAR_LEFT); ui_toolbar_add_default("NewWindow", UI_TOOLBAR_LEFT); + ui_toolbar_add_default("Refresh", UI_TOOLBAR_LEFT); ui_toolbar_add_default("Repo", UI_TOOLBAR_LEFT); ui_toolbar_add_default("NewFolder", UI_TOOLBAR_CENTER); @@ -150,6 +151,13 @@ ui_show(win); } +void action_refresh(UiEvent *event, void *data) { + DavBrowser *browser = event->document; + if (browser->current) { + davbrowser_query_path(event->obj, browser, browser->current->path); + } +} + void action_repo_selected(UiEvent *event, void *data) { DavCfgRepository *repo = event->eventdata; DavBrowser *browser = event->document;
--- a/application/application.h Tue Jan 30 16:58:03 2024 +0100 +++ b/application/application.h Wed Jan 31 12:55:11 2024 +0100 @@ -96,6 +96,7 @@ DavContext* application_dav_context(void); +void action_refresh(UiEvent *event, void *data); void action_window_new(UiEvent *event, void *data);
--- a/application/davcontroller.c Tue Jan 30 16:58:03 2024 +0100 +++ b/application/davcontroller.c Wed Jan 31 12:55:11 2024 +0100 @@ -135,6 +135,11 @@ } void davbrowser_query_path(UiObject *ui, DavBrowser *browser, const char *path) { + if (!browser->sn) { + // TODO: error + return; + } + // for comparison, we need the current base_url/repo_name + path size_t len = path ? strlen(path) : 0; if (len == 1 && *path == '/') {
--- a/application/window.c Tue Jan 30 16:58:03 2024 +0100 +++ b/application/window.c Wed Jan 31 12:55:11 2024 +0100 @@ -195,7 +195,9 @@ void action_path_selected(UiEvent *event, void *data) { DavBrowser *browser = event->document; char *path = event->eventdata; - davbrowser_query_url(event->obj, browser, path); + if (path && strlen(path) > 0) { + davbrowser_query_url(event->obj, browser, path); + } } void action_list_activate(UiEvent *event, void *data) {