Skip to content

Commit

Permalink
Merge pull request #812 from sdroege/0.16-backports
Browse files Browse the repository at this point in the history
0.16 backports
  • Loading branch information
sdroege authored Oct 23, 2022
2 parents f233e77 + 2162541 commit ac8b16f
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 8 deletions.
49 changes: 49 additions & 0 deletions gio/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<F: Fn(&glib::Variant, glib::Type) -> Option<glib::Value> + 'static>(
mut self,
Expand Down
4 changes: 2 additions & 2 deletions glib-macros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self>;
/// type Class = glib::subclass::simple::ClassStruct<Self>;
/// type Instance = glib::subclass::basic::InstanceStruct<Self>;
/// type Class = glib::subclass::basic::ClassStruct<Self>;
/// type Interfaces = ();
/// ```
///
Expand Down
6 changes: 3 additions & 3 deletions glib/src/gobject/binding_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 21 additions & 3 deletions glib/src/object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: ObjectType> ObjectExt for T {
Expand Down Expand Up @@ -3125,6 +3139,10 @@ impl<T: ObjectType> 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
Expand Down Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions glib/src/subclass/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Self::Type>;

// 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<Self>;
Expand Down Expand Up @@ -690,6 +703,14 @@ impl<T: ObjectSubclass> ObjectSubclassExt for T {
}
}

fn obj(&self) -> crate::BorrowedObject<Self::Type> {
self.instance()
}

fn from_obj(obj: &Self::Type) -> &Self {
Self::from_instance(obj)
}

fn ref_counted(&self) -> super::ObjectImplRef<Self> {
super::ObjectImplRef::new(self)
}
Expand Down

0 comments on commit ac8b16f

Please sign in to comment.