diff --git a/gdk4-macos/src/auto/versions.txt b/gdk4-macos/src/auto/versions.txt index ddff2b6744e6..9de84f287e30 100644 --- a/gdk4-macos/src/auto/versions.txt +++ b/gdk4-macos/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ae29aefbe96a) +Generated by gir (https://github.com/gtk-rs/gir @ 24f0d6639caa) from gir-files (https://github.com/gtk-rs/gir-files @ c05f5cc23cb7) diff --git a/gdk4-macos/sys/versions.txt b/gdk4-macos/sys/versions.txt index ddff2b6744e6..9de84f287e30 100644 --- a/gdk4-macos/sys/versions.txt +++ b/gdk4-macos/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ae29aefbe96a) +Generated by gir (https://github.com/gtk-rs/gir @ 24f0d6639caa) from gir-files (https://github.com/gtk-rs/gir-files @ c05f5cc23cb7) diff --git a/gdk4-wayland/src/auto/versions.txt b/gdk4-wayland/src/auto/versions.txt index ddff2b6744e6..9de84f287e30 100644 --- a/gdk4-wayland/src/auto/versions.txt +++ b/gdk4-wayland/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ae29aefbe96a) +Generated by gir (https://github.com/gtk-rs/gir @ 24f0d6639caa) from gir-files (https://github.com/gtk-rs/gir-files @ c05f5cc23cb7) diff --git a/gdk4-wayland/sys/versions.txt b/gdk4-wayland/sys/versions.txt index ddff2b6744e6..9de84f287e30 100644 --- a/gdk4-wayland/sys/versions.txt +++ b/gdk4-wayland/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ae29aefbe96a) +Generated by gir (https://github.com/gtk-rs/gir @ 24f0d6639caa) from gir-files (https://github.com/gtk-rs/gir-files @ c05f5cc23cb7) diff --git a/gdk4-win32/src/auto/versions.txt b/gdk4-win32/src/auto/versions.txt index ddff2b6744e6..9de84f287e30 100644 --- a/gdk4-win32/src/auto/versions.txt +++ b/gdk4-win32/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ae29aefbe96a) +Generated by gir (https://github.com/gtk-rs/gir @ 24f0d6639caa) from gir-files (https://github.com/gtk-rs/gir-files @ c05f5cc23cb7) diff --git a/gdk4-win32/src/auto/win32_display.rs b/gdk4-win32/src/auto/win32_display.rs index 5f2b1b16d0c6..aef3b67e8378 100644 --- a/gdk4-win32/src/auto/win32_display.rs +++ b/gdk4-win32/src/auto/win32_display.rs @@ -27,11 +27,11 @@ impl Win32Display { } #[doc(alias = "gdk_win32_display_set_cursor_theme")] - pub fn set_cursor_theme(&self, name: Option<&str>, size: i32) { + pub fn set_cursor_theme<'a>(&self, name: impl Into>, size: i32) { unsafe { ffi::gdk_win32_display_set_cursor_theme( self.to_glib_none().0, - name.to_glib_none().0, + name.into().to_glib_none().0, size, ); } diff --git a/gdk4-win32/sys/versions.txt b/gdk4-win32/sys/versions.txt index ddff2b6744e6..9de84f287e30 100644 --- a/gdk4-win32/sys/versions.txt +++ b/gdk4-win32/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ae29aefbe96a) +Generated by gir (https://github.com/gtk-rs/gir @ 24f0d6639caa) from gir-files (https://github.com/gtk-rs/gir-files @ c05f5cc23cb7) diff --git a/gdk4-x11/src/auto/functions.rs b/gdk4-x11/src/auto/functions.rs index 2b3a94fbd057..34730cc5ee3b 100644 --- a/gdk4-x11/src/auto/functions.rs +++ b/gdk4-x11/src/auto/functions.rs @@ -32,9 +32,9 @@ pub fn x11_get_server_time(surface: &X11Surface) -> u32 { } #[doc(alias = "gdk_x11_set_sm_client_id")] -pub fn x11_set_sm_client_id(sm_client_id: Option<&str>) { +pub fn x11_set_sm_client_id<'a>(sm_client_id: impl Into>) { assert_initialized_main_thread!(); unsafe { - ffi::gdk_x11_set_sm_client_id(sm_client_id.to_glib_none().0); + ffi::gdk_x11_set_sm_client_id(sm_client_id.into().to_glib_none().0); } } diff --git a/gdk4-x11/src/auto/versions.txt b/gdk4-x11/src/auto/versions.txt index ddff2b6744e6..9de84f287e30 100644 --- a/gdk4-x11/src/auto/versions.txt +++ b/gdk4-x11/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ae29aefbe96a) +Generated by gir (https://github.com/gtk-rs/gir @ 24f0d6639caa) from gir-files (https://github.com/gtk-rs/gir-files @ c05f5cc23cb7) diff --git a/gdk4-x11/src/auto/x11_device_manager_xi2.rs b/gdk4-x11/src/auto/x11_device_manager_xi2.rs index bd6b9999fd00..65242bfa6f29 100644 --- a/gdk4-x11/src/auto/x11_device_manager_xi2.rs +++ b/gdk4-x11/src/auto/x11_device_manager_xi2.rs @@ -56,9 +56,11 @@ impl X11DeviceManagerXI2Builder { } } - pub fn display(self, display: &impl IsA) -> Self { + pub fn display<'a, P: IsA>(self, display: impl Into>) -> Self { Self { - builder: self.builder.property("display", display.clone().upcast()), + builder: self + .builder + .property("display", display.into().as_ref().map(|p| p.as_ref())), } } diff --git a/gdk4-x11/src/auto/x11_device_xi2.rs b/gdk4-x11/src/auto/x11_device_xi2.rs index 3ac52ad6eaa8..a3dd5b9c2b24 100644 --- a/gdk4-x11/src/auto/x11_device_xi2.rs +++ b/gdk4-x11/src/auto/x11_device_xi2.rs @@ -51,9 +51,11 @@ impl X11DeviceXI2Builder { } } - pub fn display(self, display: &impl IsA) -> Self { + pub fn display<'a, P: IsA>(self, display: impl Into>) -> Self { Self { - builder: self.builder.property("display", display.clone().upcast()), + builder: self + .builder + .property("display", display.into().as_ref().map(|p| p.as_ref())), } } @@ -63,7 +65,7 @@ impl X11DeviceXI2Builder { } } - pub fn name(self, name: impl Into) -> Self { + pub fn name<'a>(self, name: impl Into>) -> Self { Self { builder: self.builder.property("name", name.into()), } @@ -75,15 +77,15 @@ impl X11DeviceXI2Builder { } } - pub fn product_id(self, product_id: impl Into) -> Self { + pub fn product_id<'a>(self, product_id: impl Into>) -> Self { Self { builder: self.builder.property("product-id", product_id.into()), } } - pub fn seat(self, seat: &gdk::Seat) -> Self { + pub fn seat<'a>(self, seat: impl Into>) -> Self { Self { - builder: self.builder.property("seat", seat.clone()), + builder: self.builder.property("seat", seat.into()), } } @@ -93,7 +95,7 @@ impl X11DeviceXI2Builder { } } - pub fn vendor_id(self, vendor_id: impl Into) -> Self { + pub fn vendor_id<'a>(self, vendor_id: impl Into>) -> Self { Self { builder: self.builder.property("vendor-id", vendor_id.into()), } diff --git a/gdk4-x11/src/auto/x11_display.rs b/gdk4-x11/src/auto/x11_display.rs index 904bb69e3629..c117130f60ad 100644 --- a/gdk4-x11/src/auto/x11_display.rs +++ b/gdk4-x11/src/auto/x11_display.rs @@ -134,11 +134,11 @@ impl X11Display { #[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")] #[allow(deprecated)] #[doc(alias = "gdk_x11_display_set_cursor_theme")] - pub fn set_cursor_theme(&self, theme: Option<&str>, size: i32) { + pub fn set_cursor_theme<'a>(&self, theme: impl Into>, size: i32) { unsafe { ffi::gdk_x11_display_set_cursor_theme( self.to_glib_none().0, - theme.to_glib_none().0, + theme.into().to_glib_none().0, size, ); } @@ -222,8 +222,12 @@ impl X11Display { } #[doc(alias = "gdk_x11_display_open")] - pub fn open(display_name: Option<&str>) -> Option { + pub fn open<'a>(display_name: impl Into>) -> Option { assert_initialized_main_thread!(); - unsafe { from_glib_full(ffi::gdk_x11_display_open(display_name.to_glib_none().0)) } + unsafe { + from_glib_full(ffi::gdk_x11_display_open( + display_name.into().to_glib_none().0, + )) + } } } diff --git a/gdk4-x11/src/auto/x11_surface.rs b/gdk4-x11/src/auto/x11_surface.rs index dff4cace4bea..4eccd833b017 100644 --- a/gdk4-x11/src/auto/x11_surface.rs +++ b/gdk4-x11/src/auto/x11_surface.rs @@ -100,12 +100,12 @@ impl X11Surface { } #[doc(alias = "gdk_x11_surface_set_utf8_property")] - pub fn set_utf8_property(&self, name: &str, value: Option<&str>) { + pub fn set_utf8_property<'a>(&self, name: &str, value: impl Into>) { unsafe { ffi::gdk_x11_surface_set_utf8_property( self.to_glib_none().0, name.to_glib_none().0, - value.to_glib_none().0, + value.into().to_glib_none().0, ); } } diff --git a/gdk4-x11/sys/versions.txt b/gdk4-x11/sys/versions.txt index ddff2b6744e6..9de84f287e30 100644 --- a/gdk4-x11/sys/versions.txt +++ b/gdk4-x11/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ae29aefbe96a) +Generated by gir (https://github.com/gtk-rs/gir @ 24f0d6639caa) from gir-files (https://github.com/gtk-rs/gir-files @ c05f5cc23cb7) diff --git a/gdk4/src/auto/app_launch_context.rs b/gdk4/src/auto/app_launch_context.rs index c3c18a945158..9e0c37867b10 100644 --- a/gdk4/src/auto/app_launch_context.rs +++ b/gdk4/src/auto/app_launch_context.rs @@ -37,21 +37,21 @@ pub trait GdkAppLaunchContextExt: IsA + 'static { } #[doc(alias = "gdk_app_launch_context_set_icon")] - fn set_icon(&self, icon: Option<&impl IsA>) { + fn set_icon<'a, P: IsA>(&self, icon: impl Into>) { unsafe { ffi::gdk_app_launch_context_set_icon( self.as_ref().to_glib_none().0, - icon.map(|p| p.as_ref()).to_glib_none().0, + icon.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "gdk_app_launch_context_set_icon_name")] - fn set_icon_name(&self, icon_name: Option<&str>) { + fn set_icon_name<'a>(&self, icon_name: impl Into>) { unsafe { ffi::gdk_app_launch_context_set_icon_name( self.as_ref().to_glib_none().0, - icon_name.to_glib_none().0, + icon_name.into().to_glib_none().0, ); } } diff --git a/gdk4/src/auto/clipboard.rs b/gdk4/src/auto/clipboard.rs index 91fe1874e7be..ee8494824e68 100644 --- a/gdk4/src/auto/clipboard.rs +++ b/gdk4/src/auto/clipboard.rs @@ -45,10 +45,14 @@ impl Clipboard { } #[doc(alias = "gdk_clipboard_read_text_async")] - pub fn read_text_async, glib::Error>) + 'static>( + pub fn read_text_async< + 'a, + P: IsA, + Q: FnOnce(Result, glib::Error>) + 'static, + >( &self, - cancellable: Option<&impl IsA>, - callback: P, + cancellable: impl Into>, + callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); @@ -60,10 +64,10 @@ impl Clipboard { "Async operations only allowed if the thread is owning the MainContext" ); - let user_data: Box_> = + let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn read_text_async_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, + Q: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, @@ -77,16 +81,21 @@ impl Clipboard { } else { Err(from_glib_full(error)) }; - let callback: Box_> = + let callback: Box_> = Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); + let callback: Q = callback.into_inner(); callback(result); } - let callback = read_text_async_trampoline::

; + let callback = read_text_async_trampoline::; unsafe { ffi::gdk_clipboard_read_text_async( self.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, + cancellable + .into() + .as_ref() + .map(|p| p.as_ref()) + .to_glib_none() + .0, Some(callback), Box_::into_raw(user_data) as *mut _, ); @@ -108,10 +117,14 @@ impl Clipboard { } #[doc(alias = "gdk_clipboard_read_texture_async")] - pub fn read_texture_async, glib::Error>) + 'static>( + pub fn read_texture_async< + 'a, + P: IsA, + Q: FnOnce(Result, glib::Error>) + 'static, + >( &self, - cancellable: Option<&impl IsA>, - callback: P, + cancellable: impl Into>, + callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); @@ -123,10 +136,10 @@ impl Clipboard { "Async operations only allowed if the thread is owning the MainContext" ); - let user_data: Box_> = + let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn read_texture_async_trampoline< - P: FnOnce(Result, glib::Error>) + 'static, + Q: FnOnce(Result, glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, @@ -140,16 +153,21 @@ impl Clipboard { } else { Err(from_glib_full(error)) }; - let callback: Box_> = + let callback: Box_> = Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); + let callback: Q = callback.into_inner(); callback(result); } - let callback = read_texture_async_trampoline::

; + let callback = read_texture_async_trampoline::; unsafe { ffi::gdk_clipboard_read_texture_async( self.to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, + cancellable + .into() + .as_ref() + .map(|p| p.as_ref()) + .to_glib_none() + .0, Some(callback), Box_::into_raw(user_data) as *mut _, ); @@ -168,12 +186,16 @@ impl Clipboard { } #[doc(alias = "gdk_clipboard_read_value_async")] - pub fn read_value_async) + 'static>( + pub fn read_value_async< + 'a, + P: IsA, + Q: FnOnce(Result) + 'static, + >( &self, type_: glib::types::Type, io_priority: glib::Priority, - cancellable: Option<&impl IsA>, - callback: P, + cancellable: impl Into>, + callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); @@ -185,10 +207,10 @@ impl Clipboard { "Async operations only allowed if the thread is owning the MainContext" ); - let user_data: Box_> = + let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn read_value_async_trampoline< - P: FnOnce(Result) + 'static, + Q: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, @@ -202,18 +224,23 @@ impl Clipboard { } else { Err(from_glib_full(error)) }; - let callback: Box_> = + let callback: Box_> = Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); + let callback: Q = callback.into_inner(); callback(result); } - let callback = read_value_async_trampoline::

; + let callback = read_value_async_trampoline::; unsafe { ffi::gdk_clipboard_read_value_async( self.to_glib_none().0, type_.into_glib(), io_priority.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, + cancellable + .into() + .as_ref() + .map(|p| p.as_ref()) + .to_glib_none() + .0, Some(callback), Box_::into_raw(user_data) as *mut _, ); @@ -234,15 +261,20 @@ impl Clipboard { } #[doc(alias = "gdk_clipboard_set_content")] - pub fn set_content( + pub fn set_content<'a, P: IsA>( &self, - provider: Option<&impl IsA>, + provider: impl Into>, ) -> Result<(), glib::error::BoolError> { unsafe { glib::result_from_gboolean!( ffi::gdk_clipboard_set_content( self.to_glib_none().0, - provider.map(|p| p.as_ref()).to_glib_none().0 + provider + .into() + .as_ref() + .map(|p| p.as_ref()) + .to_glib_none() + .0 ), "Can't set new clipboard content" ) @@ -267,11 +299,15 @@ impl Clipboard { } #[doc(alias = "gdk_clipboard_store_async")] - pub fn store_async) + 'static>( + pub fn store_async< + 'a, + P: IsA, + Q: FnOnce(Result<(), glib::Error>) + 'static, + >( &self, io_priority: glib::Priority, - cancellable: Option<&impl IsA>, - callback: P, + cancellable: impl Into>, + callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); @@ -283,10 +319,10 @@ impl Clipboard { "Async operations only allowed if the thread is owning the MainContext" ); - let user_data: Box_> = + let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn store_async_trampoline< - P: FnOnce(Result<(), glib::Error>) + 'static, + Q: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, @@ -299,17 +335,22 @@ impl Clipboard { } else { Err(from_glib_full(error)) }; - let callback: Box_> = + let callback: Box_> = Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); + let callback: Q = callback.into_inner(); callback(result); } - let callback = store_async_trampoline::

; + let callback = store_async_trampoline::; unsafe { ffi::gdk_clipboard_store_async( self.to_glib_none().0, io_priority.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, + cancellable + .into() + .as_ref() + .map(|p| p.as_ref()) + .to_glib_none() + .0, Some(callback), Box_::into_raw(user_data) as *mut _, ); diff --git a/gdk4/src/auto/content_provider.rs b/gdk4/src/auto/content_provider.rs index bea48c3f8af7..467f42c6d4d6 100644 --- a/gdk4/src/auto/content_provider.rs +++ b/gdk4/src/auto/content_provider.rs @@ -88,13 +88,17 @@ pub trait ContentProviderExt: IsA + 'static { } #[doc(alias = "gdk_content_provider_write_mime_type_async")] - fn write_mime_type_async) + 'static>( + fn write_mime_type_async< + 'a, + P: IsA, + Q: FnOnce(Result<(), glib::Error>) + 'static, + >( &self, mime_type: &str, stream: &impl IsA, io_priority: glib::Priority, - cancellable: Option<&impl IsA>, - callback: P, + cancellable: impl Into>, + callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); @@ -106,10 +110,10 @@ pub trait ContentProviderExt: IsA + 'static { "Async operations only allowed if the thread is owning the MainContext" ); - let user_data: Box_> = + let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn write_mime_type_async_trampoline< - P: FnOnce(Result<(), glib::Error>) + 'static, + Q: FnOnce(Result<(), glib::Error>) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, @@ -126,19 +130,24 @@ pub trait ContentProviderExt: IsA + 'static { } else { Err(from_glib_full(error)) }; - let callback: Box_> = + let callback: Box_> = Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); + let callback: Q = callback.into_inner(); callback(result); } - let callback = write_mime_type_async_trampoline::

; + let callback = write_mime_type_async_trampoline::; unsafe { ffi::gdk_content_provider_write_mime_type_async( self.as_ref().to_glib_none().0, mime_type.to_glib_none().0, stream.as_ref().to_glib_none().0, io_priority.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, + cancellable + .into() + .as_ref() + .map(|p| p.as_ref()) + .to_glib_none() + .0, Some(callback), Box_::into_raw(user_data) as *mut _, ); diff --git a/gdk4/src/auto/cursor.rs b/gdk4/src/auto/cursor.rs index ba7fde592e67..bae582650374 100644 --- a/gdk4/src/auto/cursor.rs +++ b/gdk4/src/auto/cursor.rs @@ -17,23 +17,23 @@ glib::wrapper! { impl Cursor { #[doc(alias = "gdk_cursor_new_from_name")] #[doc(alias = "new_from_name")] - pub fn from_name(name: &str, fallback: Option<&Cursor>) -> Option { + pub fn from_name<'a>(name: &str, fallback: impl Into>) -> Option { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::gdk_cursor_new_from_name( name.to_glib_none().0, - fallback.to_glib_none().0, + fallback.into().to_glib_none().0, )) } } #[doc(alias = "gdk_cursor_new_from_texture")] #[doc(alias = "new_from_texture")] - pub fn from_texture( + pub fn from_texture<'a>( texture: &impl IsA, hotspot_x: i32, hotspot_y: i32, - fallback: Option<&Cursor>, + fallback: impl Into>, ) -> Cursor { skip_assert_initialized!(); unsafe { @@ -41,7 +41,7 @@ impl Cursor { texture.as_ref().to_glib_none().0, hotspot_x, hotspot_y, - fallback.to_glib_none().0, + fallback.into().to_glib_none().0, )) } } @@ -104,9 +104,9 @@ impl CursorBuilder { } } - pub fn fallback(self, fallback: &Cursor) -> Self { + pub fn fallback<'a>(self, fallback: impl Into>) -> Self { Self { - builder: self.builder.property("fallback", fallback.clone()), + builder: self.builder.property("fallback", fallback.into()), } } @@ -122,15 +122,17 @@ impl CursorBuilder { } } - pub fn name(self, name: impl Into) -> Self { + pub fn name<'a>(self, name: impl Into>) -> Self { Self { builder: self.builder.property("name", name.into()), } } - pub fn texture(self, texture: &impl IsA) -> Self { + pub fn texture<'a, P: IsA>(self, texture: impl Into>) -> Self { Self { - builder: self.builder.property("texture", texture.clone().upcast()), + builder: self + .builder + .property("texture", texture.into().as_ref().map(|p| p.as_ref())), } } diff --git a/gdk4/src/auto/device.rs b/gdk4/src/auto/device.rs index ef71d92f8c8c..e19be64690f0 100644 --- a/gdk4/src/auto/device.rs +++ b/gdk4/src/auto/device.rs @@ -198,8 +198,12 @@ pub trait DeviceExt: IsA + 'static { ObjectExt::property(self.as_ref(), "n-axes") } - fn set_seat>(&self, seat: Option<&P>) { - ObjectExt::set_property(self.as_ref(), "seat", seat) + fn set_seat<'a, P: IsA>(&self, seat: impl Into>) { + ObjectExt::set_property( + self.as_ref(), + "seat", + seat.into().as_ref().map(|p| p.as_ref()), + ) } #[doc(alias = "changed")] diff --git a/gdk4/src/auto/display.rs b/gdk4/src/auto/display.rs index 3e165b9e25f4..2a4962608600 100644 --- a/gdk4/src/auto/display.rs +++ b/gdk4/src/auto/display.rs @@ -38,9 +38,9 @@ impl Display { } #[doc(alias = "gdk_display_open")] - pub fn open(display_name: Option<&str>) -> Option { + pub fn open<'a>(display_name: impl Into>) -> Option { assert_initialized_main_thread!(); - unsafe { from_glib_none(ffi::gdk_display_open(display_name.to_glib_none().0)) } + unsafe { from_glib_none(ffi::gdk_display_open(display_name.into().to_glib_none().0)) } } } diff --git a/gdk4/src/auto/display_manager.rs b/gdk4/src/auto/display_manager.rs index b059894cd767..4991578891fa 100644 --- a/gdk4/src/auto/display_manager.rs +++ b/gdk4/src/auto/display_manager.rs @@ -41,11 +41,11 @@ impl DisplayManager { } #[doc(alias = "gdk_display_manager_open_display")] - pub fn open_display(&self, name: Option<&str>) -> Option { + pub fn open_display<'a>(&self, name: impl Into>) -> Option { unsafe { from_glib_none(ffi::gdk_display_manager_open_display( self.to_glib_none().0, - name.to_glib_none().0, + name.into().to_glib_none().0, )) } } diff --git a/gdk4/src/auto/dmabuf_texture_builder.rs b/gdk4/src/auto/dmabuf_texture_builder.rs index f53242bb08b4..6d58f9d32199 100644 --- a/gdk4/src/auto/dmabuf_texture_builder.rs +++ b/gdk4/src/auto/dmabuf_texture_builder.rs @@ -138,11 +138,11 @@ impl DmabufTextureBuilder { #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))] #[doc(alias = "gdk_dmabuf_texture_builder_set_color_state")] #[doc(alias = "color-state")] - pub fn set_color_state(&self, color_state: Option<&ColorState>) { + pub fn set_color_state<'a>(&self, color_state: impl Into>) { unsafe { ffi::gdk_dmabuf_texture_builder_set_color_state( self.to_glib_none().0, - color_state.to_glib_none().0, + color_state.into().to_glib_none().0, ); } } @@ -224,22 +224,22 @@ impl DmabufTextureBuilder { #[doc(alias = "gdk_dmabuf_texture_builder_set_update_region")] #[doc(alias = "update-region")] - pub fn set_update_region(&self, region: Option<&cairo::Region>) { + pub fn set_update_region<'a>(&self, region: impl Into>) { unsafe { ffi::gdk_dmabuf_texture_builder_set_update_region( self.to_glib_none().0, - mut_override(region.to_glib_none().0), + mut_override(region.into().to_glib_none().0), ); } } #[doc(alias = "gdk_dmabuf_texture_builder_set_update_texture")] #[doc(alias = "update-texture")] - pub fn set_update_texture(&self, texture: Option<&impl IsA>) { + pub fn set_update_texture<'a, P: IsA>(&self, texture: impl Into>) { unsafe { ffi::gdk_dmabuf_texture_builder_set_update_texture( self.to_glib_none().0, - texture.map(|p| p.as_ref()).to_glib_none().0, + texture.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } diff --git a/gdk4/src/auto/drop.rs b/gdk4/src/auto/drop.rs index db441535deb2..a6c967d413e7 100644 --- a/gdk4/src/auto/drop.rs +++ b/gdk4/src/auto/drop.rs @@ -64,12 +64,16 @@ impl Drop { } #[doc(alias = "gdk_drop_read_value_async")] - pub fn read_value_async) + 'static>( + pub fn read_value_async< + 'a, + P: IsA, + Q: FnOnce(Result) + 'static, + >( &self, type_: glib::types::Type, io_priority: glib::Priority, - cancellable: Option<&impl IsA>, - callback: P, + cancellable: impl Into>, + callback: Q, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); @@ -81,10 +85,10 @@ impl Drop { "Async operations only allowed if the thread is owning the MainContext" ); - let user_data: Box_> = + let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); unsafe extern "C" fn read_value_async_trampoline< - P: FnOnce(Result) + 'static, + Q: FnOnce(Result) + 'static, >( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, @@ -97,18 +101,23 @@ impl Drop { } else { Err(from_glib_full(error)) }; - let callback: Box_> = + let callback: Box_> = Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); + let callback: Q = callback.into_inner(); callback(result); } - let callback = read_value_async_trampoline::

; + let callback = read_value_async_trampoline::; unsafe { ffi::gdk_drop_read_value_async( self.to_glib_none().0, type_.into_glib(), io_priority.into_glib(), - cancellable.map(|p| p.as_ref()).to_glib_none().0, + cancellable + .into() + .as_ref() + .map(|p| p.as_ref()) + .to_glib_none() + .0, Some(callback), Box_::into_raw(user_data) as *mut _, ); diff --git a/gdk4/src/auto/memory_texture_builder.rs b/gdk4/src/auto/memory_texture_builder.rs index 07a6b36f50fe..2ebb70fe229f 100644 --- a/gdk4/src/auto/memory_texture_builder.rs +++ b/gdk4/src/auto/memory_texture_builder.rs @@ -104,22 +104,22 @@ impl MemoryTextureBuilder { #[doc(alias = "gdk_memory_texture_builder_set_bytes")] #[doc(alias = "bytes")] - pub fn set_bytes(&self, bytes: Option<&glib::Bytes>) { + pub fn set_bytes<'a>(&self, bytes: impl Into>) { unsafe { ffi::gdk_memory_texture_builder_set_bytes( self.to_glib_none().0, - bytes.to_glib_none().0, + bytes.into().to_glib_none().0, ); } } #[doc(alias = "gdk_memory_texture_builder_set_color_state")] #[doc(alias = "color-state")] - pub fn set_color_state(&self, color_state: Option<&ColorState>) { + pub fn set_color_state<'a>(&self, color_state: impl Into>) { unsafe { ffi::gdk_memory_texture_builder_set_color_state( self.to_glib_none().0, - color_state.to_glib_none().0, + color_state.into().to_glib_none().0, ); } } @@ -150,22 +150,22 @@ impl MemoryTextureBuilder { #[doc(alias = "gdk_memory_texture_builder_set_update_region")] #[doc(alias = "update-region")] - pub fn set_update_region(&self, region: Option<&cairo::Region>) { + pub fn set_update_region<'a>(&self, region: impl Into>) { unsafe { ffi::gdk_memory_texture_builder_set_update_region( self.to_glib_none().0, - mut_override(region.to_glib_none().0), + mut_override(region.into().to_glib_none().0), ); } } #[doc(alias = "gdk_memory_texture_builder_set_update_texture")] #[doc(alias = "update-texture")] - pub fn set_update_texture(&self, texture: Option<&impl IsA>) { + pub fn set_update_texture<'a, P: IsA>(&self, texture: impl Into>) { unsafe { ffi::gdk_memory_texture_builder_set_update_texture( self.to_glib_none().0, - texture.map(|p| p.as_ref()).to_glib_none().0, + texture.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } diff --git a/gdk4/src/auto/surface.rs b/gdk4/src/auto/surface.rs index f5cba7d9e6db..636e2cbd993b 100644 --- a/gdk4/src/auto/surface.rs +++ b/gdk4/src/auto/surface.rs @@ -228,9 +228,12 @@ pub trait SurfaceExt: IsA + 'static { #[doc(alias = "gdk_surface_set_cursor")] #[doc(alias = "cursor")] - fn set_cursor(&self, cursor: Option<&Cursor>) { + fn set_cursor<'a>(&self, cursor: impl Into>) { unsafe { - ffi::gdk_surface_set_cursor(self.as_ref().to_glib_none().0, cursor.to_glib_none().0); + ffi::gdk_surface_set_cursor( + self.as_ref().to_glib_none().0, + cursor.into().to_glib_none().0, + ); } } @@ -258,11 +261,11 @@ pub trait SurfaceExt: IsA + 'static { #[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")] #[allow(deprecated)] #[doc(alias = "gdk_surface_set_opaque_region")] - fn set_opaque_region(&self, region: Option<&cairo::Region>) { + fn set_opaque_region<'a>(&self, region: impl Into>) { unsafe { ffi::gdk_surface_set_opaque_region( self.as_ref().to_glib_none().0, - mut_override(region.to_glib_none().0), + mut_override(region.into().to_glib_none().0), ); } } diff --git a/gdk4/src/auto/toplevel.rs b/gdk4/src/auto/toplevel.rs index 2e418a207652..c853738cfbc2 100644 --- a/gdk4/src/auto/toplevel.rs +++ b/gdk4/src/auto/toplevel.rs @@ -45,10 +45,10 @@ pub trait ToplevelExt: IsA + 'static { } #[doc(alias = "gdk_toplevel_begin_resize")] - fn begin_resize( + fn begin_resize<'a, P: IsA>( &self, edge: SurfaceEdge, - device: Option<&impl IsA>, + device: impl Into>, button: i32, x: f64, y: f64, @@ -58,7 +58,7 @@ pub trait ToplevelExt: IsA + 'static { ffi::gdk_toplevel_begin_resize( self.as_ref().to_glib_none().0, edge.into_glib(), - device.map(|p| p.as_ref()).to_glib_none().0, + device.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, button, x, y, diff --git a/gdk4/src/auto/toplevel_layout.rs b/gdk4/src/auto/toplevel_layout.rs index aadf8d03245a..1a4b92c80507 100644 --- a/gdk4/src/auto/toplevel_layout.rs +++ b/gdk4/src/auto/toplevel_layout.rs @@ -94,12 +94,16 @@ impl ToplevelLayout { } #[doc(alias = "gdk_toplevel_layout_set_fullscreen")] - pub fn set_fullscreen(&self, fullscreen: bool, monitor: Option<&impl IsA>) { + pub fn set_fullscreen<'a, P: IsA>( + &self, + fullscreen: bool, + monitor: impl Into>, + ) { unsafe { ffi::gdk_toplevel_layout_set_fullscreen( self.to_glib_none().0, fullscreen.into_glib(), - monitor.map(|p| p.as_ref()).to_glib_none().0, + monitor.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } diff --git a/gdk4/src/auto/versions.txt b/gdk4/src/auto/versions.txt index ddff2b6744e6..9de84f287e30 100644 --- a/gdk4/src/auto/versions.txt +++ b/gdk4/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ae29aefbe96a) +Generated by gir (https://github.com/gtk-rs/gir @ 24f0d6639caa) from gir-files (https://github.com/gtk-rs/gir-files @ c05f5cc23cb7) diff --git a/gdk4/sys/versions.txt b/gdk4/sys/versions.txt index ddff2b6744e6..9de84f287e30 100644 --- a/gdk4/sys/versions.txt +++ b/gdk4/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ae29aefbe96a) +Generated by gir (https://github.com/gtk-rs/gir @ 24f0d6639caa) from gir-files (https://github.com/gtk-rs/gir-files @ c05f5cc23cb7) diff --git a/gsk4/src/auto/gl_shader.rs b/gsk4/src/auto/gl_shader.rs index 80ba2e5dadd1..7044b29d1dce 100644 --- a/gsk4/src/auto/gl_shader.rs +++ b/gsk4/src/auto/gl_shader.rs @@ -212,15 +212,15 @@ impl GLShaderBuilder { } } - pub fn resource(self, resource: impl Into) -> Self { + pub fn resource<'a>(self, resource: impl Into>) -> Self { Self { builder: self.builder.property("resource", resource.into()), } } - pub fn source(self, source: &glib::Bytes) -> Self { + pub fn source<'a>(self, source: impl Into>) -> Self { Self { - builder: self.builder.property("source", source.clone()), + builder: self.builder.property("source", source.into()), } } diff --git a/gsk4/src/auto/renderer.rs b/gsk4/src/auto/renderer.rs index 7025bdfea9a9..bb0c21031177 100644 --- a/gsk4/src/auto/renderer.rs +++ b/gsk4/src/auto/renderer.rs @@ -52,12 +52,12 @@ pub trait GskRendererExt: IsA + 'static { } #[doc(alias = "gsk_renderer_realize")] - fn realize(&self, surface: Option<&gdk::Surface>) -> Result<(), glib::Error> { + fn realize<'a>(&self, surface: impl Into>) -> Result<(), glib::Error> { unsafe { let mut error = std::ptr::null_mut(); let is_ok = ffi::gsk_renderer_realize( self.as_ref().to_glib_none().0, - surface.to_glib_none().0, + surface.into().to_glib_none().0, &mut error, ); debug_assert_eq!(is_ok == glib::ffi::GFALSE, !error.is_null()); @@ -90,27 +90,31 @@ pub trait GskRendererExt: IsA + 'static { } #[doc(alias = "gsk_renderer_render")] - fn render(&self, root: impl AsRef, region: Option<&cairo::Region>) { + fn render<'a>( + &self, + root: impl AsRef, + region: impl Into>, + ) { unsafe { ffi::gsk_renderer_render( self.as_ref().to_glib_none().0, root.as_ref().to_glib_none().0, - region.to_glib_none().0, + region.into().to_glib_none().0, ); } } #[doc(alias = "gsk_renderer_render_texture")] - fn render_texture( + fn render_texture<'a>( &self, root: impl AsRef, - viewport: Option<&graphene::Rect>, + viewport: impl Into>, ) -> gdk::Texture { unsafe { from_glib_full(ffi::gsk_renderer_render_texture( self.as_ref().to_glib_none().0, root.as_ref().to_glib_none().0, - viewport.to_glib_none().0, + viewport.into().to_glib_none().0, )) } } diff --git a/gsk4/src/auto/repeat_node.rs b/gsk4/src/auto/repeat_node.rs index 55a31004491e..f264a3492760 100644 --- a/gsk4/src/auto/repeat_node.rs +++ b/gsk4/src/auto/repeat_node.rs @@ -23,17 +23,17 @@ impl StaticType for RepeatNode { impl RepeatNode { #[doc(alias = "gsk_repeat_node_new")] - pub fn new( + pub fn new<'a>( bounds: &graphene::Rect, child: impl AsRef, - child_bounds: Option<&graphene::Rect>, + child_bounds: impl Into>, ) -> RepeatNode { skip_assert_initialized!(); unsafe { from_glib_full(ffi::gsk_repeat_node_new( bounds.to_glib_none().0, child.as_ref().to_glib_none().0, - child_bounds.to_glib_none().0, + child_bounds.into().to_glib_none().0, )) } } diff --git a/gsk4/src/auto/shader_args_builder.rs b/gsk4/src/auto/shader_args_builder.rs index 50a79e2b44e7..972a36a83475 100644 --- a/gsk4/src/auto/shader_args_builder.rs +++ b/gsk4/src/auto/shader_args_builder.rs @@ -20,12 +20,15 @@ impl ShaderArgsBuilder { #[cfg_attr(feature = "v4_16", deprecated = "Since 4.16")] #[allow(deprecated)] #[doc(alias = "gsk_shader_args_builder_new")] - pub fn new(shader: &GLShader, initial_values: Option<&glib::Bytes>) -> ShaderArgsBuilder { + pub fn new<'a>( + shader: &GLShader, + initial_values: impl Into>, + ) -> ShaderArgsBuilder { skip_assert_initialized!(); unsafe { from_glib_full(ffi::gsk_shader_args_builder_new( shader.to_glib_none().0, - initial_values.to_glib_none().0, + initial_values.into().to_glib_none().0, )) } } diff --git a/gsk4/src/auto/versions.txt b/gsk4/src/auto/versions.txt index ddff2b6744e6..9de84f287e30 100644 --- a/gsk4/src/auto/versions.txt +++ b/gsk4/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ae29aefbe96a) +Generated by gir (https://github.com/gtk-rs/gir @ 24f0d6639caa) from gir-files (https://github.com/gtk-rs/gir-files @ c05f5cc23cb7) diff --git a/gsk4/sys/versions.txt b/gsk4/sys/versions.txt index ddff2b6744e6..9de84f287e30 100644 --- a/gsk4/sys/versions.txt +++ b/gsk4/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ ae29aefbe96a) +Generated by gir (https://github.com/gtk-rs/gir @ 24f0d6639caa) from gir-files (https://github.com/gtk-rs/gir-files @ c05f5cc23cb7) diff --git a/gtk4/src/auto/about_dialog.rs b/gtk4/src/auto/about_dialog.rs index fcdc48b3ca77..a109995e555c 100644 --- a/gtk4/src/auto/about_dialog.rs +++ b/gtk4/src/auto/about_dialog.rs @@ -209,17 +209,23 @@ impl AboutDialog { #[doc(alias = "gtk_about_dialog_set_comments")] #[doc(alias = "comments")] - pub fn set_comments(&self, comments: Option<&str>) { + pub fn set_comments<'a>(&self, comments: impl Into>) { unsafe { - ffi::gtk_about_dialog_set_comments(self.to_glib_none().0, comments.to_glib_none().0); + ffi::gtk_about_dialog_set_comments( + self.to_glib_none().0, + comments.into().to_glib_none().0, + ); } } #[doc(alias = "gtk_about_dialog_set_copyright")] #[doc(alias = "copyright")] - pub fn set_copyright(&self, copyright: Option<&str>) { + pub fn set_copyright<'a>(&self, copyright: impl Into>) { unsafe { - ffi::gtk_about_dialog_set_copyright(self.to_glib_none().0, copyright.to_glib_none().0); + ffi::gtk_about_dialog_set_copyright( + self.to_glib_none().0, + copyright.into().to_glib_none().0, + ); } } @@ -236,9 +242,12 @@ impl AboutDialog { #[doc(alias = "gtk_about_dialog_set_license")] #[doc(alias = "license")] - pub fn set_license(&self, license: Option<&str>) { + pub fn set_license<'a>(&self, license: impl Into>) { unsafe { - ffi::gtk_about_dialog_set_license(self.to_glib_none().0, license.to_glib_none().0); + ffi::gtk_about_dialog_set_license( + self.to_glib_none().0, + license.into().to_glib_none().0, + ); } } @@ -252,69 +261,78 @@ impl AboutDialog { #[doc(alias = "gtk_about_dialog_set_logo")] #[doc(alias = "logo")] - pub fn set_logo(&self, logo: Option<&impl IsA>) { + pub fn set_logo<'a, P: IsA>(&self, logo: impl Into>) { unsafe { ffi::gtk_about_dialog_set_logo( self.to_glib_none().0, - logo.map(|p| p.as_ref()).to_glib_none().0, + logo.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "gtk_about_dialog_set_logo_icon_name")] #[doc(alias = "logo-icon-name")] - pub fn set_logo_icon_name(&self, icon_name: Option<&str>) { + pub fn set_logo_icon_name<'a>(&self, icon_name: impl Into>) { unsafe { ffi::gtk_about_dialog_set_logo_icon_name( self.to_glib_none().0, - icon_name.to_glib_none().0, + icon_name.into().to_glib_none().0, ); } } #[doc(alias = "gtk_about_dialog_set_program_name")] #[doc(alias = "program-name")] - pub fn set_program_name(&self, name: Option<&str>) { + pub fn set_program_name<'a>(&self, name: impl Into>) { unsafe { - ffi::gtk_about_dialog_set_program_name(self.to_glib_none().0, name.to_glib_none().0); + ffi::gtk_about_dialog_set_program_name( + self.to_glib_none().0, + name.into().to_glib_none().0, + ); } } #[doc(alias = "gtk_about_dialog_set_system_information")] #[doc(alias = "system-information")] - pub fn set_system_information(&self, system_information: Option<&str>) { + pub fn set_system_information<'a>(&self, system_information: impl Into>) { unsafe { ffi::gtk_about_dialog_set_system_information( self.to_glib_none().0, - system_information.to_glib_none().0, + system_information.into().to_glib_none().0, ); } } #[doc(alias = "gtk_about_dialog_set_translator_credits")] #[doc(alias = "translator-credits")] - pub fn set_translator_credits(&self, translator_credits: Option<&str>) { + pub fn set_translator_credits<'a>(&self, translator_credits: impl Into>) { unsafe { ffi::gtk_about_dialog_set_translator_credits( self.to_glib_none().0, - translator_credits.to_glib_none().0, + translator_credits.into().to_glib_none().0, ); } } #[doc(alias = "gtk_about_dialog_set_version")] #[doc(alias = "version")] - pub fn set_version(&self, version: Option<&str>) { + pub fn set_version<'a>(&self, version: impl Into>) { unsafe { - ffi::gtk_about_dialog_set_version(self.to_glib_none().0, version.to_glib_none().0); + ffi::gtk_about_dialog_set_version( + self.to_glib_none().0, + version.into().to_glib_none().0, + ); } } #[doc(alias = "gtk_about_dialog_set_website")] #[doc(alias = "website")] - pub fn set_website(&self, website: Option<&str>) { + pub fn set_website<'a>(&self, website: impl Into>) { unsafe { - ffi::gtk_about_dialog_set_website(self.to_glib_none().0, website.to_glib_none().0); + ffi::gtk_about_dialog_set_website( + self.to_glib_none().0, + website.into().to_glib_none().0, + ); } } @@ -778,13 +796,13 @@ impl AboutDialogBuilder { } } - pub fn comments(self, comments: impl Into) -> Self { + pub fn comments<'a>(self, comments: impl Into>) -> Self { Self { builder: self.builder.property("comments", comments.into()), } } - pub fn copyright(self, copyright: impl Into) -> Self { + pub fn copyright<'a>(self, copyright: impl Into>) -> Self { Self { builder: self.builder.property("copyright", copyright.into()), } @@ -796,7 +814,7 @@ impl AboutDialogBuilder { } } - pub fn license(self, license: impl Into) -> Self { + pub fn license<'a>(self, license: impl Into>) -> Self { Self { builder: self.builder.property("license", license.into()), } @@ -808,13 +826,15 @@ impl AboutDialogBuilder { } } - pub fn logo(self, logo: &impl IsA) -> Self { + pub fn logo<'a, P: IsA>(self, logo: impl Into>) -> Self { Self { - builder: self.builder.property("logo", logo.clone().upcast()), + builder: self + .builder + .property("logo", logo.into().as_ref().map(|p| p.as_ref())), } } - pub fn logo_icon_name(self, logo_icon_name: impl Into) -> Self { + pub fn logo_icon_name<'a>(self, logo_icon_name: impl Into>) -> Self { Self { builder: self .builder @@ -822,13 +842,13 @@ impl AboutDialogBuilder { } } - pub fn program_name(self, program_name: impl Into) -> Self { + pub fn program_name<'a>(self, program_name: impl Into>) -> Self { Self { builder: self.builder.property("program-name", program_name.into()), } } - pub fn system_information(self, system_information: impl Into) -> Self { + pub fn system_information<'a>(self, system_information: impl Into>) -> Self { Self { builder: self .builder @@ -836,7 +856,7 @@ impl AboutDialogBuilder { } } - pub fn translator_credits(self, translator_credits: impl Into) -> Self { + pub fn translator_credits<'a>(self, translator_credits: impl Into>) -> Self { Self { builder: self .builder @@ -844,19 +864,19 @@ impl AboutDialogBuilder { } } - pub fn version(self, version: impl Into) -> Self { + pub fn version<'a>(self, version: impl Into>) -> Self { Self { builder: self.builder.property("version", version.into()), } } - pub fn website(self, website: impl Into) -> Self { + pub fn website<'a>(self, website: impl Into>) -> Self { Self { builder: self.builder.property("website", website.into()), } } - pub fn website_label(self, website_label: impl Into) -> Self { + pub fn website_label<'a>(self, website_label: impl Into>) -> Self { Self { builder: self.builder.property("website-label", website_label.into()), } @@ -868,17 +888,23 @@ impl AboutDialogBuilder { } } - pub fn application(self, application: &impl IsA) -> Self { + pub fn application<'a, P: IsA>( + self, + application: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("application", application.clone().upcast()), + builder: self.builder.property( + "application", + application.into().as_ref().map(|p| p.as_ref()), + ), } } - pub fn child(self, child: &impl IsA) -> Self { + pub fn child<'a, P: IsA>(self, child: impl Into>) -> Self { Self { - builder: self.builder.property("child", child.clone().upcast()), + builder: self + .builder + .property("child", child.into().as_ref().map(|p| p.as_ref())), } } @@ -894,11 +920,15 @@ impl AboutDialogBuilder { } } - pub fn default_widget(self, default_widget: &impl IsA) -> Self { + pub fn default_widget<'a, P: IsA>( + self, + default_widget: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("default-widget", default_widget.clone().upcast()), + builder: self.builder.property( + "default-widget", + default_widget.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -922,9 +952,11 @@ impl AboutDialogBuilder { } } - pub fn display(self, display: &impl IsA) -> Self { + pub fn display<'a, P: IsA>(self, display: impl Into>) -> Self { Self { - builder: self.builder.property("display", display.clone().upcast()), + builder: self + .builder + .property("display", display.into().as_ref().map(|p| p.as_ref())), } } @@ -934,11 +966,12 @@ impl AboutDialogBuilder { } } - pub fn focus_widget(self, focus_widget: &impl IsA) -> Self { + pub fn focus_widget<'a, P: IsA>(self, focus_widget: impl Into>) -> Self { Self { - builder: self - .builder - .property("focus-widget", focus_widget.clone().upcast()), + builder: self.builder.property( + "focus-widget", + focus_widget.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -964,7 +997,7 @@ impl AboutDialogBuilder { } } - pub fn icon_name(self, icon_name: impl Into) -> Self { + pub fn icon_name<'a>(self, icon_name: impl Into>) -> Self { Self { builder: self.builder.property("icon-name", icon_name.into()), } @@ -996,13 +1029,13 @@ impl AboutDialogBuilder { } } - pub fn startup_id(self, startup_id: impl Into) -> Self { + pub fn startup_id<'a>(self, startup_id: impl Into>) -> Self { Self { builder: self.builder.property("startup-id", startup_id.into()), } } - pub fn title(self, title: impl Into) -> Self { + pub fn title<'a>(self, title: impl Into>) -> Self { Self { builder: self.builder.property("title", title.into()), } @@ -1010,17 +1043,23 @@ impl AboutDialogBuilder { #[cfg(feature = "v4_6")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))] - pub fn titlebar(self, titlebar: &impl IsA) -> Self { + pub fn titlebar<'a, P: IsA>(self, titlebar: impl Into>) -> Self { Self { - builder: self.builder.property("titlebar", titlebar.clone().upcast()), + builder: self + .builder + .property("titlebar", titlebar.into().as_ref().map(|p| p.as_ref())), } } - pub fn transient_for(self, transient_for: &impl IsA) -> Self { + pub fn transient_for<'a, P: IsA>( + self, + transient_for: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("transient-for", transient_for.clone().upcast()), + builder: self.builder.property( + "transient-for", + transient_for.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -1042,15 +1081,15 @@ impl AboutDialogBuilder { } } - pub fn css_name(self, css_name: impl Into) -> Self { + pub fn css_name<'a>(self, css_name: impl Into>) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } - pub fn cursor(self, cursor: &gdk::Cursor) -> Self { + pub fn cursor<'a>(self, cursor: impl Into>) -> Self { Self { - builder: self.builder.property("cursor", cursor.clone()), + builder: self.builder.property("cursor", cursor.into()), } } @@ -1096,11 +1135,15 @@ impl AboutDialogBuilder { } } - pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { + pub fn layout_manager<'a, P: IsA>( + self, + layout_manager: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("layout-manager", layout_manager.clone().upcast()), + builder: self.builder.property( + "layout-manager", + layout_manager.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -1128,7 +1171,7 @@ impl AboutDialogBuilder { } } - pub fn name(self, name: impl Into) -> Self { + pub fn name<'a>(self, name: impl Into>) -> Self { Self { builder: self.builder.property("name", name.into()), } @@ -1158,7 +1201,7 @@ impl AboutDialogBuilder { } } - pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { + pub fn tooltip_markup<'a>(self, tooltip_markup: impl Into>) -> Self { Self { builder: self .builder @@ -1166,7 +1209,7 @@ impl AboutDialogBuilder { } } - pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { + pub fn tooltip_text<'a>(self, tooltip_text: impl Into>) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } diff --git a/gtk4/src/auto/accessible.rs b/gtk4/src/auto/accessible.rs index 8b971495683d..e68fee04f6aa 100644 --- a/gtk4/src/auto/accessible.rs +++ b/gtk4/src/auto/accessible.rs @@ -178,16 +178,21 @@ pub trait AccessibleExt: IsA + 'static { #[cfg(feature = "v4_10")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))] #[doc(alias = "gtk_accessible_set_accessible_parent")] - fn set_accessible_parent( + fn set_accessible_parent<'a, P: IsA, Q: IsA>( &self, - parent: Option<&impl IsA>, - next_sibling: Option<&impl IsA>, + parent: impl Into>, + next_sibling: impl Into>, ) { unsafe { ffi::gtk_accessible_set_accessible_parent( self.as_ref().to_glib_none().0, - parent.map(|p| p.as_ref()).to_glib_none().0, - next_sibling.map(|p| p.as_ref()).to_glib_none().0, + parent.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, + next_sibling + .into() + .as_ref() + .map(|p| p.as_ref()) + .to_glib_none() + .0, ); } } @@ -195,11 +200,19 @@ pub trait AccessibleExt: IsA + 'static { #[cfg(feature = "v4_10")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))] #[doc(alias = "gtk_accessible_update_next_accessible_sibling")] - fn update_next_accessible_sibling(&self, new_sibling: Option<&impl IsA>) { + fn update_next_accessible_sibling<'a, P: IsA>( + &self, + new_sibling: impl Into>, + ) { unsafe { ffi::gtk_accessible_update_next_accessible_sibling( self.as_ref().to_glib_none().0, - new_sibling.map(|p| p.as_ref()).to_glib_none().0, + new_sibling + .into() + .as_ref() + .map(|p| p.as_ref()) + .to_glib_none() + .0, ); } } diff --git a/gtk4/src/auto/action_bar.rs b/gtk4/src/auto/action_bar.rs index d9d1d0d99054..f32ee9b6cd96 100644 --- a/gtk4/src/auto/action_bar.rs +++ b/gtk4/src/auto/action_bar.rs @@ -72,11 +72,16 @@ impl ActionBar { } #[doc(alias = "gtk_action_bar_set_center_widget")] - pub fn set_center_widget(&self, center_widget: Option<&impl IsA>) { + pub fn set_center_widget<'a, P: IsA>(&self, center_widget: impl Into>) { unsafe { ffi::gtk_action_bar_set_center_widget( self.to_glib_none().0, - center_widget.map(|p| p.as_ref()).to_glib_none().0, + center_widget + .into() + .as_ref() + .map(|p| p.as_ref()) + .to_glib_none() + .0, ); } } @@ -159,15 +164,15 @@ impl ActionBarBuilder { } } - pub fn css_name(self, css_name: impl Into) -> Self { + pub fn css_name<'a>(self, css_name: impl Into>) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } - pub fn cursor(self, cursor: &gdk::Cursor) -> Self { + pub fn cursor<'a>(self, cursor: impl Into>) -> Self { Self { - builder: self.builder.property("cursor", cursor.clone()), + builder: self.builder.property("cursor", cursor.into()), } } @@ -213,11 +218,15 @@ impl ActionBarBuilder { } } - pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { + pub fn layout_manager<'a, P: IsA>( + self, + layout_manager: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("layout-manager", layout_manager.clone().upcast()), + builder: self.builder.property( + "layout-manager", + layout_manager.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -245,7 +254,7 @@ impl ActionBarBuilder { } } - pub fn name(self, name: impl Into) -> Self { + pub fn name<'a>(self, name: impl Into>) -> Self { Self { builder: self.builder.property("name", name.into()), } @@ -275,7 +284,7 @@ impl ActionBarBuilder { } } - pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { + pub fn tooltip_markup<'a>(self, tooltip_markup: impl Into>) -> Self { Self { builder: self .builder @@ -283,7 +292,7 @@ impl ActionBarBuilder { } } - pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { + pub fn tooltip_text<'a>(self, tooltip_text: impl Into>) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } diff --git a/gtk4/src/auto/actionable.rs b/gtk4/src/auto/actionable.rs index b2848705be46..902ad64ff341 100644 --- a/gtk4/src/auto/actionable.rs +++ b/gtk4/src/auto/actionable.rs @@ -48,22 +48,22 @@ pub trait ActionableExt: IsA + 'static { #[doc(alias = "gtk_actionable_set_action_name")] #[doc(alias = "action-name")] - fn set_action_name(&self, action_name: Option<&str>) { + fn set_action_name<'a>(&self, action_name: impl Into>) { unsafe { ffi::gtk_actionable_set_action_name( self.as_ref().to_glib_none().0, - action_name.to_glib_none().0, + action_name.into().to_glib_none().0, ); } } #[doc(alias = "gtk_actionable_set_action_target_value")] #[doc(alias = "action-target")] - fn set_action_target_value(&self, target_value: Option<&glib::Variant>) { + fn set_action_target_value<'a>(&self, target_value: impl Into>) { unsafe { ffi::gtk_actionable_set_action_target_value( self.as_ref().to_glib_none().0, - target_value.to_glib_none().0, + target_value.into().to_glib_none().0, ); } } diff --git a/gtk4/src/auto/alert_dialog.rs b/gtk4/src/auto/alert_dialog.rs index f9835f9a2679..06c4d0666291 100644 --- a/gtk4/src/auto/alert_dialog.rs +++ b/gtk4/src/auto/alert_dialog.rs @@ -34,11 +34,16 @@ impl AlertDialog { } #[doc(alias = "gtk_alert_dialog_choose")] - pub fn choose) + 'static>( + pub fn choose< + 'a, + P: IsA, + Q: IsA, + R: FnOnce(Result) + 'static, + >( &self, - parent: Option<&impl IsA>, - cancellable: Option<&impl IsA>, - callback: P, + parent: impl Into>, + cancellable: impl Into>, + callback: R, ) { let main_context = glib::MainContext::ref_thread_default(); let is_main_context_owner = main_context.is_owner(); @@ -50,9 +55,9 @@ impl AlertDialog { "Async operations only allowed if the thread is owning the MainContext" ); - let user_data: Box_> = + let user_data: Box_> = Box_::new(glib::thread_guard::ThreadGuard::new(callback)); - unsafe extern "C" fn choose_trampoline) + 'static>( + unsafe extern "C" fn choose_trampoline) + 'static>( _source_object: *mut glib::gobject_ffi::GObject, res: *mut gio::ffi::GAsyncResult, user_data: glib::ffi::gpointer, @@ -65,28 +70,33 @@ impl AlertDialog { } else { Err(from_glib_full(error)) }; - let callback: Box_> = + let callback: Box_> = Box_::from_raw(user_data as *mut _); - let callback: P = callback.into_inner(); + let callback: R = callback.into_inner(); callback(result); } - let callback = choose_trampoline::

; + let callback = choose_trampoline::; unsafe { ffi::gtk_alert_dialog_choose( self.to_glib_none().0, - parent.map(|p| p.as_ref()).to_glib_none().0, - cancellable.map(|p| p.as_ref()).to_glib_none().0, + parent.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, + cancellable + .into() + .as_ref() + .map(|p| p.as_ref()) + .to_glib_none() + .0, Some(callback), Box_::into_raw(user_data) as *mut _, ); } } - pub fn choose_future( + pub fn choose_future<'a, P: IsA + Clone + 'static>( &self, - parent: Option<&(impl IsA + Clone + 'static)>, + parent: impl Into>, ) -> Pin> + 'static>> { - let parent = parent.map(ToOwned::to_owned); + let parent = parent.into().map(ToOwned::to_owned); Box_::pin(gio::GioFuture::new(self, move |obj, cancellable, send| { obj.choose( parent.as_ref().map(::std::borrow::Borrow::borrow), @@ -190,11 +200,11 @@ impl AlertDialog { } #[doc(alias = "gtk_alert_dialog_show")] - pub fn show(&self, parent: Option<&impl IsA>) { + pub fn show<'a, P: IsA>(&self, parent: impl Into>) { unsafe { ffi::gtk_alert_dialog_show( self.to_glib_none().0, - parent.map(|p| p.as_ref()).to_glib_none().0, + parent.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } @@ -400,7 +410,7 @@ impl AlertDialogBuilder { #[cfg(feature = "v4_10")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))] - pub fn detail(self, detail: impl Into) -> Self { + pub fn detail<'a>(self, detail: impl Into>) -> Self { Self { builder: self.builder.property("detail", detail.into()), } @@ -408,7 +418,7 @@ impl AlertDialogBuilder { #[cfg(feature = "v4_10")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))] - pub fn message(self, message: impl Into) -> Self { + pub fn message<'a>(self, message: impl Into>) -> Self { Self { builder: self.builder.property("message", message.into()), } diff --git a/gtk4/src/auto/alternative_trigger.rs b/gtk4/src/auto/alternative_trigger.rs index 2dcc8dee18b7..69ef045717fc 100644 --- a/gtk4/src/auto/alternative_trigger.rs +++ b/gtk4/src/auto/alternative_trigger.rs @@ -81,15 +81,19 @@ impl AlternativeTriggerBuilder { } } - pub fn first(self, first: &impl IsA) -> Self { + pub fn first<'a, P: IsA>(self, first: impl Into>) -> Self { Self { - builder: self.builder.property("first", first.clone().upcast()), + builder: self + .builder + .property("first", first.into().as_ref().map(|p| p.as_ref())), } } - pub fn second(self, second: &impl IsA) -> Self { + pub fn second<'a, P: IsA>(self, second: impl Into>) -> Self { Self { - builder: self.builder.property("second", second.clone().upcast()), + builder: self + .builder + .property("second", second.into().as_ref().map(|p| p.as_ref())), } } diff --git a/gtk4/src/auto/app_chooser_button.rs b/gtk4/src/auto/app_chooser_button.rs index 357a937aacbe..0b55976fb8b8 100644 --- a/gtk4/src/auto/app_chooser_button.rs +++ b/gtk4/src/auto/app_chooser_button.rs @@ -387,7 +387,7 @@ impl AppChooserButtonBuilder { } } - pub fn heading(self, heading: impl Into) -> Self { + pub fn heading<'a>(self, heading: impl Into>) -> Self { Self { builder: self.builder.property("heading", heading.into()), } @@ -431,15 +431,15 @@ impl AppChooserButtonBuilder { } } - pub fn css_name(self, css_name: impl Into) -> Self { + pub fn css_name<'a>(self, css_name: impl Into>) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } - pub fn cursor(self, cursor: &gdk::Cursor) -> Self { + pub fn cursor<'a>(self, cursor: impl Into>) -> Self { Self { - builder: self.builder.property("cursor", cursor.clone()), + builder: self.builder.property("cursor", cursor.into()), } } @@ -485,11 +485,15 @@ impl AppChooserButtonBuilder { } } - pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { + pub fn layout_manager<'a, P: IsA>( + self, + layout_manager: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("layout-manager", layout_manager.clone().upcast()), + builder: self.builder.property( + "layout-manager", + layout_manager.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -517,7 +521,7 @@ impl AppChooserButtonBuilder { } } - pub fn name(self, name: impl Into) -> Self { + pub fn name<'a>(self, name: impl Into>) -> Self { Self { builder: self.builder.property("name", name.into()), } @@ -547,7 +551,7 @@ impl AppChooserButtonBuilder { } } - pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { + pub fn tooltip_markup<'a>(self, tooltip_markup: impl Into>) -> Self { Self { builder: self .builder @@ -555,7 +559,7 @@ impl AppChooserButtonBuilder { } } - pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { + pub fn tooltip_text<'a>(self, tooltip_text: impl Into>) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } @@ -597,7 +601,7 @@ impl AppChooserButtonBuilder { } } - pub fn content_type(self, content_type: impl Into) -> Self { + pub fn content_type<'a>(self, content_type: impl Into>) -> Self { Self { builder: self.builder.property("content-type", content_type.into()), } diff --git a/gtk4/src/auto/app_chooser_dialog.rs b/gtk4/src/auto/app_chooser_dialog.rs index 0b9b8f52fab5..b50c3d76008e 100644 --- a/gtk4/src/auto/app_chooser_dialog.rs +++ b/gtk4/src/auto/app_chooser_dialog.rs @@ -27,15 +27,15 @@ impl AppChooserDialog { #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")] #[allow(deprecated)] #[doc(alias = "gtk_app_chooser_dialog_new")] - pub fn new( - parent: Option<&impl IsA>, + pub fn new<'a, P: IsA>( + parent: impl Into>, flags: DialogFlags, file: &impl IsA, ) -> AppChooserDialog { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(ffi::gtk_app_chooser_dialog_new( - parent.map(|p| p.as_ref()).to_glib_none().0, + parent.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, flags.into_glib(), file.as_ref().to_glib_none().0, )) @@ -47,15 +47,15 @@ impl AppChooserDialog { #[allow(deprecated)] #[doc(alias = "gtk_app_chooser_dialog_new_for_content_type")] #[doc(alias = "new_for_content_type")] - pub fn for_content_type( - parent: Option<&impl IsA>, + pub fn for_content_type<'a, P: IsA>( + parent: impl Into>, flags: DialogFlags, content_type: &str, ) -> AppChooserDialog { assert_initialized_main_thread!(); unsafe { Widget::from_glib_none(ffi::gtk_app_chooser_dialog_new_for_content_type( - parent.map(|p| p.as_ref()).to_glib_none().0, + parent.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, flags.into_glib(), content_type.to_glib_none().0, )) diff --git a/gtk4/src/auto/app_chooser_widget.rs b/gtk4/src/auto/app_chooser_widget.rs index 9aea93dbb953..758233a4462d 100644 --- a/gtk4/src/auto/app_chooser_widget.rs +++ b/gtk4/src/auto/app_chooser_widget.rs @@ -414,7 +414,7 @@ impl AppChooserWidgetBuilder { } } - pub fn default_text(self, default_text: impl Into) -> Self { + pub fn default_text<'a>(self, default_text: impl Into>) -> Self { Self { builder: self.builder.property("default-text", default_text.into()), } @@ -468,15 +468,15 @@ impl AppChooserWidgetBuilder { } } - pub fn css_name(self, css_name: impl Into) -> Self { + pub fn css_name<'a>(self, css_name: impl Into>) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } - pub fn cursor(self, cursor: &gdk::Cursor) -> Self { + pub fn cursor<'a>(self, cursor: impl Into>) -> Self { Self { - builder: self.builder.property("cursor", cursor.clone()), + builder: self.builder.property("cursor", cursor.into()), } } @@ -522,11 +522,15 @@ impl AppChooserWidgetBuilder { } } - pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { + pub fn layout_manager<'a, P: IsA>( + self, + layout_manager: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("layout-manager", layout_manager.clone().upcast()), + builder: self.builder.property( + "layout-manager", + layout_manager.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -554,7 +558,7 @@ impl AppChooserWidgetBuilder { } } - pub fn name(self, name: impl Into) -> Self { + pub fn name<'a>(self, name: impl Into>) -> Self { Self { builder: self.builder.property("name", name.into()), } @@ -584,7 +588,7 @@ impl AppChooserWidgetBuilder { } } - pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { + pub fn tooltip_markup<'a>(self, tooltip_markup: impl Into>) -> Self { Self { builder: self .builder @@ -592,7 +596,7 @@ impl AppChooserWidgetBuilder { } } - pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { + pub fn tooltip_text<'a>(self, tooltip_text: impl Into>) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } @@ -634,7 +638,7 @@ impl AppChooserWidgetBuilder { } } - pub fn content_type(self, content_type: impl Into) -> Self { + pub fn content_type<'a>(self, content_type: impl Into>) -> Self { Self { builder: self.builder.property("content-type", content_type.into()), } diff --git a/gtk4/src/auto/application.rs b/gtk4/src/auto/application.rs index 5e58259f827d..b7619eb0c2a2 100644 --- a/gtk4/src/auto/application.rs +++ b/gtk4/src/auto/application.rs @@ -47,9 +47,11 @@ impl ApplicationBuilder { } } - pub fn menubar(self, menubar: &impl IsA) -> Self { + pub fn menubar<'a, P: IsA>(self, menubar: impl Into>) -> Self { Self { - builder: self.builder.property("menubar", menubar.clone().upcast()), + builder: self + .builder + .property("menubar", menubar.into().as_ref().map(|p| p.as_ref())), } } @@ -59,7 +61,7 @@ impl ApplicationBuilder { } } - pub fn application_id(self, application_id: impl Into) -> Self { + pub fn application_id<'a>(self, application_id: impl Into>) -> Self { Self { builder: self .builder @@ -81,7 +83,7 @@ impl ApplicationBuilder { } } - pub fn resource_base_path(self, resource_base_path: impl Into) -> Self { + pub fn resource_base_path<'a>(self, resource_base_path: impl Into>) -> Self { Self { builder: self .builder @@ -91,7 +93,7 @@ impl ApplicationBuilder { #[cfg(feature = "gio_v2_80")] #[cfg_attr(docsrs, doc(cfg(feature = "gio_v2_80")))] - pub fn version(self, version: impl Into) -> Self { + pub fn version<'a>(self, version: impl Into>) -> Self { Self { builder: self.builder.property("version", version.into()), } @@ -196,18 +198,18 @@ pub trait GtkApplicationExt: IsA + 'static { } #[doc(alias = "gtk_application_inhibit")] - fn inhibit( + fn inhibit<'a, P: IsA>( &self, - window: Option<&impl IsA>, + window: impl Into>, flags: ApplicationInhibitFlags, - reason: Option<&str>, + reason: impl Into>, ) -> u32 { unsafe { ffi::gtk_application_inhibit( self.as_ref().to_glib_none().0, - window.map(|p| p.as_ref()).to_glib_none().0, + window.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, flags.into_glib(), - reason.to_glib_none().0, + reason.into().to_glib_none().0, ) } } @@ -244,11 +246,11 @@ pub trait GtkApplicationExt: IsA + 'static { #[doc(alias = "gtk_application_set_menubar")] #[doc(alias = "menubar")] - fn set_menubar(&self, menubar: Option<&impl IsA>) { + fn set_menubar<'a, P: IsA>(&self, menubar: impl Into>) { unsafe { ffi::gtk_application_set_menubar( self.as_ref().to_glib_none().0, - menubar.map(|p| p.as_ref()).to_glib_none().0, + menubar.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } diff --git a/gtk4/src/auto/application_window.rs b/gtk4/src/auto/application_window.rs index 349e7ca927cd..0b339e610930 100644 --- a/gtk4/src/auto/application_window.rs +++ b/gtk4/src/auto/application_window.rs @@ -73,17 +73,23 @@ impl ApplicationWindowBuilder { } } - pub fn application(self, application: &impl IsA) -> Self { + pub fn application<'a, P: IsA>( + self, + application: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("application", application.clone().upcast()), + builder: self.builder.property( + "application", + application.into().as_ref().map(|p| p.as_ref()), + ), } } - pub fn child(self, child: &impl IsA) -> Self { + pub fn child<'a, P: IsA>(self, child: impl Into>) -> Self { Self { - builder: self.builder.property("child", child.clone().upcast()), + builder: self + .builder + .property("child", child.into().as_ref().map(|p| p.as_ref())), } } @@ -99,11 +105,15 @@ impl ApplicationWindowBuilder { } } - pub fn default_widget(self, default_widget: &impl IsA) -> Self { + pub fn default_widget<'a, P: IsA>( + self, + default_widget: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("default-widget", default_widget.clone().upcast()), + builder: self.builder.property( + "default-widget", + default_widget.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -127,9 +137,11 @@ impl ApplicationWindowBuilder { } } - pub fn display(self, display: &impl IsA) -> Self { + pub fn display<'a, P: IsA>(self, display: impl Into>) -> Self { Self { - builder: self.builder.property("display", display.clone().upcast()), + builder: self + .builder + .property("display", display.into().as_ref().map(|p| p.as_ref())), } } @@ -139,11 +151,12 @@ impl ApplicationWindowBuilder { } } - pub fn focus_widget(self, focus_widget: &impl IsA) -> Self { + pub fn focus_widget<'a, P: IsA>(self, focus_widget: impl Into>) -> Self { Self { - builder: self - .builder - .property("focus-widget", focus_widget.clone().upcast()), + builder: self.builder.property( + "focus-widget", + focus_widget.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -169,7 +182,7 @@ impl ApplicationWindowBuilder { } } - pub fn icon_name(self, icon_name: impl Into) -> Self { + pub fn icon_name<'a>(self, icon_name: impl Into>) -> Self { Self { builder: self.builder.property("icon-name", icon_name.into()), } @@ -201,13 +214,13 @@ impl ApplicationWindowBuilder { } } - pub fn startup_id(self, startup_id: impl Into) -> Self { + pub fn startup_id<'a>(self, startup_id: impl Into>) -> Self { Self { builder: self.builder.property("startup-id", startup_id.into()), } } - pub fn title(self, title: impl Into) -> Self { + pub fn title<'a>(self, title: impl Into>) -> Self { Self { builder: self.builder.property("title", title.into()), } @@ -215,17 +228,23 @@ impl ApplicationWindowBuilder { #[cfg(feature = "v4_6")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))] - pub fn titlebar(self, titlebar: &impl IsA) -> Self { + pub fn titlebar<'a, P: IsA>(self, titlebar: impl Into>) -> Self { Self { - builder: self.builder.property("titlebar", titlebar.clone().upcast()), + builder: self + .builder + .property("titlebar", titlebar.into().as_ref().map(|p| p.as_ref())), } } - pub fn transient_for(self, transient_for: &impl IsA) -> Self { + pub fn transient_for<'a, P: IsA>( + self, + transient_for: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("transient-for", transient_for.clone().upcast()), + builder: self.builder.property( + "transient-for", + transient_for.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -247,15 +266,15 @@ impl ApplicationWindowBuilder { } } - pub fn css_name(self, css_name: impl Into) -> Self { + pub fn css_name<'a>(self, css_name: impl Into>) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } - pub fn cursor(self, cursor: &gdk::Cursor) -> Self { + pub fn cursor<'a>(self, cursor: impl Into>) -> Self { Self { - builder: self.builder.property("cursor", cursor.clone()), + builder: self.builder.property("cursor", cursor.into()), } } @@ -301,11 +320,15 @@ impl ApplicationWindowBuilder { } } - pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { + pub fn layout_manager<'a, P: IsA>( + self, + layout_manager: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("layout-manager", layout_manager.clone().upcast()), + builder: self.builder.property( + "layout-manager", + layout_manager.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -333,7 +356,7 @@ impl ApplicationWindowBuilder { } } - pub fn name(self, name: impl Into) -> Self { + pub fn name<'a>(self, name: impl Into>) -> Self { Self { builder: self.builder.property("name", name.into()), } @@ -363,7 +386,7 @@ impl ApplicationWindowBuilder { } } - pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { + pub fn tooltip_markup<'a>(self, tooltip_markup: impl Into>) -> Self { Self { builder: self .builder @@ -371,7 +394,7 @@ impl ApplicationWindowBuilder { } } - pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { + pub fn tooltip_text<'a>(self, tooltip_text: impl Into>) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } @@ -451,11 +474,11 @@ pub trait ApplicationWindowExt: IsA + 'static { } #[doc(alias = "gtk_application_window_set_help_overlay")] - fn set_help_overlay(&self, help_overlay: Option<&ShortcutsWindow>) { + fn set_help_overlay<'a>(&self, help_overlay: impl Into>) { unsafe { ffi::gtk_application_window_set_help_overlay( self.as_ref().to_glib_none().0, - help_overlay.to_glib_none().0, + help_overlay.into().to_glib_none().0, ); } } diff --git a/gtk4/src/auto/aspect_frame.rs b/gtk4/src/auto/aspect_frame.rs index bbf8c91fa25b..b5b5ef23ebbe 100644 --- a/gtk4/src/auto/aspect_frame.rs +++ b/gtk4/src/auto/aspect_frame.rs @@ -78,11 +78,11 @@ impl AspectFrame { #[doc(alias = "gtk_aspect_frame_set_child")] #[doc(alias = "child")] - pub fn set_child(&self, child: Option<&impl IsA>) { + pub fn set_child<'a, P: IsA>(&self, child: impl Into>) { unsafe { ffi::gtk_aspect_frame_set_child( self.to_glib_none().0, - child.map(|p| p.as_ref()).to_glib_none().0, + child.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } @@ -257,9 +257,11 @@ impl AspectFrameBuilder { } } - pub fn child(self, child: &impl IsA) -> Self { + pub fn child<'a, P: IsA>(self, child: impl Into>) -> Self { Self { - builder: self.builder.property("child", child.clone().upcast()), + builder: self + .builder + .property("child", child.into().as_ref().map(|p| p.as_ref())), } } @@ -305,15 +307,15 @@ impl AspectFrameBuilder { } } - pub fn css_name(self, css_name: impl Into) -> Self { + pub fn css_name<'a>(self, css_name: impl Into>) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } - pub fn cursor(self, cursor: &gdk::Cursor) -> Self { + pub fn cursor<'a>(self, cursor: impl Into>) -> Self { Self { - builder: self.builder.property("cursor", cursor.clone()), + builder: self.builder.property("cursor", cursor.into()), } } @@ -359,11 +361,15 @@ impl AspectFrameBuilder { } } - pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { + pub fn layout_manager<'a, P: IsA>( + self, + layout_manager: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("layout-manager", layout_manager.clone().upcast()), + builder: self.builder.property( + "layout-manager", + layout_manager.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -391,7 +397,7 @@ impl AspectFrameBuilder { } } - pub fn name(self, name: impl Into) -> Self { + pub fn name<'a>(self, name: impl Into>) -> Self { Self { builder: self.builder.property("name", name.into()), } @@ -421,7 +427,7 @@ impl AspectFrameBuilder { } } - pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { + pub fn tooltip_markup<'a>(self, tooltip_markup: impl Into>) -> Self { Self { builder: self .builder @@ -429,7 +435,7 @@ impl AspectFrameBuilder { } } - pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { + pub fn tooltip_text<'a>(self, tooltip_text: impl Into>) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } diff --git a/gtk4/src/auto/assistant.rs b/gtk4/src/auto/assistant.rs index 9323ff2d84c1..4cc9d691f150 100644 --- a/gtk4/src/auto/assistant.rs +++ b/gtk4/src/auto/assistant.rs @@ -486,17 +486,23 @@ impl AssistantBuilder { } } - pub fn application(self, application: &impl IsA) -> Self { + pub fn application<'a, P: IsA>( + self, + application: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("application", application.clone().upcast()), + builder: self.builder.property( + "application", + application.into().as_ref().map(|p| p.as_ref()), + ), } } - pub fn child(self, child: &impl IsA) -> Self { + pub fn child<'a, P: IsA>(self, child: impl Into>) -> Self { Self { - builder: self.builder.property("child", child.clone().upcast()), + builder: self + .builder + .property("child", child.into().as_ref().map(|p| p.as_ref())), } } @@ -512,11 +518,15 @@ impl AssistantBuilder { } } - pub fn default_widget(self, default_widget: &impl IsA) -> Self { + pub fn default_widget<'a, P: IsA>( + self, + default_widget: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("default-widget", default_widget.clone().upcast()), + builder: self.builder.property( + "default-widget", + default_widget.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -540,9 +550,11 @@ impl AssistantBuilder { } } - pub fn display(self, display: &impl IsA) -> Self { + pub fn display<'a, P: IsA>(self, display: impl Into>) -> Self { Self { - builder: self.builder.property("display", display.clone().upcast()), + builder: self + .builder + .property("display", display.into().as_ref().map(|p| p.as_ref())), } } @@ -552,11 +564,12 @@ impl AssistantBuilder { } } - pub fn focus_widget(self, focus_widget: &impl IsA) -> Self { + pub fn focus_widget<'a, P: IsA>(self, focus_widget: impl Into>) -> Self { Self { - builder: self - .builder - .property("focus-widget", focus_widget.clone().upcast()), + builder: self.builder.property( + "focus-widget", + focus_widget.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -582,7 +595,7 @@ impl AssistantBuilder { } } - pub fn icon_name(self, icon_name: impl Into) -> Self { + pub fn icon_name<'a>(self, icon_name: impl Into>) -> Self { Self { builder: self.builder.property("icon-name", icon_name.into()), } @@ -614,13 +627,13 @@ impl AssistantBuilder { } } - pub fn startup_id(self, startup_id: impl Into) -> Self { + pub fn startup_id<'a>(self, startup_id: impl Into>) -> Self { Self { builder: self.builder.property("startup-id", startup_id.into()), } } - pub fn title(self, title: impl Into) -> Self { + pub fn title<'a>(self, title: impl Into>) -> Self { Self { builder: self.builder.property("title", title.into()), } @@ -628,17 +641,23 @@ impl AssistantBuilder { #[cfg(feature = "v4_6")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_6")))] - pub fn titlebar(self, titlebar: &impl IsA) -> Self { + pub fn titlebar<'a, P: IsA>(self, titlebar: impl Into>) -> Self { Self { - builder: self.builder.property("titlebar", titlebar.clone().upcast()), + builder: self + .builder + .property("titlebar", titlebar.into().as_ref().map(|p| p.as_ref())), } } - pub fn transient_for(self, transient_for: &impl IsA) -> Self { + pub fn transient_for<'a, P: IsA>( + self, + transient_for: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("transient-for", transient_for.clone().upcast()), + builder: self.builder.property( + "transient-for", + transient_for.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -660,15 +679,15 @@ impl AssistantBuilder { } } - pub fn css_name(self, css_name: impl Into) -> Self { + pub fn css_name<'a>(self, css_name: impl Into>) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } - pub fn cursor(self, cursor: &gdk::Cursor) -> Self { + pub fn cursor<'a>(self, cursor: impl Into>) -> Self { Self { - builder: self.builder.property("cursor", cursor.clone()), + builder: self.builder.property("cursor", cursor.into()), } } @@ -714,11 +733,15 @@ impl AssistantBuilder { } } - pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { + pub fn layout_manager<'a, P: IsA>( + self, + layout_manager: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("layout-manager", layout_manager.clone().upcast()), + builder: self.builder.property( + "layout-manager", + layout_manager.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -746,7 +769,7 @@ impl AssistantBuilder { } } - pub fn name(self, name: impl Into) -> Self { + pub fn name<'a>(self, name: impl Into>) -> Self { Self { builder: self.builder.property("name", name.into()), } @@ -776,7 +799,7 @@ impl AssistantBuilder { } } - pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { + pub fn tooltip_markup<'a>(self, tooltip_markup: impl Into>) -> Self { Self { builder: self .builder @@ -784,7 +807,7 @@ impl AssistantBuilder { } } - pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { + pub fn tooltip_text<'a>(self, tooltip_text: impl Into>) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } diff --git a/gtk4/src/auto/assistant_page.rs b/gtk4/src/auto/assistant_page.rs index cd6befbe54b5..554ffadb911f 100644 --- a/gtk4/src/auto/assistant_page.rs +++ b/gtk4/src/auto/assistant_page.rs @@ -57,8 +57,8 @@ impl AssistantPage { } #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")] - pub fn set_title(&self, title: Option<&str>) { - ObjectExt::set_property(self, "title", title) + pub fn set_title<'a>(&self, title: impl Into>) { + ObjectExt::set_property(self, "title", title.into()) } #[cfg_attr(feature = "v4_10", deprecated = "Since 4.10")] diff --git a/gtk4/src/auto/at_context.rs b/gtk4/src/auto/at_context.rs index 34e79926e6f4..cc2ea42fe75c 100644 --- a/gtk4/src/auto/at_context.rs +++ b/gtk4/src/auto/at_context.rs @@ -62,8 +62,8 @@ impl ATContext { ObjectExt::property(self, "display") } - pub fn set_display>(&self, display: Option<&P>) { - ObjectExt::set_property(self, "display", display) + pub fn set_display<'a, P: IsA>(&self, display: impl Into>) { + ObjectExt::set_property(self, "display", display.into().as_ref().map(|p| p.as_ref())) } #[doc(alias = "state-change")] diff --git a/gtk4/src/auto/bookmark_list.rs b/gtk4/src/auto/bookmark_list.rs index 57acb0a13bc7..ca18853411f1 100644 --- a/gtk4/src/auto/bookmark_list.rs +++ b/gtk4/src/auto/bookmark_list.rs @@ -21,15 +21,15 @@ glib::wrapper! { impl BookmarkList { #[doc(alias = "gtk_bookmark_list_new")] - pub fn new( + pub fn new<'a>( filename: Option>, - attributes: Option<&str>, + attributes: impl Into>, ) -> BookmarkList { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::gtk_bookmark_list_new( filename.as_ref().map(|p| p.as_ref()).to_glib_none().0, - attributes.to_glib_none().0, + attributes.into().to_glib_none().0, )) } } @@ -54,11 +54,11 @@ impl BookmarkList { #[doc(alias = "gtk_bookmark_list_set_attributes")] #[doc(alias = "attributes")] - pub fn set_attributes(&self, attributes: Option<&str>) { + pub fn set_attributes<'a>(&self, attributes: impl Into>) { unsafe { ffi::gtk_bookmark_list_set_attributes( self.to_glib_none().0, - attributes.to_glib_none().0, + attributes.into().to_glib_none().0, ); } } diff --git a/gtk4/src/auto/bool_filter.rs b/gtk4/src/auto/bool_filter.rs index 4856234c9e0f..52690dc9d148 100644 --- a/gtk4/src/auto/bool_filter.rs +++ b/gtk4/src/auto/bool_filter.rs @@ -141,11 +141,11 @@ impl BoolFilterBuilder { } } - pub fn expression(self, expression: impl AsRef) -> Self { + pub fn expression(self, expression: Option>) -> Self { Self { builder: self .builder - .property("expression", expression.as_ref().clone()), + .property("expression", expression.as_ref().map(|p| p.as_ref())), } } diff --git a/gtk4/src/auto/box_.rs b/gtk4/src/auto/box_.rs index cb16f488c261..0d627738bb54 100644 --- a/gtk4/src/auto/box_.rs +++ b/gtk4/src/auto/box_.rs @@ -110,15 +110,15 @@ impl BoxBuilder { } } - pub fn css_name(self, css_name: impl Into) -> Self { + pub fn css_name<'a>(self, css_name: impl Into>) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } - pub fn cursor(self, cursor: &gdk::Cursor) -> Self { + pub fn cursor<'a>(self, cursor: impl Into>) -> Self { Self { - builder: self.builder.property("cursor", cursor.clone()), + builder: self.builder.property("cursor", cursor.into()), } } @@ -164,11 +164,15 @@ impl BoxBuilder { } } - pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { + pub fn layout_manager<'a, P: IsA>( + self, + layout_manager: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("layout-manager", layout_manager.clone().upcast()), + builder: self.builder.property( + "layout-manager", + layout_manager.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -196,7 +200,7 @@ impl BoxBuilder { } } - pub fn name(self, name: impl Into) -> Self { + pub fn name<'a>(self, name: impl Into>) -> Self { Self { builder: self.builder.property("name", name.into()), } @@ -226,7 +230,7 @@ impl BoxBuilder { } } - pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { + pub fn tooltip_markup<'a>(self, tooltip_markup: impl Into>) -> Self { Self { builder: self .builder @@ -234,7 +238,7 @@ impl BoxBuilder { } } - pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { + pub fn tooltip_text<'a>(self, tooltip_text: impl Into>) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } @@ -336,12 +340,16 @@ pub trait BoxExt: IsA + 'static { } #[doc(alias = "gtk_box_insert_child_after")] - fn insert_child_after(&self, child: &impl IsA, sibling: Option<&impl IsA>) { + fn insert_child_after<'a, P: IsA>( + &self, + child: &impl IsA, + sibling: impl Into>, + ) { unsafe { ffi::gtk_box_insert_child_after( self.as_ref().to_glib_none().0, child.as_ref().to_glib_none().0, - sibling.map(|p| p.as_ref()).to_glib_none().0, + sibling.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } @@ -367,12 +375,16 @@ pub trait BoxExt: IsA + 'static { } #[doc(alias = "gtk_box_reorder_child_after")] - fn reorder_child_after(&self, child: &impl IsA, sibling: Option<&impl IsA>) { + fn reorder_child_after<'a, P: IsA>( + &self, + child: &impl IsA, + sibling: impl Into>, + ) { unsafe { ffi::gtk_box_reorder_child_after( self.as_ref().to_glib_none().0, child.as_ref().to_glib_none().0, - sibling.map(|p| p.as_ref()).to_glib_none().0, + sibling.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } diff --git a/gtk4/src/auto/builder.rs b/gtk4/src/auto/builder.rs index 9bf1e521d604..a8ad214978c3 100644 --- a/gtk4/src/auto/builder.rs +++ b/gtk4/src/auto/builder.rs @@ -160,11 +160,11 @@ impl Builder { } #[doc(alias = "gtk_builder_create_closure")] - pub fn create_closure( + pub fn create_closure<'a, P: IsA>( &self, function_name: &str, flags: BuilderClosureFlags, - object: Option<&impl IsA>, + object: impl Into>, ) -> Result, glib::Error> { unsafe { let mut error = std::ptr::null_mut(); @@ -172,7 +172,7 @@ impl Builder { self.to_glib_none().0, function_name.to_glib_none().0, flags.into_glib(), - object.map(|p| p.as_ref()).to_glib_none().0, + object.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, &mut error, ); if error.is_null() { @@ -261,31 +261,42 @@ impl Builder { #[doc(alias = "gtk_builder_set_current_object")] #[doc(alias = "current-object")] - pub fn set_current_object(&self, current_object: Option<&impl IsA>) { + pub fn set_current_object<'a, P: IsA>( + &self, + current_object: impl Into>, + ) { unsafe { ffi::gtk_builder_set_current_object( self.to_glib_none().0, - current_object.map(|p| p.as_ref()).to_glib_none().0, + current_object + .into() + .as_ref() + .map(|p| p.as_ref()) + .to_glib_none() + .0, ); } } #[doc(alias = "gtk_builder_set_scope")] #[doc(alias = "scope")] - pub fn set_scope(&self, scope: Option<&impl IsA>) { + pub fn set_scope<'a, P: IsA>(&self, scope: impl Into>) { unsafe { ffi::gtk_builder_set_scope( self.to_glib_none().0, - scope.map(|p| p.as_ref()).to_glib_none().0, + scope.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, ); } } #[doc(alias = "gtk_builder_set_translation_domain")] #[doc(alias = "translation-domain")] - pub fn set_translation_domain(&self, domain: Option<&str>) { + pub fn set_translation_domain<'a>(&self, domain: impl Into>) { unsafe { - ffi::gtk_builder_set_translation_domain(self.to_glib_none().0, domain.to_glib_none().0); + ffi::gtk_builder_set_translation_domain( + self.to_glib_none().0, + domain.into().to_glib_none().0, + ); } } diff --git a/gtk4/src/auto/builder_list_item_factory.rs b/gtk4/src/auto/builder_list_item_factory.rs index 2b07ec973243..645256c8439a 100644 --- a/gtk4/src/auto/builder_list_item_factory.rs +++ b/gtk4/src/auto/builder_list_item_factory.rs @@ -17,14 +17,14 @@ glib::wrapper! { impl BuilderListItemFactory { #[doc(alias = "gtk_builder_list_item_factory_new_from_bytes")] #[doc(alias = "new_from_bytes")] - pub fn from_bytes( - scope: Option<&impl IsA>, + pub fn from_bytes<'a, P: IsA>( + scope: impl Into>, bytes: &glib::Bytes, ) -> BuilderListItemFactory { assert_initialized_main_thread!(); unsafe { ListItemFactory::from_glib_full(ffi::gtk_builder_list_item_factory_new_from_bytes( - scope.map(|p| p.as_ref()).to_glib_none().0, + scope.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, bytes.to_glib_none().0, )) .unsafe_cast() @@ -33,14 +33,14 @@ impl BuilderListItemFactory { #[doc(alias = "gtk_builder_list_item_factory_new_from_resource")] #[doc(alias = "new_from_resource")] - pub fn from_resource( - scope: Option<&impl IsA>, + pub fn from_resource<'a, P: IsA>( + scope: impl Into>, resource_path: &str, ) -> BuilderListItemFactory { assert_initialized_main_thread!(); unsafe { ListItemFactory::from_glib_full(ffi::gtk_builder_list_item_factory_new_from_resource( - scope.map(|p| p.as_ref()).to_glib_none().0, + scope.into().as_ref().map(|p| p.as_ref()).to_glib_none().0, resource_path.to_glib_none().0, )) .unsafe_cast() diff --git a/gtk4/src/auto/button.rs b/gtk4/src/auto/button.rs index 538b6d4c920c..7f743d2d93a2 100644 --- a/gtk4/src/auto/button.rs +++ b/gtk4/src/auto/button.rs @@ -102,9 +102,11 @@ impl ButtonBuilder { } } - pub fn child(self, child: &impl IsA) -> Self { + pub fn child<'a, P: IsA>(self, child: impl Into>) -> Self { Self { - builder: self.builder.property("child", child.clone().upcast()), + builder: self + .builder + .property("child", child.into().as_ref().map(|p| p.as_ref())), } } @@ -114,13 +116,13 @@ impl ButtonBuilder { } } - pub fn icon_name(self, icon_name: impl Into) -> Self { + pub fn icon_name<'a>(self, icon_name: impl Into>) -> Self { Self { builder: self.builder.property("icon-name", icon_name.into()), } } - pub fn label(self, label: impl Into) -> Self { + pub fn label<'a>(self, label: impl Into>) -> Self { Self { builder: self.builder.property("label", label.into()), } @@ -150,15 +152,15 @@ impl ButtonBuilder { } } - pub fn css_name(self, css_name: impl Into) -> Self { + pub fn css_name<'a>(self, css_name: impl Into>) -> Self { Self { builder: self.builder.property("css-name", css_name.into()), } } - pub fn cursor(self, cursor: &gdk::Cursor) -> Self { + pub fn cursor<'a>(self, cursor: impl Into>) -> Self { Self { - builder: self.builder.property("cursor", cursor.clone()), + builder: self.builder.property("cursor", cursor.into()), } } @@ -204,11 +206,15 @@ impl ButtonBuilder { } } - pub fn layout_manager(self, layout_manager: &impl IsA) -> Self { + pub fn layout_manager<'a, P: IsA>( + self, + layout_manager: impl Into>, + ) -> Self { Self { - builder: self - .builder - .property("layout-manager", layout_manager.clone().upcast()), + builder: self.builder.property( + "layout-manager", + layout_manager.into().as_ref().map(|p| p.as_ref()), + ), } } @@ -236,7 +242,7 @@ impl ButtonBuilder { } } - pub fn name(self, name: impl Into) -> Self { + pub fn name<'a>(self, name: impl Into>) -> Self { Self { builder: self.builder.property("name", name.into()), } @@ -266,7 +272,7 @@ impl ButtonBuilder { } } - pub fn tooltip_markup(self, tooltip_markup: impl Into) -> Self { + pub fn tooltip_markup<'a>(self, tooltip_markup: impl Into>) -> Self { Self { builder: self .builder @@ -274,7 +280,7 @@ impl ButtonBuilder { } } - pub fn tooltip_text(self, tooltip_text: impl Into) -> Self { + pub fn tooltip_text<'a>(self, tooltip_text: impl Into>) -> Self { Self { builder: self.builder.property("tooltip-text", tooltip_text.into()), } @@ -316,17 +322,15 @@ impl ButtonBuilder { } } - pub fn action_name(self, action_name: impl Into) -> Self { + pub fn action_name<'a>(self, action_name: impl Into>) -> Self { Self { builder: self.builder.property("action-name", action_name.into()), } } - pub fn action_target(self, action_target: &glib::Variant) -> Self { + pub fn action_target<'a>(self, action_target: impl Into>) -> Self { Self { - builder: self - .builder - .property("action-target", action_target.clone()), + builder: self.builder.property("action-target", action_target.into()), } } @@ -410,11 +414,11 @@ pub trait ButtonExt: IsA