From: Olaf Wintermann Date: Fri, 25 Jul 2025 19:48:43 +0000 (+0200) Subject: implement nbconfig notebooklist_add X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=125a913cb28b91cc898665ca266c8b7b456b4a29;p=note.git implement nbconfig notebooklist_add --- diff --git a/application/nbconfig.c b/application/nbconfig.c index 275d639..429e4af 100644 --- a/application/nbconfig.c +++ b/application/nbconfig.c @@ -179,7 +179,46 @@ static void nbconfig_grouplist_name_changed(UiEvent *event, void *userdata) { } static void nbconfig_notebooklist_add(UiEvent *event, void *userdata) { + NotebookConfigDialog *wdata = event->window; + NoteStore *store = note_store_get(); + + Resource *notebook = cxCalloc(store->mp->allocator, 1, sizeof(Resource)); + notebook->notebook = cxCalloc(store->mp->allocator, 1, sizeof(Notebook)); + + if(wdata->new_notebook) { + // TODO + } + wdata->new_notebook = notebook; + + ui_set(wdata->tab2_notebook_name, ""); + ui_list_setselection(wdata->tab2_repositories, 0); + ui_list_setselection(wdata->tab2_types, 0); +} + +static void nbconfig_notebooklist_name_changed(UiEvent *event, void *userdata) { + if(event->set) { + return; + } + + NotebookConfigDialog *wdata = event->window; + NoteStore *store = note_store_get(); + + if(wdata->new_notebook) { + UiBool add_notebook = FALSE; + if(!wdata->new_notebook->nodename) { + add_notebook = TRUE; + } else { + cxFree(store->mp->allocator, wdata->new_notebook->nodename); + } + + wdata->new_notebook->nodename = cx_strdup_a(store->mp->allocator, cx_str(ui_get(wdata->tab2_notebook_name))).ptr; + + if(add_notebook) { + cxListAdd(wdata->notebooks, wdata->new_notebook); + } + nbconfig_update_lists(wdata); // TODO: update only single row + } } static void nbconfig_notebooklist_delete(UiEvent *event, void *userdata) { @@ -297,7 +336,7 @@ void notebook_config_dialog(void) { ui_newline(obj); ui_rlabel(obj, .label = "Name"); - ui_textfield(obj, .value = wdata->tab2_notebook_name); + ui_textfield(obj, .value = wdata->tab2_notebook_name, .onchange = nbconfig_notebooklist_name_changed); ui_newline(obj); ui_rlabel(obj, .label = "Repository");