40 static UiIcon* folder_icon; |
40 static UiIcon* folder_icon; |
41 static UiIcon* file_icon; |
41 static UiIcon* file_icon; |
42 |
42 |
43 static UiPathElm* dav_get_pathelm(const char *full_path, size_t len, size_t *ret_nelm, void* data); |
43 static UiPathElm* dav_get_pathelm(const char *full_path, size_t len, size_t *ret_nelm, void* data); |
44 |
44 |
|
45 static UiMenuBuilder *contextmenu; |
|
46 |
45 void window_init(void) { |
47 void window_init(void) { |
46 folder_icon = ui_foldericon(16); |
48 folder_icon = ui_foldericon(16); |
47 file_icon = ui_fileicon(16); |
49 file_icon = ui_fileicon(16); |
|
50 |
|
51 // initialize the browser context menu |
|
52 ui_contextmenu(&contextmenu) { |
|
53 ui_menuitem(.label = "New Folder", .onclick = action_mkcol, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); |
|
54 ui_menuitem(.label = "New File", .onclick = action_newfile, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); |
|
55 ui_menuseparator(); |
|
56 //ui_menuitem(.label = "Cut", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
|
57 //ui_menuitem(.label = "Copy", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
|
58 //ui_menuitem(.label = "Paste", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
|
59 ui_menuitem(.label = "Download", .onclick = action_download, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
|
60 ui_menuitem(.label = "Delete", .onclick = action_delete, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); |
|
61 ui_menuitem(.label = "Select All", .onclick = action_selectall, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); |
|
62 ui_menuseparator(); |
|
63 ui_menuitem(.label = "Rename", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
|
64 ui_menuseparator(); |
|
65 ui_menuitem("Open Properties", .onclick = action_open_properties, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
|
66 ui_menuitem("Open as Text File", .onclick = action_open_properties, .onclickdata = "text/plain", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); |
|
67 } |
48 } |
68 } |
49 |
69 |
50 UiObject* window_create(void) { |
70 UiObject* window_create(void) { |
51 UiObject* obj = ui_window("iDAV", NULL); |
71 UiObject* obj = ui_window("iDAV", NULL); |
52 ui_window_size(obj, 900, 700); |
72 ui_window_size(obj, 900, 700); |
73 // main content |
93 // main content |
74 UiModel* model = ui_model(obj->ctx, UI_ICON_TEXT, "Name", UI_STRING, "Type", UI_STRING_FREE, "Last Modified", UI_STRING_FREE, "Size", -1); |
94 UiModel* model = ui_model(obj->ctx, UI_ICON_TEXT, "Name", UI_STRING, "Type", UI_STRING_FREE, "Last Modified", UI_STRING_FREE, "Size", -1); |
75 model->columnsize[0] = -1; |
95 model->columnsize[0] = -1; |
76 model->columnsize[1] = 150; |
96 model->columnsize[1] = 150; |
77 model->getvalue = (ui_getvaluefunc) window_resource_table_getvalue; |
97 model->getvalue = (ui_getvaluefunc) window_resource_table_getvalue; |
78 ui_table(obj, .fill = UI_ON, .model = model, .onselection = action_list_selection, .onactivate = action_list_activate, .ondrop = action_dnd_drop, .varname = "reslist", .multiselection = TRUE); |
98 ui_table(obj, |
|
99 .fill = UI_ON, |
|
100 .model = model, |
|
101 .onselection = action_list_selection, |
|
102 .onactivate = action_list_activate, |
|
103 .ondrop = action_dnd_drop, |
|
104 .varname = "reslist", |
|
105 .multiselection = TRUE, |
|
106 .contextmenu = contextmenu); |
79 |
107 |
80 // status bar |
108 // status bar |
81 |
109 |
82 ui_hbox(obj, .fill = UI_OFF) { |
110 ui_hbox(obj, .fill = UI_OFF) { |
83 ui_label(obj, .label = ""); |
111 ui_label(obj, .label = ""); |