From: Olaf Wintermann Date: Sat, 2 Aug 2025 19:12:51 +0000 (+0200) Subject: add more nbconfig repolist stuff X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=d54833235fd8815c1fca5e316e652153de9c6071;p=note.git add more nbconfig repolist stuff --- diff --git a/application/nbconfig.c b/application/nbconfig.c index b1b6b0e..4090f03 100644 --- a/application/nbconfig.c +++ b/application/nbconfig.c @@ -341,13 +341,45 @@ static void nbconfig_notebooklist_move_down(UiEvent *event, void *userdata) { static void nbconfig_repolist_add(UiEvent *event, void *userdata) { + NotebookConfigDialog *wdata = event->window; + NoteStore *store = note_store_get(); + + Repository *repo = cxCalloc(store->mp->allocator, 1, sizeof(Repository)); + wdata->new_repository = repo; + ui_set(wdata->tab3_repo_name, ""); + ui_list_setselection(wdata->tab3_repositories, 0); } static void nbconfig_repolist_delete(UiEvent *event, void *userdata) { } +static void nbconfig_repolist_name_changed(UiEvent *event, void *userdata) { + if(event->set) { + return; + } + + NotebookConfigDialog *wdata = event->window; + NoteStore *store = note_store_get(); + + if(wdata->new_repository) { + UiBool add = FALSE; + if(!wdata->new_repository) { + add = TRUE; + } else { + cxFree(store->mp->allocator, wdata->new_repository->name); + } + + wdata->new_repository->name = cx_strdup_a(store->mp->allocator, cx_str(ui_get(wdata->tab3_repo_name))).ptr; + + if(add) { + cxListAdd(wdata->repositories, wdata->new_repository); + } + nbconfig_update_lists(wdata); + } +} + void notebook_config_dialog(void) { NoteStore *store = note_store_get(); // TODO: check store->root and show different dialog, when root is missing @@ -481,7 +513,7 @@ void notebook_config_dialog(void) { ui_grid(obj, .columnspacing = 10, .rowspacing = 10, .fill = TRUE, .def_vfill = TRUE) { ui_rlabel(obj, .label = "Name"); - ui_textfield(obj, .value = wdata->tab3_repo_name); + ui_textfield(obj, .value = wdata->tab3_repo_name, .onchange = nbconfig_repolist_name_changed); ui_newline(obj); ui_rlabel(obj, .label = "Local Path"); diff --git a/application/nbconfig.h b/application/nbconfig.h index 94f2c4e..1c8356d 100644 --- a/application/nbconfig.h +++ b/application/nbconfig.h @@ -62,6 +62,7 @@ typedef struct NotebookConfigDialog { Resource *new_group; Resource *new_notebook; + Repository *new_repository; } NotebookConfigDialog; void nbconfig_update_lists(NotebookConfigDialog *wdata);