From: Olaf Wintermann Date: Fri, 30 May 2025 16:09:41 +0000 (+0200) Subject: fill notebook config lists with data X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=75571a7027dd3564e41ac47f21f068e8de2bf969;p=note.git fill notebook config lists with data --- diff --git a/application/window.c b/application/window.c index 9f1e356..74a1009 100644 --- a/application/window.c +++ b/application/window.c @@ -361,7 +361,25 @@ void action_notebook_add(UiEvent *event, void *userdata) { ui_show(obj); } +static void* reslist_getvalue(void *data, int col) { + Resource *resource = data; + switch(col) { + case 0: { + return resource->displayname ? resource->displayname : resource->nodename; + } + case 1: { + //return note->lastmodified ? strdup(note->lastmodified) : NULL; + return NULL; // TODO + } + } + + return NULL; +} + void action_notebook_config(UiEvent *event, void *userdata) { + NoteStore *store = note_store_get(); + // TODO: check store->root and show different dialog, when root is missing + UiObject *obj = ui_simple_window("Notebooks", NULL); NotebookConfigDialog *wdata = ui_malloc(obj->ctx, sizeof(NotebookConfigDialog)); @@ -374,7 +392,15 @@ void action_notebook_config(UiEvent *event, void *userdata) { wdata->tab2_repositories = ui_list_new(obj->ctx, NULL); // fill data - + CxIterator i = cxListIterator(store->root->children); + cx_foreach(Resource *, res, i) { + ui_list_append(wdata->tab1_groups, res); + ui_list_append(wdata->tab2_groups, res); + CxIterator k = cxListIterator(res->children); + cx_foreach(Resource *, nb, k) { + ui_list_append(wdata->tab2_notebooks, nb); + } + } // UI @@ -383,7 +409,7 @@ void action_notebook_config(UiEvent *event, void *userdata) { ui_tab(obj, "Groups") { ui_hbox(obj, .margin = 10, .spacing = 10, .fill = UI_ON) { ui_vbox(obj, .fill = UI_OFF) { - ui_listview(obj, .list = wdata->tab1_groups, .fill = UI_ON); + ui_listview(obj, .list = wdata->tab1_groups, .getvalue = reslist_getvalue, .fill = UI_ON); ui_hbox(obj, .fill = UI_OFF) { ui_button(obj, .icon = UI_ICON_NEW_FOLDER); ui_button(obj, .icon = UI_ICON_DELETE); @@ -410,7 +436,7 @@ void action_notebook_config(UiEvent *event, void *userdata) { ui_tab(obj, "Notebooks") { ui_hbox(obj, .margin = 10, .spacing = 10, .fill = UI_ON) { ui_vbox(obj, .fill = UI_OFF) { - ui_listview(obj, .list = wdata->tab2_groups, .fill = UI_ON); + ui_listview(obj, .list = wdata->tab2_notebooks, .getvalue = reslist_getvalue, .fill = UI_ON); ui_hbox(obj, .fill = UI_OFF) { ui_button(obj, .icon = UI_ICON_NEW_FOLDER); ui_button(obj, .icon = UI_ICON_DELETE); @@ -421,7 +447,7 @@ void action_notebook_config(UiEvent *event, void *userdata) { ui_grid(obj, .columnspacing = 10, .rowspacing = 10, .fill = UI_ON, .def_vfill = TRUE) { ui_rlabel(obj, .label = "Group"); - ui_combobox(obj, .list = wdata->tab2_groups); + ui_combobox(obj, .list = wdata->tab2_groups, .getvalue = reslist_getvalue); ui_newline(obj); ui_rlabel(obj, .label = "Name");