application/window.c

changeset 13
5a8762fcfecc
parent 11
26acbfa75c1f
child 15
78684a24dc52
equal deleted inserted replaced
12:3eb0cbab53db 13:5a8762fcfecc
30 30
31 #include "davcontroller.h" 31 #include "davcontroller.h"
32 32
33 #include <ui/stock.h> 33 #include <ui/stock.h>
34 34
35 #include <libidav/utils.h>
36
35 static UiIcon* folder_icon; 37 static UiIcon* folder_icon;
36 static UiIcon* file_icon; 38 static UiIcon* file_icon;
37 39
38 static UiPathElm* dav_get_pathelm(const char *full_path, size_t len, size_t *ret_nelm, void* data); 40 static UiPathElm* dav_get_pathelm(const char *full_path, size_t len, size_t *ret_nelm, void* data);
39 41
42 file_icon = ui_fileicon(16); 44 file_icon = ui_fileicon(16);
43 } 45 }
44 46
45 UiObject* window_create(void) { 47 UiObject* window_create(void) {
46 UiObject* obj = ui_window("iDAV", NULL); 48 UiObject* obj = ui_window("iDAV", NULL);
49 ui_window_size(obj, 900, 700);
47 50
48 MainWindow* wdata = ui_malloc(obj->ctx, sizeof(MainWindow)); 51 MainWindow* wdata = ui_malloc(obj->ctx, sizeof(MainWindow));
49 memset(wdata, 0, sizeof(MainWindow)); 52 memset(wdata, 0, sizeof(MainWindow));
50 obj->window = wdata; 53 obj->window = wdata;
51 54
60 63
61 ui_progressspinner(obj, .value = wdata->progress); 64 ui_progressspinner(obj, .value = wdata->progress);
62 } 65 }
63 66
64 // main content 67 // main content
65 UiModel* model = ui_model(obj->ctx, UI_ICON_TEXT, "Name", UI_STRING, "Type", UI_STRING, "Last Modified", UI_STRING, "Size", -1); 68 UiModel* model = ui_model(obj->ctx, UI_ICON_TEXT, "Name", UI_STRING, "Type", UI_STRING_FREE, "Last Modified", UI_STRING_FREE, "Size", -1);
66 model->getvalue = (ui_getvaluefunc)window_resource_table_getvalue; 69 model->getvalue = (ui_getvaluefunc)window_resource_table_getvalue;
67 ui_table(obj, .fill = UI_ON, .model = model, .varname = "reslist"); 70 ui_table(obj, .fill = UI_ON, .model = model, .onactivate = action_list_activate, .varname = "reslist");
68 71
69 // status bar 72 // status bar
70 ui_hbox(obj, .fill = UI_OFF) { 73 ui_hbox(obj, .fill = UI_OFF) {
71 ui_label(obj, .label = ""); 74 ui_label(obj, .label = "");
72 } 75 }
83 } 86 }
84 case 1: { // resource name 87 case 1: { // resource name
85 return res->name; 88 return res->name;
86 } 89 }
87 case 2: { // type 90 case 2: { // type
88 return ""; // TODO 91 return res->iscollection ? "Collection" : (res->contenttype ? res->contenttype : "Resource");
89 } 92 }
90 case 3: { // last modified 93 case 3: { // last modified
91 return ""; // TODO 94 return util_date_str(res->lastmodified);
92 } 95 }
93 case 4: { // size 96 case 4: { // size
94 return ""; // TODO 97 return util_size_str(res->iscollection, res->contentlength);
95 } 98 }
96 } 99 }
97 return NULL; 100 return NULL;
98 } 101 }
99 102
183 void action_path_selected(UiEvent *event, void *data) { 186 void action_path_selected(UiEvent *event, void *data) {
184 DavBrowser *browser = event->document; 187 DavBrowser *browser = event->document;
185 char *path = event->eventdata; 188 char *path = event->eventdata;
186 davbrowser_query_url(event->obj, browser, path); 189 davbrowser_query_url(event->obj, browser, path);
187 } 190 }
191
192 void action_list_activate(UiEvent *event, void *data) {
193 UiListSelection *selection = event->eventdata;
194 DavBrowser *browser = event->document;
195
196 if (selection->count == 1) {
197 DavResource *res = ui_list_get(browser->resources, selection->rows[0]);
198 if (res) {
199 if (res->iscollection) {
200 davbrowser_query_path(event->obj, browser, res->path);
201 } else {
202 // TODO
203 }
204 }
205 }
206 }

mercurial