diff --git a/gio/src/settings.rs b/gio/src/settings.rs index fdc273f8c395..cf322f8d92f9 100644 --- a/gio/src/settings.rs +++ b/gio/src/settings.rs @@ -23,6 +23,55 @@ impl<'a> BindingBuilder<'a> { self } + // rustdoc-stripper-ignore-next + /// Set the binding flags to [`GET`][crate::SettingsBindFlags::GET]. + pub fn get(mut self) -> Self { + self.flags |= SettingsBindFlags::GET; + self + } + + // rustdoc-stripper-ignore-next + /// Set the binding flags to [`SET`][crate::SettingsBindFlags::SET]. + pub fn set(mut self) -> Self { + self.flags |= SettingsBindFlags::SET; + self + } + + // rustdoc-stripper-ignore-next + /// Unsets the default [`GET`][crate::SettingsBindFlags::GET] flag. + pub fn set_only(mut self) -> Self { + self.flags = (self.flags - SettingsBindFlags::GET) | SettingsBindFlags::SET; + self + } + + // rustdoc-stripper-ignore-next + /// Unsets the default [`SET`][crate::SettingsBindFlags::SET] flag. + pub fn get_only(mut self) -> Self { + self.flags = (self.flags - SettingsBindFlags::SET) | SettingsBindFlags::GET; + self + } + + // rustdoc-stripper-ignore-next + /// Set the binding flags to [`NO_SENSITIVITY`][crate::SettingsBindFlags::NO_SENSITIVITY]. + pub fn no_sensitivity(mut self) -> Self { + self.flags |= SettingsBindFlags::NO_SENSITIVITY; + self + } + + // rustdoc-stripper-ignore-next + /// Set the binding flags to [`GET_NO_CHANGES`][crate::SettingsBindFlags::GET_NO_CHANGES]. + pub fn get_no_changes(mut self) -> Self { + self.flags |= SettingsBindFlags::GET_NO_CHANGES; + self + } + + // rustdoc-stripper-ignore-next + /// Set the binding flags to [`INVERT_BOOLEAN`][crate::SettingsBindFlags::INVERT_BOOLEAN]. + pub fn invert_boolean(mut self) -> Self { + self.flags |= SettingsBindFlags::INVERT_BOOLEAN; + self + } + #[doc(alias = "get_mapping")] pub fn mapping Option + 'static>( mut self, diff --git a/glib-macros/src/lib.rs b/glib-macros/src/lib.rs index 43910b6806ee..527c1dbc6ea7 100644 --- a/glib-macros/src/lib.rs +++ b/glib-macros/src/lib.rs @@ -593,8 +593,8 @@ pub fn shared_boxed_derive(input: TokenStream) -> TokenStream { /// necessary for types that implement interfaces. /// /// ```ignore -/// type Instance = glib::subclass::simple::InstanceStruct; -/// type Class = glib::subclass::simple::ClassStruct; +/// type Instance = glib::subclass::basic::InstanceStruct; +/// type Class = glib::subclass::basic::ClassStruct; /// type Interfaces = (); /// ``` /// diff --git a/glib/src/gobject/binding_group.rs b/glib/src/gobject/binding_group.rs index 69d4fa1eb86f..51a2dd8fb9f8 100644 --- a/glib/src/gobject/binding_group.rs +++ b/glib/src/gobject/binding_group.rs @@ -100,21 +100,21 @@ impl<'a> BindingGroupBuilder<'a> { } // rustdoc-stripper-ignore-next - /// Set the binding flags to (`BIDIRECTIONAL`)[crate::BindingFlags::BIDIRECTIONAL]. + /// Set the binding flags to [`BIDIRECTIONAL`][crate::BindingFlags::BIDIRECTIONAL]. pub fn bidirectional(mut self) -> Self { self.flags |= crate::BindingFlags::BIDIRECTIONAL; self } // rustdoc-stripper-ignore-next - /// Set the binding flags to (`SYNC_CREATE`)[crate::BindingFlags::SYNC_CREATE]. + /// Set the binding flags to [`SYNC_CREATE`][crate::BindingFlags::SYNC_CREATE]. pub fn sync_create(mut self) -> Self { self.flags |= crate::BindingFlags::SYNC_CREATE; self } // rustdoc-stripper-ignore-next - /// Set the binding flags to (`INVERT_BOOLEAN`)[crate::BindingFlags::INVERT_BOOLEAN]. + /// Set the binding flags to [`INVERT_BOOLEAN`][crate::BindingFlags::INVERT_BOOLEAN]. pub fn invert_boolean(mut self) -> Self { self.flags |= crate::BindingFlags::INVERT_BOOLEAN; self diff --git a/glib/src/object.rs b/glib/src/object.rs index 7ed5207b80f0..98edbc34e5bb 100644 --- a/glib/src/object.rs +++ b/glib/src/object.rs @@ -2228,6 +2228,20 @@ pub trait ObjectExt: ObjectType { // rustdoc-stripper-ignore-next /// Returns the strong reference count of this object. fn ref_count(&self) -> u32; + + // rustdoc-stripper-ignore-next + /// Runs the dispose mechanism of the object. + /// + /// This will dispose of any references the object has to other objects, and among other things + /// will disconnect all signal handlers. + /// + /// # Safety + /// + /// Theoretically this is safe to run and afterwards the object is simply in a non-functional + /// state, however many object implementations in C end up with memory safety issues if the + /// object is used after disposal. + #[doc(alias = "g_object_run_dispose")] + unsafe fn run_dispose(&self); } impl ObjectExt for T { @@ -3125,6 +3139,10 @@ impl ObjectExt for T { unsafe { ffi::g_atomic_int_get(&(*ptr).ref_count as *const u32 as *const i32) as u32 } } + + unsafe fn run_dispose(&self) { + gobject_ffi::g_object_run_dispose(self.as_ptr() as *mut _); + } } // Helper struct to avoid creating an extra ref on objects inside closure watches. This is safe @@ -3703,21 +3721,21 @@ impl<'a, 'f, 't> BindingBuilder<'a, 'f, 't> { } // rustdoc-stripper-ignore-next - /// Set the binding flags to (`BIDIRECTIONAL`)[crate::BindingFlags::BIDIRECTIONAL]. + /// Set the binding flags to [`BIDIRECTIONAL`][crate::BindingFlags::BIDIRECTIONAL]. pub fn bidirectional(mut self) -> Self { self.flags |= crate::BindingFlags::BIDIRECTIONAL; self } // rustdoc-stripper-ignore-next - /// Set the binding flags to (`SYNC_CREATE`)[crate::BindingFlags::SYNC_CREATE]. + /// Set the binding flags to [`SYNC_CREATE`][crate::BindingFlags::SYNC_CREATE]. pub fn sync_create(mut self) -> Self { self.flags |= crate::BindingFlags::SYNC_CREATE; self } // rustdoc-stripper-ignore-next - /// Set the binding flags to (`INVERT_BOOLEAN`)[crate::BindingFlags::INVERT_BOOLEAN]. + /// Set the binding flags to [`INVERT_BOOLEAN`][crate::BindingFlags::INVERT_BOOLEAN]. pub fn invert_boolean(mut self) -> Self { self.flags |= crate::BindingFlags::INVERT_BOOLEAN; self diff --git a/glib/src/subclass/types.rs b/glib/src/subclass/types.rs index 65b40652dcbe..3b654bf7809a 100644 --- a/glib/src/subclass/types.rs +++ b/glib/src/subclass/types.rs @@ -649,6 +649,19 @@ pub trait ObjectSubclassExt: ObjectSubclass { /// Returns the implementation from an instance. fn from_instance(obj: &Self::Type) -> &Self; + // rustdoc-stripper-ignore-next + /// Returns the corresponding object instance. + /// + /// Shorter alias for `instance()`. + #[doc(alias = "get_instance")] + fn obj(&self) -> crate::BorrowedObject; + + // rustdoc-stripper-ignore-next + /// Returns the implementation from an instance. + /// + /// Shorter alias for `from_instance()`. + fn from_obj(obj: &Self::Type) -> &Self; + // rustdoc-stripper-ignore-next /// Returns a new reference-counted wrapper around `self`. fn ref_counted(&self) -> super::ObjectImplRef; @@ -690,6 +703,14 @@ impl ObjectSubclassExt for T { } } + fn obj(&self) -> crate::BorrowedObject { + self.instance() + } + + fn from_obj(obj: &Self::Type) -> &Self { + Self::from_instance(obj) + } + fn ref_counted(&self) -> super::ObjectImplRef { super::ObjectImplRef::new(self) }