diff -r 09ac07345656 -r 905ac52c910f application/application.c --- a/application/application.c Mon Jan 29 10:41:00 2024 +0100 +++ b/application/application.c Mon Jan 29 12:09:24 2024 +0100 @@ -51,10 +51,10 @@ exit(-1); } - UiObject* win = window_create(); + UiObject *win = window_create(); - DavApp* app = application_create_app_document(); - UiContext* global = ui_global_context(); + DavApp *app = application_create_app_document(); + UiContext *global = ui_global_context(); ui_attach_document(global, app); ui_show(win); @@ -68,7 +68,7 @@ ui_toolbar_item("Home", .icon = "Home"); ui_toolbar_item("NewWindow", .icon = "NewWindow"); ui_toolbar_menu("Repo", .label = "Repository") { - ui_menu_itemlist(.varname = "repolist"); + ui_menu_itemlist(.varname = "repolist", .onselect = action_repo_selected); } ui_toolbar_item("Refresh", .icon = "Refresh"); ui_toolbar_item("NewFolder", .icon = "NewFolder"); @@ -76,8 +76,8 @@ ui_toolbar_item("Upload", .label = "Upload", .icon = "Upload"); ui_toolbar_item("Download", .icon = "SaveLocal"); ui_toolbar_item("Remove", .icon = "Delete"); - ui_toolbar_item("LocalBrowser", .icon = "DockLeft", .label = "Local Browser"); - ui_toolbar_item("PreviewPane", .icon = "DockRight"); + ui_toolbar_toggleitem("LocalBrowser", .icon = "DockLeft", .label = "Local Browser"); + ui_toolbar_toggleitem("PreviewPane", .icon = "DockRight"); ui_toolbar_appmenu() { ui_menuitem("TODO", NULL); @@ -101,8 +101,8 @@ DavApp* application_create_app_document(void) { - DavApp* doc = ui_document_new(sizeof(DavApp)); - UiContext* ctx = ui_document_context(doc); + DavApp *doc = ui_document_new(sizeof(DavApp)); + UiContext *ctx = ui_document_context(doc); doc->repos = ui_list_new(ctx, "repolist"); // create repo list @@ -111,15 +111,26 @@ return doc; } -void application_update_repolist(DavApp* app) { - DavConfig* config = get_config(); - DavCfgRepository* repo = config->repositories; +void application_update_repolist(DavApp *app) { + DavConfig *config = get_config(); + DavCfgRepository *repo = config->repositories; + // TODO: free list content ptr ui_list_clear(app->repos); - for (DavCfgRepository* repo = config->repositories; repo; repo = repo->next) { + for (DavCfgRepository *repo = config->repositories; repo; repo = repo->next) { // TODO: copy repo name ui_list_append(app->repos, repo->name.value.ptr); } } + + +DavContext* application_dav_context(void) { + return davctx; +} + + +void action_repo_selected(UiEvent *event, void *data) { + +}