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::object::ObjectExt; 14 use glib::signal::connect_raw; 15 use glib::signal::SignalHandlerId; 16 use glib::translate::*; 17 use glib::StaticType; 18 use glib::ToValue; 19 use std::boxed::Box as Box_; 20 use std::fmt; 21 use std::mem::transmute; 22 23 glib::wrapper! { 24 #[doc(alias = "GtkFlowBoxChild")] 25 pub struct FlowBoxChild(Object<ffi::GtkFlowBoxChild, ffi::GtkFlowBoxChildClass>) @extends Bin, Container, Widget, @implements Buildable; 26 27 match fn { 28 type_ => || ffi::gtk_flow_box_child_get_type(), 29 } 30 } 31 32 impl FlowBoxChild { 33 #[doc(alias = "gtk_flow_box_child_new")] new() -> FlowBoxChild34 pub fn new() -> FlowBoxChild { 35 assert_initialized_main_thread!(); 36 unsafe { Widget::from_glib_none(ffi::gtk_flow_box_child_new()).unsafe_cast() } 37 } 38 39 // rustdoc-stripper-ignore-next 40 /// Creates a new builder-pattern struct instance to construct [`FlowBoxChild`] objects. 41 /// 42 /// This method returns an instance of [`FlowBoxChildBuilder`] which can be used to create [`FlowBoxChild`] objects. builder() -> FlowBoxChildBuilder43 pub fn builder() -> FlowBoxChildBuilder { 44 FlowBoxChildBuilder::default() 45 } 46 } 47 48 impl Default for FlowBoxChild { default() -> Self49 fn default() -> Self { 50 Self::new() 51 } 52 } 53 54 #[derive(Clone, Default)] 55 // rustdoc-stripper-ignore-next 56 /// A [builder-pattern] type to construct [`FlowBoxChild`] objects. 57 /// 58 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html 59 pub struct FlowBoxChildBuilder { 60 border_width: Option<u32>, 61 child: Option<Widget>, 62 resize_mode: Option<ResizeMode>, 63 app_paintable: Option<bool>, 64 can_default: Option<bool>, 65 can_focus: Option<bool>, 66 events: Option<gdk::EventMask>, 67 expand: Option<bool>, 68 #[cfg(any(feature = "v3_20", feature = "dox"))] 69 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] 70 focus_on_click: Option<bool>, 71 halign: Option<Align>, 72 has_default: Option<bool>, 73 has_focus: Option<bool>, 74 has_tooltip: Option<bool>, 75 height_request: Option<i32>, 76 hexpand: Option<bool>, 77 hexpand_set: Option<bool>, 78 is_focus: Option<bool>, 79 margin: Option<i32>, 80 margin_bottom: Option<i32>, 81 margin_end: Option<i32>, 82 margin_start: Option<i32>, 83 margin_top: Option<i32>, 84 name: Option<String>, 85 no_show_all: Option<bool>, 86 opacity: Option<f64>, 87 parent: Option<Container>, 88 receives_default: Option<bool>, 89 sensitive: Option<bool>, 90 tooltip_markup: Option<String>, 91 tooltip_text: Option<String>, 92 valign: Option<Align>, 93 vexpand: Option<bool>, 94 vexpand_set: Option<bool>, 95 visible: Option<bool>, 96 width_request: Option<i32>, 97 } 98 99 impl FlowBoxChildBuilder { 100 // rustdoc-stripper-ignore-next 101 /// Create a new [`FlowBoxChildBuilder`]. new() -> Self102 pub fn new() -> Self { 103 Self::default() 104 } 105 106 // rustdoc-stripper-ignore-next 107 /// Build the [`FlowBoxChild`]. build(self) -> FlowBoxChild108 pub fn build(self) -> FlowBoxChild { 109 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 110 if let Some(ref border_width) = self.border_width { 111 properties.push(("border-width", border_width)); 112 } 113 if let Some(ref child) = self.child { 114 properties.push(("child", child)); 115 } 116 if let Some(ref resize_mode) = self.resize_mode { 117 properties.push(("resize-mode", resize_mode)); 118 } 119 if let Some(ref app_paintable) = self.app_paintable { 120 properties.push(("app-paintable", app_paintable)); 121 } 122 if let Some(ref can_default) = self.can_default { 123 properties.push(("can-default", can_default)); 124 } 125 if let Some(ref can_focus) = self.can_focus { 126 properties.push(("can-focus", can_focus)); 127 } 128 if let Some(ref events) = self.events { 129 properties.push(("events", events)); 130 } 131 if let Some(ref expand) = self.expand { 132 properties.push(("expand", expand)); 133 } 134 #[cfg(any(feature = "v3_20", feature = "dox"))] 135 if let Some(ref focus_on_click) = self.focus_on_click { 136 properties.push(("focus-on-click", focus_on_click)); 137 } 138 if let Some(ref halign) = self.halign { 139 properties.push(("halign", halign)); 140 } 141 if let Some(ref has_default) = self.has_default { 142 properties.push(("has-default", has_default)); 143 } 144 if let Some(ref has_focus) = self.has_focus { 145 properties.push(("has-focus", has_focus)); 146 } 147 if let Some(ref has_tooltip) = self.has_tooltip { 148 properties.push(("has-tooltip", has_tooltip)); 149 } 150 if let Some(ref height_request) = self.height_request { 151 properties.push(("height-request", height_request)); 152 } 153 if let Some(ref hexpand) = self.hexpand { 154 properties.push(("hexpand", hexpand)); 155 } 156 if let Some(ref hexpand_set) = self.hexpand_set { 157 properties.push(("hexpand-set", hexpand_set)); 158 } 159 if let Some(ref is_focus) = self.is_focus { 160 properties.push(("is-focus", is_focus)); 161 } 162 if let Some(ref margin) = self.margin { 163 properties.push(("margin", margin)); 164 } 165 if let Some(ref margin_bottom) = self.margin_bottom { 166 properties.push(("margin-bottom", margin_bottom)); 167 } 168 if let Some(ref margin_end) = self.margin_end { 169 properties.push(("margin-end", margin_end)); 170 } 171 if let Some(ref margin_start) = self.margin_start { 172 properties.push(("margin-start", margin_start)); 173 } 174 if let Some(ref margin_top) = self.margin_top { 175 properties.push(("margin-top", margin_top)); 176 } 177 if let Some(ref name) = self.name { 178 properties.push(("name", name)); 179 } 180 if let Some(ref no_show_all) = self.no_show_all { 181 properties.push(("no-show-all", no_show_all)); 182 } 183 if let Some(ref opacity) = self.opacity { 184 properties.push(("opacity", opacity)); 185 } 186 if let Some(ref parent) = self.parent { 187 properties.push(("parent", parent)); 188 } 189 if let Some(ref receives_default) = self.receives_default { 190 properties.push(("receives-default", receives_default)); 191 } 192 if let Some(ref sensitive) = self.sensitive { 193 properties.push(("sensitive", sensitive)); 194 } 195 if let Some(ref tooltip_markup) = self.tooltip_markup { 196 properties.push(("tooltip-markup", tooltip_markup)); 197 } 198 if let Some(ref tooltip_text) = self.tooltip_text { 199 properties.push(("tooltip-text", tooltip_text)); 200 } 201 if let Some(ref valign) = self.valign { 202 properties.push(("valign", valign)); 203 } 204 if let Some(ref vexpand) = self.vexpand { 205 properties.push(("vexpand", vexpand)); 206 } 207 if let Some(ref vexpand_set) = self.vexpand_set { 208 properties.push(("vexpand-set", vexpand_set)); 209 } 210 if let Some(ref visible) = self.visible { 211 properties.push(("visible", visible)); 212 } 213 if let Some(ref width_request) = self.width_request { 214 properties.push(("width-request", width_request)); 215 } 216 glib::Object::new::<FlowBoxChild>(&properties) 217 .expect("Failed to create an instance of FlowBoxChild") 218 } 219 border_width(mut self, border_width: u32) -> Self220 pub fn border_width(mut self, border_width: u32) -> Self { 221 self.border_width = Some(border_width); 222 self 223 } 224 child<P: IsA<Widget>>(mut self, child: &P) -> Self225 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 226 self.child = Some(child.clone().upcast()); 227 self 228 } 229 resize_mode(mut self, resize_mode: ResizeMode) -> Self230 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 231 self.resize_mode = Some(resize_mode); 232 self 233 } 234 app_paintable(mut self, app_paintable: bool) -> Self235 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 236 self.app_paintable = Some(app_paintable); 237 self 238 } 239 can_default(mut self, can_default: bool) -> Self240 pub fn can_default(mut self, can_default: bool) -> Self { 241 self.can_default = Some(can_default); 242 self 243 } 244 can_focus(mut self, can_focus: bool) -> Self245 pub fn can_focus(mut self, can_focus: bool) -> Self { 246 self.can_focus = Some(can_focus); 247 self 248 } 249 events(mut self, events: gdk::EventMask) -> Self250 pub fn events(mut self, events: gdk::EventMask) -> Self { 251 self.events = Some(events); 252 self 253 } 254 expand(mut self, expand: bool) -> Self255 pub fn expand(mut self, expand: bool) -> Self { 256 self.expand = Some(expand); 257 self 258 } 259 260 #[cfg(any(feature = "v3_20", feature = "dox"))] 261 #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))] focus_on_click(mut self, focus_on_click: bool) -> Self262 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 263 self.focus_on_click = Some(focus_on_click); 264 self 265 } 266 halign(mut self, halign: Align) -> Self267 pub fn halign(mut self, halign: Align) -> Self { 268 self.halign = Some(halign); 269 self 270 } 271 has_default(mut self, has_default: bool) -> Self272 pub fn has_default(mut self, has_default: bool) -> Self { 273 self.has_default = Some(has_default); 274 self 275 } 276 has_focus(mut self, has_focus: bool) -> Self277 pub fn has_focus(mut self, has_focus: bool) -> Self { 278 self.has_focus = Some(has_focus); 279 self 280 } 281 has_tooltip(mut self, has_tooltip: bool) -> Self282 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 283 self.has_tooltip = Some(has_tooltip); 284 self 285 } 286 height_request(mut self, height_request: i32) -> Self287 pub fn height_request(mut self, height_request: i32) -> Self { 288 self.height_request = Some(height_request); 289 self 290 } 291 hexpand(mut self, hexpand: bool) -> Self292 pub fn hexpand(mut self, hexpand: bool) -> Self { 293 self.hexpand = Some(hexpand); 294 self 295 } 296 hexpand_set(mut self, hexpand_set: bool) -> Self297 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 298 self.hexpand_set = Some(hexpand_set); 299 self 300 } 301 is_focus(mut self, is_focus: bool) -> Self302 pub fn is_focus(mut self, is_focus: bool) -> Self { 303 self.is_focus = Some(is_focus); 304 self 305 } 306 margin(mut self, margin: i32) -> Self307 pub fn margin(mut self, margin: i32) -> Self { 308 self.margin = Some(margin); 309 self 310 } 311 margin_bottom(mut self, margin_bottom: i32) -> Self312 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 313 self.margin_bottom = Some(margin_bottom); 314 self 315 } 316 margin_end(mut self, margin_end: i32) -> Self317 pub fn margin_end(mut self, margin_end: i32) -> Self { 318 self.margin_end = Some(margin_end); 319 self 320 } 321 margin_start(mut self, margin_start: i32) -> Self322 pub fn margin_start(mut self, margin_start: i32) -> Self { 323 self.margin_start = Some(margin_start); 324 self 325 } 326 margin_top(mut self, margin_top: i32) -> Self327 pub fn margin_top(mut self, margin_top: i32) -> Self { 328 self.margin_top = Some(margin_top); 329 self 330 } 331 name(mut self, name: &str) -> Self332 pub fn name(mut self, name: &str) -> Self { 333 self.name = Some(name.to_string()); 334 self 335 } 336 no_show_all(mut self, no_show_all: bool) -> Self337 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 338 self.no_show_all = Some(no_show_all); 339 self 340 } 341 opacity(mut self, opacity: f64) -> Self342 pub fn opacity(mut self, opacity: f64) -> Self { 343 self.opacity = Some(opacity); 344 self 345 } 346 parent<P: IsA<Container>>(mut self, parent: &P) -> Self347 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 348 self.parent = Some(parent.clone().upcast()); 349 self 350 } 351 receives_default(mut self, receives_default: bool) -> Self352 pub fn receives_default(mut self, receives_default: bool) -> Self { 353 self.receives_default = Some(receives_default); 354 self 355 } 356 sensitive(mut self, sensitive: bool) -> Self357 pub fn sensitive(mut self, sensitive: bool) -> Self { 358 self.sensitive = Some(sensitive); 359 self 360 } 361 tooltip_markup(mut self, tooltip_markup: &str) -> Self362 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 363 self.tooltip_markup = Some(tooltip_markup.to_string()); 364 self 365 } 366 tooltip_text(mut self, tooltip_text: &str) -> Self367 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 368 self.tooltip_text = Some(tooltip_text.to_string()); 369 self 370 } 371 valign(mut self, valign: Align) -> Self372 pub fn valign(mut self, valign: Align) -> Self { 373 self.valign = Some(valign); 374 self 375 } 376 vexpand(mut self, vexpand: bool) -> Self377 pub fn vexpand(mut self, vexpand: bool) -> Self { 378 self.vexpand = Some(vexpand); 379 self 380 } 381 vexpand_set(mut self, vexpand_set: bool) -> Self382 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 383 self.vexpand_set = Some(vexpand_set); 384 self 385 } 386 visible(mut self, visible: bool) -> Self387 pub fn visible(mut self, visible: bool) -> Self { 388 self.visible = Some(visible); 389 self 390 } 391 width_request(mut self, width_request: i32) -> Self392 pub fn width_request(mut self, width_request: i32) -> Self { 393 self.width_request = Some(width_request); 394 self 395 } 396 } 397 398 pub const NONE_FLOW_BOX_CHILD: Option<&FlowBoxChild> = None; 399 400 pub trait FlowBoxChildExt: 'static { 401 #[doc(alias = "gtk_flow_box_child_changed")] changed(&self)402 fn changed(&self); 403 404 #[doc(alias = "gtk_flow_box_child_get_index")] 405 #[doc(alias = "get_index")] index(&self) -> i32406 fn index(&self) -> i32; 407 408 #[doc(alias = "gtk_flow_box_child_is_selected")] is_selected(&self) -> bool409 fn is_selected(&self) -> bool; 410 411 #[doc(alias = "activate")] connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId412 fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 413 emit_activate(&self)414 fn emit_activate(&self); 415 } 416 417 impl<O: IsA<FlowBoxChild>> FlowBoxChildExt for O { changed(&self)418 fn changed(&self) { 419 unsafe { 420 ffi::gtk_flow_box_child_changed(self.as_ref().to_glib_none().0); 421 } 422 } 423 index(&self) -> i32424 fn index(&self) -> i32 { 425 unsafe { ffi::gtk_flow_box_child_get_index(self.as_ref().to_glib_none().0) } 426 } 427 is_selected(&self) -> bool428 fn is_selected(&self) -> bool { 429 unsafe { 430 from_glib(ffi::gtk_flow_box_child_is_selected( 431 self.as_ref().to_glib_none().0, 432 )) 433 } 434 } 435 connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId436 fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 437 unsafe extern "C" fn activate_trampoline<P: IsA<FlowBoxChild>, F: Fn(&P) + 'static>( 438 this: *mut ffi::GtkFlowBoxChild, 439 f: glib::ffi::gpointer, 440 ) { 441 let f: &F = &*(f as *const F); 442 f(FlowBoxChild::from_glib_borrow(this).unsafe_cast_ref()) 443 } 444 unsafe { 445 let f: Box_<F> = Box_::new(f); 446 connect_raw( 447 self.as_ptr() as *mut _, 448 b"activate\0".as_ptr() as *const _, 449 Some(transmute::<_, unsafe extern "C" fn()>( 450 activate_trampoline::<Self, F> as *const (), 451 )), 452 Box_::into_raw(f), 453 ) 454 } 455 } 456 emit_activate(&self)457 fn emit_activate(&self) { 458 let _ = unsafe { 459 glib::Object::from_glib_borrow(self.as_ptr() as *mut glib::gobject_ffi::GObject) 460 .emit_by_name("activate", &[]) 461 .unwrap() 462 }; 463 } 464 } 465 466 impl fmt::Display for FlowBoxChild { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result467 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 468 f.write_str("FlowBoxChild") 469 } 470 } 471