application/window.c

changeset 51
e324291ca9f8
parent 45
ab71409644b0
equal deleted inserted replaced
50:9c25e2616bfa 51:e324291ca9f8
105 105
106 void window_progress(MainWindow *win, int on) { 106 void window_progress(MainWindow *win, int on) {
107 ui_set(win->progress, on); 107 ui_set(win->progress, on);
108 } 108 }
109 109
110
111
112
113
114 void dav_resourceviewer_new(DavBrowser *browser, const char *path, DavResourceViewType type) {
115 const char *name = util_resource_name(path);
116 UiObject *win = ui_simple_window(name, NULL);
117
118 DavResourceViewer *doc = dav_resourceviewer_create(browser->sn, path, type);
119 ui_attach_document(win->ctx, doc);
120
121 ui_tabview(win, .tabview = UI_TABVIEW_INVISIBLE, .varname = "tabview") {
122 /* loading / message tab */
123 ui_tab(win, NULL) {
124 ui_hbox(win, .margin = 16, .spacing = 10, .fill = UI_OFF) {
125 ui_progressspinner(win, .varname = "loading");
126 ui_label(win, .varname = "message");
127 }
128 }
129
130 /* preview tab */
131 ui_tab(win, NULL) {
132 ui_tabview0(win) {
133 if(type == DAV_RESOURCE_VIEW_TEXT) {
134 ui_tab(win, "Content") {
135 ui_textarea(win, .varname = "text");
136 }
137 } else if(type == DAV_RESOURCE_VIEW_IMAGE) {
138 ui_tab(win, "Preview") {
139 ui_imageviewer(win, .varname = "image");
140 }
141 }
142
143 ui_tab(win, "Properties") {
144 UiModel* model = ui_model(win->ctx, UI_STRING, "Namespace", UI_STRING, "Name", UI_STRING, "Value", -1);
145 model->getvalue = (ui_getvaluefunc) resourceviewer_proplist_getvalue;
146 ui_table(win, .fill = UI_ON, .model = model, .varname = "properties");
147 }
148 }
149 }
150 }
151
152 dav_resourceviewer_load(win, doc);
153
154 ui_show(win);
155 }
156
157 void* resourceviewer_proplist_getvalue(DavPropertyList *property, int col) {
158 return NULL;
159 }
160
110 static UiPathElm* dav_get_pathelm(const char *full_path, size_t len, size_t *ret_nelm, void* data) { 161 static UiPathElm* dav_get_pathelm(const char *full_path, size_t len, size_t *ret_nelm, void* data) {
111 cxstring fpath = cx_strn(full_path, len); 162 cxstring fpath = cx_strn(full_path, len);
112 int protocol = 0; 163 int protocol = 0;
113 if (cx_strcaseprefix(fpath, CX_STR("http://"))) { 164 if (cx_strcaseprefix(fpath, CX_STR("http://"))) {
114 protocol = 7; 165 protocol = 7;
210 DavResource *res = ui_list_get(browser->resources, selection->rows[0]); 261 DavResource *res = ui_list_get(browser->resources, selection->rows[0]);
211 if (res) { 262 if (res) {
212 if (res->iscollection) { 263 if (res->iscollection) {
213 davbrowser_query_path(event->obj, browser, res->path); 264 davbrowser_query_path(event->obj, browser, res->path);
214 } else { 265 } else {
215 // TODO 266 davbrowser_open_resource(event->obj, browser, res);
216 } 267 }
217 } 268 }
218 } 269 }
219 } 270 }
220 271

mercurial