}
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) {
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");