ui/common/document.c

changeset 163
b70e2a77dea0
parent 140
c03c338a7dcf
child 174
0358f1d9c506
--- a/ui/common/document.c	Sat Dec 05 11:54:58 2020 +0100
+++ b/ui/common/document.c	Sat Dec 05 17:50:22 2020 +0100
@@ -39,11 +39,12 @@
 }
 
 void ui_set_document(UiObject *obj, void *document) {
-    obj->ctx->set_document(obj->ctx, document);
+    uic_context_detach_all(obj->ctx);
+    obj->ctx->attach_document(obj->ctx, document);
 }
 
 void ui_detach_document(UiObject *obj) {
-    obj->ctx->detach_document(obj->ctx);
+    uic_context_detach_all(obj->ctx);
 }
 
 void* ui_get_document(UiObject *obj) {
@@ -55,7 +56,7 @@
     if(!ctx) {
         fprintf(stderr, "UI Error: pointer is not a document\n");
     }
-    uic_context_set_document(ctx, sub);
+    // TODO
 }
 
 void ui_detach_subdocument(void *document, void *sub) {
@@ -63,7 +64,7 @@
     if(!ctx) {
         fprintf(stderr, "UI Error: pointer is not a document\n");
     }
-    uic_context_detach_document(ctx);
+    // TODO
 }
 
 void* ui_get_subdocument(void *document) {
@@ -71,14 +72,15 @@
     if(!ctx) {
         fprintf(stderr, "UI Error: pointer is not a document\n");
     }
-    return ctx->document;
+    // TODO
+    return NULL;
 }
 
 void* ui_document_new(size_t size) {
     UcxMempool *mp = ucx_mempool_new(256);
     UiContext *ctx = ucx_mempool_calloc(mp, 1, sizeof(UiContext));
-    ctx->set_document = uic_context_set_document;
-    ctx->detach_document = uic_context_detach_document;
+    ctx->attach_document = uic_context_attach_document;
+    ctx->detach_document2 = uic_context_detach_document2;
     ctx->mempool = mp;
     ctx->vars = ucx_map_new_a(mp->allocator, 16);
     

mercurial