From: Olaf Wintermann Date: Fri, 22 May 2026 16:41:39 +0000 (+0200) Subject: implement notes loading in the notebook ui model X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=b7c2d74619d581d5ef6961231db6a156db06cd72;p=note.git implement notes loading in the notebook ui model --- diff --git a/application/src/notebook.rs b/application/src/notebook.rs index 7386fe9..86dd006 100644 --- a/application/src/notebook.rs +++ b/application/src/notebook.rs @@ -7,7 +7,7 @@ use entity::note::Model as Note; pub struct Notebook { pub collection_id: i32, - #[bind] + #[bind("notes")] pub notes: UiList } @@ -18,6 +18,15 @@ impl Notebook { collection_id: id, ..Default::default() } } + + pub fn set_notes(&mut self, notes: Vec) { + let notes_list = self.notes.data_mut(); + notes_list.clear(); + for note in notes { + notes_list.push(note); + } + self.notes.update(); + } } pub fn note_getvalue<'a>(elm: &Note, col: i32, _row: i32) -> ListValue<'a> { diff --git a/application/src/window.rs b/application/src/window.rs index b7a2cbf..9d39932 100644 --- a/application/src/window.rs +++ b/application/src/window.rs @@ -134,8 +134,19 @@ pub fn create_window(app: &App, ctx: &AppContext) -> UiObject { + nb.set_notes(notes); + }, + Err(err) => { + eprintln!("get_notes failed: {}", err); + } + } + }); + }); e.obj.ctx.attach(&doc); e.data.selected_notebook = Some(doc); @@ -152,6 +163,7 @@ pub fn create_window(app: &App, ctx: &AppContext) -> UiObject() .varname("notes") + .model(&model) .fill(true) .getvalue(note_getvalue) .create(); diff --git a/ui/common/wrapper.c b/ui/common/wrapper.c index b457e20..a6ef56a 100644 --- a/ui/common/wrapper.c +++ b/ui/common/wrapper.c @@ -55,6 +55,8 @@ static int obj_unref(void *ptr) { } void ui_mainthread_object_unref(UiObject *obj) { + // TODO: detect if this is already the main thread and call + // ui_object_unref directly in that case ui_call_mainthread(obj_unref, obj); } @@ -63,6 +65,7 @@ static int doc_unref(void *ptr) { } void ui_mainthread_document_unref(void *doc) { + // TODO: see ui_mainthread_object_unref ui_call_mainthread(doc_unref, doc); }