diff --git a/gdk-pixbuf/src/subclass/pixbuf_animation.rs b/gdk-pixbuf/src/subclass/pixbuf_animation.rs index 4a014d8be908..d51da8c3866b 100644 --- a/gdk-pixbuf/src/subclass/pixbuf_animation.rs +++ b/gdk-pixbuf/src/subclass/pixbuf_animation.rs @@ -13,7 +13,10 @@ use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, Pixbuf, PixbufAnimation, PixbufAnimationIter}; -pub trait PixbufAnimationImpl: ObjectImpl { +pub trait PixbufAnimationImpl: ObjectImpl +where + ::Type: IsA, +{ fn is_static_image(&self) -> bool { self.parent_is_static_image() } @@ -32,11 +35,18 @@ pub trait PixbufAnimationImpl: ObjectImpl { } mod sealed { + use glib::{prelude::*, subclass::prelude::*}; pub trait Sealed {} - impl Sealed for T {} + impl Sealed for T where + ::Type: IsA + { + } } -pub trait PixbufAnimationImplExt: sealed::Sealed + ObjectSubclass { +pub trait PixbufAnimationImplExt: sealed::Sealed + ObjectSubclass +where + ::Type: IsA, +{ fn parent_is_static_image(&self) -> bool { unsafe { let data = Self::type_data(); @@ -116,9 +126,15 @@ pub trait PixbufAnimationImplExt: sealed::Sealed + ObjectSubclass { } } -impl PixbufAnimationImplExt for T {} +impl PixbufAnimationImplExt for T where + ::Type: IsA +{ +} -unsafe impl IsSubclassable for PixbufAnimation { +unsafe impl IsSubclassable for PixbufAnimation +where + ::Type: IsA, +{ fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); @@ -132,7 +148,10 @@ unsafe impl IsSubclassable for PixbufAnimation { unsafe extern "C" fn animation_is_static_image( ptr: *mut ffi::GdkPixbufAnimation, -) -> glib::ffi::gboolean { +) -> glib::ffi::gboolean +where + ::Type: IsA, +{ let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -143,7 +162,9 @@ unsafe extern "C" fn animation_get_size( ptr: *mut ffi::GdkPixbufAnimation, width_ptr: *mut libc::c_int, height_ptr: *mut libc::c_int, -) { +) where + ::Type: IsA, +{ if width_ptr.is_null() && height_ptr.is_null() { return; } @@ -162,7 +183,10 @@ unsafe extern "C" fn animation_get_size( unsafe extern "C" fn animation_get_static_image( ptr: *mut ffi::GdkPixbufAnimation, -) -> *mut ffi::GdkPixbuf { +) -> *mut ffi::GdkPixbuf +where + ::Type: IsA, +{ let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -192,7 +216,10 @@ unsafe extern "C" fn animation_get_static_image( unsafe extern "C" fn animation_get_iter( ptr: *mut ffi::GdkPixbufAnimation, start_time_ptr: *const glib::ffi::GTimeVal, -) -> *mut ffi::GdkPixbufAnimationIter { +) -> *mut ffi::GdkPixbufAnimationIter +where + ::Type: IsA, +{ let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); diff --git a/gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs b/gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs index 99d05ccae3ae..4b97b5098e6d 100644 --- a/gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs +++ b/gdk-pixbuf/src/subclass/pixbuf_animation_iter.rs @@ -12,7 +12,10 @@ use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, Pixbuf, PixbufAnimationIter}; -pub trait PixbufAnimationIterImpl: ObjectImpl { +pub trait PixbufAnimationIterImpl: ObjectImpl +where + ::Type: IsA, +{ // rustdoc-stripper-ignore-next /// Time in milliseconds, returning `None` implies showing the same pixbuf forever. fn delay_time(&self) -> Option { @@ -33,11 +36,18 @@ pub trait PixbufAnimationIterImpl: ObjectImpl { } mod sealed { + use glib::{prelude::*, subclass::prelude::*}; pub trait Sealed {} - impl Sealed for T {} + impl Sealed for T where + ::Type: IsA + { + } } -pub trait PixbufAnimationIterImplExt: sealed::Sealed + ObjectSubclass { +pub trait PixbufAnimationIterImplExt: sealed::Sealed + ObjectSubclass +where + ::Type: IsA, +{ fn parent_delay_time(&self) -> Option { unsafe { let data = Self::type_data(); @@ -121,9 +131,15 @@ pub trait PixbufAnimationIterImplExt: sealed::Sealed + ObjectSubclass { } } -impl PixbufAnimationIterImplExt for T {} +impl PixbufAnimationIterImplExt for T where + ::Type: IsA +{ +} -unsafe impl IsSubclassable for PixbufAnimationIter { +unsafe impl IsSubclassable for PixbufAnimationIter +where + ::Type: IsA, +{ fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); @@ -137,7 +153,10 @@ unsafe impl IsSubclassable for PixbufAnimationIte unsafe extern "C" fn animation_iter_get_delay_time( ptr: *mut ffi::GdkPixbufAnimationIter, -) -> i32 { +) -> i32 +where + ::Type: IsA, +{ let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -146,7 +165,10 @@ unsafe extern "C" fn animation_iter_get_delay_time( unsafe extern "C" fn animation_iter_get_pixbuf( ptr: *mut ffi::GdkPixbufAnimationIter, -) -> *mut ffi::GdkPixbuf { +) -> *mut ffi::GdkPixbuf +where + ::Type: IsA, +{ let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -162,7 +184,10 @@ unsafe extern "C" fn animation_iter_get_pixbuf( unsafe extern "C" fn animation_iter_on_currently_loading_frame( ptr: *mut ffi::GdkPixbufAnimationIter, -) -> glib::ffi::gboolean { +) -> glib::ffi::gboolean +where + ::Type: IsA, +{ let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -172,7 +197,10 @@ unsafe extern "C" fn animation_iter_on_currently_loading_frame( ptr: *mut ffi::GdkPixbufAnimationIter, current_time_ptr: *const glib::ffi::GTimeVal, -) -> glib::ffi::gboolean { +) -> glib::ffi::gboolean +where + ::Type: IsA, +{ let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); diff --git a/gdk-pixbuf/src/subclass/pixbuf_loader.rs b/gdk-pixbuf/src/subclass/pixbuf_loader.rs index c2d53a7132f5..01d152cb33f8 100644 --- a/gdk-pixbuf/src/subclass/pixbuf_loader.rs +++ b/gdk-pixbuf/src/subclass/pixbuf_loader.rs @@ -7,7 +7,10 @@ use glib::{prelude::*, subclass::prelude::*, translate::*}; use crate::{ffi, PixbufLoader}; -pub trait PixbufLoaderImpl: ObjectImpl { +pub trait PixbufLoaderImpl: ObjectImpl +where + ::Type: IsA, +{ fn size_prepared(&self, width: i32, height: i32) { self.parent_size_prepared(width, height) } @@ -26,11 +29,18 @@ pub trait PixbufLoaderImpl: ObjectImpl { } mod sealed { + use glib::{prelude::*, subclass::prelude::*}; pub trait Sealed {} - impl Sealed for T {} + impl Sealed for T where + ::Type: IsA + { + } } -pub trait PixbufLoaderImplExt: sealed::Sealed + ObjectSubclass { +pub trait PixbufLoaderImplExt: sealed::Sealed + ObjectSubclass +where + ::Type: IsA, +{ fn parent_size_prepared(&self, width: i32, height: i32) { unsafe { let data = Self::type_data(); @@ -96,9 +106,15 @@ pub trait PixbufLoaderImplExt: sealed::Sealed + ObjectSubclass { } } -impl PixbufLoaderImplExt for T {} +impl PixbufLoaderImplExt for T where + ::Type: IsA +{ +} -unsafe impl IsSubclassable for PixbufLoader { +unsafe impl IsSubclassable for PixbufLoader +where + ::Type: IsA, +{ fn class_init(class: &mut ::glib::Class) { Self::parent_class_init::(class); @@ -114,14 +130,19 @@ unsafe extern "C" fn loader_size_prepared( ptr: *mut ffi::GdkPixbufLoader, width: i32, height: i32, -) { +) where + ::Type: IsA, +{ let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.size_prepared(width, height) } -unsafe extern "C" fn loader_area_prepared(ptr: *mut ffi::GdkPixbufLoader) { +unsafe extern "C" fn loader_area_prepared(ptr: *mut ffi::GdkPixbufLoader) +where + ::Type: IsA, +{ let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -134,14 +155,19 @@ unsafe extern "C" fn loader_area_updated( y: i32, width: i32, height: i32, -) { +) where + ::Type: IsA, +{ let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); imp.area_updated(x, y, width, height) } -unsafe extern "C" fn loader_closed(ptr: *mut ffi::GdkPixbufLoader) { +unsafe extern "C" fn loader_closed(ptr: *mut ffi::GdkPixbufLoader) +where + ::Type: IsA, +{ let instance = &*(ptr as *mut T::Instance); let imp = instance.imp();