diff -r 7fdf1489b82f -r e92c72705da4 application/application.c --- a/application/application.c Wed Nov 27 17:14:57 2024 +0100 +++ b/application/application.c Wed Nov 27 18:45:08 2024 +0100 @@ -113,6 +113,10 @@ ui_menu_itemlist(.varname = "repolist", .getvalue = davrepo_getname, .onselect = action_repo_selected); } } + + ui_menu("View") { + ui_menu_itemlist(.varname = "transferlist", .getvalue = transfers_getlabel, .onselect = action_transfer_selected); + } // toolbar ui_toolbar_item("Home", .icon = UI_ICON_HOME); @@ -138,6 +142,10 @@ ui_menuitem("Open Properties", .onclick = action_open_properties, .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); ui_menuitem("Open as Text File", .onclick = action_open_properties, .onclickdata = "text/plain", .groups = UI_GROUPS(APP_STATE_BROWSER_SESSION, APP_STATE_BROWSER_SELECTION)); ui_menuseparator(); + ui_menu("Downloads/Uploads") { + ui_menu_itemlist(.varname = "transferlist", .getvalue = transfers_getlabel, .onselect = action_transfer_selected); + } + ui_menuseparator(); ui_menuitem("Preferences", .onclick = action_open_settings); } @@ -162,7 +170,10 @@ DavApp *doc = ui_document_new(sizeof(DavApp)); UiContext *ctx = ui_document_context(doc); doc->repos = ui_list_new(ctx, "repolist"); - + doc->transfers = ui_list_new(ctx, "transferlist"); + CxList *transfers = doc->transfers->data; + transfers->collection.cmpfunc = cx_cmp_ptr; + // create repo list application_update_repolist(doc); @@ -186,6 +197,44 @@ return davctx; } +void* transfers_getlabel(void *data, int col) { + DavTransfer *trans = data; + return trans->label; +} + +void application_register_transfer(DavTransfer *trans) { + DavApp *app = get_application(); + ui_list_append(app->transfers, trans); + application_update_transferlist(); +} + +void application_remove_transfer(DavTransfer *trans) { + DavApp *app = get_application(); + CxList *transfers = app->transfers->data; + cxListFindRemove(transfers, trans); + application_update_transferlist(); +} + +/* +static int transfers_cmp(const DavTransfer *left, const DavTransfer *right) { + return cx_cmp_double(&right->progress, &left->progress); +} +*/ + +void application_update_transferlist(void) { + DavApp *app = get_application(); + + /* + CxList *transfers = app->transfers->data; + transfers->collection.cmpfunc = (cx_compare_func)transfers_cmp; + cxListSort(transfers); + transfers->collection.cmpfunc = cx_cmp_ptr; + */ + + ui_list_update(app->transfers); + ui_list_notify(app->transfers); +} + void action_window_new(UiEvent *event, void *data) { UiObject *win = window_create(); @@ -390,3 +439,7 @@ } ui_listselection_free(sel); } + +void action_transfer_selected(UiEvent *event, void *data) { + +}