]> uap-core.de Git - note.git/commitdiff
update sourcelist when notebooks are added
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 12 May 2025 17:18:10 +0000 (19:18 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Mon, 12 May 2025 17:18:10 +0000 (19:18 +0200)
application/window.c
application/window.h

index bb1e251cdb4da0b8a3cd08e14e3cfa524b8f9f7b..9428d6b63c16e2753e9a1c7f5c3c74e7be8aba71 100644 (file)
@@ -276,17 +276,17 @@ static void action_nnd_new_group(UiEvent *event, void *userdata) {
     }
 }
 
-struct NotebookCreatedResult {
+typedef struct NotebookCreatedResult {
+    MainWindow *window;
     Resource *parent;
     Resource *notebook;
-};
+} NotebookCreatedResult;
 
 static void notebook_created(UiEvent *event, int64_t newid, int error, void *userdata) {
-    struct NotebookCreatedResult *result = userdata;
+    NotebookCreatedResult *result = userdata;
     cxListAdd(result->parent->children, result->notebook);
+    update_sublists(result->window->obj->ctx, result->window->notebooks);
     free(result);
-    
-    // TODO: update windows
 }
 
 static void action_nnd_button(UiEvent *event, void *userdata) {
@@ -318,7 +318,8 @@ static void action_nnd_button(UiEvent *event, void *userdata) {
         notebook->parent_id = parent->resource_id;
         notebook->nodename = cx_strdup_a(store->mp->allocator, name).ptr;
         
-        struct NotebookCreatedResult *result = malloc(sizeof(struct NotebookCreatedResult));
+        NotebookCreatedResult *result = malloc(sizeof(NotebookCreatedResult));
+        result->window = wdata->parent;
         result->parent = parent;
         result->notebook = notebook;
         
@@ -347,7 +348,9 @@ void action_notebook_add(UiEvent *event, void *userdata) {
     //ui_set_group(obj->ctx, NEWNOTEBOOK_DIALOG_STATE_SELECT_GROUP);
     
     NewNotebookDialog *wdata = ui_malloc(obj->ctx, sizeof(NewNotebookDialog));
+    wdata->parent = event->window;
     wdata->groups = ui_list_new(obj->ctx, NULL);
+    wdata->group_name = ui_string_new(obj->ctx, NULL);
     wdata->notebook_name = ui_string_new(obj->ctx, NULL);
     wdata->gs_new_group = ui_int_new(obj->ctx, NULL);
     wdata->gn_new_group = ui_int_new(obj->ctx, NULL);
@@ -365,7 +368,7 @@ void action_notebook_add(UiEvent *event, void *userdata) {
         ui_widget_set_groups(obj->ctx, gs_button, (ui_enablefunc)ui_set_visible, NEWNOTEBOOK_DIALOG_STATE_SELECT_GROUP, -1);
         
         UIWIDGET gn_label = ui_rlabel(obj, .label = "Group");
-        UIWIDGET gn_textfield = ui_textfield(obj, .varname = "notebook_group_name", .hexpand = TRUE, .hfill = TRUE);
+        UIWIDGET gn_textfield = ui_textfield(obj, .value = wdata->group_name, .hexpand = TRUE, .hfill = TRUE);
         UIWIDGET gn_button = ui_togglebutton(obj, .label = "New Group", .value = wdata->gn_new_group, .onchange = action_nnd_new_group);
         ui_newline(obj);
         
@@ -375,7 +378,7 @@ void action_notebook_add(UiEvent *event, void *userdata) {
         
         ui_newline(obj);
         ui_rlabel(obj, .label = "Name");
-        ui_textfield(obj, .varname = "notebook_name", .colspan = 2, .hfill = TRUE);
+        ui_textfield(obj, .value = wdata->notebook_name, .colspan = 2, .hfill = TRUE);
     }
     
     // Dialog Data
index 29be0bc5f94589fbcdfd7d10fe4fdf76db613812..dc06ae53b139108a477bc55be0901c8f7bb09d43 100644 (file)
@@ -44,6 +44,7 @@ extern "C" {
     
     
 typedef struct NewNotebookDialog {
+    MainWindow *parent;
     UiList *groups;
     UiString *group_name;
     UiString *notebook_name;