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; |