Skip to content

Commit fefa565

Browse files
sdroegebilelmoussaoui
authored andcommitted
gdk: Take self by value in GLTextureBuilder for setting the color-state too
1 parent 4befb60 commit fefa565

File tree

3 files changed

+19
-54
lines changed

3 files changed

+19
-54
lines changed

gdk4/Gir.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ generate_builder = false
537537
name = "region"
538538
const = true
539539
[[object.function]]
540-
pattern = "set_(context|format|has_mipmap|height|id|update_region|update_texture|width)"
540+
pattern = "set_(color_state|context|format|has_mipmap|height|id|update_region|update_texture|width)"
541541
# Take by value and return self
542542
manual = true
543543
[[object.function]]
@@ -547,7 +547,7 @@ generate_builder = false
547547
name = "build"
548548
manual = true
549549
[[object.property]]
550-
pattern = "(context|format|has-mipmap|height|id|sync|update-region|update-texture|width)"
550+
pattern = "(color-state|context|format|has-mipmap|height|id|sync|update-region|update-texture|width)"
551551
generate = [] # ignore get/set/notify
552552

553553
[[object]]

gdk4/src/auto/gl_texture_builder.rs

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@
77
use crate::ColorState;
88
use crate::{ffi, GLContext, MemoryFormat, Texture};
99
use glib::translate::*;
10-
#[cfg(feature = "v4_16")]
11-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
12-
use glib::{
13-
prelude::*,
14-
signal::{connect_raw, SignalHandlerId},
15-
};
16-
#[cfg(feature = "v4_16")]
17-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
18-
use std::boxed::Box as Box_;
1910

2011
glib::wrapper! {
2112
#[doc(alias = "GdkGLTextureBuilder")]
@@ -116,49 +107,6 @@ impl GLTextureBuilder {
116107
pub fn width(&self) -> i32 {
117108
unsafe { ffi::gdk_gl_texture_builder_get_width(self.to_glib_none().0) }
118109
}
119-
120-
#[cfg(feature = "v4_16")]
121-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
122-
#[doc(alias = "gdk_gl_texture_builder_set_color_state")]
123-
#[doc(alias = "color-state")]
124-
pub fn set_color_state(&self, color_state: &ColorState) {
125-
unsafe {
126-
ffi::gdk_gl_texture_builder_set_color_state(
127-
self.to_glib_none().0,
128-
color_state.to_glib_none().0,
129-
);
130-
}
131-
}
132-
133-
#[cfg(feature = "v4_16")]
134-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
135-
#[doc(alias = "color-state")]
136-
pub fn connect_color_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
137-
&self,
138-
f: F,
139-
) -> SignalHandlerId {
140-
unsafe extern "C" fn notify_color_state_trampoline<
141-
F: Fn(&GLTextureBuilder) + Send + Sync + 'static,
142-
>(
143-
this: *mut ffi::GdkGLTextureBuilder,
144-
_param_spec: glib::ffi::gpointer,
145-
f: glib::ffi::gpointer,
146-
) {
147-
let f: &F = &*(f as *const F);
148-
f(&from_glib_borrow(this))
149-
}
150-
unsafe {
151-
let f: Box_<F> = Box_::new(f);
152-
connect_raw(
153-
self.as_ptr() as *mut _,
154-
c"notify::color-state".as_ptr() as *const _,
155-
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
156-
notify_color_state_trampoline::<F> as *const (),
157-
)),
158-
Box_::into_raw(f),
159-
)
160-
}
161-
}
162110
}
163111

164112
#[cfg(feature = "v4_12")]

gdk4/src/gl_texture_builder.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
use glib::{prelude::*, translate::*};
44

5+
#[cfg(feature = "v4_16")]
6+
use crate::ColorState;
57
use crate::{ffi, GLContext, GLTextureBuilder, MemoryFormat, Texture};
68

79
#[cfg(not(feature = "gl"))]
@@ -43,6 +45,21 @@ impl GLTextureBuilder {
4345
))
4446
}
4547

48+
#[cfg(feature = "v4_16")]
49+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
50+
#[doc(alias = "gdk_gl_texture_builder_set_color_state")]
51+
#[doc(alias = "color-state")]
52+
pub fn set_color_state(self, color_state: &ColorState) -> Self {
53+
unsafe {
54+
ffi::gdk_gl_texture_builder_set_color_state(
55+
self.to_glib_none().0,
56+
color_state.to_glib_none().0,
57+
);
58+
}
59+
60+
self
61+
}
62+
4663
#[doc(alias = "gdk_gl_texture_builder_set_context")]
4764
pub fn set_context(self, context: Option<&impl IsA<GLContext>>) -> Self {
4865
unsafe {

0 commit comments

Comments
 (0)