]> uap-core.de Git - note.git/commitdiff
switch to Rust 2024 main
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 14 Jun 2026 15:36:17 +0000 (17:36 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Sun, 14 Jun 2026 15:36:17 +0000 (17:36 +0200)
17 files changed:
application/Cargo.toml
application/src/note.rs
ui-rs-derive/Cargo.toml
ui-rs/Cargo.toml
ui-rs/src/ui/application.rs
ui-rs/src/ui/button.rs
ui-rs/src/ui/container.rs
ui-rs/src/ui/event.rs
ui-rs/src/ui/icon.rs
ui-rs/src/ui/label.rs
ui-rs/src/ui/list.rs
ui-rs/src/ui/menu.rs
ui-rs/src/ui/text.rs
ui-rs/src/ui/toolbar.rs
ui-rs/src/ui/toolkit.rs
ui-rs/src/ui/widget.rs
ui-rs/src/ui/window.rs

index ff1c6f5c61e46d7719c26f1dd587ef0e5b20bb51..ed6f7a683a11f00874275778e22a5b873f2127af 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "note"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 [dependencies]
 ui-rs = { path = "../ui-rs" }
index 9dc7743bb71bace41f64da75c4762128bd58d6c9..5aea4cc196b44d3905e92b6a5b51d5eb4539e66e 100644 (file)
@@ -98,16 +98,20 @@ impl Note {
                 n.init_from_model(model);
                 n.load_content(d);
             }
-
+            // make sure we receive an event, when this note is attached or detached
             d.ctx.on_attachment_status_change_action("attachment_status_changed");
         })
     }
 
