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::BaselinePosition; 7 use crate::Box; 8 use crate::Buildable; 9 use crate::ButtonBoxStyle; 10 use crate::Container; 11 use crate::Orientable; 12 use crate::Orientation; 13 use crate::ResizeMode; 14 use crate::Widget; 15 use glib::object::Cast; 16 use glib::object::IsA; 17 use glib::signal::connect_raw; 18 use glib::signal::SignalHandlerId; 19 use glib::translate::*; 20 use glib::StaticType; 21 use glib::ToValue; 22 use std::boxed::Box as Box_; 23 use std::fmt; 24 use std::mem::transmute; 25 26 glib::wrapper! { 27 #[doc(alias = "GtkButtonBox")] 28 pub struct ButtonBox(Object<ffi::GtkButtonBox, ffi::GtkButtonBoxClass>) @extends Box, Container, Widget, @implements Buildable, Orientable; 29 30 match fn { 31 type_ => || ffi::gtk_button_box_get_type(), 32 } 33 } 34 35 impl ButtonBox { 36 #[doc(alias = "gtk_button_box_new")] new(orientation: Orientation) -> ButtonBox37 pub fn new(orientation: Orientation) -> ButtonBox { 38 assert_initialized_main_thread!(); 39 unsafe { 40 Widget::from_glib_none(ffi::gtk_button_box_new(orientation.into_glib())).unsafe_cast() 41 } 42 } 43 44 // rustdoc-stripper-ignore-next 45 /// Creates a new builder-pattern struct instance to construct [`ButtonBox`] objects. 46 /// 47 /// This method returns an instance of [`ButtonBoxBuilder`] which can be used to create [`ButtonBox`] objects. builder() -> ButtonBoxBuilder48 pub fn builder() -> ButtonBoxBuilder { 49 ButtonBoxBuilder::default() 50 } 51 } 52 53 #[derive(Clone, Default)] 54 // rustdoc-stripper-ignore-next 55 /// A [builder-pattern] type to construct [`ButtonBox`] objects. 56 /// 57 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 58 pub struct ButtonBoxBuilder { 59 layout_style: Option<ButtonBoxStyle>, 60 baseline_position: Option<BaselinePosition>, 61 homogeneous: Option<bool>, 62 spacing: Option<i32>, 63 border_width: Option<u32>, 64 child: Option<Widget>, 65 resize_mode: Option<ResizeMode>, 66 app_paintable: Option<bool>, 67 can_default: Option<bool>, 68 can_focus: Option<bool>, 69 events: Option<gdk::EventMask>, 70 expand: Option<bool>, 71 #[cfg(any(feature = "v3_20", feature = "dox"))] 72 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 73 focus_on_click: Option<bool>, 74 halign: Option<Align>, 75 has_default: Option<bool>, 76 has_focus: Option<bool>, 77 has_tooltip: Option<bool>, 78 height_request: Option<i32>, 79 hexpand: Option<bool>, 80 hexpand_set: Option<bool>, 81 is_focus: Option<bool>, 82 margin: Option<i32>, 83 margin_bottom: Option<i32>, 84 margin_end: Option<i32>, 85 margin_start: Option<i32>, 86 margin_top: Option<i32>, 87 name: Option<String>, 88 no_show_all: Option<bool>, 89 opacity: Option<f64>, 90 parent: Option<Container>, 91 receives_default: Option<bool>, 92 sensitive: Option<bool>, 93 tooltip_markup: Option<String>, 94 tooltip_text: Option<String>, 95 valign: Option<Align>, 96 vexpand: Option<bool>, 97 vexpand_set: Option<bool>, 98 visible: Option<bool>, 99 width_request: Option<i32>, 100 orientation: Option<Orientation>, 101 } 102 103 impl ButtonBoxBuilder { 104 // rustdoc-stripper-ignore-next 105 /// Create a new [`ButtonBoxBuilder`]. new() -> Self106 pub fn new() -> Self { 107 Self::default() 108 } 109 110 // rustdoc-stripper-ignore-next 111 /// Build the [`ButtonBox`]. build(self) -> ButtonBox112 pub fn build(self) -> ButtonBox { 113 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 114 if let Some(ref layout_style) = self.layout_style { 115 properties.push(("layout-style", layout_style)); 116 } 117 if let Some(ref baseline_position) = self.baseline_position { 118 properties.push(("baseline-position", baseline_position)); 119 } 120 if let Some(ref homogeneous) = self.homogeneous { 121 properties.push(("homogeneous", homogeneous)); 122 } 123 if let Some(ref spacing) = self.spacing { 124 properties.push(("spacing", spacing)); 125 } 126 if let Some(ref border_width) = self.border_width { 127 properties.push(("border-width", border_width)); 128 } 129 if let Some(ref child) = self.child { 130 properties.push(("child", child)); 131 } 132 if let Some(ref resize_mode) = self.resize_mode { 133 properties.push(("resize-mode", resize_mode)); 134 } 135 if let Some(ref app_paintable) = self.app_paintable { 136 properties.push(("app-paintable", app_paintable)); 137 } 138 if let Some(ref can_default) = self.can_default { 139 properties.push(("can-default", can_default)); 140 } 141 if let Some(ref can_focus) = self.can_focus { 142 properties.push(("can-focus", can_focus)); 143 } 144 if let Some(ref events) = self.events { 145 properties.push(("events", events)); 146 } 147 if let Some(ref expand) = self.expand { 148 properties.push(("expand", expand)); 149 } 150 #[cfg(any(feature = "v3_20", feature = "dox"))] 151 if let Some(ref focus_on_click) = self.focus_on_click { 152 properties.push(("focus-on-click", focus_on_click)); 153 } 154 if let Some(ref halign) = self.halign { 155 properties.push(("halign", halign)); 156 } 157 if let Some(ref has_default) = self.has_default { 158 properties.push(("has-default", has_default)); 159 } 160 if let Some(ref has_focus) = self.has_focus { 161 properties.push(("has-focus", has_focus)); 162 } 163 if let Some(ref has_tooltip) = self.has_tooltip { 164 properties.push(("has-tooltip", has_tooltip)); 165 } 166 if let Some(ref height_request) = self.height_request { 167 properties.push(("height-request", height_request)); 168 } 169 if let Some(ref hexpand) = self.hexpand { 170 properties.push(("hexpand", hexpand)); 171 } 172 if let Some(ref hexpand_set) = self.hexpand_set { 173 properties.push(("hexpand-set", hexpand_set)); 174 } 175 if let Some(ref is_focus) = self.is_focus { 176 properties.push(("is-focus", is_focus)); 177 } 178 if let Some(ref margin) = self.margin { 179 properties.push(("margin", margin)); 180 } 181 if let Some(ref margin_bottom) = self.margin_bottom { 182 properties.push(("margin-bottom", margin_bottom)); 183 } 184 if let Some(ref margin_end) = self.margin_end { 185 properties.push(("margin-end", margin_end)); 186 } 187 if let Some(ref margin_start) = self.margin_start { 188 properties.push(("margin-start", margin_start)); 189 } 190 if let Some(ref margin_top) = self.margin_top { 191 properties.push(("margin-top", margin_top)); 192 } 193 if let Some(ref name) = self.name { 194 properties.push(("name", name)); 195 } 196 if let Some(ref no_show_all) = self.no_show_all { 197 properties.push(("no-show-all", no_show_all)); 198 } 199 if let Some(ref opacity) = self.opacity { 200 properties.push(("opacity", opacity)); 201 } 202 if let Some(ref parent) = self.parent { 203 properties.push(("parent", parent)); 204 } 205 if let Some(ref receives_default) = self.receives_default { 206 properties.push(("receives-default", receives_default)); 207 } 208 if let Some(ref sensitive) = self.sensitive { 209 properties.push(("sensitive", sensitive)); 210 } 211 if let Some(ref tooltip_markup) = self.tooltip_markup { 212 properties.push(("tooltip-markup", tooltip_markup)); 213 } 214 if let Some(ref tooltip_text) = self.tooltip_text { 215 properties.push(("tooltip-text", tooltip_text)); 216 } 217 if let Some(ref valign) = self.valign { 218 properties.push(("valign", valign)); 219 } 220 if let Some(ref vexpand) = self.vexpand { 221 properties.push(("vexpand", vexpand)); 222 } 223 if let Some(ref vexpand_set) = self.vexpand_set { 224 properties.push(("vexpand-set", vexpand_set)); 225 } 226 if let Some(ref visible) = self.visible { 227 properties.push(("visible", visible)); 228 } 229 if let Some(ref width_request) = self.width_request { 230 properties.push(("width-request", width_request)); 231 } 232 if let Some(ref orientation) = self.orientation { 233 properties.push(("orientation", orientation)); 234 } 235 glib::Object::new::<ButtonBox>(&properties) 236 .expect("Failed to create an instance of ButtonBox") 237 } 238 layout_style(mut self, layout_style: ButtonBoxStyle) -> Self239 pub fn layout_style(mut self, layout_style: ButtonBoxStyle) -> Self { 240 self.layout_style = Some(layout_style); 241 self 242 } 243 baseline_position(mut self, baseline_position: BaselinePosition) -> Self244 pub fn baseline_position(mut self, baseline_position: BaselinePosition) -> Self { 245 self.baseline_position = Some(baseline_position); 246 self 247 } 248 homogeneous(mut self, homogeneous: bool) -> Self249 pub fn homogeneous(mut self, homogeneous: bool) -> Self { 250 self.homogeneous = Some(homogeneous); 251 self 252 } 253 spacing(mut self, spacing: i32) -> Self254 pub fn spacing(mut self, spacing: i32) -> Self { 255 self.spacing = Some(spacing); 256 self 257 } 258 border_width(mut self, border_width: u32) -> Self259 pub fn border_width(mut self, border_width: u32) -> Self { 260 self.border_width = Some(border_width); 261 self 262 } 263 child<P: IsA<Widget>>(mut self, child: &P) -> Self264 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 265 self.child = Some(child.clone().upcast()); 266 self 267 } 268 resize_mode(mut self, resize_mode: ResizeMode) -> Self269 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 270 self.resize_mode = Some(resize_mode); 271 self 272 } 273 app_paintable(mut self, app_paintable: bool) -> Self274 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 275 self.app_paintable = Some(app_paintable); 276 self 277 } 278 can_default(mut self, can_default: bool) -> Self279 pub fn can_default(mut self, can_default: bool) -> Self { 280 self.can_default = Some(can_default); 281 self 282 } 283 can_focus(mut self, can_focus: bool) -> Self284 pub fn can_focus(mut self, can_focus: bool) -> Self { 285 self.can_focus = Some(can_focus); 286 self 287 } 288 events(mut self, events: gdk::EventMask) -> Self289 pub fn events(mut self, events: gdk::EventMask) -> Self { 290 self.events = Some(events); 291 self 292 } 293 expand(mut self, expand: bool) -> Self294 pub fn expand(mut self, expand: bool) -> Self { 295 self.expand = Some(expand); 296 self 297 } 298 299 #[cfg(any(feature = "v3_20", feature = "dox"))] 300 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self301 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 302 self.focus_on_click = Some(focus_on_click); 303 self 304 } 305 halign(mut self, halign: Align) -> Self306 pub fn halign(mut self, halign: Align) -> Self { 307 self.halign = Some(halign); 308 self 309 } 310 has_default(mut self, has_default: bool) -> Self311 pub fn has_default(mut self, has_default: bool) -> Self { 312 self.has_default = Some(has_default); 313 self 314 } 315 has_focus(mut self, has_focus: bool) -> Self316 pub fn has_focus(mut self, has_focus: bool) -> Self { 317 self.has_focus = Some(has_focus); 318 self 319 } 320 has_tooltip(mut self, has_tooltip: bool) -> Self321 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 322 self.has_tooltip = Some(has_tooltip); 323 self 324 } 325 height_request(mut self, height_request: i32) -> Self326 pub fn height_request(mut self, height_request: i32) -> Self { 327 self.height_request = Some(height_request); 328 self 329 } 330 hexpand(mut self, hexpand: bool) -> Self331 pub fn hexpand(mut self, hexpand: bool) -> Self { 332 self.hexpand = Some(hexpand); 333 self 334 } 335 hexpand_set(mut self, hexpand_set: bool) -> Self336 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 337 self.hexpand_set = Some(hexpand_set); 338 self 339 } 340 is_focus(mut self, is_focus: bool) -> Self341 pub fn is_focus(mut self, is_focus: bool) -> Self { 342 self.is_focus = Some(is_focus); 343 self 344 } 345 margin(mut self, margin: i32) -> Self346 pub fn margin(mut self, margin: i32) -> Self { 347 self.margin = Some(margin); 348 self 349 } 350 margin_bottom(mut self, margin_bottom: i32) -> Self351 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 352 self.margin_bottom = Some(margin_bottom); 353 self 354 } 355 margin_end(mut self, margin_end: i32) -> Self356 pub fn margin_end(mut self, margin_end: i32) -> Self { 357 self.margin_end = Some(margin_end); 358 self 359 } 360 margin_start(mut self, margin_start: i32) -> Self361 pub fn margin_start(mut self, margin_start: i32) -> Self { 362 self.margin_start = Some(margin_start); 363 self 364 } 365 margin_top(mut self, margin_top: i32) -> Self366 pub fn margin_top(mut self, margin_top: i32) -> Self { 367 self.margin_top = Some(margin_top); 368 self 369 } 370 name(mut self, name: &str) -> Self371 pub fn name(mut self, name: &str) -> Self { 372 self.name = Some(name.to_string()); 373 self 374 } 375 no_show_all(mut self, no_show_all: bool) -> Self376 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 377 self.no_show_all = Some(no_show_all); 378 self 379 } 380 opacity(mut self, opacity: f64) -> Self381 pub fn opacity(mut self, opacity: f64) -> Self { 382 self.opacity = Some(opacity); 383 self 384 } 385 parent<P: IsA<Container>>(mut self, parent: &P) -> Self386 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 387 self.parent = Some(parent.clone().upcast()); 388 self 389 } 390 receives_default(mut self, receives_default: bool) -> Self391 pub fn receives_default(mut self, receives_default: bool) -> Self { 392 self.receives_default = Some(receives_default); 393 self 394 } 395 sensitive(mut self, sensitive: bool) -> Self396 pub fn sensitive(mut self, sensitive: bool) -> Self { 397 self.sensitive = Some(sensitive); 398 self 399 } 400 tooltip_markup(mut self, tooltip_markup: &str) -> Self401 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 402 self.tooltip_markup = Some(tooltip_markup.to_string()); 403 self 404 } 405 tooltip_text(mut self, tooltip_text: &str) -> Self406 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 407 self.tooltip_text = Some(tooltip_text.to_string()); 408 self 409 } 410 valign(mut self, valign: Align) -> Self411 pub fn valign(mut self, valign: Align) -> Self { 412 self.valign = Some(valign); 413 self 414 } 415 vexpand(mut self, vexpand: bool) -> Self416 pub fn vexpand(mut self, vexpand: bool) -> Self { 417 self.vexpand = Some(vexpand); 418 self 419 } 420 vexpand_set(mut self, vexpand_set: bool) -> Self421 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 422 self.vexpand_set = Some(vexpand_set); 423 self 424 } 425 visible(mut self, visible: bool) -> Self426 pub fn visible(mut self, visible: bool) -> Self { 427 self.visible = Some(visible); 428 self 429 } 430 width_request(mut self, width_request: i32) -> Self431 pub fn width_request(mut self, width_request: i32) -> Self { 432 self.width_request = Some(width_request); 433 self 434 } 435 orientation(mut self, orientation: Orientation) -> Self436 pub fn orientation(mut self, orientation: Orientation) -> Self { 437 self.orientation = Some(orientation); 438 self 439 } 440 } 441 442 pub const NONE_BUTTON_BOX: Option<&ButtonBox> = None; 443 444 pub trait ButtonBoxExt: 'static { 445 #[doc(alias = "gtk_button_box_get_child_non_homogeneous")] 446 #[doc(alias = "get_child_non_homogeneous")] child_is_non_homogeneous<P: IsA<Widget>>(&self, child: &P) -> bool447 fn child_is_non_homogeneous<P: IsA<Widget>>(&self, child: &P) -> bool; 448 449 #[doc(alias = "gtk_button_box_get_child_secondary")] 450 #[doc(alias = "get_child_secondary")] child_is_secondary<P: IsA<Widget>>(&self, child: &P) -> bool451 fn child_is_secondary<P: IsA<Widget>>(&self, child: &P) -> bool; 452 453 #[doc(alias = "gtk_button_box_get_layout")] 454 #[doc(alias = "get_layout")] layout(&self) -> ButtonBoxStyle455 fn layout(&self) -> ButtonBoxStyle; 456 457 #[doc(alias = "gtk_button_box_set_child_non_homogeneous")] set_child_non_homogeneous<P: IsA<Widget>>(&self, child: &P, non_homogeneous: bool)458 fn set_child_non_homogeneous<P: IsA<Widget>>(&self, child: &P, non_homogeneous: bool); 459 460 #[doc(alias = "gtk_button_box_set_child_secondary")] set_child_secondary<P: IsA<Widget>>(&self, child: &P, is_secondary: bool)461 fn set_child_secondary<P: IsA<Widget>>(&self, child: &P, is_secondary: bool); 462 463 #[doc(alias = "gtk_button_box_set_layout")] set_layout(&self, layout_style: ButtonBoxStyle)464 fn set_layout(&self, layout_style: ButtonBoxStyle); 465 466 #[doc(alias = "layout-style")] layout_style(&self) -> ButtonBoxStyle467 fn layout_style(&self) -> ButtonBoxStyle; 468 469 #[doc(alias = "layout-style")] set_layout_style(&self, layout_style: ButtonBoxStyle)470 fn set_layout_style(&self, layout_style: ButtonBoxStyle); 471 472 #[doc(alias = "layout-style")] connect_layout_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId473 fn connect_layout_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 474 } 475 476 impl<O: IsA<ButtonBox>> ButtonBoxExt for O { child_is_non_homogeneous<P: IsA<Widget>>(&self, child: &P) -> bool477 fn child_is_non_homogeneous<P: IsA<Widget>>(&self, child: &P) -> bool { 478 unsafe { 479 from_glib(ffi::gtk_button_box_get_child_non_homogeneous( 480 self.as_ref().to_glib_none().0, 481 child.as_ref().to_glib_none().0, 482 )) 483 } 484 } 485 child_is_secondary<P: IsA<Widget>>(&self, child: &P) -> bool486 fn child_is_secondary<P: IsA<Widget>>(&self, child: &P) -> bool { 487 unsafe { 488 from_glib(ffi::gtk_button_box_get_child_secondary( 489 self.as_ref().to_glib_none().0, 490 child.as_ref().to_glib_none().0, 491 )) 492 } 493 } 494 layout(&self) -> ButtonBoxStyle495 fn layout(&self) -> ButtonBoxStyle { 496 unsafe { 497 from_glib(ffi::gtk_button_box_get_layout( 498 self.as_ref().to_glib_none().0, 499 )) 500 } 501 } 502 set_child_non_homogeneous<P: IsA<Widget>>(&self, child: &P, non_homogeneous: bool)503 fn set_child_non_homogeneous<P: IsA<Widget>>(&self, child: &P, non_homogeneous: bool) { 504 unsafe { 505 ffi::gtk_button_box_set_child_non_homogeneous( 506 self.as_ref().to_glib_none().0, 507 child.as_ref().to_glib_none().0, 508 non_homogeneous.into_glib(), 509 ); 510 } 511 } 512 set_child_secondary<P: IsA<Widget>>(&self, child: &P, is_secondary: bool)513 fn set_child_secondary<P: IsA<Widget>>(&self, child: &P, is_secondary: bool) { 514 unsafe { 515 ffi::gtk_button_box_set_child_secondary( 516 self.as_ref().to_glib_none().0, 517 child.as_ref().to_glib_none().0, 518 is_secondary.into_glib(), 519 ); 520 } 521 } 522 set_layout(&self, layout_style: ButtonBoxStyle)523 fn set_layout(&self, layout_style: ButtonBoxStyle) { 524 unsafe { 525 ffi::gtk_button_box_set_layout( 526 self.as_ref().to_glib_none().0, 527 layout_style.into_glib(), 528 ); 529 } 530 } 531 layout_style(&self) -> ButtonBoxStyle532 fn layout_style(&self) -> ButtonBoxStyle { 533 unsafe { 534 let mut value = glib::Value::from_type(<ButtonBoxStyle as StaticType>::static_type()); 535 glib::gobject_ffi::g_object_get_property( 536 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, 537 b"layout-style\0".as_ptr() as *const _, 538 value.to_glib_none_mut().0, 539 ); 540 value 541 .get() 542 .expect("Return Value for property `layout-style` getter") 543 } 544 } 545 set_layout_style(&self, layout_style: ButtonBoxStyle)546 fn set_layout_style(&self, layout_style: ButtonBoxStyle) { 547 unsafe { 548 glib::gobject_ffi::g_object_set_property( 549 self.to_glib_none().0 as *mut glib::gobject_ffi::GObject, 550 b"layout-style\0".as_ptr() as *const _, 551 layout_style.to_value().to_glib_none().0, 552 ); 553 } 554 } 555 connect_layout_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId556 fn connect_layout_style_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 557 unsafe extern "C" fn notify_layout_style_trampoline< 558 P: IsA<ButtonBox>, 559 F: Fn(&P) + 'static, 560 >( 561 this: *mut ffi::GtkButtonBox, 562 _param_spec: glib::ffi::gpointer, 563 f: glib::ffi::gpointer, 564 ) { 565 let f: &F = &*(f as *const F); 566 f(ButtonBox::from_glib_borrow(this).unsafe_cast_ref()) 567 } 568 unsafe { 569 let f: Box_<F> = Box_::new(f); 570 connect_raw( 571 self.as_ptr() as *mut _, 572 b"notify::layout-style\0".as_ptr() as *const _, 573 Some(transmute::<_, unsafe extern "C" fn()>( 574 notify_layout_style_trampoline::<Self, F> as *const (), 575 )), 576 Box_::into_raw(f), 577 ) 578 } 579 } 580 } 581 582 impl fmt::Display for ButtonBox { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result583 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 584 f.write_str("ButtonBox") 585 } 586 } 587