Skip to content

Commit d53f4d8

Browse files
gtk: Generate PathPaintable
1 parent 4428a73 commit d53f4d8

File tree

3 files changed

+200
-0
lines changed

3 files changed

+200
-0
lines changed

gtk4/Gir.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ generate = [
187187
"Gtk.PanDirection",
188188
"Gtk.PasswordEntry",
189189
"Gtk.PasswordEntryBuffer",
190+
"Gtk.PathPaintable",
190191
"Gtk.PickFlags",
191192
"Gtk.PolicyType",
192193
"Gtk.PopoverMenu",

gtk4/src/auto/mod.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -730,6 +730,13 @@ mod password_entry_buffer;
730730
#[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
731731
pub use self::password_entry_buffer::PasswordEntryBuffer;
732732

733+
#[cfg(feature = "v4_22")]
734+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
735+
mod path_paintable;
736+
#[cfg(feature = "v4_22")]
737+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
738+
pub use self::path_paintable::PathPaintable;
739+
733740
mod picture;
734741
pub use self::picture::Picture;
735742

@@ -1755,6 +1762,9 @@ pub(crate) mod builders {
17551762
#[cfg(feature = "v4_4")]
17561763
#[cfg_attr(docsrs, doc(cfg(feature = "v4_4")))]
17571764
pub use super::password_entry_buffer::PasswordEntryBufferBuilder;
1765+
#[cfg(feature = "v4_22")]
1766+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
1767+
pub use super::path_paintable::PathPaintableBuilder;
17581768
pub use super::picture::PictureBuilder;
17591769
pub use super::popover::PopoverBuilder;
17601770
pub use super::popover_menu::PopoverMenuBuilder;

gtk4/src/auto/path_paintable.rs

Lines changed: 189 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,189 @@
1+
// This file was generated by gir (https://github.com/gtk-rs/gir)
2+
// from gir-files (https://github.com/gtk-rs/gir-files)
3+
// DO NOT EDIT
4+
5+
use crate::{ffi, SymbolicPaintable};
6+
use glib::{
7+
prelude::*,
8+
signal::{connect_raw, SignalHandlerId},
9+
translate::*,
10+
};
11+
use std::boxed::Box as Box_;
12+
13+
glib::wrapper! {
14+
#[doc(alias = "GtkPathPaintable")]
15+
pub struct PathPaintable(Object<ffi::GtkPathPaintable, ffi::GtkPathPaintableClass>) @implements gdk::Paintable, SymbolicPaintable;
16+
17+
match fn {
18+
type_ => || ffi::gtk_path_paintable_get_type(),
19+
}
20+
}
21+
22+
impl PathPaintable {
23+
#[doc(alias = "gtk_path_paintable_new_from_bytes")]
24+
#[doc(alias = "new_from_bytes")]
25+
pub fn from_bytes(bytes: &glib::Bytes) -> Result<PathPaintable, glib::Error> {
26+
assert_initialized_main_thread!();
27+
unsafe {
28+
let mut error = std::ptr::null_mut();
29+
let ret = ffi::gtk_path_paintable_new_from_bytes(bytes.to_glib_none().0, &mut error);
30+
if error.is_null() {
31+
Ok(from_glib_full(ret))
32+
} else {
33+
Err(from_glib_full(error))
34+
}
35+
}
36+
}
37+
38+
#[doc(alias = "gtk_path_paintable_new_from_resource")]
39+
#[doc(alias = "new_from_resource")]
40+
pub fn from_resource(path: &str) -> PathPaintable {
41+
assert_initialized_main_thread!();
42+
unsafe {
43+
from_glib_full(ffi::gtk_path_paintable_new_from_resource(
44+
path.to_glib_none().0,
45+
))
46+
}
47+
}
48+
49+
// rustdoc-stripper-ignore-next
50+
/// Creates a new builder-pattern struct instance to construct [`PathPaintable`] objects.
51+
///
52+
/// This method returns an instance of [`PathPaintableBuilder`](crate::builders::PathPaintableBuilder) which can be used to create [`PathPaintable`] objects.
53+
pub fn builder() -> PathPaintableBuilder {
54+
PathPaintableBuilder::new()
55+
}
56+
57+
#[doc(alias = "gtk_path_paintable_get_max_state")]
58+
#[doc(alias = "get_max_state")]
59+
pub fn max_state(&self) -> u32 {
60+
unsafe { ffi::gtk_path_paintable_get_max_state(self.to_glib_none().0) }
61+
}
62+
63+
#[doc(alias = "gtk_path_paintable_get_state")]
64+
#[doc(alias = "get_state")]
65+
pub fn state(&self) -> u32 {
66+
unsafe { ffi::gtk_path_paintable_get_state(self.to_glib_none().0) }
67+
}
68+
69+
#[doc(alias = "gtk_path_paintable_get_weight")]
70+
#[doc(alias = "get_weight")]
71+
pub fn weight(&self) -> f32 {
72+
unsafe { ffi::gtk_path_paintable_get_weight(self.to_glib_none().0) }
73+
}
74+
75+
#[doc(alias = "gtk_path_paintable_set_state")]
76+
#[doc(alias = "state")]
77+
pub fn set_state(&self, state: u32) {
78+
unsafe {
79+
ffi::gtk_path_paintable_set_state(self.to_glib_none().0, state);
80+
}
81+
}
82+
83+
#[doc(alias = "gtk_path_paintable_set_weight")]
84+
#[doc(alias = "weight")]
85+
pub fn set_weight(&self, weight: f32) {
86+
unsafe {
87+
ffi::gtk_path_paintable_set_weight(self.to_glib_none().0, weight);
88+
}
89+
}
90+
91+
#[cfg(feature = "v4_22")]
92+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
93+
#[doc(alias = "state")]
94+
pub fn connect_state_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
95+
unsafe extern "C" fn notify_state_trampoline<F: Fn(&PathPaintable) + 'static>(
96+
this: *mut ffi::GtkPathPaintable,
97+
_param_spec: glib::ffi::gpointer,
98+
f: glib::ffi::gpointer,
99+
) {
100+
let f: &F = &*(f as *const F);
101+
f(&from_glib_borrow(this))
102+
}
103+
unsafe {
104+
let f: Box_<F> = Box_::new(f);
105+
connect_raw(
106+
self.as_ptr() as *mut _,
107+
c"notify::state".as_ptr() as *const _,
108+
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
109+
notify_state_trampoline::<F> as *const (),
110+
)),
111+
Box_::into_raw(f),
112+
)
113+
}
114+
}
115+
116+
#[cfg(feature = "v4_22")]
117+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
118+
#[doc(alias = "weight")]
119+
pub fn connect_weight_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
120+
unsafe extern "C" fn notify_weight_trampoline<F: Fn(&PathPaintable) + 'static>(
121+
this: *mut ffi::GtkPathPaintable,
122+
_param_spec: glib::ffi::gpointer,
123+
f: glib::ffi::gpointer,
124+
) {
125+
let f: &F = &*(f as *const F);
126+
f(&from_glib_borrow(this))
127+
}
128+
unsafe {
129+
let f: Box_<F> = Box_::new(f);
130+
connect_raw(
131+
self.as_ptr() as *mut _,
132+
c"notify::weight".as_ptr() as *const _,
133+
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
134+
notify_weight_trampoline::<F> as *const (),
135+
)),
136+
Box_::into_raw(f),
137+
)
138+
}
139+
}
140+
}
141+
142+
// rustdoc-stripper-ignore-next
143+
/// A [builder-pattern] type to construct [`PathPaintable`] objects.
144+
///
145+
/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
146+
#[must_use = "The builder must be built to be used"]
147+
pub struct PathPaintableBuilder {
148+
builder: glib::object::ObjectBuilder<'static, PathPaintable>,
149+
}
150+
151+
impl PathPaintableBuilder {
152+
fn new() -> Self {
153+
Self {
154+
builder: glib::object::Object::builder(),
155+
}
156+
}
157+
158+
#[cfg(feature = "v4_22")]
159+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
160+
pub fn resource(self, resource: impl Into<glib::GString>) -> Self {
161+
Self {
162+
builder: self.builder.property("resource", resource.into()),
163+
}
164+
}
165+
166+
#[cfg(feature = "v4_22")]
167+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
168+
pub fn state(self, state: u32) -> Self {
169+
Self {
170+
builder: self.builder.property("state", state),
171+
}
172+
}
173+
174+
#[cfg(feature = "v4_22")]
175+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_22")))]
176+
pub fn weight(self, weight: f32) -> Self {
177+
Self {
178+
builder: self.builder.property("weight", weight),
179+
}
180+
}
181+
182+
// rustdoc-stripper-ignore-next
183+
/// Build the [`PathPaintable`].
184+
#[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
185+
pub fn build(self) -> PathPaintable {
186+
assert_initialized_main_thread!();
187+
self.builder.build()
188+
}
189+
}

0 commit comments

Comments
 (0)