Skip to content

Commit 7c56f7a

Browse files
gtk: Generate GLArea new APIs
1 parent 13dd84d commit 7c56f7a

File tree

2 files changed

+42
-33
lines changed

2 files changed

+42
-33
lines changed

gtk4/Gir.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,7 @@ manual = [
301301
"Gdk.Event",
302302
"Gdk.EventSequence",
303303
"Gdk.FrameClock",
304+
"Gdk.GLAPI",
304305
"Gdk.GLContext",
305306
"Gdk.Gravity",
306307
"Gdk.KeyMatch",

gtk4/src/auto/gl_area.rs

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,13 @@ impl GLAreaBuilder {
6262
}
6363
}
6464

65-
// #[cfg(feature = "v4_12")]
65+
#[cfg(feature = "v4_12")]
6666
#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
67-
//pub fn allowed_apis(self, allowed_apis: /*Ignored*/gdk::GLAPI) -> Self {
68-
// Self { builder: self.builder.property("allowed-apis", allowed_apis), }
69-
//}
67+
pub fn allowed_apis(self, allowed_apis: gdk::GLAPI) -> Self {
68+
Self {
69+
builder: self.builder.property("allowed-apis", allowed_apis),
70+
}
71+
}
7072

7173
pub fn auto_render(self, auto_render: bool) -> Self {
7274
Self {
@@ -291,17 +293,17 @@ pub trait GLAreaExt: 'static {
291293
#[doc(alias = "gtk_gl_area_attach_buffers")]
292294
fn attach_buffers(&self);
293295

294-
//#[cfg(feature = "v4_12")]
295-
//#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
296-
//#[doc(alias = "gtk_gl_area_get_allowed_apis")]
297-
//#[doc(alias = "get_allowed_apis")]
298-
//fn allowed_apis(&self) -> /*Ignored*/gdk::GLAPI;
296+
#[cfg(feature = "v4_12")]
297+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
298+
#[doc(alias = "gtk_gl_area_get_allowed_apis")]
299+
#[doc(alias = "get_allowed_apis")]
300+
fn allowed_apis(&self) -> gdk::GLAPI;
299301

300-
//#[cfg(feature = "v4_12")]
301-
//#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
302-
//#[doc(alias = "gtk_gl_area_get_api")]
303-
//#[doc(alias = "get_api")]
304-
//fn api(&self) -> /*Ignored*/gdk::GLAPI;
302+
#[cfg(feature = "v4_12")]
303+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
304+
#[doc(alias = "gtk_gl_area_get_api")]
305+
#[doc(alias = "get_api")]
306+
fn api(&self) -> gdk::GLAPI;
305307

306308
#[doc(alias = "gtk_gl_area_get_auto_render")]
307309
#[doc(alias = "get_auto_render")]
@@ -339,10 +341,10 @@ pub trait GLAreaExt: 'static {
339341
#[doc(alias = "gtk_gl_area_queue_render")]
340342
fn queue_render(&self);
341343

342-
//#[cfg(feature = "v4_12")]
343-
//#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
344-
//#[doc(alias = "gtk_gl_area_set_allowed_apis")]
345-
//fn set_allowed_apis(&self, apis: /*Ignored*/gdk::GLAPI);
344+
#[cfg(feature = "v4_12")]
345+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
346+
#[doc(alias = "gtk_gl_area_set_allowed_apis")]
347+
fn set_allowed_apis(&self, apis: gdk::GLAPI);
346348

347349
#[doc(alias = "gtk_gl_area_set_auto_render")]
348350
fn set_auto_render(&self, auto_render: bool);
@@ -413,17 +415,21 @@ impl<O: IsA<GLArea>> GLAreaExt for O {
413415
}
414416
}
415417

416-
//#[cfg(feature = "v4_12")]
417-
//#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
418-
//fn allowed_apis(&self) -> /*Ignored*/gdk::GLAPI {
419-
// unsafe { TODO: call ffi:gtk_gl_area_get_allowed_apis() }
420-
//}
418+
#[cfg(feature = "v4_12")]
419+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
420+
fn allowed_apis(&self) -> gdk::GLAPI {
421+
unsafe {
422+
from_glib(ffi::gtk_gl_area_get_allowed_apis(
423+
self.as_ref().to_glib_none().0,
424+
))
425+
}
426+
}
421427

422-
//#[cfg(feature = "v4_12")]
423-
//#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
424-
//fn api(&self) -> /*Ignored*/gdk::GLAPI {
425-
// unsafe { TODO: call ffi:gtk_gl_area_get_api() }
426-
//}
428+
#[cfg(feature = "v4_12")]
429+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
430+
fn api(&self) -> gdk::GLAPI {
431+
unsafe { from_glib(ffi::gtk_gl_area_get_api(self.as_ref().to_glib_none().0)) }
432+
}
427433

428434
fn is_auto_render(&self) -> bool {
429435
unsafe {
@@ -487,11 +493,13 @@ impl<O: IsA<GLArea>> GLAreaExt for O {
487493
}
488494
}
489495

490-
//#[cfg(feature = "v4_12")]
491-
//#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
492-
//fn set_allowed_apis(&self, apis: /*Ignored*/gdk::GLAPI) {
493-
// unsafe { TODO: call ffi:gtk_gl_area_set_allowed_apis() }
494-
//}
496+
#[cfg(feature = "v4_12")]
497+
#[cfg_attr(docsrs, doc(cfg(feature = "v4_12")))]
498+
fn set_allowed_apis(&self, apis: gdk::GLAPI) {
499+
unsafe {
500+
ffi::gtk_gl_area_set_allowed_apis(self.as_ref().to_glib_none().0, apis.into_glib());
501+
}
502+
}
495503

496504
fn set_auto_render(&self, auto_render: bool) {
497505
unsafe {

0 commit comments

Comments
 (0)