Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
features: "v4_20,xml_validation,blueprint",
test_sys: false,
}
- { name: "gsk4", features: "v4_18,broadway,vulkan", test_sys: true }
- { name: "gsk4", features: "v4_20,broadway,vulkan", test_sys: true }
- { name: "gdk4", features: "v4_20,gl", test_sys: true }
- {
name: "gdk4-wayland",
Expand Down
2 changes: 1 addition & 1 deletion gdk4-macos/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ b3d444a058cf)
from gir-files (https://github.com/gtk-rs/gir-files @ 4453f2993956)
from gir-files (https://github.com/gtk-rs/gir-files @ 5c1e490fe50a)
2 changes: 1 addition & 1 deletion gdk4-macos/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ b3d444a058cf)
from gir-files (https://github.com/gtk-rs/gir-files @ 4453f2993956)
from gir-files (https://github.com/gtk-rs/gir-files @ 5c1e490fe50a)
2 changes: 1 addition & 1 deletion gdk4-wayland/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ b3d444a058cf)
from gir-files (https://github.com/gtk-rs/gir-files @ 4453f2993956)
from gir-files (https://github.com/gtk-rs/gir-files @ 5c1e490fe50a)
2 changes: 1 addition & 1 deletion gdk4-wayland/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ b3d444a058cf)
from gir-files (https://github.com/gtk-rs/gir-files @ 4453f2993956)
from gir-files (https://github.com/gtk-rs/gir-files @ 5c1e490fe50a)
2 changes: 1 addition & 1 deletion gdk4-win32/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ b3d444a058cf)
from gir-files (https://github.com/gtk-rs/gir-files @ 4453f2993956)
from gir-files (https://github.com/gtk-rs/gir-files @ 5c1e490fe50a)
2 changes: 1 addition & 1 deletion gdk4-win32/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ b3d444a058cf)
from gir-files (https://github.com/gtk-rs/gir-files @ 4453f2993956)
from gir-files (https://github.com/gtk-rs/gir-files @ 5c1e490fe50a)
2 changes: 1 addition & 1 deletion gdk4-x11/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ b3d444a058cf)
from gir-files (https://github.com/gtk-rs/gir-files @ 4453f2993956)
from gir-files (https://github.com/gtk-rs/gir-files @ 5c1e490fe50a)
2 changes: 1 addition & 1 deletion gdk4-x11/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ b3d444a058cf)
from gir-files (https://github.com/gtk-rs/gir-files @ 4453f2993956)
from gir-files (https://github.com/gtk-rs/gir-files @ 5c1e490fe50a)
2 changes: 1 addition & 1 deletion gdk4/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ b3d444a058cf)
from gir-files (https://github.com/gtk-rs/gir-files @ 4453f2993956)
from gir-files (https://github.com/gtk-rs/gir-files @ 5c1e490fe50a)
2 changes: 1 addition & 1 deletion gdk4/sys/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ b3d444a058cf)
from gir-files (https://github.com/gtk-rs/gir-files @ 4453f2993956)
from gir-files (https://github.com/gtk-rs/gir-files @ 5c1e490fe50a)
2 changes: 1 addition & 1 deletion gir-files
Submodule gir-files updated 3 files
+92 −12 Gio-2.0.gir
+91 −0 Gsk-4.0.gir
+1 −1 Gtk-4.0.gir
1 change: 1 addition & 0 deletions gsk4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ v4_10 = ["gsk4-sys/v4_10", "gdk/v4_10", "v4_6"]
v4_14 = ["gsk4-sys/v4_14", "gdk/v4_14", "v4_10"]
v4_16 = ["gsk4-sys/v4_16", "gdk/v4_16", "v4_14"]
v4_18 = ["gsk4-sys/v4_18", "gdk/v4_18", "v4_16"]
v4_20 = ["gsk4-sys/v4_20", "gdk/v4_20", "v4_18"]

[dependencies]
gsk4-sys.workspace = true
Expand Down
4 changes: 4 additions & 0 deletions gsk4/Gir.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ generate = [
"Gsk.OutsetShadowNode",
"Gsk.PathDirection",
"Gsk.PathForeachFlags",
"Gsk.PathIntersection",
"Gsk.PathMeasure",
"Gsk.PathOperation",
"Gsk.RadialGradientNode",
Expand Down Expand Up @@ -172,6 +173,9 @@ status = "generate"
[[object.function]]
name = "foreach"
manual = true # tries to call from_glib_borrow on an enum
[[object.function]]
name = "foreach_intersection"
manual = true # tries to call from_glib_borrow on an enum

[[object]]
name = "Gsk.PathBuilder"
Expand Down
1 change: 1 addition & 0 deletions gsk4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ gsk = { git = "https://github.com/gtk-rs/gtk4-rs.git", package = "gsk4" }
| --- | ----------- |
| `vulkan` | Enable `vulkan` Renderer. Only if GTK is compiled with Vulkan support |
| `broadway` | Enable `broadway` Renderer. Only if GTK is compiled with Broadway support |
| `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 |
| `v4_14` | Enable the new APIs part of GTK 4.14 |
Expand Down
122 changes: 122 additions & 0 deletions gsk4/src/auto/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -982,6 +982,128 @@ impl From<PathDirection> for glib::Value {
}
}

#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
#[non_exhaustive]
#[doc(alias = "GskPathIntersection")]
pub enum PathIntersection {
#[doc(alias = "GSK_PATH_INTERSECTION_NONE")]
None,
#[doc(alias = "GSK_PATH_INTERSECTION_NORMAL")]
Normal,
#[doc(alias = "GSK_PATH_INTERSECTION_START")]
Start,
#[doc(alias = "GSK_PATH_INTERSECTION_END")]
End,
#[doc(hidden)]
__Unknown(i32),
}

#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
#[doc(hidden)]
impl IntoGlib for PathIntersection {
type GlibType = ffi::GskPathIntersection;

#[inline]
fn into_glib(self) -> ffi::GskPathIntersection {
match self {
Self::None => ffi::GSK_PATH_INTERSECTION_NONE,
Self::Normal => ffi::GSK_PATH_INTERSECTION_NORMAL,
Self::Start => ffi::GSK_PATH_INTERSECTION_START,
Self::End => ffi::GSK_PATH_INTERSECTION_END,
Self::__Unknown(value) => value,
}
}
}

#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
#[doc(hidden)]
impl FromGlib<ffi::GskPathIntersection> for PathIntersection {
#[inline]
unsafe fn from_glib(value: ffi::GskPathIntersection) -> Self {
skip_assert_initialized!();

match value {
ffi::GSK_PATH_INTERSECTION_NONE => Self::None,
ffi::GSK_PATH_INTERSECTION_NORMAL => Self::Normal,
ffi::GSK_PATH_INTERSECTION_START => Self::Start,
ffi::GSK_PATH_INTERSECTION_END => Self::End,
value => Self::__Unknown(value),
}
}
}

#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
impl StaticType for PathIntersection {
#[inline]
#[doc(alias = "gsk_path_intersection_get_type")]
fn static_type() -> glib::Type {
unsafe { from_glib(ffi::gsk_path_intersection_get_type()) }
}
}

#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
impl glib::HasParamSpec for PathIntersection {
type ParamSpec = glib::ParamSpecEnum;
type SetValue = Self;
type BuilderFn = fn(&str, Self) -> glib::ParamSpecEnumBuilder<Self>;

fn param_spec_builder() -> Self::BuilderFn {
Self::ParamSpec::builder_with_default
}
}

#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
impl glib::value::ValueType for PathIntersection {
type Type = Self;
}

#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
unsafe impl<'a> glib::value::FromValue<'a> for PathIntersection {
type Checker = glib::value::GenericValueTypeChecker<Self>;

#[inline]
unsafe fn from_value(value: &'a glib::Value) -> Self {
skip_assert_initialized!();
from_glib(glib::gobject_ffi::g_value_get_enum(value.to_glib_none().0))
}
}

#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
impl ToValue for PathIntersection {
#[inline]
fn to_value(&self) -> glib::Value {
let mut value = glib::Value::for_value_type::<Self>();
unsafe {
glib::gobject_ffi::g_value_set_enum(value.to_glib_none_mut().0, self.into_glib());
}
value
}

#[inline]
fn value_type(&self) -> glib::Type {
Self::static_type()
}
}

#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
impl From<PathIntersection> for glib::Value {
#[inline]
fn from(v: PathIntersection) -> Self {
skip_assert_initialized!();
ToValue::to_value(&v)
}
}

#[cfg(feature = "v4_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
#[derive(Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Clone, Copy)]
Expand Down
3 changes: 3 additions & 0 deletions gsk4/src/auto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ pub use self::enums::MaskMode;
#[cfg(feature = "v4_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
pub use self::enums::PathDirection;
#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
pub use self::enums::PathIntersection;
#[cfg(feature = "v4_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
pub use self::enums::PathOperation;
Expand Down
2 changes: 1 addition & 1 deletion gsk4/src/auto/versions.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Generated by gir (https://github.com/gtk-rs/gir @ b3d444a058cf)
from gir-files (https://github.com/gtk-rs/gir-files @ 4453f2993956)
from gir-files (https://github.com/gtk-rs/gir-files @ 5c1e490fe50a)
43 changes: 43 additions & 0 deletions gsk4/src/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
use glib::translate::*;

use crate::{ffi, Path, PathForeachFlags, PathOperation};
#[cfg(feature = "v4_20")]
use crate::{PathIntersection, PathPoint};

impl Path {
#[doc(alias = "gsk_path_foreach")]
Expand Down Expand Up @@ -37,6 +39,47 @@ impl Path {
))
}
}

#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
#[doc(alias = "gsk_path_foreach_intersection")]
pub fn foreach_intersection<
P: FnMut(&Path, &PathPoint, &Path, &PathPoint, PathIntersection) -> bool,
>(
&self,
path2: Option<&Path>,
func: P,
) -> bool {
let mut func_data: P = func;
unsafe extern "C" fn func_func<
P: FnMut(&Path, &PathPoint, &Path, &PathPoint, PathIntersection) -> bool,
>(
path1: *mut ffi::GskPath,
point1: *const ffi::GskPathPoint,
path2: *mut ffi::GskPath,
point2: *const ffi::GskPathPoint,
kind: ffi::GskPathIntersection,
user_data: glib::ffi::gpointer,
) -> glib::ffi::gboolean {
let path1 = from_glib_borrow(path1);
let point1 = from_glib_borrow(point1);
let path2 = from_glib_borrow(path2);
let point2 = from_glib_borrow(point2);
let kind = from_glib(kind);
let callback = user_data as *mut P;
(*callback)(&path1, &point1, &path2, &point2, kind).into_glib()
}
let func = Some(func_func::<P> as _);
let super_callback0: &mut P = &mut func_data;
unsafe {
from_glib(ffi::gsk_path_foreach_intersection(
self.to_glib_none().0,
path2.to_glib_none().0,
func,
super_callback0 as *mut _ as *mut _,
))
}
}
}

impl std::str::FromStr for Path {
Expand Down
4 changes: 4 additions & 0 deletions gsk4/sys/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ version = "4.16"
[package.metadata.system-deps.gtk4.v4_18]
version = "4.18"

[package.metadata.system-deps.gtk4.v4_20]
version = "4.19"

[package.metadata.docs.rs]
rustc-args = ["--cfg", "docsrs"]
rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"]
Expand All @@ -72,6 +75,7 @@ broadway = []
v4_14 = ["v4_10"]
v4_16 = ["v4_14"]
v4_18 = ["v4_16"]
v4_20 = ["v4_18"]

[dependencies]
libc = "0.2"
Expand Down
31 changes: 31 additions & 0 deletions gsk4/sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ pub const GSK_PATH_TO_START: GskPathDirection = 1;
pub const GSK_PATH_TO_END: GskPathDirection = 2;
pub const GSK_PATH_FROM_END: GskPathDirection = 3;

pub type GskPathIntersection = c_int;
pub const GSK_PATH_INTERSECTION_NONE: GskPathIntersection = 0;
pub const GSK_PATH_INTERSECTION_NORMAL: GskPathIntersection = 1;
pub const GSK_PATH_INTERSECTION_START: GskPathIntersection = 2;
pub const GSK_PATH_INTERSECTION_END: GskPathIntersection = 3;

pub type GskPathOperation = c_int;
pub const GSK_PATH_MOVE: GskPathOperation = 0;
pub const GSK_PATH_CLOSE: GskPathOperation = 1;
Expand Down Expand Up @@ -206,6 +212,16 @@ pub type GskPathForeachFunc = Option<
gpointer,
) -> gboolean,
>;
pub type GskPathIntersectionFunc = Option<
unsafe extern "C" fn(
*mut GskPath,
*const GskPathPoint,
*mut GskPath,
*const GskPathPoint,
GskPathIntersection,
gpointer,
) -> gboolean,
>;

// Records
#[cfg(feature = "broadway")]
Expand Down Expand Up @@ -1044,6 +1060,13 @@ extern "C" {
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
pub fn gsk_path_direction_get_type() -> GType;

//=========================================================================
// GskPathIntersection
//=========================================================================
#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
pub fn gsk_path_intersection_get_type() -> GType;

//=========================================================================
// GskPathOperation
//=========================================================================
Expand Down Expand Up @@ -1093,6 +1116,14 @@ extern "C" {
func: GskPathForeachFunc,
user_data: gpointer,
) -> gboolean;
#[cfg(feature = "v4_20")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
pub fn gsk_path_foreach_intersection(
path1: *mut GskPath,
path2: *mut GskPath,
func: GskPathIntersectionFunc,
user_data: gpointer,
) -> gboolean;
#[cfg(feature = "v4_14")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_14")))]
pub fn gsk_path_get_bounds(
Expand Down
11 changes: 11 additions & 0 deletions gsk4/sys/tests/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ const RUST_LAYOUTS: &[(&str, Layout)] = &[
alignment: align_of::<GskPathForeachFlags>(),
},
),
(
"GskPathIntersection",
Layout {
size: size_of::<GskPathIntersection>(),
alignment: align_of::<GskPathIntersection>(),
},
),
(
"GskPathOperation",
Layout {
Expand Down Expand Up @@ -412,6 +419,10 @@ const RUST_CONSTANTS: &[(&str, &str)] = &[
("(guint) GSK_PATH_FOREACH_ALLOW_QUAD", "1"),
("(gint) GSK_PATH_FROM_END", "3"),
("(gint) GSK_PATH_FROM_START", "0"),
("(gint) GSK_PATH_INTERSECTION_END", "3"),
("(gint) GSK_PATH_INTERSECTION_NONE", "0"),
("(gint) GSK_PATH_INTERSECTION_NORMAL", "1"),
("(gint) GSK_PATH_INTERSECTION_START", "2"),
("(gint) GSK_PATH_LINE", "2"),
("(gint) GSK_PATH_MOVE", "0"),
("(gint) GSK_PATH_QUAD", "3"),
Expand Down
4 changes: 4 additions & 0 deletions gsk4/sys/tests/constant.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ int main() {
PRINT_CONSTANT((guint) GSK_PATH_FOREACH_ALLOW_QUAD);
PRINT_CONSTANT((gint) GSK_PATH_FROM_END);
PRINT_CONSTANT((gint) GSK_PATH_FROM_START);
PRINT_CONSTANT((gint) GSK_PATH_INTERSECTION_END);
PRINT_CONSTANT((gint) GSK_PATH_INTERSECTION_NONE);
PRINT_CONSTANT((gint) GSK_PATH_INTERSECTION_NORMAL);
PRINT_CONSTANT((gint) GSK_PATH_INTERSECTION_START);
PRINT_CONSTANT((gint) GSK_PATH_LINE);
PRINT_CONSTANT((gint) GSK_PATH_MOVE);
PRINT_CONSTANT((gint) GSK_PATH_QUAD);
Expand Down
Loading
Loading