diff --git a/gdk4/src/clipboard.rs b/gdk4/src/clipboard.rs index 4787e08d819f..49d8be7bef60 100644 --- a/gdk4/src/clipboard.rs +++ b/gdk4/src/clipboard.rs @@ -10,14 +10,11 @@ use std::ptr; impl Clipboard { #[doc(alias = "gdk_clipboard_read_async")] - pub fn read_async< - P: IsA, - Q: FnOnce(Result<(gio::InputStream, GString), glib::Error>) + 'static, - >( + pub fn read_async) + 'static>( &self, mime_types: &[&str], io_priority: glib::Priority, - cancellable: Option<&P>, + cancellable: Option<&impl IsA>, callback: Q, ) { let user_data: Box = Box::new(callback); @@ -89,10 +86,10 @@ impl Clipboard { } #[doc(alias = "gdk_clipboard_store_async")] - pub fn store_async, Q: FnOnce(Result<(), glib::Error>) + 'static>( + pub fn store_async) + 'static>( &self, io_priority: glib::Priority, - cancellable: Option<&P>, + cancellable: Option<&impl IsA>, callback: Q, ) { let user_data: Box = Box::new(callback); @@ -137,14 +134,11 @@ impl Clipboard { } #[doc(alias = "gdk_clipboard_read_value_async")] - pub fn read_value_async< - P: IsA, - Q: FnOnce(Result) + 'static, - >( + pub fn read_value_async) + 'static>( &self, type_: glib::types::Type, io_priority: glib::Priority, - cancellable: Option<&P>, + cancellable: Option<&impl IsA>, callback: Q, ) { let user_data: Box = Box::new(callback); @@ -193,12 +187,9 @@ impl Clipboard { } #[doc(alias = "gdk_clipboard_read_text_async")] - pub fn read_text_async< - P: IsA, - Q: FnOnce(Result, glib::Error>) + 'static, - >( + pub fn read_text_async, glib::Error>) + 'static>( &self, - cancellable: Option<&P>, + cancellable: Option<&impl IsA>, callback: Q, ) { let user_data: Box = Box::new(callback); @@ -244,12 +235,9 @@ impl Clipboard { } #[doc(alias = "gdk_clipboard_read_texture_async")] - pub fn read_texture_async< - P: IsA, - Q: FnOnce(Result, glib::Error>) + 'static, - >( + pub fn read_texture_async, glib::Error>) + 'static>( &self, - cancellable: Option<&P>, + cancellable: Option<&impl IsA>, callback: Q, ) { let user_data: Box = Box::new(callback); diff --git a/gdk4/src/drop.rs b/gdk4/src/drop.rs index 7f13d3e5db92..c73163d915e0 100644 --- a/gdk4/src/drop.rs +++ b/gdk4/src/drop.rs @@ -11,14 +11,11 @@ use std::ptr; impl Drop { #[doc(alias = "gdk_drop_read_async")] - pub fn read_async< - P: IsA, - Q: FnOnce(Result<(gio::InputStream, GString), glib::Error>) + 'static, - >( + pub fn read_async) + 'static>( &self, mime_types: &[&str], io_priority: glib::Priority, - cancellable: Option<&P>, + cancellable: Option<&impl IsA>, callback: Q, ) { let user_data: Box = Box::new(callback); @@ -81,14 +78,11 @@ impl Drop { } #[doc(alias = "gdk_drop_read_value_async")] - pub fn read_value_async< - P: IsA, - Q: FnOnce(Result) + 'static, - >( + pub fn read_value_async) + 'static>( &self, type_: glib::types::Type, io_priority: glib::Priority, - cancellable: Option<&P>, + cancellable: Option<&impl IsA>, callback: Q, ) { let user_data: Box = Box::new(callback); diff --git a/gdk4/src/event.rs b/gdk4/src/event.rs index 02ca952efc76..8109c57d8107 100644 --- a/gdk4/src/event.rs +++ b/gdk4/src/event.rs @@ -29,7 +29,7 @@ impl Event { #[doc(alias = "gdk_events_get_angle")] #[doc(alias = "get_angle")] - pub fn angle>(&self, event: P) -> Option { + pub fn angle(&self, event: impl AsRef) -> Option { skip_assert_initialized!(); unsafe { let mut angle = mem::MaybeUninit::uninit(); @@ -49,7 +49,7 @@ impl Event { #[doc(alias = "gdk_events_get_center")] #[doc(alias = "get_center")] - pub fn center>(&self, event: P) -> Option<(f64, f64)> { + pub fn center(&self, event: impl AsRef) -> Option<(f64, f64)> { skip_assert_initialized!(); unsafe { let mut x = mem::MaybeUninit::uninit(); @@ -72,7 +72,7 @@ impl Event { #[doc(alias = "gdk_events_get_distance")] #[doc(alias = "get_distance")] - pub fn distance>(&self, event: P) -> Option { + pub fn distance(&self, event: impl AsRef) -> Option { skip_assert_initialized!(); unsafe { let mut distance = mem::MaybeUninit::uninit(); diff --git a/gdk4/src/functions.rs b/gdk4/src/functions.rs index e223ff1764a7..f7f248591ccb 100644 --- a/gdk4/src/functions.rs +++ b/gdk4/src/functions.rs @@ -32,16 +32,12 @@ pub fn pango_layout_get_clip_region( } #[doc(alias = "gdk_content_deserialize_async")] -pub fn content_deserialize_async< - P: IsA, - Q: IsA, - R: FnOnce(Result) + Send + 'static, ->( - stream: &P, +pub fn content_deserialize_async) + Send + 'static>( + stream: &impl IsA, mime_type: &str, type_: glib::types::Type, io_priority: glib::Priority, - cancellable: Option<&Q>, + cancellable: Option<&impl IsA>, callback: R, ) { assert_initialized_main_thread!(); @@ -78,8 +74,8 @@ pub fn content_deserialize_async< } } -pub fn content_deserialize_future + Clone + 'static>( - stream: &P, +pub fn content_deserialize_future( + stream: &(impl IsA + Clone + 'static), mime_type: &str, type_: glib::types::Type, io_priority: glib::Priority, @@ -222,16 +218,12 @@ pub fn content_register_serializer< } #[doc(alias = "gdk_content_serialize_async")] -pub fn content_serialize_async< - P: IsA, - Q: IsA, - R: FnOnce(Result<(), glib::Error>) + Send + 'static, ->( - stream: &P, +pub fn content_serialize_async) + Send + 'static>( + stream: &impl IsA, mime_type: &str, value: &glib::Value, io_priority: glib::Priority, - cancellable: Option<&Q>, + cancellable: Option<&impl IsA>, callback: R, ) { assert_initialized_main_thread!(); @@ -267,8 +259,8 @@ pub fn content_serialize_async< } } -pub fn content_serialize_future + Clone + 'static>( - stream: &P, +pub fn content_serialize_future( + stream: &(impl IsA + Clone + 'static), mime_type: &str, value: &glib::Value, io_priority: glib::Priority, diff --git a/gtk4/Gir.toml b/gtk4/Gir.toml index 1a21f36c8f88..4c84305fe25b 100644 --- a/gtk4/Gir.toml +++ b/gtk4/Gir.toml @@ -55,6 +55,7 @@ generate = [ "Gtk.BuilderScope", "Gtk.ButtonsType", "Gtk.CellAreaBox", + "Gtk.CellEditable", "Gtk.CellRendererAccelMode", "Gtk.CellRendererMode", "Gtk.CellRendererPixbuf", @@ -130,6 +131,7 @@ generate = [ "Gtk.IconThemeError", "Gtk.IconViewDropPosition", "Gtk.ImageType", + "Gtk.IMContext", "Gtk.IMMulticontext", "Gtk.InputHints", "Gtk.InputPurpose", @@ -671,14 +673,6 @@ manual_traits = ["CellAreaExtManual"] pattern = "cell_[gs]et_property" manual = true [[object.function]] - name = "activate_cell" - manual = true # to handlndle gdk::Event - doc_trait_name = "CellAreaExtManual" - [[object.function]] - name = "event" - manual = true # to handlndle gdk::Event - doc_trait_name = "CellAreaExtManual" - [[object.function]] name = "apply_attributes" [[object.function.parameter]] name = "iter" @@ -705,15 +699,6 @@ name = "Gtk.CellAreaContext" status = "generate" generate_builder = false -[[object]] -name = "Gtk.CellEditable" -status = "generate" -manual_traits = ["CellEditableExtManual"] - [[object.function]] - name = "start_editing" - manual = true # to handle gdk::Event - doc_trait_name = "CellEditableExtManual" - [[object]] name = "Gtk.CellLayout" status = "generate" @@ -734,20 +719,12 @@ manual_traits = ["CellRendererExtManual"] [[object.property]] pattern = "*-set" # those properties are read only generate = ["get", "notify"] - [[object.function]] - name = "activate" - manual = true # to handle gdk::Event - doc_trait_name = "CellRendererExtManual" [[object.signal]] name = "editing-started" [[object.signal.parameter]] name = "path" transformation = "treepath" [[object.function]] - name = "start_editing" - manual = true # to handle gdk::Event - doc_trait_name = "CellRendererExtManual" - [[object.function]] name = "render" ignore = true # docs only @@ -1278,14 +1255,6 @@ status = "generate" name = "pixbuf" nullable = false -[[object]] -name = "Gtk.IMContext" -status = "generate" -manual_traits = ["IMContextExtManual"] - [[object.function]] - name = "filter_keypress" - manual = true # to handle gdk::Event - doc_trait_name = "IMContextExtManual" [[object]] name = "Gtk.IMContextSimple" @@ -1816,10 +1785,6 @@ manual_traits = ["ShortcutTriggerExtManual"] name = "compare" manual = true # complains about the trait IsA being so generic doc_trait_name = "ShortcutTriggerExtManual" - [[object.function]] - name = "trigger" - manual = true # to handle gdk::Event - doc_trait_name = "ShortcutTriggerExtManual" [[object]] name = "Gtk.SignalAction" @@ -1961,11 +1926,6 @@ status = "generate" [[object]] name = "Gtk.TextView" status = "generate" -manual_traits = ["TextViewExtManual"] - [[object.function]] - name = "im_context_filter_keypress" - manual = true # to handle gdk::Event - doc_trait_name = "TextViewExtManual" [[object.signal]] name = "extend-selection" inhibit = true diff --git a/gtk4/src/auto/cell_area.rs b/gtk4/src/auto/cell_area.rs index de7170bcf678..60ac75740807 100644 --- a/gtk4/src/auto/cell_area.rs +++ b/gtk4/src/auto/cell_area.rs @@ -50,6 +50,16 @@ pub trait CellAreaExt: 'static { edit_only: bool, ) -> bool; + #[doc(alias = "gtk_cell_area_activate_cell")] + fn activate_cell( + &self, + widget: &impl IsA, + renderer: &impl IsA, + event: impl AsRef, + cell_area: &gdk::Rectangle, + flags: CellRendererState, + ) -> bool; + #[doc(alias = "gtk_cell_area_add")] fn add(&self, renderer: &impl IsA); @@ -84,6 +94,16 @@ pub trait CellAreaExt: 'static { #[doc(alias = "gtk_cell_area_create_context")] fn create_context(&self) -> CellAreaContext; + #[doc(alias = "gtk_cell_area_event")] + fn event( + &self, + context: &impl IsA, + widget: &impl IsA, + event: impl AsRef, + cell_area: &gdk::Rectangle, + flags: CellRendererState, + ) -> i32; + #[doc(alias = "gtk_cell_area_focus")] fn focus(&self, direction: DirectionType) -> bool; @@ -297,6 +317,26 @@ impl> CellAreaExt for O { } } + fn activate_cell( + &self, + widget: &impl IsA, + renderer: &impl IsA, + event: impl AsRef, + cell_area: &gdk::Rectangle, + flags: CellRendererState, + ) -> bool { + unsafe { + from_glib(ffi::gtk_cell_area_activate_cell( + self.as_ref().to_glib_none().0, + widget.as_ref().to_glib_none().0, + renderer.as_ref().to_glib_none().0, + event.as_ref().to_glib_none().0, + cell_area.to_glib_none().0, + flags.into_glib(), + )) + } + } + fn add(&self, renderer: &impl IsA) { unsafe { ffi::gtk_cell_area_add( @@ -386,6 +426,26 @@ impl> CellAreaExt for O { } } + fn event( + &self, + context: &impl IsA, + widget: &impl IsA, + event: impl AsRef, + cell_area: &gdk::Rectangle, + flags: CellRendererState, + ) -> i32 { + unsafe { + ffi::gtk_cell_area_event( + self.as_ref().to_glib_none().0, + context.as_ref().to_glib_none().0, + widget.as_ref().to_glib_none().0, + event.as_ref().to_glib_none().0, + cell_area.to_glib_none().0, + flags.into_glib(), + ) + } + } + fn focus(&self, direction: DirectionType) -> bool { unsafe { from_glib(ffi::gtk_cell_area_focus( diff --git a/gtk4/src/auto/cell_editable.rs b/gtk4/src/auto/cell_editable.rs index 36fc2745644b..f8bb785a94ce 100644 --- a/gtk4/src/auto/cell_editable.rs +++ b/gtk4/src/auto/cell_editable.rs @@ -37,6 +37,9 @@ pub trait CellEditableExt: 'static { #[doc(alias = "gtk_cell_editable_remove_widget")] fn remove_widget(&self); + #[doc(alias = "gtk_cell_editable_start_editing")] + fn start_editing(&self, event: Option>); + #[doc(alias = "editing-canceled")] fn is_editing_canceled(&self) -> bool; @@ -66,6 +69,15 @@ impl> CellEditableExt for O { } } + fn start_editing(&self, event: Option>) { + unsafe { + ffi::gtk_cell_editable_start_editing( + self.as_ref().to_glib_none().0, + event.as_ref().map(|p| p.as_ref()).to_glib_none().0, + ); + } + } + fn is_editing_canceled(&self) -> bool { glib::ObjectExt::property(self.as_ref(), "editing-canceled") } diff --git a/gtk4/src/auto/cell_renderer.rs b/gtk4/src/auto/cell_renderer.rs index 9665c2ef9bd7..6936ef5b7a98 100644 --- a/gtk4/src/auto/cell_renderer.rs +++ b/gtk4/src/auto/cell_renderer.rs @@ -37,6 +37,17 @@ impl CellRenderer { } pub trait CellRendererExt: 'static { + #[doc(alias = "gtk_cell_renderer_activate")] + fn activate( + &self, + event: impl AsRef, + widget: &impl IsA, + path: &str, + background_area: &gdk::Rectangle, + cell_area: &gdk::Rectangle, + flags: CellRendererState, + ) -> bool; + #[doc(alias = "gtk_cell_renderer_get_aligned_area")] #[doc(alias = "get_aligned_area")] fn aligned_area( @@ -137,6 +148,17 @@ pub trait CellRendererExt: 'static { flags: CellRendererState, ); + #[doc(alias = "gtk_cell_renderer_start_editing")] + fn start_editing( + &self, + event: Option>, + widget: &impl IsA, + path: &str, + background_area: &gdk::Rectangle, + cell_area: &gdk::Rectangle, + flags: CellRendererState, + ) -> Option; + #[doc(alias = "gtk_cell_renderer_stop_editing")] fn stop_editing(&self, canceled: bool); @@ -238,6 +260,28 @@ pub trait CellRendererExt: 'static { } impl> CellRendererExt for O { + fn activate( + &self, + event: impl AsRef, + widget: &impl IsA, + path: &str, + background_area: &gdk::Rectangle, + cell_area: &gdk::Rectangle, + flags: CellRendererState, + ) -> bool { + unsafe { + from_glib(ffi::gtk_cell_renderer_activate( + self.as_ref().to_glib_none().0, + event.as_ref().to_glib_none().0, + widget.as_ref().to_glib_none().0, + path.to_glib_none().0, + background_area.to_glib_none().0, + cell_area.to_glib_none().0, + flags.into_glib(), + )) + } + } + fn aligned_area( &self, widget: &impl IsA, @@ -515,6 +559,28 @@ impl> CellRendererExt for O { } } + fn start_editing( + &self, + event: Option>, + widget: &impl IsA, + path: &str, + background_area: &gdk::Rectangle, + cell_area: &gdk::Rectangle, + flags: CellRendererState, + ) -> Option { + unsafe { + from_glib_none(ffi::gtk_cell_renderer_start_editing( + self.as_ref().to_glib_none().0, + event.as_ref().map(|p| p.as_ref()).to_glib_none().0, + widget.as_ref().to_glib_none().0, + path.to_glib_none().0, + background_area.to_glib_none().0, + cell_area.to_glib_none().0, + flags.into_glib(), + )) + } + } + fn stop_editing(&self, canceled: bool) { unsafe { ffi::gtk_cell_renderer_stop_editing( diff --git a/gtk4/src/auto/im_context.rs b/gtk4/src/auto/im_context.rs index 55fa6f1ac9d6..0967ea783163 100644 --- a/gtk4/src/auto/im_context.rs +++ b/gtk4/src/auto/im_context.rs @@ -47,6 +47,9 @@ pub trait IMContextExt: 'static { group: i32, ) -> bool; + #[doc(alias = "gtk_im_context_filter_keypress")] + fn filter_keypress(&self, event: impl AsRef) -> bool; + #[doc(alias = "gtk_im_context_focus_in")] fn focus_in(&self); @@ -165,6 +168,15 @@ impl> IMContextExt for O { } } + fn filter_keypress(&self, event: impl AsRef) -> bool { + unsafe { + from_glib(ffi::gtk_im_context_filter_keypress( + self.as_ref().to_glib_none().0, + event.as_ref().to_glib_none().0, + )) + } + } + fn focus_in(&self) { unsafe { ffi::gtk_im_context_focus_in(self.as_ref().to_glib_none().0); diff --git a/gtk4/src/auto/shortcut_trigger.rs b/gtk4/src/auto/shortcut_trigger.rs index c4d3cfd1a2c0..5a21582b6874 100644 --- a/gtk4/src/auto/shortcut_trigger.rs +++ b/gtk4/src/auto/shortcut_trigger.rs @@ -43,6 +43,9 @@ pub trait ShortcutTriggerExt: 'static { #[doc(alias = "gtk_shortcut_trigger_to_string")] #[doc(alias = "to_string")] fn to_str(&self) -> glib::GString; + + #[doc(alias = "gtk_shortcut_trigger_trigger")] + fn trigger(&self, event: impl AsRef, enable_mnemonics: bool) -> gdk::KeyMatch; } impl> ShortcutTriggerExt for O { @@ -62,4 +65,14 @@ impl> ShortcutTriggerExt for O { )) } } + + fn trigger(&self, event: impl AsRef, enable_mnemonics: bool) -> gdk::KeyMatch { + unsafe { + from_glib(ffi::gtk_shortcut_trigger_trigger( + self.as_ref().to_glib_none().0, + event.as_ref().to_glib_none().0, + enable_mnemonics.into_glib(), + )) + } + } } diff --git a/gtk4/src/auto/text_view.rs b/gtk4/src/auto/text_view.rs index a02805826732..be69471e7568 100644 --- a/gtk4/src/auto/text_view.rs +++ b/gtk4/src/auto/text_view.rs @@ -756,6 +756,9 @@ pub trait TextViewExt: 'static { #[doc(alias = "get_wrap_mode")] fn wrap_mode(&self) -> WrapMode; + #[doc(alias = "gtk_text_view_im_context_filter_keypress")] + fn im_context_filter_keypress(&self, event: impl AsRef) -> bool; + #[doc(alias = "gtk_text_view_move_mark_onscreen")] fn move_mark_onscreen(&self, mark: &impl IsA) -> bool; @@ -1371,6 +1374,15 @@ impl> TextViewExt for O { } } + fn im_context_filter_keypress(&self, event: impl AsRef) -> bool { + unsafe { + from_glib(ffi::gtk_text_view_im_context_filter_keypress( + self.as_ref().to_glib_none().0, + event.as_ref().to_glib_none().0, + )) + } + } + fn move_mark_onscreen(&self, mark: &impl IsA) -> bool { unsafe { from_glib(ffi::gtk_text_view_move_mark_onscreen( diff --git a/gtk4/src/builder.rs b/gtk4/src/builder.rs index 88d0b32e9a70..d230f0ea3749 100644 --- a/gtk4/src/builder.rs +++ b/gtk4/src/builder.rs @@ -9,7 +9,7 @@ use std::path::Path; impl Builder { #[doc(alias = "gtk_builder_new_from_file")] #[doc(alias = "new_from_file")] - pub fn from_file>(file_path: T) -> Self { + pub fn from_file(file_path: impl AsRef) -> Self { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::gtk_builder_new_from_file( @@ -45,7 +45,7 @@ impl Builder { } #[doc(alias = "gtk_builder_add_from_file")] - pub fn add_from_file>(&self, file_path: T) -> Result<(), glib::Error> { + pub fn add_from_file(&self, file_path: impl AsRef) -> Result<(), glib::Error> { unsafe { let mut error = ::std::ptr::null_mut(); ffi::gtk_builder_add_from_file( diff --git a/gtk4/src/cell_area.rs b/gtk4/src/cell_area.rs index fdb528bfbe65..ec31db7b4d5b 100644 --- a/gtk4/src/cell_area.rs +++ b/gtk4/src/cell_area.rs @@ -1,8 +1,7 @@ // Take a look at the license at the top of the repository in the LICENSE file. use crate::prelude::*; -use crate::{CellArea, CellAreaContext, CellRenderer, CellRendererState, Widget}; -use gdk::Event; +use crate::{CellArea, CellRenderer}; use glib::translate::*; use glib::{value::FromValue, IsA, ToValue}; @@ -16,52 +15,24 @@ pub trait CellAreaExtManual { properties: &[(&str, &dyn ToValue)], ); - #[doc(alias = "gtk_cell_area_activate_cell")] - fn activate_cell, Q: IsA, R: AsRef>( - &self, - widget: &P, - renderer: &Q, - event: &R, - cell_area: &gdk::Rectangle, - flags: CellRendererState, - ) -> bool; - - #[doc(alias = "gtk_cell_area_event")] - fn event, Q: IsA, R: AsRef>( - &self, - context: &P, - widget: &Q, - event: &R, - cell_area: &gdk::Rectangle, - flags: CellRendererState, - ) -> i32; - #[doc(alias = "gtk_cell_area_cell_get_valist")] #[doc(alias = "gtk_cell_area_cell_get_property")] - fn cell_get_value>( - &self, - renderer: &P, - property_name: &str, - ) -> glib::Value; + fn cell_get_value(&self, renderer: &impl IsA, property_name: &str) + -> glib::Value; // rustdoc-stripper-ignore-next /// Similar to [`Self::cell_get_value`] but panics if the value is of a different type. #[doc(alias = "gtk_cell_area_cell_get_valist")] #[doc(alias = "gtk_cell_area_cell_get_property")] - fn cell_get FromValue<'b> + 'static, P: IsA>( + fn cell_get FromValue<'b> + 'static>( &self, - renderer: &P, + renderer: &impl IsA, property_name: &str, ) -> V; #[doc(alias = "gtk_cell_area_cell_set_valist")] #[doc(alias = "gtk_cell_area_cell_set_property")] - fn cell_set>( - &self, - renderer: &P, - property_name: &str, - value: &dyn ToValue, - ); + fn cell_set(&self, renderer: &impl IsA, property_name: &str, value: &dyn ToValue); } impl> CellAreaExtManual for O { @@ -75,29 +46,10 @@ impl> CellAreaExtManual for O { self.as_ref().cell_set(renderer, property_name, *value); }); } - fn activate_cell, Q: IsA, R: AsRef>( - &self, - widget: &P, - renderer: &Q, - event: &R, - cell_area: &gdk::Rectangle, - flags: CellRendererState, - ) -> bool { - unsafe { - from_glib(ffi::gtk_cell_area_activate_cell( - self.as_ref().to_glib_none().0, - widget.as_ref().to_glib_none().0, - renderer.as_ref().to_glib_none().0, - event.as_ref().to_glib_none().0, - cell_area.to_glib_none().0, - flags.into_glib(), - )) - } - } - fn cell_get_value>( + fn cell_get_value( &self, - renderer: &P, + renderer: &impl IsA, property_name: &str, ) -> glib::Value { unsafe { @@ -121,9 +73,9 @@ impl> CellAreaExtManual for O { } } - fn cell_get FromValue<'b> + 'static, P: IsA>( + fn cell_get FromValue<'b> + 'static>( &self, - renderer: &P, + renderer: &impl IsA, property_name: &str, ) -> V { let value = self.cell_get_value(renderer, property_name); @@ -132,9 +84,9 @@ impl> CellAreaExtManual for O { .expect("Failed to get value of renderer") } - fn cell_set>( + fn cell_set( &self, - renderer: &P, + renderer: &impl IsA, property_name: &str, value: &dyn ToValue, ) { @@ -164,24 +116,4 @@ impl> CellAreaExtManual for O { ); } } - - fn event, Q: IsA, R: AsRef>( - &self, - context: &P, - widget: &Q, - event: &R, - cell_area: &gdk::Rectangle, - flags: CellRendererState, - ) -> i32 { - unsafe { - ffi::gtk_cell_area_event( - self.as_ref().to_glib_none().0, - context.as_ref().to_glib_none().0, - widget.as_ref().to_glib_none().0, - event.as_ref().to_glib_none().0, - cell_area.to_glib_none().0, - flags.into_glib(), - ) - } - } } diff --git a/gtk4/src/cell_editable.rs b/gtk4/src/cell_editable.rs deleted file mode 100644 index 98a134d95ac8..000000000000 --- a/gtk4/src/cell_editable.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -use crate::CellEditable; -use glib::translate::*; -use glib::IsA; - -pub trait CellEditableExtManual { - #[doc(alias = "gtk_cell_editable_start_editing")] - fn start_editing>(&self, event: Option<&P>); -} - -impl> CellEditableExtManual for O { - fn start_editing>(&self, event: Option<&P>) { - unsafe { - ffi::gtk_cell_editable_start_editing( - self.as_ref().to_glib_none().0, - event.map(|e| e.as_ref()).to_glib_none().0, - ); - } - } -} diff --git a/gtk4/src/cell_renderer.rs b/gtk4/src/cell_renderer.rs deleted file mode 100644 index 95154126b5f7..000000000000 --- a/gtk4/src/cell_renderer.rs +++ /dev/null @@ -1,77 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -use crate::{CellEditable, CellRenderer, CellRendererState, Widget}; -use glib::translate::*; -use glib::IsA; - -// rustdoc-stripper-ignore-next -/// Trait containing manually implemented methods of [`CellRenderer`](crate::CellRenderer). -pub trait CellRendererExtManual { - #[doc(alias = "gtk_cell_renderer_activate")] - fn activate, R: AsRef>( - &self, - event: &R, - widget: &Q, - path: &str, - background_area: &gdk::Rectangle, - cell_area: &gdk::Rectangle, - flags: CellRendererState, - ) -> bool; - - #[doc(alias = "gtk_cell_renderer_start_editing")] - fn start_editing, R: AsRef>( - &self, - event: Option<&R>, - widget: &Q, - path: &str, - background_area: &gdk::Rectangle, - cell_area: &gdk::Rectangle, - flags: CellRendererState, - ) -> Option; -} - -impl> CellRendererExtManual for O { - fn activate, R: AsRef>( - &self, - event: &R, - widget: &Q, - path: &str, - background_area: &gdk::Rectangle, - cell_area: &gdk::Rectangle, - flags: CellRendererState, - ) -> bool { - unsafe { - from_glib(ffi::gtk_cell_renderer_activate( - self.as_ref().to_glib_none().0, - event.as_ref().to_glib_none().0, - widget.as_ref().to_glib_none().0, - path.to_glib_none().0, - background_area.to_glib_none().0, - cell_area.to_glib_none().0, - flags.into_glib(), - )) - } - } - - fn start_editing, R: AsRef>( - &self, - event: Option<&R>, - widget: &Q, - path: &str, - background_area: &gdk::Rectangle, - cell_area: &gdk::Rectangle, - flags: CellRendererState, - ) -> Option { - unsafe { - from_glib_none(ffi::gtk_cell_renderer_start_editing( - self.as_ref().to_glib_none().0, - event.map(|e| e.as_ref()).to_glib_none().0, - widget.as_ref().to_glib_none().0, - path.to_glib_none().0, - background_area.to_glib_none().0, - cell_area.to_glib_none().0, - flags.into_glib(), - )) - } - } -} diff --git a/gtk4/src/closure_expression.rs b/gtk4/src/closure_expression.rs index 0036ee565eb8..ac535cac5801 100644 --- a/gtk4/src/closure_expression.rs +++ b/gtk4/src/closure_expression.rs @@ -32,12 +32,11 @@ impl ClosureExpression { } #[doc(alias = "gtk_closure_expression_new")] - pub fn with_callback( - params: impl IntoIterator>, - callback: F, - ) -> Self + pub fn with_callback(params: I, callback: F) -> Self where F: Fn(&[Value]) -> R + 'static, + I: IntoIterator, + E: AsRef, R: ValueType, { assert_initialized_main_thread!(); diff --git a/gtk4/src/directory_list.rs b/gtk4/src/directory_list.rs index 2046c8017950..d0b82cacf391 100644 --- a/gtk4/src/directory_list.rs +++ b/gtk4/src/directory_list.rs @@ -73,7 +73,7 @@ impl DirectoryListBuilder { self } - pub fn file>(mut self, file: &P) -> Self { + pub fn file(mut self, file: &impl IsA) -> Self { self.file = Some(file.clone().upcast()); self } diff --git a/gtk4/src/expression.rs b/gtk4/src/expression.rs index 9c939c1b2dde..534c35e71b10 100644 --- a/gtk4/src/expression.rs +++ b/gtk4/src/expression.rs @@ -52,7 +52,7 @@ impl Expression { } #[doc(alias = "gtk_expression_evaluate")] - pub fn evaluate>(&self, this: Option<&T>) -> Option { + pub fn evaluate(&self, this: Option<&impl IsA>) -> Option { assert_initialized_main_thread!(); unsafe { let mut value = Value::uninitialized(); diff --git a/gtk4/src/file_chooser_dialog.rs b/gtk4/src/file_chooser_dialog.rs index 43097fe43898..35f39f1d3b39 100644 --- a/gtk4/src/file_chooser_dialog.rs +++ b/gtk4/src/file_chooser_dialog.rs @@ -9,9 +9,9 @@ use std::ptr; impl FileChooserDialog { #[doc(alias = "gtk_file_chooser_dialog_new")] - pub fn new>( + pub fn new( title: Option<&str>, - parent: Option<&T>, + parent: Option<&impl IsA>, action: FileChooserAction, buttons: &[(&str, ResponseType)], ) -> Self { diff --git a/gtk4/src/im_context.rs b/gtk4/src/im_context.rs deleted file mode 100644 index 46278ca67191..000000000000 --- a/gtk4/src/im_context.rs +++ /dev/null @@ -1,24 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -use crate::IMContext; -use glib::translate::*; -use glib::IsA; - -// rustdoc-stripper-ignore-next -/// Trait containing manually implemented methods of [`IMContext`](crate::IMContext). -#[allow(clippy::upper_case_acronyms)] -pub trait IMContextExtManual { - #[doc(alias = "gtk_im_context_filter_keypress")] - fn filter_keypress>(&self, event: &R) -> bool; -} - -impl> IMContextExtManual for O { - fn filter_keypress>(&self, event: &R) -> bool { - unsafe { - from_glib(ffi::gtk_im_context_filter_keypress( - self.as_ref().to_glib_none().0, - event.as_ref().to_glib_none().0, - )) - } - } -} diff --git a/gtk4/src/im_context_simple.rs b/gtk4/src/im_context_simple.rs index 287e9a43acaf..34673cbf2b04 100644 --- a/gtk4/src/im_context_simple.rs +++ b/gtk4/src/im_context_simple.rs @@ -6,7 +6,7 @@ use std::path::Path; impl IMContextSimple { #[doc(alias = "gtk_im_context_simple_add_compose_file")] - pub fn add_compose_file>(&self, compose_file: P) { + pub fn add_compose_file(&self, compose_file: impl AsRef) { unsafe { let compose_file = compose_file.as_ref(); ffi::gtk_im_context_simple_add_compose_file( diff --git a/gtk4/src/lib.rs b/gtk4/src/lib.rs index 80d9e9d3e1fc..90203eb4b4ad 100644 --- a/gtk4/src/lib.rs +++ b/gtk4/src/lib.rs @@ -123,9 +123,7 @@ mod border; mod builder; mod builder_rust_scope; mod cell_area; -mod cell_editable; mod cell_layout; -mod cell_renderer; mod closure_expression; mod color_chooser; mod combo_box; @@ -153,7 +151,6 @@ mod font_chooser; mod functions; mod gesture_stylus; mod icon_theme; -mod im_context; mod im_context_simple; mod info_bar; mod keyval_trigger; @@ -191,7 +188,6 @@ mod spin_button; mod string_list; mod text; mod text_buffer; -mod text_view; mod tree_model; mod tree_model_filter; mod tree_path; diff --git a/gtk4/src/map_list_model.rs b/gtk4/src/map_list_model.rs index 6b47145301bd..14f6a62c2a08 100644 --- a/gtk4/src/map_list_model.rs +++ b/gtk4/src/map_list_model.rs @@ -6,7 +6,7 @@ use glib::IsA; impl MapListModel { #[doc(alias = "gtk_map_list_model_new")] - pub fn without_map_func>(model: Option<&P>) -> Self { + pub fn without_map_func(model: Option<&impl IsA>) -> Self { assert_initialized_main_thread!(); unsafe { from_glib_full(ffi::gtk_map_list_model_new( diff --git a/gtk4/src/message_dialog.rs b/gtk4/src/message_dialog.rs index 1edcc3157de8..16f5d988c773 100644 --- a/gtk4/src/message_dialog.rs +++ b/gtk4/src/message_dialog.rs @@ -9,8 +9,8 @@ use crate::{ButtonsType, DialogFlags, MessageDialog, MessageType, Widget, Window impl MessageDialog { #[doc(alias = "gtk_message_dialog_new")] - pub fn new>( - parent: Option<&T>, + pub fn new( + parent: Option<&impl IsA>, flags: DialogFlags, type_: MessageType, buttons: ButtonsType, @@ -34,8 +34,8 @@ impl MessageDialog { #[doc(alias = "gtk_message_dialog_new_with_markup")] #[doc(alias = "new_with_markup")] - pub fn with_markup>( - parent: Option<&P>, + pub fn with_markup( + parent: Option<&impl IsA>, flags: DialogFlags, type_: MessageType, buttons: ButtonsType, diff --git a/gtk4/src/notebook.rs b/gtk4/src/notebook.rs index 30a84d0aad91..8ace1447e214 100644 --- a/gtk4/src/notebook.rs +++ b/gtk4/src/notebook.rs @@ -7,10 +7,10 @@ use libc::c_int; impl Notebook { #[doc(alias = "gtk_notebook_append_page")] - pub fn append_page, U: IsA>( + pub fn append_page( &self, - child: &T, - tab_label: Option<&U>, + child: &impl IsA, + tab_label: Option<&impl IsA>, ) -> u32 { unsafe { let ret = ffi::gtk_notebook_append_page( @@ -24,17 +24,12 @@ impl Notebook { } #[doc(alias = "gtk_notebook_append_page_menu")] - pub fn append_page_menu( + pub fn append_page_menu( &self, - child: &T, - tab_label: Option<&U>, - menu_label: Option<&V>, - ) -> u32 - where - T: IsA, - U: IsA, - V: IsA, - { + child: &impl IsA, + tab_label: Option<&impl IsA>, + menu_label: Option<&impl IsA>, + ) -> u32 { unsafe { let ret = ffi::gtk_notebook_append_page_menu( self.to_glib_none().0, @@ -82,11 +77,12 @@ impl Notebook { } #[doc(alias = "gtk_notebook_insert_page")] - pub fn insert_page(&self, child: &T, tab_label: Option<&U>, position: Option) -> u32 - where - T: IsA, - U: IsA, - { + pub fn insert_page( + &self, + child: &impl IsA, + tab_label: Option<&impl IsA>, + position: Option, + ) -> u32 { unsafe { let ret = ffi::gtk_notebook_insert_page( self.to_glib_none().0, @@ -100,18 +96,13 @@ impl Notebook { } #[doc(alias = "gtk_notebook_insert_page_menu")] - pub fn insert_page_menu( + pub fn insert_page_menu( &self, - child: &T, - tab_label: Option<&U>, - menu_label: Option<&V>, + child: &impl IsA, + tab_label: Option<&impl IsA>, + menu_label: Option<&impl IsA>, position: Option, - ) -> u32 - where - T: IsA, - U: IsA, - V: IsA, - { + ) -> u32 { unsafe { let ret = ffi::gtk_notebook_insert_page_menu( self.to_glib_none().0, @@ -125,7 +116,7 @@ impl Notebook { } } #[doc(alias = "gtk_notebook_page_num")] - pub fn page_num>(&self, child: &T) -> Option { + pub fn page_num(&self, child: &impl IsA) -> Option { unsafe { let ret = ffi::gtk_notebook_page_num(self.to_glib_none().0, child.as_ref().to_glib_none().0); @@ -137,11 +128,11 @@ impl Notebook { } } #[doc(alias = "gtk_notebook_prepend_page")] - pub fn prepend_page(&self, child: &T, tab_label: Option<&U>) -> u32 - where - T: IsA, - U: IsA, - { + pub fn prepend_page( + &self, + child: &impl IsA, + tab_label: Option<&impl IsA>, + ) -> u32 { unsafe { let ret = ffi::gtk_notebook_prepend_page( self.to_glib_none().0, @@ -154,17 +145,12 @@ impl Notebook { } #[doc(alias = "gtk_notebook_prepend_page_menu")] - pub fn prepend_page_menu( + pub fn prepend_page_menu( &self, - child: &T, - tab_label: Option<&U>, - menu_label: Option<&V>, - ) -> u32 - where - T: IsA, - U: IsA, - V: IsA, - { + child: &impl IsA, + tab_label: Option<&impl IsA>, + menu_label: Option<&impl IsA>, + ) -> u32 { unsafe { let ret = ffi::gtk_notebook_prepend_page_menu( self.to_glib_none().0, @@ -188,7 +174,7 @@ impl Notebook { } #[doc(alias = "gtk_notebook_reorder_child")] - pub fn reorder_child>(&self, child: &T, position: Option) { + pub fn reorder_child(&self, child: &impl IsA, position: Option) { unsafe { ffi::gtk_notebook_reorder_child( self.to_glib_none().0, diff --git a/gtk4/src/prelude.rs b/gtk4/src/prelude.rs index 1e43511435c2..779ecd751743 100644 --- a/gtk4/src/prelude.rs +++ b/gtk4/src/prelude.rs @@ -8,9 +8,7 @@ pub use crate::auto::traits::*; pub use crate::accessible::AccessibleExtManual; pub use crate::actionable::ActionableExtManual; pub use crate::cell_area::CellAreaExtManual; -pub use crate::cell_editable::CellEditableExtManual; pub use crate::cell_layout::CellLayoutExtManual; -pub use crate::cell_renderer::CellRendererExtManual; pub use crate::color_chooser::ColorChooserExtManual; pub use crate::combo_box::ComboBoxExtManual; pub use crate::dialog::DialogExtManual; @@ -21,13 +19,11 @@ pub use crate::entry_buffer::EntryBufferExtManual; pub use crate::expression::{GObjectPropertyExpressionExt, IsExpression}; pub use crate::file_chooser::FileChooserExtManual; pub use crate::font_chooser::FontChooserExtManual; -pub use crate::im_context::IMContextExtManual; pub use crate::media_stream::MediaStreamExtManual; pub use crate::native_dialog::NativeDialogExtManual; pub use crate::scale::ScaleExtManual; pub use crate::shortcut_trigger::ShortcutTriggerExtManual; pub use crate::text_buffer::TextBufferExtManual; -pub use crate::text_view::TextViewExtManual; pub use crate::tree_model::TreeModelExtManual; pub use crate::tree_model_filter::TreeModelFilterExtManual; pub use crate::tree_sortable::TreeSortableExtManual; diff --git a/gtk4/src/shortcut_trigger.rs b/gtk4/src/shortcut_trigger.rs index 1c124ed1042a..bf13406ba96a 100644 --- a/gtk4/src/shortcut_trigger.rs +++ b/gtk4/src/shortcut_trigger.rs @@ -8,20 +8,17 @@ use glib::IsA; /// Trait containing manually implemented methods of [`ShortcutTrigger`](crate::ShortcutTrigger). pub trait ShortcutTriggerExtManual { #[doc(alias = "gtk_shortcut_trigger_compare")] - fn compare>(&self, trigger2: &P) -> std::cmp::Ordering; + fn compare(&self, trigger2: &impl IsA) -> std::cmp::Ordering; #[doc(alias = "gtk_shortcut_trigger_equal")] - fn equal>(&self, trigger2: &P) -> bool; + fn equal(&self, trigger2: &impl IsA) -> bool; #[doc(alias = "gtk_shortcut_trigger_hash")] fn hash(&self) -> u32; - - #[doc(alias = "gtk_shortcut_trigger_trigger")] - fn trigger(&self, event: &gdk::Event, enable_mnemonics: bool) -> gdk::KeyMatch; } impl> ShortcutTriggerExtManual for O { - fn compare>(&self, trigger2: &P) -> std::cmp::Ordering { + fn compare(&self, trigger2: &impl IsA) -> std::cmp::Ordering { unsafe { from_glib(ffi::gtk_shortcut_trigger_compare( ToGlibPtr::<*mut ffi::GtkShortcutTrigger>::to_glib_none(self.as_ref()).0 @@ -32,7 +29,7 @@ impl> ShortcutTriggerExtManual for O { } } - fn equal>(&self, trigger2: &P) -> bool { + fn equal(&self, trigger2: &impl IsA) -> bool { unsafe { from_glib(ffi::gtk_shortcut_trigger_equal( ToGlibPtr::<*mut ffi::GtkShortcutTrigger>::to_glib_none(self.as_ref()).0 @@ -51,14 +48,4 @@ impl> ShortcutTriggerExtManual for O { ) } } - - fn trigger(&self, event: &gdk::Event, enable_mnemonics: bool) -> gdk::KeyMatch { - unsafe { - from_glib(ffi::gtk_shortcut_trigger_trigger( - self.as_ref().to_glib_none().0, - event.to_glib_none().0, - enable_mnemonics.into_glib(), - )) - } - } } diff --git a/gtk4/src/text_view.rs b/gtk4/src/text_view.rs deleted file mode 100644 index bcc547d89733..000000000000 --- a/gtk4/src/text_view.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Take a look at the license at the top of the repository in the LICENSE file. - -use crate::TextView; -use glib::translate::*; -use glib::IsA; - -// rustdoc-stripper-ignore-next -/// Trait containing manually implemented methods of [`TextView`](crate::TextView). -pub trait TextViewExtManual { - #[doc(alias = "gtk_text_view_im_context_filter_keypress")] - fn im_context_filter_keypress>(&self, event: &R) -> bool; -} - -impl> TextViewExtManual for O { - fn im_context_filter_keypress>(&self, event: &R) -> bool { - unsafe { - from_glib(ffi::gtk_text_view_im_context_filter_keypress( - self.as_ref().to_glib_none().0, - event.as_ref().to_glib_none().0, - )) - } - } -} diff --git a/gtk4/src/tree_model_filter.rs b/gtk4/src/tree_model_filter.rs index 9666da0c2cb2..ff3582e37869 100644 --- a/gtk4/src/tree_model_filter.rs +++ b/gtk4/src/tree_model_filter.rs @@ -8,7 +8,7 @@ use crate::{TreeIter, TreeModel, TreeModelFilter, TreePath}; impl TreeModelFilter { #[doc(alias = "gtk_tree_model_filter_new")] - pub fn new>(child_model: &T, root: Option<&TreePath>) -> Self { + pub fn new(child_model: &impl IsA, root: Option<&TreePath>) -> Self { skip_assert_initialized!(); unsafe { TreeModel::from_glib_none(ffi::gtk_tree_model_filter_new( diff --git a/gtk4/src/tree_row_reference.rs b/gtk4/src/tree_row_reference.rs index 1c71e208b41b..6db20aac05dc 100644 --- a/gtk4/src/tree_row_reference.rs +++ b/gtk4/src/tree_row_reference.rs @@ -7,9 +7,9 @@ use glib::IsA; impl TreeRowReference { #[doc(alias = "gtk_tree_row_reference_reordered")] - pub fn reordered>( + pub fn reordered( &self, - proxy: &P, + proxy: &impl IsA, path: &TreePath, iter: &TreeIter, new_order: &[i32], diff --git a/gtk4/src/tree_view_column.rs b/gtk4/src/tree_view_column.rs index 4bec73f61b0c..c0d1df4500c1 100644 --- a/gtk4/src/tree_view_column.rs +++ b/gtk4/src/tree_view_column.rs @@ -91,7 +91,7 @@ impl TreeViewColumn { #[doc(alias = "gtk_tree_view_column_set_cell_data_func")] #[doc(alias = "set_cell_data_func")] - pub fn unset_cell_data_func>(&self, cell_renderer: &P) { + pub fn unset_cell_data_func(&self, cell_renderer: &impl IsA) { unsafe { ffi::gtk_tree_view_column_set_cell_data_func( self.to_glib_none().0,