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::Align; 6 use crate::Buildable; 7 use crate::Container; 8 use crate::Widget; 9 use glib::object::Cast; 10 use glib::object::IsA; 11 use glib::signal::connect_raw; 12 use glib::signal::SignalHandlerId; 13 use glib::translate::*; 14 use glib::StaticType; 15 use glib::ToValue; 16 use std::boxed::Box as Box_; 17 use std::fmt; 18 use std::mem; 19 use std::mem::transmute; 20 21 glib::wrapper! { 22 #[doc(alias = "GtkGLArea")] 23 pub struct GLArea(Object<ffi::GtkGLArea, ffi::GtkGLAreaClass>) @extends Widget, @implements Buildable; 24 25 match fn { 26 type_ => || ffi::gtk_gl_area_get_type(), 27 } 28 } 29 30 impl GLArea { 31 #[doc(alias = "gtk_gl_area_new")] new() -> GLArea32 pub fn new() -> GLArea { 33 assert_initialized_main_thread!(); 34 unsafe { Widget::from_glib_none(ffi::gtk_gl_area_new()).unsafe_cast() } 35 } 36 37 // rustdoc-stripper-ignore-next 38 /// Creates a new builder-pattern struct instance to construct [`GLArea`] objects. 39 /// 40 /// This method returns an instance of [`GLAreaBuilder`] which can be used to create [`GLArea`] objects. builder() -> GLAreaBuilder41 pub fn builder() -> GLAreaBuilder { 42 GLAreaBuilder::default() 43 } 44 } 45 46 impl Default for GLArea { default() -> Self47 fn default() -> Self { 48 Self::new() 49 } 50 } 51 52 #[derive(Clone, Default)] 53 // rustdoc-stripper-ignore-next 54 /// A [builder-pattern] type to construct [`GLArea`] objects. 55 /// 56 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 57 pub struct GLAreaBuilder { 58 auto_render: Option<bool>, 59 has_alpha: Option<bool>, 60 has_depth_buffer: Option<bool>, 61 has_stencil_buffer: Option<bool>, 62 #[cfg(any(feature = "v3_22", feature = "dox"))] 63 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] 64 use_es: Option<bool>, 65 app_paintable: Option<bool>, 66 can_default: Option<bool>, 67 can_focus: Option<bool>, 68 events: Option<gdk::EventMask>, 69 expand: Option<bool>, 70 #[cfg(any(feature = "v3_20", feature = "dox"))] 71 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 72 focus_on_click: Option<bool>, 73 halign: Option<Align>, 74 has_default: Option<bool>, 75 has_focus: Option<bool>, 76 has_tooltip: Option<bool>, 77 height_request: Option<i32>, 78 hexpand: Option<bool>, 79 hexpand_set: Option<bool>, 80 is_focus: Option<bool>, 81 margin: Option<i32>, 82 margin_bottom: Option<i32>, 83 margin_end: Option<i32>, 84 margin_start: Option<i32>, 85 margin_top: Option<i32>, 86 name: Option<String>, 87 no_show_all: Option<bool>, 88 opacity: Option<f64>, 89 parent: Option<Container>, 90 receives_default: Option<bool>, 91 sensitive: Option<bool>, 92 tooltip_markup: Option<String>, 93 tooltip_text: Option<String>, 94 valign: Option<Align>, 95 vexpand: Option<bool>, 96 vexpand_set: Option<bool>, 97 visible: Option<bool>, 98 width_request: Option<i32>, 99 } 100 101 impl GLAreaBuilder { 102 // rustdoc-stripper-ignore-next 103 /// Create a new [`GLAreaBuilder`]. new() -> Self104 pub fn new() -> Self { 105 Self::default() 106 } 107 108 // rustdoc-stripper-ignore-next 109 /// Build the [`GLArea`]. build(self) -> GLArea110 pub fn build(self) -> GLArea { 111 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 112 if let Some(ref auto_render) = self.auto_render { 113 properties.push(("auto-render", auto_render)); 114 } 115 if let Some(ref has_alpha) = self.has_alpha { 116 properties.push(("has-alpha", has_alpha)); 117 } 118 if let Some(ref has_depth_buffer) = self.has_depth_buffer { 119 properties.push(("has-depth-buffer", has_depth_buffer)); 120 } 121 if let Some(ref has_stencil_buffer) = self.has_stencil_buffer { 122 properties.push(("has-stencil-buffer", has_stencil_buffer)); 123 } 124 #[cfg(any(feature = "v3_22", feature = "dox"))] 125 if let Some(ref use_es) = self.use_es { 126 properties.push(("use-es", use_es)); 127 } 128 if let Some(ref app_paintable) = self.app_paintable { 129 properties.push(("app-paintable", app_paintable)); 130 } 131 if let Some(ref can_default) = self.can_default { 132 properties.push(("can-default", can_default)); 133 } 134 if let Some(ref can_focus) = self.can_focus { 135 properties.push(("can-focus", can_focus)); 136 } 137 if let Some(ref events) = self.events { 138 properties.push(("events", events)); 139 } 140 if let Some(ref expand) = self.expand { 141 properties.push(("expand", expand)); 142 } 143 #[cfg(any(feature = "v3_20", feature = "dox"))] 144 if let Some(ref focus_on_click) = self.focus_on_click { 145 properties.push(("focus-on-click", focus_on_click)); 146 } 147 if let Some(ref halign) = self.halign { 148 properties.push(("halign", halign)); 149 } 150 if let Some(ref has_default) = self.has_default { 151 properties.push(("has-default", has_default)); 152 } 153 if let Some(ref has_focus) = self.has_focus { 154 properties.push(("has-focus", has_focus)); 155 } 156 if let Some(ref has_tooltip) = self.has_tooltip { 157 properties.push(("has-tooltip", has_tooltip)); 158 } 159 if let Some(ref height_request) = self.height_request { 160 properties.push(("height-request", height_request)); 161 } 162 if let Some(ref hexpand) = self.hexpand { 163 properties.push(("hexpand", hexpand)); 164 } 165 if let Some(ref hexpand_set) = self.hexpand_set { 166 properties.push(("hexpand-set", hexpand_set)); 167 } 168 if let Some(ref is_focus) = self.is_focus { 169 properties.push(("is-focus", is_focus)); 170 } 171 if let Some(ref margin) = self.margin { 172 properties.push(("margin", margin)); 173 } 174 if let Some(ref margin_bottom) = self.margin_bottom { 175 properties.push(("margin-bottom", margin_bottom)); 176 } 177 if let Some(ref margin_end) = self.margin_end { 178 properties.push(("margin-end", margin_end)); 179 } 180 if let Some(ref margin_start) = self.margin_start { 181 properties.push(("margin-start", margin_start)); 182 } 183 if let Some(ref margin_top) = self.margin_top { 184 properties.push(("margin-top", margin_top)); 185 } 186 if let Some(ref name) = self.name { 187 properties.push(("name", name)); 188 } 189 if let Some(ref no_show_all) = self.no_show_all { 190 properties.push(("no-show-all", no_show_all)); 191 } 192 if let Some(ref opacity) = self.opacity { 193 properties.push(("opacity", opacity)); 194 } 195 if let Some(ref parent) = self.parent { 196 properties.push(("parent", parent)); 197 } 198 if let Some(ref receives_default) = self.receives_default { 199 properties.push(("receives-default", receives_default)); 200 } 201 if let Some(ref sensitive) = self.sensitive { 202 properties.push(("sensitive", sensitive)); 203 } 204 if let Some(ref tooltip_markup) = self.tooltip_markup { 205 properties.push(("tooltip-markup", tooltip_markup)); 206 } 207 if let Some(ref tooltip_text) = self.tooltip_text { 208 properties.push(("tooltip-text", tooltip_text)); 209 } 210 if let Some(ref valign) = self.valign { 211 properties.push(("valign", valign)); 212 } 213 if let Some(ref vexpand) = self.vexpand { 214 properties.push(("vexpand", vexpand)); 215 } 216 if let Some(ref vexpand_set) = self.vexpand_set { 217 properties.push(("vexpand-set", vexpand_set)); 218 } 219 if let Some(ref visible) = self.visible { 220 properties.push(("visible", visible)); 221 } 222 if let Some(ref width_request) = self.width_request { 223 properties.push(("width-request", width_request)); 224 } 225 glib::Object::new::<GLArea>(&properties).expect("Failed to create an instance of GLArea") 226 } 227 auto_render(mut self, auto_render: bool) -> Self228 pub fn auto_render(mut self, auto_render: bool) -> Self { 229 self.auto_render = Some(auto_render); 230 self 231 } 232 has_alpha(mut self, has_alpha: bool) -> Self233 pub fn has_alpha(mut self, has_alpha: bool) -> Self { 234 self.has_alpha = Some(has_alpha); 235 self 236 } 237 has_depth_buffer(mut self, has_depth_buffer: bool) -> Self238 pub fn has_depth_buffer(mut self, has_depth_buffer: bool) -> Self { 239 self.has_depth_buffer = Some(has_depth_buffer); 240 self 241 } 242 has_stencil_buffer(mut self, has_stencil_buffer: bool) -> Self243 pub fn has_stencil_buffer(mut self, has_stencil_buffer: bool) -> Self { 244 self.has_stencil_buffer = Some(has_stencil_buffer); 245 self 246 } 247 248 #[cfg(any(feature = "v3_22", feature = "dox"))] 249 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] use_es(mut self, use_es: bool) -> Self250 pub fn use_es(mut self, use_es: bool) -> Self { 251 self.use_es = Some(use_es); 252 self 253 } 254 app_paintable(mut self, app_paintable: bool) -> Self255 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 256 self.app_paintable = Some(app_paintable); 257 self 258 } 259 can_default(mut self, can_default: bool) -> Self260 pub fn can_default(mut self, can_default: bool) -> Self { 261 self.can_default = Some(can_default); 262 self 263 } 264 can_focus(mut self, can_focus: bool) -> Self265 pub fn can_focus(mut self, can_focus: bool) -> Self { 266 self.can_focus = Some(can_focus); 267 self 268 } 269 events(mut self, events: gdk::EventMask) -> Self270 pub fn events(mut self, events: gdk::EventMask) -> Self { 271 self.events = Some(events); 272 self 273 } 274 expand(mut self, expand: bool) -> Self275 pub fn expand(mut self, expand: bool) -> Self { 276 self.expand = Some(expand); 277 self 278 } 279 280 #[cfg(any(feature = "v3_20", feature = "dox"))] 281 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self282 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 283 self.focus_on_click = Some(focus_on_click); 284 self 285 } 286 halign(mut self, halign: Align) -> Self287 pub fn halign(mut self, halign: Align) -> Self { 288 self.halign = Some(halign); 289 self 290 } 291 has_default(mut self, has_default: bool) -> Self292 pub fn has_default(mut self, has_default: bool) -> Self { 293 self.has_default = Some(has_default); 294 self 295 } 296 has_focus(mut self, has_focus: bool) -> Self297 pub fn has_focus(mut self, has_focus: bool) -> Self { 298 self.has_focus = Some(has_focus); 299 self 300 } 301 has_tooltip(mut self, has_tooltip: bool) -> Self302 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 303 self.has_tooltip = Some(has_tooltip); 304 self 305 } 306 height_request(mut self, height_request: i32) -> Self307 pub fn height_request(mut self, height_request: i32) -> Self { 308 self.height_request = Some(height_request); 309 self 310 } 311 hexpand(mut self, hexpand: bool) -> Self312 pub fn hexpand(mut self, hexpand: bool) -> Self { 313 self.hexpand = Some(hexpand); 314 self 315 } 316 hexpand_set(mut self, hexpand_set: bool) -> Self317 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 318 self.hexpand_set = Some(hexpand_set); 319 self 320 } 321 is_focus(mut self, is_focus: bool) -> Self322 pub fn is_focus(mut self, is_focus: bool) -> Self { 323 self.is_focus = Some(is_focus); 324 self 325 } 326 margin(mut self, margin: i32) -> Self327 pub fn margin(mut self, margin: i32) -> Self { 328 self.margin = Some(margin); 329 self 330 } 331 margin_bottom(mut self, margin_bottom: i32) -> Self332 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 333 self.margin_bottom = Some(margin_bottom); 334 self 335 } 336 margin_end(mut self, margin_end: i32) -> Self337 pub fn margin_end(mut self, margin_end: i32) -> Self { 338 self.margin_end = Some(margin_end); 339 self 340 } 341 margin_start(mut self, margin_start: i32) -> Self342 pub fn margin_start(mut self, margin_start: i32) -> Self { 343 self.margin_start = Some(margin_start); 344 self 345 } 346 margin_top(mut self, margin_top: i32) -> Self347 pub fn margin_top(mut self, margin_top: i32) -> Self { 348 self.margin_top = Some(margin_top); 349 self 350 } 351 name(mut self, name: &str) -> Self352 pub fn name(mut self, name: &str) -> Self { 353 self.name = Some(name.to_string()); 354 self 355 } 356 no_show_all(mut self, no_show_all: bool) -> Self357 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 358 self.no_show_all = Some(no_show_all); 359 self 360 } 361 opacity(mut self, opacity: f64) -> Self362 pub fn opacity(mut self, opacity: f64) -> Self { 363 self.opacity = Some(opacity); 364 self 365 } 366 parent<P: IsA<Container>>(mut self, parent: &P) -> Self367 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 368 self.parent = Some(parent.clone().upcast()); 369 self 370 } 371 receives_default(mut self, receives_default: bool) -> Self372 pub fn receives_default(mut self, receives_default: bool) -> Self { 373 self.receives_default = Some(receives_default); 374 self 375 } 376 sensitive(mut self, sensitive: bool) -> Self377 pub fn sensitive(mut self, sensitive: bool) -> Self { 378 self.sensitive = Some(sensitive); 379 self 380 } 381 tooltip_markup(mut self, tooltip_markup: &str) -> Self382 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 383 self.tooltip_markup = Some(tooltip_markup.to_string()); 384 self 385 } 386 tooltip_text(mut self, tooltip_text: &str) -> Self387 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 388 self.tooltip_text = Some(tooltip_text.to_string()); 389 self 390 } 391 valign(mut self, valign: Align) -> Self392 pub fn valign(mut self, valign: Align) -> Self { 393 self.valign = Some(valign); 394 self 395 } 396 vexpand(mut self, vexpand: bool) -> Self397 pub fn vexpand(mut self, vexpand: bool) -> Self { 398 self.vexpand = Some(vexpand); 399 self 400 } 401 vexpand_set(mut self, vexpand_set: bool) -> Self402 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 403 self.vexpand_set = Some(vexpand_set); 404 self 405 } 406 visible(mut self, visible: bool) -> Self407 pub fn visible(mut self, visible: bool) -> Self { 408 self.visible = Some(visible); 409 self 410 } 411 width_request(mut self, width_request: i32) -> Self412 pub fn width_request(mut self, width_request: i32) -> Self { 413 self.width_request = Some(width_request); 414 self 415 } 416 } 417 418 pub const NONE_GL_AREA: Option<&GLArea> = None; 419 420 pub trait GLAreaExt: 'static { 421 #[doc(alias = "gtk_gl_area_attach_buffers")] attach_buffers(&self)422 fn attach_buffers(&self); 423 424 #[doc(alias = "gtk_gl_area_get_auto_render")] 425 #[doc(alias = "get_auto_render")] is_auto_render(&self) -> bool426 fn is_auto_render(&self) -> bool; 427 428 #[doc(alias = "gtk_gl_area_get_context")] 429 #[doc(alias = "get_context")] context(&self) -> Option<gdk::GLContext>430 fn context(&self) -> Option<gdk::GLContext>; 431 432 #[doc(alias = "gtk_gl_area_get_error")] 433 #[doc(alias = "get_error")] error(&self) -> Option<glib::Error>434 fn error(&self) -> Option<glib::Error>; 435 436 #[doc(alias = "gtk_gl_area_get_has_alpha")] 437 #[doc(alias = "get_has_alpha")] has_alpha(&self) -> bool438 fn has_alpha(&self) -> bool; 439 440 #[doc(alias = "gtk_gl_area_get_has_depth_buffer")] 441 #[doc(alias = "get_has_depth_buffer")] has_depth_buffer(&self) -> bool442 fn has_depth_buffer(&self) -> bool; 443 444 #[doc(alias = "gtk_gl_area_get_has_stencil_buffer")] 445 #[doc(alias = "get_has_stencil_buffer")] has_stencil_buffer(&self) -> bool446 fn has_stencil_buffer(&self) -> bool; 447 448 #[doc(alias = "gtk_gl_area_get_required_version")] 449 #[doc(alias = "get_required_version")] required_version(&self) -> (i32, i32)450 fn required_version(&self) -> (i32, i32); 451 452 #[cfg(any(feature = "v3_22", feature = "dox"))] 453 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] 454 #[doc(alias = "gtk_gl_area_get_use_es")] 455 #[doc(alias = "get_use_es")] uses_es(&self) -> bool456 fn uses_es(&self) -> bool; 457 458 #[doc(alias = "gtk_gl_area_make_current")] make_current(&self)459 fn make_current(&self); 460 461 #[doc(alias = "gtk_gl_area_queue_render")] queue_render(&self)462 fn queue_render(&self); 463 464 #[doc(alias = "gtk_gl_area_set_auto_render")] set_auto_render(&self, auto_render: bool)465 fn set_auto_render(&self, auto_render: bool); 466 467 #[doc(alias = "gtk_gl_area_set_error")] set_error(&self, error: Option<&glib::Error>)468 fn set_error(&self, error: Option<&glib::Error>); 469 470 #[doc(alias = "gtk_gl_area_set_has_alpha")] set_has_alpha(&self, has_alpha: bool)471 fn set_has_alpha(&self, has_alpha: bool); 472 473 #[doc(alias = "gtk_gl_area_set_has_depth_buffer")] set_has_depth_buffer(&self, has_depth_buffer: bool)474 fn set_has_depth_buffer(&self, has_depth_buffer: bool); 475 476 #[doc(alias = "gtk_gl_area_set_has_stencil_buffer")] set_has_stencil_buffer(&self, has_stencil_buffer: bool)477 fn set_has_stencil_buffer(&self, has_stencil_buffer: bool); 478 479 #[doc(alias = "gtk_gl_area_set_required_version")] set_required_version(&self, major: i32, minor: i32)480 fn set_required_version(&self, major: i32, minor: i32); 481 482 #[cfg(any(feature = "v3_22", feature = "dox"))] 483 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] 484 #[doc(alias = "gtk_gl_area_set_use_es")] set_use_es(&self, use_es: bool)485 fn set_use_es(&self, use_es: bool); 486 487 #[doc(alias = "create-context")] connect_create_context<F: Fn(&Self) -> Option<gdk::GLContext> + 'static>( &self, f: F, ) -> SignalHandlerId488 fn connect_create_context<F: Fn(&Self) -> Option<gdk::GLContext> + 'static>( 489 &self, 490 f: F, 491 ) -> SignalHandlerId; 492 493 #[doc(alias = "render")] connect_render<F: Fn(&Self, &gdk::GLContext) -> glib::signal::Inhibit + 'static>( &self, f: F, ) -> SignalHandlerId494 fn connect_render<F: Fn(&Self, &gdk::GLContext) -> glib::signal::Inhibit + 'static>( 495 &self, 496 f: F, 497 ) -> SignalHandlerId; 498 499 #[doc(alias = "resize")] connect_resize<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId500 fn connect_resize<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId; 501 502 #[doc(alias = "auto-render")] connect_auto_render_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId503 fn connect_auto_render_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 504 505 #[doc(alias = "context")] connect_context_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId506 fn connect_context_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 507 508 #[doc(alias = "has-alpha")] connect_has_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId509 fn connect_has_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 510 511 #[doc(alias = "has-depth-buffer")] connect_has_depth_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId512 fn connect_has_depth_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 513 514 #[doc(alias = "has-stencil-buffer")] connect_has_stencil_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId515 fn connect_has_stencil_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 516 517 #[cfg(any(feature = "v3_22", feature = "dox"))] 518 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] 519 #[doc(alias = "use-es")] connect_use_es_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId520 fn connect_use_es_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 521 } 522 523 impl<O: IsA<GLArea>> GLAreaExt for O { attach_buffers(&self)524 fn attach_buffers(&self) { 525 unsafe { 526 ffi::gtk_gl_area_attach_buffers(self.as_ref().to_glib_none().0); 527 } 528 } 529 is_auto_render(&self) -> bool530 fn is_auto_render(&self) -> bool { 531 unsafe { 532 from_glib(ffi::gtk_gl_area_get_auto_render( 533 self.as_ref().to_glib_none().0, 534 )) 535 } 536 } 537 context(&self) -> Option<gdk::GLContext>538 fn context(&self) -> Option<gdk::GLContext> { 539 unsafe { from_glib_none(ffi::gtk_gl_area_get_context(self.as_ref().to_glib_none().0)) } 540 } 541 error(&self) -> Option<glib::Error>542 fn error(&self) -> Option<glib::Error> { 543 unsafe { from_glib_none(ffi::gtk_gl_area_get_error(self.as_ref().to_glib_none().0)) } 544 } 545 has_alpha(&self) -> bool546 fn has_alpha(&self) -> bool { 547 unsafe { 548 from_glib(ffi::gtk_gl_area_get_has_alpha( 549 self.as_ref().to_glib_none().0, 550 )) 551 } 552 } 553 has_depth_buffer(&self) -> bool554 fn has_depth_buffer(&self) -> bool { 555 unsafe { 556 from_glib(ffi::gtk_gl_area_get_has_depth_buffer( 557 self.as_ref().to_glib_none().0, 558 )) 559 } 560 } 561 has_stencil_buffer(&self) -> bool562 fn has_stencil_buffer(&self) -> bool { 563 unsafe { 564 from_glib(ffi::gtk_gl_area_get_has_stencil_buffer( 565 self.as_ref().to_glib_none().0, 566 )) 567 } 568 } 569 required_version(&self) -> (i32, i32)570 fn required_version(&self) -> (i32, i32) { 571 unsafe { 572 let mut major = mem::MaybeUninit::uninit(); 573 let mut minor = mem::MaybeUninit::uninit(); 574 ffi::gtk_gl_area_get_required_version( 575 self.as_ref().to_glib_none().0, 576 major.as_mut_ptr(), 577 minor.as_mut_ptr(), 578 ); 579 let major = major.assume_init(); 580 let minor = minor.assume_init(); 581 (major, minor) 582 } 583 } 584 585 #[cfg(any(feature = "v3_22", feature = "dox"))] 586 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] uses_es(&self) -> bool587 fn uses_es(&self) -> bool { 588 unsafe { from_glib(ffi::gtk_gl_area_get_use_es(self.as_ref().to_glib_none().0)) } 589 } 590 make_current(&self)591 fn make_current(&self) { 592 unsafe { 593 ffi::gtk_gl_area_make_current(self.as_ref().to_glib_none().0); 594 } 595 } 596 queue_render(&self)597 fn queue_render(&self) { 598 unsafe { 599 ffi::gtk_gl_area_queue_render(self.as_ref().to_glib_none().0); 600 } 601 } 602 set_auto_render(&self, auto_render: bool)603 fn set_auto_render(&self, auto_render: bool) { 604 unsafe { 605 ffi::gtk_gl_area_set_auto_render( 606 self.as_ref().to_glib_none().0, 607 auto_render.into_glib(), 608 ); 609 } 610 } 611 set_error(&self, error: Option<&glib::Error>)612 fn set_error(&self, error: Option<&glib::Error>) { 613 unsafe { 614 ffi::gtk_gl_area_set_error(self.as_ref().to_glib_none().0, error.to_glib_none().0); 615 } 616 } 617 set_has_alpha(&self, has_alpha: bool)618 fn set_has_alpha(&self, has_alpha: bool) { 619 unsafe { 620 ffi::gtk_gl_area_set_has_alpha(self.as_ref().to_glib_none().0, has_alpha.into_glib()); 621 } 622 } 623 set_has_depth_buffer(&self, has_depth_buffer: bool)624 fn set_has_depth_buffer(&self, has_depth_buffer: bool) { 625 unsafe { 626 ffi::gtk_gl_area_set_has_depth_buffer( 627 self.as_ref().to_glib_none().0, 628 has_depth_buffer.into_glib(), 629 ); 630 } 631 } 632 set_has_stencil_buffer(&self, has_stencil_buffer: bool)633 fn set_has_stencil_buffer(&self, has_stencil_buffer: bool) { 634 unsafe { 635 ffi::gtk_gl_area_set_has_stencil_buffer( 636 self.as_ref().to_glib_none().0, 637 has_stencil_buffer.into_glib(), 638 ); 639 } 640 } 641 set_required_version(&self, major: i32, minor: i32)642 fn set_required_version(&self, major: i32, minor: i32) { 643 unsafe { 644 ffi::gtk_gl_area_set_required_version(self.as_ref().to_glib_none().0, major, minor); 645 } 646 } 647 648 #[cfg(any(feature = "v3_22", feature = "dox"))] 649 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] set_use_es(&self, use_es: bool)650 fn set_use_es(&self, use_es: bool) { 651 unsafe { 652 ffi::gtk_gl_area_set_use_es(self.as_ref().to_glib_none().0, use_es.into_glib()); 653 } 654 } 655 connect_create_context<F: Fn(&Self) -> Option<gdk::GLContext> + 'static>( &self, f: F, ) -> SignalHandlerId656 fn connect_create_context<F: Fn(&Self) -> Option<gdk::GLContext> + 'static>( 657 &self, 658 f: F, 659 ) -> SignalHandlerId { 660 unsafe extern "C" fn create_context_trampoline< 661 P: IsA<GLArea>, 662 F: Fn(&P) -> Option<gdk::GLContext> + 'static, 663 >( 664 this: *mut ffi::GtkGLArea, 665 f: glib::ffi::gpointer, 666 ) -> *mut gdk::ffi::GdkGLContext { 667 let f: &F = &*(f as *const F); 668 f(GLArea::from_glib_borrow(this).unsafe_cast_ref()).to_glib_full() 669 } 670 unsafe { 671 let f: Box_<F> = Box_::new(f); 672 connect_raw( 673 self.as_ptr() as *mut _, 674 b"create-context\0".as_ptr() as *const _, 675 Some(transmute::<_, unsafe extern "C" fn()>( 676 create_context_trampoline::<Self, F> as *const (), 677 )), 678 Box_::into_raw(f), 679 ) 680 } 681 } 682 connect_render<F: Fn(&Self, &gdk::GLContext) -> glib::signal::Inhibit + 'static>( &self, f: F, ) -> SignalHandlerId683 fn connect_render<F: Fn(&Self, &gdk::GLContext) -> glib::signal::Inhibit + 'static>( 684 &self, 685 f: F, 686 ) -> SignalHandlerId { 687 unsafe extern "C" fn render_trampoline< 688 P: IsA<GLArea>, 689 F: Fn(&P, &gdk::GLContext) -> glib::signal::Inhibit + 'static, 690 >( 691 this: *mut ffi::GtkGLArea, 692 context: *mut gdk::ffi::GdkGLContext, 693 f: glib::ffi::gpointer, 694 ) -> glib::ffi::gboolean { 695 let f: &F = &*(f as *const F); 696 f( 697 GLArea::from_glib_borrow(this).unsafe_cast_ref(), 698 &from_glib_borrow(context), 699 ) 700 .into_glib() 701 } 702 unsafe { 703 let f: Box_<F> = Box_::new(f); 704 connect_raw( 705 self.as_ptr() as *mut _, 706 b"render\0".as_ptr() as *const _, 707 Some(transmute::<_, unsafe extern "C" fn()>( 708 render_trampoline::<Self, F> as *const (), 709 )), 710 Box_::into_raw(f), 711 ) 712 } 713 } 714 connect_resize<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId715 fn connect_resize<F: Fn(&Self, i32, i32) + 'static>(&self, f: F) -> SignalHandlerId { 716 unsafe extern "C" fn resize_trampoline<P: IsA<GLArea>, F: Fn(&P, i32, i32) + 'static>( 717 this: *mut ffi::GtkGLArea, 718 width: libc::c_int, 719 height: libc::c_int, 720 f: glib::ffi::gpointer, 721 ) { 722 let f: &F = &*(f as *const F); 723 f( 724 GLArea::from_glib_borrow(this).unsafe_cast_ref(), 725 width, 726 height, 727 ) 728 } 729 unsafe { 730 let f: Box_<F> = Box_::new(f); 731 connect_raw( 732 self.as_ptr() as *mut _, 733 b"resize\0".as_ptr() as *const _, 734 Some(transmute::<_, unsafe extern "C" fn()>( 735 resize_trampoline::<Self, F> as *const (), 736 )), 737 Box_::into_raw(f), 738 ) 739 } 740 } 741 connect_auto_render_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId742 fn connect_auto_render_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 743 unsafe extern "C" fn notify_auto_render_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>( 744 this: *mut ffi::GtkGLArea, 745 _param_spec: glib::ffi::gpointer, 746 f: glib::ffi::gpointer, 747 ) { 748 let f: &F = &*(f as *const F); 749 f(GLArea::from_glib_borrow(this).unsafe_cast_ref()) 750 } 751 unsafe { 752 let f: Box_<F> = Box_::new(f); 753 connect_raw( 754 self.as_ptr() as *mut _, 755 b"notify::auto-render\0".as_ptr() as *const _, 756 Some(transmute::<_, unsafe extern "C" fn()>( 757 notify_auto_render_trampoline::<Self, F> as *const (), 758 )), 759 Box_::into_raw(f), 760 ) 761 } 762 } 763 connect_context_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId764 fn connect_context_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 765 unsafe extern "C" fn notify_context_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>( 766 this: *mut ffi::GtkGLArea, 767 _param_spec: glib::ffi::gpointer, 768 f: glib::ffi::gpointer, 769 ) { 770 let f: &F = &*(f as *const F); 771 f(GLArea::from_glib_borrow(this).unsafe_cast_ref()) 772 } 773 unsafe { 774 let f: Box_<F> = Box_::new(f); 775 connect_raw( 776 self.as_ptr() as *mut _, 777 b"notify::context\0".as_ptr() as *const _, 778 Some(transmute::<_, unsafe extern "C" fn()>( 779 notify_context_trampoline::<Self, F> as *const (), 780 )), 781 Box_::into_raw(f), 782 ) 783 } 784 } 785 connect_has_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId786 fn connect_has_alpha_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 787 unsafe extern "C" fn notify_has_alpha_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>( 788 this: *mut ffi::GtkGLArea, 789 _param_spec: glib::ffi::gpointer, 790 f: glib::ffi::gpointer, 791 ) { 792 let f: &F = &*(f as *const F); 793 f(GLArea::from_glib_borrow(this).unsafe_cast_ref()) 794 } 795 unsafe { 796 let f: Box_<F> = Box_::new(f); 797 connect_raw( 798 self.as_ptr() as *mut _, 799 b"notify::has-alpha\0".as_ptr() as *const _, 800 Some(transmute::<_, unsafe extern "C" fn()>( 801 notify_has_alpha_trampoline::<Self, F> as *const (), 802 )), 803 Box_::into_raw(f), 804 ) 805 } 806 } 807 connect_has_depth_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId808 fn connect_has_depth_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 809 unsafe extern "C" fn notify_has_depth_buffer_trampoline< 810 P: IsA<GLArea>, 811 F: Fn(&P) + 'static, 812 >( 813 this: *mut ffi::GtkGLArea, 814 _param_spec: glib::ffi::gpointer, 815 f: glib::ffi::gpointer, 816 ) { 817 let f: &F = &*(f as *const F); 818 f(GLArea::from_glib_borrow(this).unsafe_cast_ref()) 819 } 820 unsafe { 821 let f: Box_<F> = Box_::new(f); 822 connect_raw( 823 self.as_ptr() as *mut _, 824 b"notify::has-depth-buffer\0".as_ptr() as *const _, 825 Some(transmute::<_, unsafe extern "C" fn()>( 826 notify_has_depth_buffer_trampoline::<Self, F> as *const (), 827 )), 828 Box_::into_raw(f), 829 ) 830 } 831 } 832 connect_has_stencil_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId833 fn connect_has_stencil_buffer_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 834 unsafe extern "C" fn notify_has_stencil_buffer_trampoline< 835 P: IsA<GLArea>, 836 F: Fn(&P) + 'static, 837 >( 838 this: *mut ffi::GtkGLArea, 839 _param_spec: glib::ffi::gpointer, 840 f: glib::ffi::gpointer, 841 ) { 842 let f: &F = &*(f as *const F); 843 f(GLArea::from_glib_borrow(this).unsafe_cast_ref()) 844 } 845 unsafe { 846 let f: Box_<F> = Box_::new(f); 847 connect_raw( 848 self.as_ptr() as *mut _, 849 b"notify::has-stencil-buffer\0".as_ptr() as *const _, 850 Some(transmute::<_, unsafe extern "C" fn()>( 851 notify_has_stencil_buffer_trampoline::<Self, F> as *const (), 852 )), 853 Box_::into_raw(f), 854 ) 855 } 856 } 857 858 #[cfg(any(feature = "v3_22", feature = "dox"))] 859 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_22")))] connect_use_es_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId860 fn connect_use_es_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 861 unsafe extern "C" fn notify_use_es_trampoline<P: IsA<GLArea>, F: Fn(&P) + 'static>( 862 this: *mut ffi::GtkGLArea, 863 _param_spec: glib::ffi::gpointer, 864 f: glib::ffi::gpointer, 865 ) { 866 let f: &F = &*(f as *const F); 867 f(GLArea::from_glib_borrow(this).unsafe_cast_ref()) 868 } 869 unsafe { 870 let f: Box_<F> = Box_::new(f); 871 connect_raw( 872 self.as_ptr() as *mut _, 873 b"notify::use-es\0".as_ptr() as *const _, 874 Some(transmute::<_, unsafe extern "C" fn()>( 875 notify_use_es_trampoline::<Self, F> as *const (), 876 )), 877 Box_::into_raw(f), 878 ) 879 } 880 } 881 } 882 883 impl fmt::Display for GLArea { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result884 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 885 f.write_str("GLArea") 886 } 887 } 888