Skip to content

Commit 4e32f64

Browse files
sdroegebilelmoussaoui
authored andcommitted
gdk: Take self by value in MemoryTextureBuilder for consistency
1 parent fefa565 commit 4e32f64

File tree

4 files changed

+135
-344
lines changed

4 files changed

+135
-344
lines changed

gdk4/Gir.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,13 @@ concurrency = "send+sync"
587587
[[object.function.parameter]]
588588
name = "region"
589589
const = true
590+
[[object.function]]
591+
pattern = "set_(bytes|color_state|format|height|offset|stride|stride_for_plane|update_region|update_texture|width)"
592+
# Take by value and return self
593+
manual = true
594+
[[object.property]]
595+
pattern = "(bytes|color-state|format|height|stride|update-region|update-texture|width)"
596+
generate = [] # ignore get/set/notify
590597

591598
[[object]]
592599
name = "Gdk.Monitor"

gdk4/src/auto/memory_texture_builder.rs

Lines changed: 1 addition & 344 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@
33
// DO NOT EDIT
44

55
use crate::{ffi, ColorState, MemoryFormat, Texture};
6-
use glib::{
7-
prelude::*,
8-
signal::{connect_raw, SignalHandlerId},
9-
translate::*,
10-
};
11-
use std::boxed::Box as Box_;
6+
use glib::translate::*;
127

