]> uap-core.de Git - note.git/commitdiff
fill notebook config lists with data
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 30 May 2025 16:09:41 +0000 (18:09 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 30 May 2025 16:09:41 +0000 (18:09 +0200)
application/window.c

index 9f1e3566ee8cb253b25a0da1607cd9c296fbba92..74a100921d17417d45bb6d083783455e3fc843f8 100644 (file)
@@ -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");