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::Bin; 7 use crate::Buildable; 8 use crate::Container; 9 use crate::ResizeMode; 10 use crate::Widget; 11 use glib::object::Cast; 12 use glib::object::IsA; 13 use glib::translate::*; 14 use glib::StaticType; 15 use glib::ToValue; 16 use std::fmt; 17 18 glib::wrapper! { 19 #[doc(alias = "GtkOverlay")] 20 pub struct Overlay(Object<ffi::GtkOverlay, ffi::GtkOverlayClass>) @extends Bin, Container, Widget, @implements Buildable; 21 22 match fn { 23 type_ => || ffi::gtk_overlay_get_type(), 24 } 25 } 26 27 impl Overlay { 28 #[doc(alias = "gtk_overlay_new")] new() -> Overlay29 pub fn new() -> Overlay { 30 assert_initialized_main_thread!(); 31 unsafe { Widget::from_glib_none(ffi::gtk_overlay_new()).unsafe_cast() } 32 } 33 34 // rustdoc-stripper-ignore-next 35 /// Creates a new builder-pattern struct instance to construct [`Overlay`] objects. 36 /// 37 /// This method returns an instance of [`OverlayBuilder`] which can be used to create [`Overlay`] objects. builder() -> OverlayBuilder38 pub fn builder() -> OverlayBuilder { 39 OverlayBuilder::default() 40 } 41 } 42 43 impl Default for Overlay { default() -> Self44 fn default() -> Self { 45 Self::new() 46 } 47 } 48 49 #[derive(Clone, Default)] 50 // rustdoc-stripper-ignore-next 51 /// A [builder-pattern] type to construct [`Overlay`] objects. 52 /// 53 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 54 pub struct OverlayBuilder { 55 border_width: Option<u32>, 56 child: Option<Widget>, 57 resize_mode: Option<ResizeMode>, 58 app_paintable: Option<bool>, 59 can_default: Option<bool>, 60 can_focus: Option<bool>, 61 events: Option<gdk::EventMask>, 62 expand: Option<bool>, 63 #[cfg(any(feature = "v3_20", feature = "dox"))] 64 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 65 focus_on_click: Option<bool>, 66 halign: Option<Align>, 67 has_default: Option<bool>, 68 has_focus: Option<bool>, 69 has_tooltip: Option<bool>, 70 height_request: Option<i32>, 71 hexpand: Option<bool>, 72 hexpand_set: Option<bool>, 73 is_focus: Option<bool>, 74 margin: Option<i32>, 75 margin_bottom: Option<i32>, 76 margin_end: Option<i32>, 77 margin_start: Option<i32>, 78 margin_top: Option<i32>, 79 name: Option<String>, 80 no_show_all: Option<bool>, 81 opacity: Option<f64>, 82 parent: Option<Container>, 83 receives_default: Option<bool>, 84 sensitive: Option<bool>, 85 tooltip_markup: Option<String>, 86 tooltip_text: Option<String>, 87 valign: Option<Align>, 88 vexpand: Option<bool>, 89 vexpand_set: Option<bool>, 90 visible: Option<bool>, 91 width_request: Option<i32>, 92 } 93 94 impl OverlayBuilder { 95 // rustdoc-stripper-ignore-next 96 /// Create a new [`OverlayBuilder`]. new() -> Self97 pub fn new() -> Self { 98 Self::default() 99 } 100 101 // rustdoc-stripper-ignore-next 102 /// Build the [`Overlay`]. build(self) -> Overlay103 pub fn build(self) -> Overlay { 104 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 105 if let Some(ref border_width) = self.border_width { 106 properties.push(("border-width", border_width)); 107 } 108 if let Some(ref child) = self.child { 109 properties.push(("child", child)); 110 } 111 if let Some(ref resize_mode) = self.resize_mode { 112 properties.push(("resize-mode", resize_mode)); 113 } 114 if let Some(ref app_paintable) = self.app_paintable { 115 properties.push(("app-paintable", app_paintable)); 116 } 117 if let Some(ref can_default) = self.can_default { 118 properties.push(("can-default", can_default)); 119 } 120 if let Some(ref can_focus) = self.can_focus { 121 properties.push(("can-focus", can_focus)); 122 } 123 if let Some(ref events) = self.events { 124 properties.push(("events", events)); 125 } 126 if let Some(ref expand) = self.expand { 127 properties.push(("expand", expand)); 128 } 129 #[cfg(any(feature = "v3_20", feature = "dox"))] 130 if let Some(ref focus_on_click) = self.focus_on_click { 131 properties.push(("focus-on-click", focus_on_click)); 132 } 133 if let Some(ref halign) = self.halign { 134 properties.push(("halign", halign)); 135 } 136 if let Some(ref has_default) = self.has_default { 137 properties.push(("has-default", has_default)); 138 } 139 if let Some(ref has_focus) = self.has_focus { 140 properties.push(("has-focus", has_focus)); 141 } 142 if let Some(ref has_tooltip) = self.has_tooltip { 143 properties.push(("has-tooltip", has_tooltip)); 144 } 145 if let Some(ref height_request) = self.height_request { 146 properties.push(("height-request", height_request)); 147 } 148 if let Some(ref hexpand) = self.hexpand { 149 properties.push(("hexpand", hexpand)); 150 } 151 if let Some(ref hexpand_set) = self.hexpand_set { 152 properties.push(("hexpand-set", hexpand_set)); 153 } 154 if let Some(ref is_focus) = self.is_focus { 155 properties.push(("is-focus", is_focus)); 156 } 157 if let Some(ref margin) = self.margin { 158 properties.push(("margin", margin)); 159 } 160 if let Some(ref margin_bottom) = self.margin_bottom { 161 properties.push(("margin-bottom", margin_bottom)); 162 } 163 if let Some(ref margin_end) = self.margin_end { 164 properties.push(("margin-end", margin_end)); 165 } 166 if let Some(ref margin_start) = self.margin_start { 167 properties.push(("margin-start", margin_start)); 168 } 169 if let Some(ref margin_top) = self.margin_top { 170 properties.push(("margin-top", margin_top)); 171 } 172 if let Some(ref name) = self.name { 173 properties.push(("name", name)); 174 } 175 if let Some(ref no_show_all) = self.no_show_all { 176 properties.push(("no-show-all", no_show_all)); 177 } 178 if let Some(ref opacity) = self.opacity { 179 properties.push(("opacity", opacity)); 180 } 181 if let Some(ref parent) = self.parent { 182 properties.push(("parent", parent)); 183 } 184 if let Some(ref receives_default) = self.receives_default { 185 properties.push(("receives-default", receives_default)); 186 } 187 if let Some(ref sensitive) = self.sensitive { 188 properties.push(("sensitive", sensitive)); 189 } 190 if let Some(ref tooltip_markup) = self.tooltip_markup { 191 properties.push(("tooltip-markup", tooltip_markup)); 192 } 193 if let Some(ref tooltip_text) = self.tooltip_text { 194 properties.push(("tooltip-text", tooltip_text)); 195 } 196 if let Some(ref valign) = self.valign { 197 properties.push(("valign", valign)); 198 } 199 if let Some(ref vexpand) = self.vexpand { 200 properties.push(("vexpand", vexpand)); 201 } 202 if let Some(ref vexpand_set) = self.vexpand_set { 203 properties.push(("vexpand-set", vexpand_set)); 204 } 205 if let Some(ref visible) = self.visible { 206 properties.push(("visible", visible)); 207 } 208 if let Some(ref width_request) = self.width_request { 209 properties.push(("width-request", width_request)); 210 } 211 glib::Object::new::<Overlay>(&properties).expect("Failed to create an instance of Overlay") 212 } 213 border_width(mut self, border_width: u32) -> Self214 pub fn border_width(mut self, border_width: u32) -> Self { 215 self.border_width = Some(border_width); 216 self 217 } 218 child<P: IsA<Widget>>(mut self, child: &P) -> Self219 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 220 self.child = Some(child.clone().upcast()); 221 self 222 } 223 resize_mode(mut self, resize_mode: ResizeMode) -> Self224 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 225 self.resize_mode = Some(resize_mode); 226 self 227 } 228 app_paintable(mut self, app_paintable: bool) -> Self229 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 230 self.app_paintable = Some(app_paintable); 231 self 232 } 233 can_default(mut self, can_default: bool) -> Self234 pub fn can_default(mut self, can_default: bool) -> Self { 235 self.can_default = Some(can_default); 236 self 237 } 238 can_focus(mut self, can_focus: bool) -> Self239 pub fn can_focus(mut self, can_focus: bool) -> Self { 240 self.can_focus = Some(can_focus); 241 self 242 } 243 events(mut self, events: gdk::EventMask) -> Self244 pub fn events(mut self, events: gdk::EventMask) -> Self { 245 self.events = Some(events); 246 self 247 } 248 expand(mut self, expand: bool) -> Self249 pub fn expand(mut self, expand: bool) -> Self { 250 self.expand = Some(expand); 251 self 252 } 253 254 #[cfg(any(feature = "v3_20", feature = "dox"))] 255 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self256 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 257 self.focus_on_click = Some(focus_on_click); 258 self 259 } 260 halign(mut self, halign: Align) -> Self261 pub fn halign(mut self, halign: Align) -> Self { 262 self.halign = Some(halign); 263 self 264 } 265 has_default(mut self, has_default: bool) -> Self266 pub fn has_default(mut self, has_default: bool) -> Self { 267 self.has_default = Some(has_default); 268 self 269 } 270 has_focus(mut self, has_focus: bool) -> Self271 pub fn has_focus(mut self, has_focus: bool) -> Self { 272 self.has_focus = Some(has_focus); 273 self 274 } 275 has_tooltip(mut self, has_tooltip: bool) -> Self276 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 277 self.has_tooltip = Some(has_tooltip); 278 self 279 } 280 height_request(mut self, height_request: i32) -> Self281 pub fn height_request(mut self, height_request: i32) -> Self { 282 self.height_request = Some(height_request); 283 self 284 } 285 hexpand(mut self, hexpand: bool) -> Self286 pub fn hexpand(mut self, hexpand: bool) -> Self { 287 self.hexpand = Some(hexpand); 288 self 289 } 290 hexpand_set(mut self, hexpand_set: bool) -> Self291 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 292 self.hexpand_set = Some(hexpand_set); 293 self 294 } 295 is_focus(mut self, is_focus: bool) -> Self296 pub fn is_focus(mut self, is_focus: bool) -> Self { 297 self.is_focus = Some(is_focus); 298 self 299 } 300 margin(mut self, margin: i32) -> Self301 pub fn margin(mut self, margin: i32) -> Self { 302 self.margin = Some(margin); 303 self 304 } 305 margin_bottom(mut self, margin_bottom: i32) -> Self306 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 307 self.margin_bottom = Some(margin_bottom); 308 self 309 } 310 margin_end(mut self, margin_end: i32) -> Self311 pub fn margin_end(mut self, margin_end: i32) -> Self { 312 self.margin_end = Some(margin_end); 313 self 314 } 315 margin_start(mut self, margin_start: i32) -> Self316 pub fn margin_start(mut self, margin_start: i32) -> Self { 317 self.margin_start = Some(margin_start); 318 self 319 } 320 margin_top(mut self, margin_top: i32) -> Self321 pub fn margin_top(mut self, margin_top: i32) -> Self { 322 self.margin_top = Some(margin_top); 323 self 324 } 325 name(mut self, name: &str) -> Self326 pub fn name(mut self, name: &str) -> Self { 327 self.name = Some(name.to_string()); 328 self 329 } 330 no_show_all(mut self, no_show_all: bool) -> Self331 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 332 self.no_show_all = Some(no_show_all); 333 self 334 } 335 opacity(mut self, opacity: f64) -> Self336 pub fn opacity(mut self, opacity: f64) -> Self { 337 self.opacity = Some(opacity); 338 self 339 } 340 parent<P: IsA<Container>>(mut self, parent: &P) -> Self341 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 342 self.parent = Some(parent.clone().upcast()); 343 self 344 } 345 receives_default(mut self, receives_default: bool) -> Self346 pub fn receives_default(mut self, receives_default: bool) -> Self { 347 self.receives_default = Some(receives_default); 348 self 349 } 350 sensitive(mut self, sensitive: bool) -> Self351 pub fn sensitive(mut self, sensitive: bool) -> Self { 352 self.sensitive = Some(sensitive); 353 self 354 } 355 tooltip_markup(mut self, tooltip_markup: &str) -> Self356 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 357 self.tooltip_markup = Some(tooltip_markup.to_string()); 358 self 359 } 360 tooltip_text(mut self, tooltip_text: &str) -> Self361 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 362 self.tooltip_text = Some(tooltip_text.to_string()); 363 self 364 } 365 valign(mut self, valign: Align) -> Self366 pub fn valign(mut self, valign: Align) -> Self { 367 self.valign = Some(valign); 368 self 369 } 370 vexpand(mut self, vexpand: bool) -> Self371 pub fn vexpand(mut self, vexpand: bool) -> Self { 372 self.vexpand = Some(vexpand); 373 self 374 } 375 vexpand_set(mut self, vexpand_set: bool) -> Self376 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 377 self.vexpand_set = Some(vexpand_set); 378 self 379 } 380 visible(mut self, visible: bool) -> Self381 pub fn visible(mut self, visible: bool) -> Self { 382 self.visible = Some(visible); 383 self 384 } 385 width_request(mut self, width_request: i32) -> Self386 pub fn width_request(mut self, width_request: i32) -> Self { 387 self.width_request = Some(width_request); 388 self 389 } 390 } 391 392 pub const NONE_OVERLAY: Option<&Overlay> = None; 393 394 pub trait OverlayExt: 'static { 395 #[doc(alias = "gtk_overlay_add_overlay")] add_overlay<P: IsA<Widget>>(&self, widget: &P)396 fn add_overlay<P: IsA<Widget>>(&self, widget: &P); 397 398 #[doc(alias = "gtk_overlay_get_overlay_pass_through")] 399 #[doc(alias = "get_overlay_pass_through")] is_overlay_pass_through<P: IsA<Widget>>(&self, widget: &P) -> bool400 fn is_overlay_pass_through<P: IsA<Widget>>(&self, widget: &P) -> bool; 401 402 #[doc(alias = "gtk_overlay_reorder_overlay")] reorder_overlay<P: IsA<Widget>>(&self, child: &P, index_: i32)403 fn reorder_overlay<P: IsA<Widget>>(&self, child: &P, index_: i32); 404 405 #[doc(alias = "gtk_overlay_set_overlay_pass_through")] set_overlay_pass_through<P: IsA<Widget>>(&self, widget: &P, pass_through: bool)406 fn set_overlay_pass_through<P: IsA<Widget>>(&self, widget: &P, pass_through: bool); 407 child_index<T: IsA<Widget>>(&self, item: &T) -> i32408 fn child_index<T: IsA<Widget>>(&self, item: &T) -> i32; 409 set_child_index<T: IsA<Widget>>(&self, item: &T, index: i32)410 fn set_child_index<T: IsA<Widget>>(&self, item: &T, index: i32); 411 412 //#[doc(alias = "get-child-position")] 413 //fn connect_get_child_position<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId; 414 } 415 416 impl<O: IsA<Overlay>> OverlayExt for O { add_overlay<P: IsA<Widget>>(&self, widget: &P)417 fn add_overlay<P: IsA<Widget>>(&self, widget: &P) { 418 unsafe { 419 ffi::gtk_overlay_add_overlay( 420 self.as_ref().to_glib_none().0, 421 widget.as_ref().to_glib_none().0, 422 ); 423 } 424 } 425 is_overlay_pass_through<P: IsA<Widget>>(&self, widget: &P) -> bool426 fn is_overlay_pass_through<P: IsA<Widget>>(&self, widget: &P) -> bool { 427 unsafe { 428 from_glib(ffi::gtk_overlay_get_overlay_pass_through( 429 self.as_ref().to_glib_none().0, 430 widget.as_ref().to_glib_none().0, 431 )) 432 } 433 } 434 reorder_overlay<P: IsA<Widget>>(&self, child: &P, index_: i32)435 fn reorder_overlay<P: IsA<Widget>>(&self, child: &P, index_: i32) { 436 unsafe { 437 ffi::gtk_overlay_reorder_overlay( 438 self.as_ref().to_glib_none().0, 439 child.as_ref().to_glib_none().0, 440 index_, 441 ); 442 } 443 } 444 set_overlay_pass_through<P: IsA<Widget>>(&self, widget: &P, pass_through: bool)445 fn set_overlay_pass_through<P: IsA<Widget>>(&self, widget: &P, pass_through: bool) { 446 unsafe { 447 ffi::gtk_overlay_set_overlay_pass_through( 448 self.as_ref().to_glib_none().0, 449 widget.as_ref().to_glib_none().0, 450 pass_through.into_glib(), 451 ); 452 } 453 } 454 child_index<T: IsA<Widget>>(&self, item: &T) -> i32455 fn child_index<T: IsA<Widget>>(&self, item: &T) -> i32 { 456 unsafe { 457 let mut value = glib::Value::from_type(<i32 as StaticType>::static_type()); 458 crate::ffi::gtk_container_child_get_property( 459 self.to_glib_none().0 as *mut crate::ffi::GtkContainer, 460 item.to_glib_none().0 as *mut _, 461 b"index\0".as_ptr() as *const _, 462 value.to_glib_none_mut().0, 463 ); 464 value 465 .get() 466 .expect("Return Value for property `index` getter") 467 } 468 } 469 set_child_index<T: IsA<Widget>>(&self, item: &T, index: i32)470 fn set_child_index<T: IsA<Widget>>(&self, item: &T, index: i32) { 471 unsafe { 472 crate::ffi::gtk_container_child_set_property( 473 self.to_glib_none().0 as *mut crate::ffi::GtkContainer, 474 item.to_glib_none().0 as *mut _, 475 b"index\0".as_ptr() as *const _, 476 index.to_value().to_glib_none().0, 477 ); 478 } 479 } 480 481 //fn connect_get_child_position<Unsupported or ignored types>(&self, f: F) -> SignalHandlerId { 482 // Out allocation: Gdk.Rectangle 483 //} 484 } 485 486 impl fmt::Display for Overlay { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result487 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 488 f.write_str("Overlay") 489 } 490 } 491