26 * POSSIBILITY OF SUCH DAMAGE. |
26 * POSSIBILITY OF SUCH DAMAGE. |
27 */ |
27 */ |
28 |
28 |
29 #include "window.h" |
29 #include "window.h" |
30 |
30 |
|
31 #include "davcontroller.h" |
|
32 |
31 #include <ui/stock.h> |
33 #include <ui/stock.h> |
32 |
34 |
|
35 static UiIcon* folder_icon; |
|
36 static UiIcon* file_icon; |
|
37 |
|
38 void window_init(void) { |
|
39 folder_icon = ui_foldericon(16); |
|
40 file_icon = ui_fileicon(16); |
|
41 } |
33 |
42 |
34 UiObject* window_create(void) { |
43 UiObject* window_create(void) { |
35 UiObject* obj = ui_window("iDAV", NULL); |
44 UiObject* obj = ui_window("iDAV", NULL); |
36 |
45 |
37 MainWindow* wdata = ui_malloc(obj->ctx, sizeof(MainWindow)); |
46 MainWindow* wdata = ui_malloc(obj->ctx, sizeof(MainWindow)); |
38 memset(wdata, 0, sizeof(MainWindow)); |
47 memset(wdata, 0, sizeof(MainWindow)); |
39 obj->window = wdata; |
48 obj->window = wdata; |
40 |
49 |
41 wdata->dav_queue = ui_threadpool_create(1); |
50 wdata->progress = ui_int_new(obj->ctx, "progress"); |
42 |
51 |
43 // navigation bar |
52 // navigation bar |
44 ui_hbox(obj, .fill = UI_OFF, .margin = 8) { |
53 ui_hbox(obj, .fill = UI_OFF, .margin = 8) { |
45 ui_button(obj, .icon = "Back"); |
54 ui_button(obj, .icon = "Back"); |
46 ui_button(obj, .icon = "Forward"); |
55 ui_button(obj, .icon = "Forward"); |
47 |
56 |
48 ui_path_textfield(obj, .fill = UI_ON); |
57 ui_path_textfield(obj, .fill = UI_ON, .varname = "path"); |
|
58 |
|
59 ui_progressspinner(obj, .value = wdata->progress); |
49 } |
60 } |
50 |
61 |
51 // main content |
62 // main content |
52 UiModel* model = ui_model(obj->ctx, UI_ICON_TEXT, "Name", UI_STRING, "Type", UI_STRING, "Last Modified", UI_STRING, "Size", -1); |
63 UiModel* model = ui_model(obj->ctx, UI_ICON_TEXT, "Name", UI_STRING, "Type", UI_STRING, "Last Modified", UI_STRING, "Size", -1); |
53 ui_table(obj, .fill = UI_ON, .model = model); |
64 model->getvalue = (ui_getvaluefunc)window_resource_table_getvalue; |
|
65 ui_table(obj, .fill = UI_ON, .model = model, .varname = "reslist"); |
54 |
66 |
55 // status bar |
67 // status bar |
56 ui_hbox(obj, .fill = UI_OFF) { |
68 ui_hbox(obj, .fill = UI_OFF) { |
57 ui_label(obj, .label = ""); |
69 ui_label(obj, .label = ""); |
58 } |
70 } |
59 |
71 |
60 ui_model_free(obj->ctx, model); |
72 ui_model_free(obj->ctx, model); |
61 |
73 |
62 return obj; |
74 return obj; |
63 } |
75 } |
|
76 |
|
77 void* window_resource_table_getvalue(DavResource *res, int col) { |
|
78 switch (col) { |
|
79 case 0: { // icon |
|
80 return res->iscollection ? folder_icon : file_icon; |
|
81 } |
|
82 case 1: { // resource name |
|
83 return res->name; |
|
84 } |
|
85 case 2: { // type |
|
86 return ""; // TODO |
|
87 } |
|
88 case 3: { // last modified |
|
89 return ""; // TODO |
|
90 } |
|
91 case 4: { // size |
|
92 return ""; // TODO |
|
93 } |
|
94 } |
|
95 return NULL; |
|
96 } |
|
97 |
|
98 void window_progress(MainWindow *win, int on) { |
|
99 ui_set(win->progress, on); |
|
100 } |