138
glib::wrapper! {
149
#[doc(alias = "GdkMemoryTextureBuilder")]
@@ -119,344 +114,6 @@ impl MemoryTextureBuilder {
119114
pub fn width(&self) -> i32 {
120115
unsafe { ffi::gdk_memory_texture_builder_get_width(self.to_glib_none().0) }
121116
}
122-
123-
#[doc(alias = "gdk_memory_texture_builder_set_bytes")]
124-
#[doc(alias = "bytes")]
125-
pub fn set_bytes(&self, bytes: Option<&glib::Bytes>) {
126-
unsafe {
127-
ffi::gdk_memory_texture_builder_set_bytes(
128-
self.to_glib_none().0,
129-
bytes.to_glib_none().0,
130-
);
131-
}
132-
}
133-
134-
#[doc(alias = "gdk_memory_texture_builder_set_color_state")]
135-
#[doc(alias = "color-state")]
136-
pub fn set_color_state(&self, color_state: Option<&ColorState>) {
137-
unsafe {
138-
ffi::gdk_memory_texture_builder_set_color_state(
139-
self.to_glib_none().0,
140-
color_state.to_glib_none().0,
141-
);
142-
}
143-
}
144-
145-
#[doc(alias = "gdk_memory_texture_builder_set_format")]
146-
#[doc(alias = "format")]
147-
pub fn set_format(&self, format: MemoryFormat) {
148-
unsafe {
149-
ffi::gdk_memory_texture_builder_set_format(self.to_glib_none().0, format.into_glib());
150-
}
151-
}
152-
153-
#[doc(alias = "gdk_memory_texture_builder_set_height")]
154-
#[doc(alias = "height")]
155-
pub fn set_height(&self, height: i32) {
156-
unsafe {
157-
ffi::gdk_memory_texture_builder_set_height(self.to_glib_none().0, height);
158-
}
159-
}
160-
161-
#[cfg(feature = "v4_20")]
162-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
163-
#[doc(alias = "gdk_memory_texture_builder_set_offset")]
164-
pub fn set_offset(&self, plane: u32, offset: usize) {
165-
unsafe {
166-
ffi::gdk_memory_texture_builder_set_offset(self.to_glib_none().0, plane, offset);
167-
}
168-
}
169-
170-
#[doc(alias = "gdk_memory_texture_builder_set_stride")]
171-
#[doc(alias = "stride")]
172-
pub fn set_stride(&self, stride: usize) {
173-
unsafe {
174-
ffi::gdk_memory_texture_builder_set_stride(self.to_glib_none().0, stride);
175-
}
176-
}
177-
178-
#[cfg(feature = "v4_20")]
179-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_20")))]
180-
#[doc(alias = "gdk_memory_texture_builder_set_stride_for_plane")]
181-
pub fn set_stride_for_plane(&self, plane: u32, stride: usize) {
182-
unsafe {
183-
ffi::gdk_memory_texture_builder_set_stride_for_plane(
184-
self.to_glib_none().0,
185-
plane,
186-
stride,
187-
);
188-
}
189-
}
190-
191-
#[doc(alias = "gdk_memory_texture_builder_set_update_region")]
192-
#[doc(alias = "update-region")]
193-
pub fn set_update_region(&self, region: Option<&cairo::Region>) {
194-
unsafe {
195-
ffi::gdk_memory_texture_builder_set_update_region(
196-
self.to_glib_none().0,
197-
mut_override(region.to_glib_none().0),
198-
);
199-
}
200-
}
201-
202-
#[doc(alias = "gdk_memory_texture_builder_set_update_texture")]
203-
#[doc(alias = "update-texture")]
204-
pub fn set_update_texture(&self, texture: Option<&impl IsA<Texture>>) {
205-
unsafe {
206-
ffi::gdk_memory_texture_builder_set_update_texture(
207-
self.to_glib_none().0,
208-
texture.map(|p| p.as_ref()).to_glib_none().0,
209-
);
210-
}
211-
}
212-
213-
#[doc(alias = "gdk_memory_texture_builder_set_width")]
214-
#[doc(alias = "width")]
215-
pub fn set_width(&self, width: i32) {
216-
unsafe {
217-
ffi::gdk_memory_texture_builder_set_width(self.to_glib_none().0, width);
218-
}
219-
}
220-
221-
#[cfg(feature = "v4_16")]
222-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
223-
#[doc(alias = "bytes")]
224-
pub fn connect_bytes_notify<F: Fn(&Self) + Send + Sync + 'static>(
225-
&self,
226-
f: F,
227-
) -> SignalHandlerId {
228-
unsafe extern "C" fn notify_bytes_trampoline<
229-
F: Fn(&MemoryTextureBuilder) + Send + Sync + 'static,
230-
>(
231-
this: *mut ffi::GdkMemoryTextureBuilder,
232-
_param_spec: glib::ffi::gpointer,
233-
f: glib::ffi::gpointer,
234-
) {
235-
let f: &F = &*(f as *const F);
236-
f(&from_glib_borrow(this))
237-
}
238-
unsafe {
239-
let f: Box_<F> = Box_::new(f);
240-
connect_raw(
241-
self.as_ptr() as *mut _,
242-
c"notify::bytes".as_ptr() as *const _,
243-
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
244-
notify_bytes_trampoline::<F> as *const (),
245-
)),
246-
Box_::into_raw(f),
247-
)
248-
}
249-
}
250-
251-
#[cfg(feature = "v4_16")]
252-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
253-
#[doc(alias = "color-state")]
254-
pub fn connect_color_state_notify<F: Fn(&Self) + Send + Sync + 'static>(
255-
&self,
256-
f: F,
257-
) -> SignalHandlerId {
258-
unsafe extern "C" fn notify_color_state_trampoline<
259-
F: Fn(&MemoryTextureBuilder) + Send + Sync + 'static,
260-
>(
261-
this: *mut ffi::GdkMemoryTextureBuilder,
262-
_param_spec: glib::ffi::gpointer,
263-
f: glib::ffi::gpointer,
264-
) {
265-
let f: &F = &*(f as *const F);
266-
f(&from_glib_borrow(this))
267-
}
268-
unsafe {
269-
let f: Box_<F> = Box_::new(f);
270-
connect_raw(
271-
self.as_ptr() as *mut _,
272-
c"notify::color-state".as_ptr() as *const _,
273-
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
274-
notify_color_state_trampoline::<F> as *const (),
275-
)),
276-
Box_::into_raw(f),
277-
)
278-
}
279-
}
280-
281-
#[cfg(feature = "v4_16")]
282-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
283-
#[doc(alias = "format")]
284-
pub fn connect_format_notify<F: Fn(&Self) + Send + Sync + 'static>(
285-
&self,
286-
f: F,
287-
) -> SignalHandlerId {
288-
unsafe extern "C" fn notify_format_trampoline<
289-
F: Fn(&MemoryTextureBuilder) + Send + Sync + 'static,
290-
>(
291-
this: *mut ffi::GdkMemoryTextureBuilder,
292-
_param_spec: glib::ffi::gpointer,
293-
f: glib::ffi::gpointer,
294-
) {
295-
let f: &F = &*(f as *const F);
296-
f(&from_glib_borrow(this))
297-
}
298-
unsafe {
299-
let f: Box_<F> = Box_::new(f);
300-
connect_raw(
301-
self.as_ptr() as *mut _,
302-
c"notify::format".as_ptr() as *const _,
303-
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
304-
notify_format_trampoline::<F> as *const (),
305-
)),
306-
Box_::into_raw(f),
307-
)
308-
}
309-
}
310-
311-
#[cfg(feature = "v4_16")]
312-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
313-
#[doc(alias = "height")]
314-
pub fn connect_height_notify<F: Fn(&Self) + Send + Sync + 'static>(
315-
&self,
316-
f: F,
317-
) -> SignalHandlerId {
318-
unsafe extern "C" fn notify_height_trampoline<
319-
F: Fn(&MemoryTextureBuilder) + Send + Sync + 'static,
320-
>(
321-
this: *mut ffi::GdkMemoryTextureBuilder,
322-
_param_spec: glib::ffi::gpointer,
323-
f: glib::ffi::gpointer,
324-
) {
325-
let f: &F = &*(f as *const F);
326-
f(&from_glib_borrow(this))
327-
}
328-
unsafe {
329-
let f: Box_<F> = Box_::new(f);
330-
connect_raw(
331-
self.as_ptr() as *mut _,
332-
c"notify::height".as_ptr() as *const _,
333-
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
334-
notify_height_trampoline::<F> as *const (),
335-
)),
336-
Box_::into_raw(f),
337-
)
338-
}
339-
}
340-
341-
#[cfg(feature = "v4_16")]
342-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
343-
#[doc(alias = "stride")]
344-
pub fn connect_stride_notify<F: Fn(&Self) + Send + Sync + 'static>(
345-
&self,
346-
f: F,
347-
) -> SignalHandlerId {
348-
unsafe extern "C" fn notify_stride_trampoline<
349-
F: Fn(&MemoryTextureBuilder) + Send + Sync + 'static,
350-
>(
351-
this: *mut ffi::GdkMemoryTextureBuilder,
352-
_param_spec: glib::ffi::gpointer,
353-
f: glib::ffi::gpointer,
354-
) {
355-
let f: &F = &*(f as *const F);
356-
f(&from_glib_borrow(this))
357-
}
358-
unsafe {
359-
let f: Box_<F> = Box_::new(f);
360-
connect_raw(
361-
self.as_ptr() as *mut _,
362-
c"notify::stride".as_ptr() as *const _,
363-
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
364-
notify_stride_trampoline::<F> as *const (),
365-
)),
366-
Box_::into_raw(f),
367-
)
368-
}
369-
}
370-
371-
#[cfg(feature = "v4_16")]
372-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
373-
#[doc(alias = "update-region")]
374-
pub fn connect_update_region_notify<F: Fn(&Self) + Send + Sync + 'static>(
375-
&self,
376-
f: F,
377-
) -> SignalHandlerId {
378-
unsafe extern "C" fn notify_update_region_trampoline<
379-
F: Fn(&MemoryTextureBuilder) + Send + Sync + 'static,
380-
>(
381-
this: *mut ffi::GdkMemoryTextureBuilder,
382-
_param_spec: glib::ffi::gpointer,
383-
f: glib::ffi::gpointer,
384-
) {
385-
let f: &F = &*(f as *const F);
386-
f(&from_glib_borrow(this))
387-
}
388-
unsafe {
389-
let f: Box_<F> = Box_::new(f);
390-
connect_raw(
391-
self.as_ptr() as *mut _,
392-
c"notify::update-region".as_ptr() as *const _,
393-
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
394-
notify_update_region_trampoline::<F> as *const (),
395-
)),
396-
Box_::into_raw(f),
397-
)
398-
}
399-
}
400-
401-
#[cfg(feature = "v4_16")]
402-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
403-
#[doc(alias = "update-texture")]
404-
pub fn connect_update_texture_notify<F: Fn(&Self) + Send + Sync + 'static>(
405-
&self,
406-
f: F,
407-
) -> SignalHandlerId {
408-
unsafe extern "C" fn notify_update_texture_trampoline<
409-
F: Fn(&MemoryTextureBuilder) + Send + Sync + 'static,
410-
>(
411-
this: *mut ffi::GdkMemoryTextureBuilder,
412-
_param_spec: glib::ffi::gpointer,
413-
f: glib::ffi::gpointer,
414-
) {
415-
let f: &F = &*(f as *const F);
416-
f(&from_glib_borrow(this))
417-
}
418-
unsafe {
419-
let f: Box_<F> = Box_::new(f);
420-
connect_raw(
421-
self.as_ptr() as *mut _,
422-
c"notify::update-texture".as_ptr() as *const _,
423-
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
424-
notify_update_texture_trampoline::<F> as *const (),
425-
)),
426-
Box_::into_raw(f),
427-
)
428-
}
429-
}
430-
431-
#[cfg(feature = "v4_16")]
432-
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
433-
#[doc(alias = "width")]
434-
pub fn connect_width_notify<F: Fn(&Self) + Send + Sync + 'static>(
435-
&self,
436-
f: F,
437-
) -> SignalHandlerId {
438-
unsafe extern "C" fn notify_width_trampoline<
439-
F: Fn(&MemoryTextureBuilder) + Send + Sync + 'static,
440-
>(
441-
this: *mut ffi::GdkMemoryTextureBuilder,
442-
_param_spec: glib::ffi::gpointer,
443-
f: glib::ffi::gpointer,
444-
) {
445-
let f: &F = &*(f as *const F);
446-
f(&from_glib_borrow(this))
447-
}
448-
unsafe {
449-
let f: Box_<F> = Box_::new(f);
450-
connect_raw(
451-
self.as_ptr() as *mut _,
452-
c"notify::width".as_ptr() as *const _,
453-
Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
454-
notify_width_trampoline::<F> as *const (),
455-
)),
456-
Box_::into_raw(f),
457-
)
458-
}
459-
}
460117
}
461118

462119
#[cfg(feature = "v4_16")]

gdk4/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ mod grab_broken_event;
100100
mod key_event;
101101
mod keymap_key;
102102
mod keys;
103+
#[cfg(feature = "v4_16")]
104+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
105+
mod memory_texture_builder;
103106
mod motion_event;
104107
mod pad_event;
105108
mod popup_layout;

0 commit comments

Comments
 (0)