application/application.c

changeset 95
e92c72705da4
parent 94
7fdf1489b82f
child 96
493959648de6
equal deleted inserted replaced
94:7fdf1489b82f 95:e92c72705da4
111 ui_menuseparator(); 111 ui_menuseparator();
112 ui_menu("Repositories") { 112 ui_menu("Repositories") {
113 ui_menu_itemlist(.varname = "repolist", .getvalue = davrepo_getname, .onselect = action_repo_selected); 113 ui_menu_itemlist(.varname = "repolist", .getvalue = davrepo_getname, .onselect = action_repo_selected);
114 } 114 }
115 } 115 }
116
117 ui_menu("View") {
118 ui_menu_itemlist(.varname = "transferlist", .getvalue = transfers_getlabel, .onselect = action_transfer_selected);
119 }
116 120
117 // toolbar 121 // toolbar
118 ui_toolbar_item("Home", .icon = UI_ICON_HOME); 122 ui_toolbar_item("Home", .icon = UI_ICON_HOME);
119 ui_toolbar_item("NewWindow", .icon = UI_ICON_NEW_WINDOW, .onclick = action_window_new); 123 ui_toolbar_item("NewWindow", .icon = UI_ICON_NEW_WINDOW, .onclick = action_window_new);
120 ui_toolbar_item("Refresh", .icon = UI_ICON_REFRESH, .onclick = action_refresh, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); 124 ui_toolbar_item("Refresh", .icon = UI_ICON_REFRESH, .onclick = action_refresh, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
136 ui_menuitem("Upload Files", .onclick = action_upload_file, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); 140 ui_menuitem("Upload Files", .onclick = action_upload_file, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
137 ui_menuitem("Upload Directory", .onclick = action_upload_dir, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION)); 141 ui_menuitem("Upload Directory", .onclick = action_upload_dir, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION));
138 ui_menuitem("Open Properties", .onclick = action_open_properties, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); 142 ui_menuitem("Open Properties", .onclick = action_open_properties, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
139 ui_menuitem("Open as Text File", .onclick = action_open_properties, .onclickdata = "text/plain", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); 143 ui_menuitem("Open as Text File", .onclick = action_open_properties, .onclickdata = "text/plain", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION));
140 ui_menuseparator(); 144 ui_menuseparator();
145 ui_menu("Downloads/Uploads") {
146 ui_menu_itemlist(.varname = "transferlist", .getvalue = transfers_getlabel, .onselect = action_transfer_selected);
147 }
148 ui_menuseparator();
141 ui_menuitem("Preferences", .onclick = action_open_settings); 149 ui_menuitem("Preferences", .onclick = action_open_settings);
142 } 150 }
143 151
144 //ui_toolbar_add_default("Home", UI_TOOLBAR_LEFT); 152 //ui_toolbar_add_default("Home", UI_TOOLBAR_LEFT);
145 //ui_toolbar_add_default("NewWindow", UI_TOOLBAR_LEFT); 153 //ui_toolbar_add_default("NewWindow", UI_TOOLBAR_LEFT);
160 168
161 DavApp* application_create_app_document(void) { 169 DavApp* application_create_app_document(void) {
162 DavApp *doc = ui_document_new(sizeof(DavApp)); 170 DavApp *doc = ui_document_new(sizeof(DavApp));
163 UiContext *ctx = ui_document_context(doc); 171 UiContext *ctx = ui_document_context(doc);
164 doc->repos = ui_list_new(ctx, "repolist"); 172 doc->repos = ui_list_new(ctx, "repolist");
165 173 doc->transfers = ui_list_new(ctx, "transferlist");
174 CxList *transfers = doc->transfers->data;
175 transfers->collection.cmpfunc = cx_cmp_ptr;
176
166 // create repo list 177 // create repo list
167 application_update_repolist(doc); 178 application_update_repolist(doc);
168 179
169 return doc; 180 return doc;
170 } 181 }
182 } 193 }
183 194
184 195
185 DavContext* application_dav_context(void) { 196 DavContext* application_dav_context(void) {
186 return davctx; 197 return davctx;
198 }
199
200 void* transfers_getlabel(void *data, int col) {
201 DavTransfer *trans = data;
202 return trans->label;
203 }
204
205 void application_register_transfer(DavTransfer *trans) {
206 DavApp *app = get_application();
207 ui_list_append(app->transfers, trans);
208 application_update_transferlist();
209 }
210
211 void application_remove_transfer(DavTransfer *trans) {
212 DavApp *app = get_application();
213 CxList *transfers = app->transfers->data;
214 cxListFindRemove(transfers, trans);
215 application_update_transferlist();
216 }
217
218 /*
219 static int transfers_cmp(const DavTransfer *left, const DavTransfer *right) {
220 return cx_cmp_double(&right->progress, &left->progress);
221 }
222 */
223
224 void application_update_transferlist(void) {
225 DavApp *app = get_application();
226
227 /*
228 CxList *transfers = app->transfers->data;
229 transfers->collection.cmpfunc = (cx_compare_func)transfers_cmp;
230 cxListSort(transfers);
231 transfers->collection.cmpfunc = cx_cmp_ptr;
232 */
233
234 ui_list_update(app->transfers);
235 ui_list_notify(app->transfers);
187 } 236 }
188 237
189 238
190 void action_window_new(UiEvent *event, void *data) { 239 void action_window_new(UiEvent *event, void *data) {
191 UiObject *win = window_create(); 240 UiObject *win = window_create();
388 davbrowser_open_resource(event->obj, browser, res, type); 437 davbrowser_open_resource(event->obj, browser, res, type);
389 } 438 }
390 } 439 }
391 ui_listselection_free(sel); 440 ui_listselection_free(sel);
392 } 441 }
442
443 void action_transfer_selected(UiEvent *event, void *data) {
444
445 }

mercurial