diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 64db297cdc5a..1bff00bbc41d 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -49,7 +49,7 @@ jobs: conf: - { name: "gtk4", - features: "v4_20,xml_validation,blueprint", + features: "v4_22,xml_validation,blueprint", test_sys: false, } - { name: "gsk4", features: "v4_20,broadway,vulkan", test_sys: true } @@ -140,6 +140,7 @@ jobs: profile: minimal toolchain: stable override: true + components: rustfmt - run: git submodule update --checkout - run: python3 ./generator.py --yes ./ - run: git diff --exit-code @@ -157,6 +158,7 @@ jobs: profile: minimal toolchain: stable override: true + components: rustfmt - run: git submodule update --checkout - run: cargo install rustdoc-stripper - run: python3 generator.py --embed-docs diff --git a/gdk4-macos/src/auto/versions.txt b/gdk4-macos/src/auto/versions.txt index 14eea57bb513..a9408cdf7100 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 @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gdk4-macos/sys/versions.txt b/gdk4-macos/sys/versions.txt index 14eea57bb513..a9408cdf7100 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 @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gdk4-wayland/src/auto/versions.txt b/gdk4-wayland/src/auto/versions.txt index 14eea57bb513..a9408cdf7100 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 @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gdk4-wayland/sys/versions.txt b/gdk4-wayland/sys/versions.txt index 14eea57bb513..a9408cdf7100 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 @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gdk4-win32/src/auto/versions.txt b/gdk4-win32/src/auto/versions.txt index 14eea57bb513..a9408cdf7100 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 @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gdk4-win32/sys/versions.txt b/gdk4-win32/sys/versions.txt index 14eea57bb513..a9408cdf7100 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 @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gdk4-x11/src/auto/versions.txt b/gdk4-x11/src/auto/versions.txt index 14eea57bb513..a9408cdf7100 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 @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gdk4-x11/sys/versions.txt b/gdk4-x11/sys/versions.txt index 14eea57bb513..a9408cdf7100 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 @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gdk4/src/auto/surface.rs b/gdk4/src/auto/surface.rs index c8f8cbf728a4..47c57bac08c0 100644 --- a/gdk4/src/auto/surface.rs +++ b/gdk4/src/auto/surface.rs @@ -249,7 +249,7 @@ pub trait SurfaceExt: IsA + 'static { } #[doc(alias = "gdk_surface_set_input_region")] - fn set_input_region(&self, region: &cairo::Region) { + fn set_input_region(&self, region: Option<&cairo::Region>) { unsafe { ffi::gdk_surface_set_input_region( self.as_ref().to_glib_none().0, diff --git a/gdk4/src/auto/versions.txt b/gdk4/src/auto/versions.txt index 14eea57bb513..a9408cdf7100 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 @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gdk4/sys/versions.txt b/gdk4/sys/versions.txt index 14eea57bb513..a9408cdf7100 100644 --- a/gdk4/sys/versions.txt +++ b/gdk4/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gir b/gir index 7047e1b433e2..be9aa145267c 160000 --- a/gir +++ b/gir @@ -1 +1 @@ -Subproject commit 7047e1b433e2ea39d96b25ae3242a2a780d2f59a +Subproject commit be9aa145267cb915b3c79c4ae6d896beecc061ee diff --git a/gir-files b/gir-files index 1490bcc19dc8..e121d92cee84 160000 --- a/gir-files +++ b/gir-files @@ -1 +1 @@ -Subproject commit 1490bcc19dc80accb62a7ebc5d75c2dd49c386d0 +Subproject commit e121d92cee84f498c5d69611326b5b17208db067 diff --git a/gsk4/src/auto/versions.txt b/gsk4/src/auto/versions.txt index 14eea57bb513..a9408cdf7100 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 @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gsk4/sys/versions.txt b/gsk4/sys/versions.txt index 14eea57bb513..a9408cdf7100 100644 --- a/gsk4/sys/versions.txt +++ b/gsk4/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gtk4/Cargo.toml b/gtk4/Cargo.toml index 0fb277eed1cc..da1fe8e6a735 100644 --- a/gtk4/Cargo.toml +++ b/gtk4/Cargo.toml @@ -27,6 +27,7 @@ v4_14 = ["gtk4-sys/v4_14", "v4_12", "gdk/v4_14", "gsk/v4_14"] v4_16 = ["gtk4-sys/v4_16", "v4_14", "gdk/v4_16", "gsk/v4_16"] v4_18 = ["gtk4-sys/v4_18", "gdk/v4_18", "v4_16"] v4_20 = ["gtk4-sys/v4_20", "gdk/v4_20", "gsk/v4_20", "v4_18"] +v4_22 = ["gtk4-sys/v4_22", "v4_20"] gio_v2_80 = ["gio/v2_80"] xml_validation = ["gtk4-macros/xml_validation"] blueprint = ["gtk4-macros/blueprint"] diff --git a/gtk4/Gir.toml b/gtk4/Gir.toml index d7f2f50074db..9148770b99da 100644 --- a/gtk4/Gir.toml +++ b/gtk4/Gir.toml @@ -187,6 +187,7 @@ generate = [ "Gtk.PanDirection", "Gtk.PasswordEntry", "Gtk.PasswordEntryBuffer", + "Gtk.PathPaintable", "Gtk.PickFlags", "Gtk.PolicyType", "Gtk.PopoverMenu", diff --git a/gtk4/README.md b/gtk4/README.md index 454a268b6a59..777e0a68e80f 100644 --- a/gtk4/README.md +++ b/gtk4/README.md @@ -182,6 +182,7 @@ gtk = { git = "https://github.com/gtk-rs/gtk4-rs.git", package = "gtk4" } | Feature | Description | | --- | ----------- | +| `v4_22` | Enable the new APIs part of GTK 4.22 | | `v4_20` | Enable the new APIs part of GTK 4.20 | | `v4_18` | Enable the new APIs part of GTK 4.18 | | `v4_16` | Enable the new APIs part of GTK 4.16 | diff --git a/gtk4/src/auto/enums.rs b/gtk4/src/auto/enums.rs index 66e1769147ec..62299b989a6b 100644 --- a/gtk4/src/auto/enums.rs +++ b/gtk4/src/auto/enums.rs @@ -11320,6 +11320,10 @@ pub enum SymbolicColor { Warning, #[doc(alias = "GTK_SYMBOLIC_COLOR_SUCCESS")] Success, + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + #[doc(alias = "GTK_SYMBOLIC_COLOR_ACCENT")] + Accent, #[doc(hidden)] __Unknown(i32), } @@ -11337,6 +11341,8 @@ impl IntoGlib for SymbolicColor { Self::Error => ffi::GTK_SYMBOLIC_COLOR_ERROR, Self::Warning => ffi::GTK_SYMBOLIC_COLOR_WARNING, Self::Success => ffi::GTK_SYMBOLIC_COLOR_SUCCESS, + #[cfg(feature = "v4_22")] + Self::Accent => ffi::GTK_SYMBOLIC_COLOR_ACCENT, Self::__Unknown(value) => value, } } @@ -11355,6 +11361,8 @@ impl FromGlib for SymbolicColor { ffi::GTK_SYMBOLIC_COLOR_ERROR => Self::Error, ffi::GTK_SYMBOLIC_COLOR_WARNING => Self::Warning, ffi::GTK_SYMBOLIC_COLOR_SUCCESS => Self::Success, + #[cfg(feature = "v4_22")] + ffi::GTK_SYMBOLIC_COLOR_ACCENT => Self::Accent, value => Self::__Unknown(value), } } diff --git a/gtk4/src/auto/im_context.rs b/gtk4/src/auto/im_context.rs index 87cca6e6adbe..057bc3feb773 100644 --- a/gtk4/src/auto/im_context.rs +++ b/gtk4/src/auto/im_context.rs @@ -316,6 +316,41 @@ pub trait IMContextExt: IsA + 'static { } } + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + #[doc(alias = "invalid-composition")] + fn connect_invalid_composition bool + 'static>( + &self, + f: F, + ) -> SignalHandlerId { + unsafe extern "C" fn invalid_composition_trampoline< + P: IsA, + F: Fn(&P, &str) -> bool + 'static, + >( + this: *mut ffi::GtkIMContext, + str: *mut std::ffi::c_char, + f: glib::ffi::gpointer, + ) -> glib::ffi::gboolean { + let f: &F = &*(f as *const F); + f( + IMContext::from_glib_borrow(this).unsafe_cast_ref(), + &glib::GString::from_glib_borrow(str), + ) + .into_glib() + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + c"invalid-composition".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + invalid_composition_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + #[doc(alias = "preedit-changed")] fn connect_preedit_changed(&self, f: F) -> SignalHandlerId { unsafe extern "C" fn preedit_changed_trampoline, F: Fn(&P) + 'static>( diff --git a/gtk4/src/auto/mod.rs b/gtk4/src/auto/mod.rs index e3f0038965aa..de129ab3842e 100644 --- a/gtk4/src/auto/mod.rs +++ b/gtk4/src/auto/mod.rs @@ -730,6 +730,13 @@ mod password_entry_buffer; #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))] pub use self::password_entry_buffer::PasswordEntryBuffer; +#[cfg(feature = "v4_22")] +#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] +mod path_paintable; +#[cfg(feature = "v4_22")] +#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] +pub use self::path_paintable::PathPaintable; + mod picture; pub use self::picture::Picture; @@ -1755,6 +1762,9 @@ pub(crate) mod builders { #[cfg(feature = "v4_4")] #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))] pub use super::password_entry_buffer::PasswordEntryBufferBuilder; + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub use super::path_paintable::PathPaintableBuilder; pub use super::picture::PictureBuilder; pub use super::popover::PopoverBuilder; pub use super::popover_menu::PopoverMenuBuilder; diff --git a/gtk4/src/auto/path_paintable.rs b/gtk4/src/auto/path_paintable.rs new file mode 100644 index 000000000000..c0fbb9840c64 --- /dev/null +++ b/gtk4/src/auto/path_paintable.rs @@ -0,0 +1,189 @@ +// This file was generated by gir (https://github.com/gtk-rs/gir) +// from gir-files (https://github.com/gtk-rs/gir-files) +// DO NOT EDIT + +use crate::{ffi, SymbolicPaintable}; +use glib::{ + prelude::*, + signal::{connect_raw, SignalHandlerId}, + translate::*, +}; +use std::boxed::Box as Box_; + +glib::wrapper! { + #[doc(alias = "GtkPathPaintable")] + pub struct PathPaintable(Object) @implements gdk::Paintable, SymbolicPaintable; + + match fn { + type_ => || ffi::gtk_path_paintable_get_type(), + } +} + +impl PathPaintable { + #[doc(alias = "gtk_path_paintable_new_from_bytes")] + #[doc(alias = "new_from_bytes")] + pub fn from_bytes(bytes: &glib::Bytes) -> Result { + assert_initialized_main_thread!(); + unsafe { + let mut error = std::ptr::null_mut(); + let ret = ffi::gtk_path_paintable_new_from_bytes(bytes.to_glib_none().0, &mut error); + if error.is_null() { + Ok(from_glib_full(ret)) + } else { + Err(from_glib_full(error)) + } + } + } + + #[doc(alias = "gtk_path_paintable_new_from_resource")] + #[doc(alias = "new_from_resource")] + pub fn from_resource(path: &str) -> PathPaintable { + assert_initialized_main_thread!(); + unsafe { + from_glib_full(ffi::gtk_path_paintable_new_from_resource( + path.to_glib_none().0, + )) + } + } + + // rustdoc-stripper-ignore-next + /// Creates a new builder-pattern struct instance to construct [`PathPaintable`] objects. + /// + /// This method returns an instance of [`PathPaintableBuilder`](crate::builders::PathPaintableBuilder) which can be used to create [`PathPaintable`] objects. + pub fn builder() -> PathPaintableBuilder { + PathPaintableBuilder::new() + } + + #[doc(alias = "gtk_path_paintable_get_max_state")] + #[doc(alias = "get_max_state")] + pub fn max_state(&self) -> u32 { + unsafe { ffi::gtk_path_paintable_get_max_state(self.to_glib_none().0) } + } + + #[doc(alias = "gtk_path_paintable_get_state")] + #[doc(alias = "get_state")] + pub fn state(&self) -> u32 { + unsafe { ffi::gtk_path_paintable_get_state(self.to_glib_none().0) } + } + + #[doc(alias = "gtk_path_paintable_get_weight")] + #[doc(alias = "get_weight")] + pub fn weight(&self) -> f32 { + unsafe { ffi::gtk_path_paintable_get_weight(self.to_glib_none().0) } + } + + #[doc(alias = "gtk_path_paintable_set_state")] + #[doc(alias = "state")] + pub fn set_state(&self, state: u32) { + unsafe { + ffi::gtk_path_paintable_set_state(self.to_glib_none().0, state); + } + } + + #[doc(alias = "gtk_path_paintable_set_weight")] + #[doc(alias = "weight")] + pub fn set_weight(&self, weight: f32) { + unsafe { + ffi::gtk_path_paintable_set_weight(self.to_glib_none().0, weight); + } + } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + #[doc(alias = "state")] + pub fn connect_state_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_state_trampoline( + this: *mut ffi::GtkPathPaintable, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + c"notify::state".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_state_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + #[doc(alias = "weight")] + pub fn connect_weight_notify(&self, f: F) -> SignalHandlerId { + unsafe extern "C" fn notify_weight_trampoline( + this: *mut ffi::GtkPathPaintable, + _param_spec: glib::ffi::gpointer, + f: glib::ffi::gpointer, + ) { + let f: &F = &*(f as *const F); + f(&from_glib_borrow(this)) + } + unsafe { + let f: Box_ = Box_::new(f); + connect_raw( + self.as_ptr() as *mut _, + c"notify::weight".as_ptr() as *const _, + Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>( + notify_weight_trampoline:: as *const (), + )), + Box_::into_raw(f), + ) + } + } +} + +// rustdoc-stripper-ignore-next +/// A [builder-pattern] type to construct [`PathPaintable`] objects. +/// +/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html +#[must_use = "The builder must be built to be used"] +pub struct PathPaintableBuilder { + builder: glib::object::ObjectBuilder<'static, PathPaintable>, +} + +impl PathPaintableBuilder { + fn new() -> Self { + Self { + builder: glib::object::Object::builder(), + } + } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub fn resource(self, resource: impl Into) -> Self { + Self { + builder: self.builder.property("resource", resource.into()), + } + } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub fn state(self, state: u32) -> Self { + Self { + builder: self.builder.property("state", state), + } + } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub fn weight(self, weight: f32) -> Self { + Self { + builder: self.builder.property("weight", weight), + } + } + + // rustdoc-stripper-ignore-next + /// Build the [`PathPaintable`]. + #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"] + pub fn build(self) -> PathPaintable { + assert_initialized_main_thread!(); + self.builder.build() + } +} diff --git a/gtk4/src/auto/symbolic_paintable.rs b/gtk4/src/auto/symbolic_paintable.rs index 40b5692f67ce..2597dfae78df 100644 --- a/gtk4/src/auto/symbolic_paintable.rs +++ b/gtk4/src/auto/symbolic_paintable.rs @@ -39,6 +39,31 @@ pub trait SymbolicPaintableExt: IsA + 'static { ); } } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + #[doc(alias = "gtk_symbolic_paintable_snapshot_with_weight")] + fn snapshot_with_weight( + &self, + snapshot: &impl IsA, + width: f64, + height: f64, + colors: &[gdk::RGBA], + weight: f64, + ) { + let n_colors = colors.len() as _; + unsafe { + ffi::gtk_symbolic_paintable_snapshot_with_weight( + self.as_ref().to_glib_none().0, + snapshot.as_ref().to_glib_none().0, + width, + height, + colors.to_glib_none().0, + n_colors, + weight, + ); + } + } } impl> SymbolicPaintableExt for O {} diff --git a/gtk4/src/auto/versions.txt b/gtk4/src/auto/versions.txt index 14eea57bb513..a9408cdf7100 100644 --- a/gtk4/src/auto/versions.txt +++ b/gtk4/src/auto/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84) diff --git a/gtk4/src/subclass/accessible_text.rs b/gtk4/src/subclass/accessible_text.rs index 2a8351a1d14b..f6a4a31ef797 100644 --- a/gtk4/src/subclass/accessible_text.rs +++ b/gtk4/src/subclass/accessible_text.rs @@ -57,6 +57,18 @@ pub trait AccessibleTextImpl: WidgetImpl { fn selection(&self) -> Vec { self.parent_selection() } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + fn set_caret_position(&self, position: u32) -> bool { + self.parent_set_caret_position(position) + } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + fn set_selection(&self, selection: usize, range: AccessibleTextRange) -> bool { + self.parent_set_selection(selection, range) + } } pub trait AccessibleTextImplExt: AccessibleTextImpl { @@ -314,6 +326,51 @@ pub trait AccessibleTextImplExt: AccessibleTextImpl { } } } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + fn parent_set_caret_position(&self, position: u32) -> bool { + unsafe { + let type_data = Self::type_data(); + let parent_iface = type_data.as_ref().parent_interface::() + as *const ffi::GtkAccessibleTextInterface; + + let func = (*parent_iface) + .set_caret_position + .expect("no parent \"set_caret_position\" implementation"); + + from_glib(func( + self.obj() + .unsafe_cast_ref::() + .to_glib_none() + .0, + position, + )) + } + } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + fn parent_set_selection(&self, selection: usize, range: AccessibleTextRange) -> bool { + unsafe { + let type_data = Self::type_data(); + let parent_iface = type_data.as_ref().parent_interface::() + as *const ffi::GtkAccessibleTextInterface; + + let func = (*parent_iface) + .set_selection + .expect("no parent \"set_selection\" implementation"); + + from_glib(func( + self.obj() + .unsafe_cast_ref::() + .to_glib_none() + .0, + selection, + mut_override(range.to_glib_none().0), + )) + } + } } impl AccessibleTextImplExt for T {} @@ -334,6 +391,12 @@ unsafe impl IsImplementable for AccessibleText { iface.get_extents = Some(accessible_text_get_extents::); iface.get_offset = Some(accessible_text_get_offset::); } + + #[cfg(feature = "v4_22")] + { + iface.set_caret_position = Some(accessible_text_set_caret_position::); + iface.set_selection = Some(accessible_text_set_selection::); + } } } @@ -497,7 +560,6 @@ unsafe extern "C" fn accessible_text_get_extents( } #[cfg(feature = "v4_16")] -#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))] unsafe extern "C" fn accessible_text_get_offset( accessible_text: *mut ffi::GtkAccessibleText, point: *const graphene::ffi::graphene_point_t, @@ -519,6 +581,30 @@ unsafe extern "C" fn accessible_text_get_offset( .into_glib() } +#[cfg(feature = "v4_22")] +unsafe extern "C" fn accessible_text_set_caret_position( + accessible_text: *mut ffi::GtkAccessibleText, + position: u32, +) -> glib::ffi::gboolean { + let instance = &*(accessible_text as *mut T::Instance); + let imp = instance.imp(); + + imp.set_caret_position(position).into_glib() +} + +#[cfg(feature = "v4_22")] +unsafe extern "C" fn accessible_text_set_selection( + accessible_text: *mut ffi::GtkAccessibleText, + selection: usize, + range: *mut ffi::GtkAccessibleTextRange, +) -> glib::ffi::gboolean { + let instance = &*(accessible_text as *mut T::Instance); + let imp = instance.imp(); + + imp.set_selection(selection, from_glib_none(range)) + .into_glib() +} + #[cfg(test)] mod test { use crate as gtk4; diff --git a/gtk4/src/subclass/im_context.rs b/gtk4/src/subclass/im_context.rs index a7f18415c8f1..fee7b0a51803 100644 --- a/gtk4/src/subclass/im_context.rs +++ b/gtk4/src/subclass/im_context.rs @@ -72,6 +72,11 @@ pub trait IMContextImpl: ObjectImpl + ObjectSubclass> { fn activate_osk_with_event(&self, event: Option<&gdk::Event>) -> bool { self.parent_activate_osk_with_event(event) } + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + fn invalid_composition(&self, string: &str) -> bool { + self.parent_invalid_composition(string) + } } #[allow(clippy::upper_case_acronyms)] @@ -327,6 +332,23 @@ pub trait IMContextImplExt: IMContextImpl { } } } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + fn parent_invalid_composition(&self, string: &str) -> bool { + unsafe { + let data = Self::type_data(); + let parent_class = data.as_ref().parent_class() as *mut ffi::GtkIMContextClass; + if let Some(f) = (*parent_class).invalid_composition { + from_glib(f( + self.obj().unsafe_cast_ref::().to_glib_none().0, + string.to_glib_none().0, + )) + } else { + false + } + } + } } impl IMContextImplExt for T {} @@ -364,6 +386,11 @@ unsafe impl IsSubclassable for IMContext { { klass.activate_osk_with_event = Some(im_context_activate_osk_with_event::); }; + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + { + klass.invalid_composition = Some(im_context_invalid_composition::); + }; } } @@ -538,7 +565,6 @@ unsafe extern "C" fn im_context_set_use_preedit( } #[cfg(feature = "v4_10")] -#[cfg_attr(docsrs, doc(cfg(feature = "v4_10")))] unsafe extern "C" fn im_context_activate_osk(ptr: *mut ffi::GtkIMContext) { let instance = &*(ptr as *mut T::Instance); let imp = instance.imp(); @@ -547,7 +573,6 @@ unsafe extern "C" fn im_context_activate_osk(ptr: *mut ffi::Gt } #[cfg(feature = "v4_14")] -#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))] unsafe extern "C" fn im_context_activate_osk_with_event( ptr: *mut ffi::GtkIMContext, eventptr: *mut gdk::ffi::GdkEvent, @@ -560,3 +585,15 @@ unsafe extern "C" fn im_context_activate_osk_with_event( imp.activate_osk_with_event(event.as_ref().as_ref()) .into_glib() } + +#[cfg(feature = "v4_22")] +unsafe extern "C" fn im_context_invalid_composition( + ptr: *mut ffi::GtkIMContext, + stringptr: *const libc::c_char, +) -> glib::ffi::gboolean { + let instance = &*(ptr as *mut T::Instance); + let imp = instance.imp(); + let text: Borrowed = from_glib_borrow(stringptr); + + imp.invalid_composition(&text).into_glib() +} diff --git a/gtk4/src/subclass/symbolic_paintable.rs b/gtk4/src/subclass/symbolic_paintable.rs index 166bb77893de..ceb8ff794976 100644 --- a/gtk4/src/subclass/symbolic_paintable.rs +++ b/gtk4/src/subclass/symbolic_paintable.rs @@ -19,6 +19,19 @@ pub trait SymbolicPaintableImpl: ) { self.parent_snapshot_symbolic(snapshot, width, height, colors) } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + fn snapshot_with_weight( + &self, + snapshot: &gdk::Snapshot, + width: f64, + height: f64, + colors: &[gdk::RGBA], + weight: f64, + ) { + self.parent_snapshot_with_weight(snapshot, width, height, colors, weight) + } } pub trait SymbolicPaintableImplExt: SymbolicPaintableImpl { @@ -43,8 +56,39 @@ pub trait SymbolicPaintableImplExt: SymbolicPaintableImpl { snapshot.to_glib_none().0, width, height, - colors.to_glib_none().0, + colors.as_ptr() as *const gdk::ffi::GdkRGBA, + colors.len() as _, + ) + } + } + + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + fn parent_snapshot_with_weight( + &self, + snapshot: &gdk::Snapshot, + width: f64, + height: f64, + colors: &[gdk::RGBA], + weight: f64, + ) { + unsafe { + let type_data = Self::type_data(); + let parent_iface = type_data.as_ref().parent_interface::() + as *const ffi::GtkSymbolicPaintableInterface; + + let func = (*parent_iface).snapshot_with_weight.unwrap(); + func( + self.obj() + .unsafe_cast_ref::() + .to_glib_none() + .0, + snapshot.to_glib_none().0, + width, + height, + colors.as_ptr() as *const gdk::ffi::GdkRGBA, colors.len() as _, + weight, ) } } @@ -59,6 +103,10 @@ unsafe impl IsImplementable for SymbolicPaintable { assert_initialized_main_thread!(); iface.snapshot_symbolic = Some(symbolic_paintable_snapshot_symbolic::); + #[cfg(feature = "v4_22")] + { + iface.snapshot_with_weight = Some(symbolic_paintable_snapshot_with_weight::); + } } } @@ -86,3 +134,31 @@ unsafe extern "C" fn symbolic_paintable_snapshot_symbolic( + paintable: *mut ffi::GtkSymbolicPaintable, + snapshotptr: *mut gdk::ffi::GdkSnapshot, + width: f64, + height: f64, + colors: *const gdk::ffi::GdkRGBA, + n_colors: usize, + weight: f64, +) { + let instance = &*(paintable as *mut T::Instance); + let imp = instance.imp(); + + let snapshot: Borrowed = from_glib_borrow(snapshotptr); + + imp.snapshot_with_weight( + &snapshot, + width, + height, + if n_colors == 0 { + &[] + } else { + std::slice::from_raw_parts(colors as *const gdk::RGBA, n_colors) + }, + weight, + ) +} diff --git a/gtk4/sys/Cargo.toml b/gtk4/sys/Cargo.toml index 03e242977ff9..b0ad6ce899c4 100644 --- a/gtk4/sys/Cargo.toml +++ b/gtk4/sys/Cargo.toml @@ -64,6 +64,9 @@ version = "4.18" [package.metadata.system-deps.gtk4.v4_20] version = "4.19" +[package.metadata.system-deps.gtk4.v4_22] +version = "4.21" + [package.metadata.docs.rs] rustc-args = ["--cfg", "docsrs"] rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"] @@ -83,6 +86,7 @@ v4_14 = ["v4_12"] v4_16 = ["v4_14"] v4_18 = ["v4_16"] v4_20 = ["v4_18"] +v4_22 = ["v4_20"] [dependencies] libc = "0.2" diff --git a/gtk4/sys/src/lib.rs b/gtk4/sys/src/lib.rs index c416e1af562e..5eee3b118252 100644 --- a/gtk4/sys/src/lib.rs +++ b/gtk4/sys/src/lib.rs @@ -890,6 +890,9 @@ pub const GTK_SYMBOLIC_COLOR_FOREGROUND: GtkSymbolicColor = 0; pub const GTK_SYMBOLIC_COLOR_ERROR: GtkSymbolicColor = 1; pub const GTK_SYMBOLIC_COLOR_WARNING: GtkSymbolicColor = 2; pub const GTK_SYMBOLIC_COLOR_SUCCESS: GtkSymbolicColor = 3; +#[cfg(feature = "v4_22")] +#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] +pub const GTK_SYMBOLIC_COLOR_ACCENT: GtkSymbolicColor = 4; pub type GtkSystemSetting = c_int; pub const GTK_SYSTEM_SETTING_DPI: GtkSystemSetting = 0; @@ -1527,6 +1530,15 @@ pub struct GtkAccessibleTextInterface { *mut c_uint, ) -> gboolean, >, + pub set_caret_position: + Option gboolean>, + pub set_selection: Option< + unsafe extern "C" fn( + *mut GtkAccessibleText, + size_t, + *mut GtkAccessibleTextRange, + ) -> gboolean, + >, } impl ::std::fmt::Debug for GtkAccessibleTextInterface { @@ -1540,6 +1552,8 @@ impl ::std::fmt::Debug for GtkAccessibleTextInterface { .field("get_default_attributes", &self.get_default_attributes) .field("get_extents", &self.get_extents) .field("get_offset", &self.get_offset) + .field("set_caret_position", &self.set_caret_position) + .field("set_selection", &self.set_selection) .finish() } } @@ -3533,7 +3547,8 @@ pub struct GtkIMContextClass { pub activate_osk: Option, pub activate_osk_with_event: Option gboolean>, - pub _gtk_reserved2: Option, + pub invalid_composition: + Option gboolean>, pub _gtk_reserved3: Option, pub _gtk_reserved4: Option, } @@ -3567,7 +3582,7 @@ impl ::std::fmt::Debug for GtkIMContextClass { ) .field("activate_osk", &self.activate_osk) .field("activate_osk_with_event", &self.activate_osk_with_event) - .field("_gtk_reserved2", &self._gtk_reserved2) + .field("invalid_composition", &self.invalid_composition) .field("_gtk_reserved3", &self._gtk_reserved3) .field("_gtk_reserved4", &self._gtk_reserved4) .finish() @@ -4218,6 +4233,15 @@ pub struct _GtkPasswordEntryClass { pub type GtkPasswordEntryClass = _GtkPasswordEntryClass; +#[repr(C)] +#[allow(dead_code)] +pub struct _GtkPathPaintableClass { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +pub type GtkPathPaintableClass = _GtkPathPaintableClass; + #[derive(Copy, Clone)] #[repr(C)] pub struct GtkPictureClass { @@ -4975,12 +4999,24 @@ pub struct GtkSymbolicPaintableInterface { size_t, ), >, + pub snapshot_with_weight: Option< + unsafe extern "C" fn( + *mut GtkSymbolicPaintable, + *mut gdk::GdkSnapshot, + c_double, + c_double, + *const gdk::GdkRGBA, + size_t, + c_double, + ), + >, } impl ::std::fmt::Debug for GtkSymbolicPaintableInterface { fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { f.debug_struct(&format!("GtkSymbolicPaintableInterface @ {self:p}")) .field("snapshot_symbolic", &self.snapshot_symbolic) + .field("snapshot_with_weight", &self.snapshot_with_weight) .finish() } } @@ -8377,6 +8413,20 @@ impl ::std::fmt::Debug for GtkPasswordEntryBuffer { } } +#[repr(C)] +#[allow(dead_code)] +pub struct GtkPathPaintable { + _data: [u8; 0], + _marker: core::marker::PhantomData<(*mut u8, core::marker::PhantomPinned)>, +} + +impl ::std::fmt::Debug for GtkPathPaintable { + fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + f.debug_struct(&format!("GtkPathPaintable @ {self:p}")) + .finish() + } +} + #[repr(C)] #[allow(dead_code)] pub struct GtkPicture { @@ -16768,6 +16818,37 @@ extern "C" { #[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))] pub fn gtk_password_entry_buffer_new() -> *mut GtkEntryBuffer; + //========================================================================= + // GtkPathPaintable + //========================================================================= + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub fn gtk_path_paintable_get_type() -> GType; + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub fn gtk_path_paintable_new_from_bytes( + bytes: *mut glib::GBytes, + error: *mut *mut glib::GError, + ) -> *mut GtkPathPaintable; + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub fn gtk_path_paintable_new_from_resource(path: *const c_char) -> *mut GtkPathPaintable; + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub fn gtk_path_paintable_get_max_state(self_: *mut GtkPathPaintable) -> c_uint; + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub fn gtk_path_paintable_get_state(self_: *mut GtkPathPaintable) -> c_uint; + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub fn gtk_path_paintable_get_weight(self_: *mut GtkPathPaintable) -> c_float; + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub fn gtk_path_paintable_set_state(self_: *mut GtkPathPaintable, state: c_uint); + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub fn gtk_path_paintable_set_weight(self_: *mut GtkPathPaintable, weight: c_float); + //========================================================================= // GtkPicture //========================================================================= @@ -21273,6 +21354,17 @@ extern "C" { colors: *const gdk::GdkRGBA, n_colors: size_t, ); + #[cfg(feature = "v4_22")] + #[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))] + pub fn gtk_symbolic_paintable_snapshot_with_weight( + paintable: *mut GtkSymbolicPaintable, + snapshot: *mut gdk::GdkSnapshot, + width: c_double, + height: c_double, + colors: *const gdk::GdkRGBA, + n_colors: size_t, + weight: c_double, + ); //========================================================================= // GtkTreeDragDest diff --git a/gtk4/sys/tests/abi.rs b/gtk4/sys/tests/abi.rs index 2bd619418c8d..a55d81b73954 100644 --- a/gtk4/sys/tests/abi.rs +++ b/gtk4/sys/tests/abi.rs @@ -3464,6 +3464,7 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[ ("GTK_STYLE_PROVIDER_PRIORITY_SETTINGS", "400"), ("GTK_STYLE_PROVIDER_PRIORITY_THEME", "200"), ("GTK_STYLE_PROVIDER_PRIORITY_USER", "800"), + ("(gint) GTK_SYMBOLIC_COLOR_ACCENT", "4"), ("(gint) GTK_SYMBOLIC_COLOR_ERROR", "1"), ("(gint) GTK_SYMBOLIC_COLOR_FOREGROUND", "0"), ("(gint) GTK_SYMBOLIC_COLOR_SUCCESS", "3"), diff --git a/gtk4/sys/tests/constant.c b/gtk4/sys/tests/constant.c index e74d45146f29..5cac5428f712 100644 --- a/gtk4/sys/tests/constant.c +++ b/gtk4/sys/tests/constant.c @@ -829,6 +829,7 @@ int main() { PRINT_CONSTANT(GTK_STYLE_PROVIDER_PRIORITY_SETTINGS); PRINT_CONSTANT(GTK_STYLE_PROVIDER_PRIORITY_THEME); PRINT_CONSTANT(GTK_STYLE_PROVIDER_PRIORITY_USER); + PRINT_CONSTANT((gint) GTK_SYMBOLIC_COLOR_ACCENT); PRINT_CONSTANT((gint) GTK_SYMBOLIC_COLOR_ERROR); PRINT_CONSTANT((gint) GTK_SYMBOLIC_COLOR_FOREGROUND); PRINT_CONSTANT((gint) GTK_SYMBOLIC_COLOR_SUCCESS); diff --git a/gtk4/sys/versions.txt b/gtk4/sys/versions.txt index 14eea57bb513..a9408cdf7100 100644 --- a/gtk4/sys/versions.txt +++ b/gtk4/sys/versions.txt @@ -1,2 +1,2 @@ -Generated by gir (https://github.com/gtk-rs/gir @ 7047e1b433e2) -from gir-files (https://github.com/gtk-rs/gir-files @ 1490bcc19dc8) +Generated by gir (https://github.com/gtk-rs/gir @ be9aa145267c) +from gir-files (https://github.com/gtk-rs/gir-files @ e121d92cee84)