+    /// Handles any attachment status change, which includes if this note is
+    /// directly attached or detached, but also if any parent attachment status changes
     #[action]
     pub fn attachment_status_changed(&mut self, _event: &ActionEvent) -> Option<()>{
         let doc = self.doc.get_doc()?;
 
         if doc.ctx.is_attached_to_obj() {
+
+
             if let NoteId::Id(note_id) = self.id {
                 self.lock = self.backend.backend.lockmgr.lock_note(note_id);
                 if self.lock.is_none() {
index 65ad52292ef3b424cd879e79ca7fefe58c74106d..35383d54f424f013fae3b8fa3c86fab8a931a7a2 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "ui-rs-derive"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 [lib]
 proc-macro = true
index 4014cbc8b1e616899f073dbb195875011f8ca520..4f04a2847ee25e0fa511420b022a2fd418fc5e5b 100644 (file)
@@ -1,7 +1,7 @@
 [package]
 name = "ui-rs"
 version = "0.1.0"
-edition = "2021"
+edition = "2024"
 
 [dependencies]
 ui-rs-derive = { path = "../ui-rs-derive" }
index 88df6417f761f85c0a4393ec62658e73a229f46b..0ba86f2cf5fb16bc20f8c334962d9cc01e2090c5 100644 (file)
@@ -62,7 +62,7 @@ impl UiActions for NoAppData {
     fn init_actions(&mut self, _ctx: &UiContext) {}
 }
 
-extern "C" {
+unsafe extern "C" {
     fn ui_main();
 
     fn ui_onstartup(callback: UiCallback, userdata: *mut c_void);
index f13a9b2ccb70e9ca3d50c04688d2c5a400c8127b..48e7d3d90050e04f44758ee9136555d350cd6444 100644 (file)
@@ -821,7 +821,7 @@ impl LinkButton {
     }
 }
 
-extern "C" {
+unsafe extern "C" {
     fn ui_button_create(obj: *const UiObject, args: *const UiButtonArgs) -> *mut c_void;
     fn ui_togglebutton_create(obj: *const UiObject, args: *const UiToggleArgs) -> *mut c_void;
     fn ui_checkbox_create(obj: *const UiObject, args: *const UiToggleArgs) -> *mut c_void;
index a3c7d015b8223052151c0f74f21540d238f28897..261db104ceececb9c4af0fc735857546d00e8e06 100644 (file)
@@ -1137,7 +1137,7 @@ impl<'a, T> TabViewBuilder<'a, T> {
 
 /* -------------------------------- C functions -------------------------------- */
 
-extern "C" {
+unsafe extern "C" {
     fn ui_container_begin_close(obj: *mut UiObject);
     fn ui_container_finish(obj: *mut UiObject) -> c_int;
 
index 2610d9546144c16513f701936743c7891454364d..3fb2104326b108ffb6390c8cad6384285c5547dd 100644 (file)
@@ -380,7 +380,7 @@ impl SubListEvent {
 }
 
 
-extern "C" {
+unsafe extern "C" {
     fn ui_event_get_obj(event: *const UiEvent) -> *mut ffi::UiObject;
     fn ui_event_get_windowdata(event: *const UiEvent) -> *const c_void;
     fn ui_event_get_document(event: *const UiEvent) -> *const c_void;
index d4d4ccabc510dfd0890df82d5c6813964e537f11..008763b8de708d6dacb1e5c5ea24852766bf446a 100644 (file)
@@ -55,6 +55,6 @@ impl UiIconSet {
     }
 }
 
-extern "C" {
+unsafe extern "C" {
     fn ui_icon_name(id: i32) ->  *const c_char ;
 }
\ No newline at end of file
index 8dfe3fef47eeee402caf63af9773983e55c0539c..501ba0ca4b2982c3861f743c13b662c189cb9414 100644 (file)
@@ -252,7 +252,7 @@ impl<'a, T> LabelBuilder<'a, T> {
     }
 }
 
-extern "C" {
+unsafe extern "C" {
     fn ui_label_create(obj: *const ffi::UiObject, args: *const UiLabelArgs) -> *mut c_void;
     fn ui_llabel_create(obj: *const ffi::UiObject, args: *const UiLabelArgs) -> *mut c_void;
     fn ui_rlabel_create(obj: *const ffi::UiObject, args: *const UiLabelArgs) -> *mut c_void;
index 5236170ea5ba81bc7a9faa7bd1cb169e78f65367..0a732d684c5e9c4c8fac925cf78fe62848e4bb65 100644 (file)
@@ -988,7 +988,7 @@ type SLGetValueFunc = extern "C" fn(
         userdata: *mut c_void);
 
 
-extern "C" {
+unsafe extern "C" {
     fn malloc(size: usize) -> *mut c_void;
 
     fn ui_listview_create(obj: *const UiObject, args: *const UiListArgs) -> *mut c_void;
index b5b2c4c68e8cc3e28cf10d249a77d7e56db731e2..bf060ec2734d1c07342c163bb0fcac6f41f9d6ac 100644 (file)
@@ -230,7 +230,7 @@ impl<T: UiModel + UiActions> Drop for MenuToggleItemBuilder<T> {
     }
 }
 
-extern "C" {
+unsafe extern "C" {
     fn ui_menu_create(label: *const c_char);
     fn ui_menuitem_create(args: *const UiMenuItemArgs);
     fn ui_menu_toggleitem_create(args: *const UiMenuToggleItemArgs);
index 378f113e413bd5d2614b9bdba8240d537945c7c1..3064de0d7dd1cf0b972663f7f50d2dd263156ea4 100644 (file)
@@ -615,7 +615,7 @@ impl<'a, T> TextFieldBuilder<'a, T> {
 
 /* -------------------------------- C functions -------------------------------- */
 
-extern "C" {
+unsafe extern "C" {
     fn ui_textarea_create(obj: *const UiObject, args: *const UiTextAreaArgs) -> *mut c_void;
     fn ui_textfield_create(obj: *const UiObject, args: *const UiTextFieldArgs) -> *mut c_void;
     fn ui_frameless_textfield_create(obj: *const UiObject, args: *const UiTextFieldArgs) -> *mut c_void;
index e204ad01308416a3d69c366653dc833c47eba374..f5d06184f2fddaba1d3a8a60fe056065d5d80b41 100644 (file)
@@ -317,7 +317,7 @@ impl<T: UiModel + UiActions> ToolbarMenuItemBuilder<T> {
 }
 
 
-extern "C" {
+unsafe extern "C" {
     fn ui_toolbar_item_create(name: *const c_char, args: *const UiToolbarItemArgs);
     fn ui_toolbar_toggleitem_create(name: *const c_char, args: *const UiToolbarToggleItemArgs);
     fn ui_toolbar_menu_create(name: *const c_char, args: *const UiToolbarMenuArgs);
index fb1b544a01a091d7e1b006615a6023262704630f..298c084cadd53093f178acea7ed103693c780eca 100644 (file)
@@ -156,18 +156,20 @@ impl UiContext {
     where F: FnMut(&mut T, &mut event::ActionEvent) + 'static {
         // if this is a document context, use the document pointer as target
         // otherwise it is a UiObject context, in that case we use the window_data as target
-        let doc_ptr = ui_context_document(self.ptr) as *mut T;
-        let target_ptr = if !doc_ptr.is_null() {
-            let doc_storage: *mut *mut T = doc_ptr.cast();
-            *doc_storage
-        } else {
-            let obj_ptr = ui_context_obj(self.ptr);
-            assert!(!obj_ptr.is_null());
-            let obj_wdata_ptr = ui_object_get_windowdata(obj_ptr);
-            assert!(!obj_wdata_ptr.is_null());
-            obj_wdata_ptr as *mut T
-        };
-        self.add_action_for_target(target_ptr, name, f);
+        unsafe {
+            let doc_ptr = ui_context_document(self.ptr) as *mut T;
+            let target_ptr = if !doc_ptr.is_null() {
+                let doc_storage: *mut *mut T = doc_ptr.cast();
+                *doc_storage
+            } else {
+                let obj_ptr = ui_context_obj(self.ptr);
+                assert!(!obj_ptr.is_null());
+                let obj_wdata_ptr = ui_object_get_windowdata(obj_ptr);
+                assert!(!obj_wdata_ptr.is_null());
+                obj_wdata_ptr as *mut T
+            };
+            self.add_action_for_target(target_ptr, name, f);
+        }
     }
     
     pub unsafe fn add_action_for_target<T, F>(&self, target_ptr: *mut T, name: &str, f: F)
@@ -175,7 +177,9 @@ impl UiContext {
         let wrapper = Box::new(ActionEventWrapper { callback: Box::new(f), target: target_ptr });
         let ptr = self.reg_box(wrapper);
         let cstr = CString::new(name).unwrap();
-        ui_add_action(self.ptr, cstr.as_ptr(), Some(action_event_wrapper::<T>), ptr as *mut c_void);
+        unsafe {
+            ui_add_action(self.ptr, cstr.as_ptr(), Some(action_event_wrapper::<T>), ptr as *mut c_void);
+        }
     }
 
     pub fn add_action_untyped<F>(&self, name: &str, f: F)
@@ -296,8 +300,10 @@ impl<T: UiModel + UiActions> UiDoc<T> {
     }
 
     pub unsafe fn get_data_ptr(&self) -> *mut T {
-        let ptr: *mut *mut T = self.ptr.cast();
-        *ptr
+        unsafe {
+            let ptr: *mut *mut T = self.ptr.cast();
+            *ptr
+        }
     }
 
     pub fn add_action<F>(&mut self, name: &str, f: F)
@@ -1223,9 +1229,11 @@ extern "C" fn list_destroy<T>(_ctx: *mut ffi::UiContext, _list: *mut ffi::UiList
 }
 
 pub unsafe fn ui_list_get<'a, T>(list: *const ffi::UiList, index: usize) -> Option<&'a T> {
-    let data = ui_list_get_data(list);
-    let ls = &*(data as *mut Vec<T>);
-    ls.get(index)
+    unsafe {
+        let data = ui_list_get_data(list);
+        let ls = &*(data as *mut Vec<T>);
+        ls.get(index)
+    }
 }
 
 
@@ -1308,7 +1316,7 @@ pub fn app_set_configdir(path: &str) {
 
 /* -------------------------------- C functions -------------------------------- */
 
-extern "C" {
+unsafe extern "C" {
     fn ui_init(appname: *const c_char, argc: c_int, argv: *const *const c_char);
     pub fn ui_global_context() -> *mut ffi::UiContext;
     fn ui_getappdir() -> *mut c_char;
@@ -1358,7 +1366,7 @@ type UiListNextFunc  = extern "C" fn(*mut ffi::UiList) -> *mut c_void;
 type UiListGetFunc   = extern "C" fn(*const ffi::UiList, c_int) -> *mut c_void;
 type UiListCountFunc = extern "C" fn(*const ffi::UiList) -> c_int;
 
-extern "C" {
+unsafe extern "C" {
     pub fn ui_app_ref();
     pub fn ui_app_unref();
 
index 07bdc7689b79c8efdfb248e8ea27792108979a52..bf0f7e83b9b2a5824444d8b0da9ace1522008a6e 100644 (file)
@@ -59,7 +59,7 @@ pub trait Widget {
 
 /* ------------------------------ C functions ----------------------------- */
 
-extern "C" {
+unsafe extern "C" {
     fn ui_widget_set_size(widget: *mut c_void, width: c_int, height: c_int);
     fn ui_widget_redraw(widget: *mut c_void);
     fn ui_widget_set_enabled(widget: *mut c_void, enable: c_int);
index b0df4658599572f47bad7b1dafd598d139bddfaa..bc28e3a4ec585191895c982e2180eee6f3dab846 100644 (file)
@@ -494,7 +494,7 @@ where F: FnMut(&mut event::Event<T>) + 'static {
 
 /* ---------------------------------- C functions ---------------------------------- */
 
-extern "C" {
+unsafe extern "C" {
     fn ui_window(title: *const c_char) -> *mut UiObject;
     fn ui_sidebar_window(title: *const c_char) -> *mut UiObject;
     fn ui_splitview_window(title: *const c_char, sidebar: c_int) -> *mut UiObject;