diff -r 9c25e2616bfa -r e324291ca9f8 application/window.c --- a/application/window.c Sun Oct 06 18:43:06 2024 +0200 +++ b/application/window.c Sun Oct 20 21:24:13 2024 +0200 @@ -107,6 +107,57 @@ ui_set(win->progress, on); } + + + + +void dav_resourceviewer_new(DavBrowser *browser, const char *path, DavResourceViewType type) { + const char *name = util_resource_name(path); + UiObject *win = ui_simple_window(name, NULL); + + DavResourceViewer *doc = dav_resourceviewer_create(browser->sn, path, type); + ui_attach_document(win->ctx, doc); + + ui_tabview(win, .tabview = UI_TABVIEW_INVISIBLE, .varname = "tabview") { + /* loading / message tab */ + ui_tab(win, NULL) { + ui_hbox(win, .margin = 16, .spacing = 10, .fill = UI_OFF) { + ui_progressspinner(win, .varname = "loading"); + ui_label(win, .varname = "message"); + } + } + + /* preview tab */ + ui_tab(win, NULL) { + ui_tabview0(win) { + if(type == DAV_RESOURCE_VIEW_TEXT) { + ui_tab(win, "Content") { + ui_textarea(win, .varname = "text"); + } + } else if(type == DAV_RESOURCE_VIEW_IMAGE) { + ui_tab(win, "Preview") { + ui_imageviewer(win, .varname = "image"); + } + } + + ui_tab(win, "Properties") { + UiModel* model = ui_model(win->ctx, UI_STRING, "Namespace", UI_STRING, "Name", UI_STRING, "Value", -1); + model->getvalue = (ui_getvaluefunc) resourceviewer_proplist_getvalue; + ui_table(win, .fill = UI_ON, .model = model, .varname = "properties"); + } + } + } + } + + dav_resourceviewer_load(win, doc); + + ui_show(win); +} + +void* resourceviewer_proplist_getvalue(DavPropertyList *property, int col) { + return NULL; +} + static UiPathElm* dav_get_pathelm(const char *full_path, size_t len, size_t *ret_nelm, void* data) { cxstring fpath = cx_strn(full_path, len); int protocol = 0; @@ -212,7 +263,7 @@ if (res->iscollection) { davbrowser_query_path(event->obj, browser, res->path); } else { - // TODO + davbrowser_open_resource(event->obj, browser, res); } } }