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 gdk; 6 use glib; 7 use glib::object::Cast; 8 use glib::object::IsA; 9 use glib::object::ObjectExt; 10 use glib::signal::connect_raw; 11 use glib::signal::SignalHandlerId; 12 use glib::translate::*; 13 use glib::StaticType; 14 use glib::ToValue; 15 use glib_sys; 16 use gobject_sys; 17 use gtk_sys; 18 use std::boxed::Box as Box_; 19 use std::fmt; 20 use std::mem::transmute; 21 use Align; 22 use Bin; 23 use Buildable; 24 use Container; 25 use ResizeMode; 26 use Widget; 27 28 glib_wrapper! { 29 pub struct FlowBoxChild(Object<gtk_sys::GtkFlowBoxChild, gtk_sys::GtkFlowBoxChildClass, FlowBoxChildClass>) @extends Bin, Container, Widget, @implements Buildable; 30 31 match fn { 32 get_type => || gtk_sys::gtk_flow_box_child_get_type(), 33 } 34 } 35 36 impl FlowBoxChild { new() -> FlowBoxChild37 pub fn new() -> FlowBoxChild { 38 assert_initialized_main_thread!(); 39 unsafe { Widget::from_glib_none(gtk_sys::gtk_flow_box_child_new()).unsafe_cast() } 40 } 41 } 42 43 impl Default for FlowBoxChild { default() -> Self44 fn default() -> Self { 45 Self::new() 46 } 47 } 48 49 #[derive(Clone, Default)] 50 pub struct FlowBoxChildBuilder { 51 border_width: Option<u32>, 52 child: Option<Widget>, 53 resize_mode: Option<ResizeMode>, 54 app_paintable: Option<bool>, 55 can_default: Option<bool>, 56 can_focus: Option<bool>, 57 events: Option<gdk::EventMask>, 58 expand: Option<bool>, 59 #[cfg(any(feature = "v3_20", feature = "dox"))] 60 focus_on_click: Option<bool>, 61 halign: Option<Align>, 62 has_default: Option<bool>, 63 has_focus: Option<bool>, 64 has_tooltip: Option<bool>, 65 height_request: Option<i32>, 66 hexpand: Option<bool>, 67 hexpand_set: Option<bool>, 68 is_focus: Option<bool>, 69 margin: Option<i32>, 70 margin_bottom: Option<i32>, 71 margin_end: Option<i32>, 72 margin_start: Option<i32>, 73 margin_top: Option<i32>, 74 name: Option<String>, 75 no_show_all: Option<bool>, 76 opacity: Option<f64>, 77 parent: Option<Container>, 78 receives_default: Option<bool>, 79 sensitive: Option<bool>, 80 tooltip_markup: Option<String>, 81 tooltip_text: Option<String>, 82 valign: Option<Align>, 83 vexpand: Option<bool>, 84 vexpand_set: Option<bool>, 85 visible: Option<bool>, 86 width_request: Option<i32>, 87 } 88 89 impl FlowBoxChildBuilder { new() -> Self90 pub fn new() -> Self { 91 Self::default() 92 } 93 build(self) -> FlowBoxChild94 pub fn build(self) -> FlowBoxChild { 95 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 96 if let Some(ref border_width) = self.border_width { 97 properties.push(("border-width", border_width)); 98 } 99 if let Some(ref child) = self.child { 100 properties.push(("child", child)); 101 } 102 if let Some(ref resize_mode) = self.resize_mode { 103 properties.push(("resize-mode", resize_mode)); 104 } 105 if let Some(ref app_paintable) = self.app_paintable { 106 properties.push(("app-paintable", app_paintable)); 107 } 108 if let Some(ref can_default) = self.can_default { 109 properties.push(("can-default", can_default)); 110 } 111 if let Some(ref can_focus) = self.can_focus { 112 properties.push(("can-focus", can_focus)); 113 } 114 if let Some(ref events) = self.events { 115 properties.push(("events", events)); 116 } 117 if let Some(ref expand) = self.expand { 118 properties.push(("expand", expand)); 119 } 120 #[cfg(any(feature = "v3_20", feature = "dox"))] 121 { 122 if let Some(ref focus_on_click) = self.focus_on_click { 123 properties.push(("focus-on-click", focus_on_click)); 124 } 125 } 126 if let Some(ref halign) = self.halign { 127 properties.push(("halign", halign)); 128 } 129 if let Some(ref has_default) = self.has_default { 130 properties.push(("has-default", has_default)); 131 } 132 if let Some(ref has_focus) = self.has_focus { 133 properties.push(("has-focus", has_focus)); 134 } 135 if let Some(ref has_tooltip) = self.has_tooltip { 136 properties.push(("has-tooltip", has_tooltip)); 137 } 138 if let Some(ref height_request) = self.height_request { 139 properties.push(("height-request", height_request)); 140 } 141 if let Some(ref hexpand) = self.hexpand { 142 properties.push(("hexpand", hexpand)); 143 } 144 if let Some(ref hexpand_set) = self.hexpand_set { 145 properties.push(("hexpand-set", hexpand_set)); 146 } 147 if let Some(ref is_focus) = self.is_focus { 148 properties.push(("is-focus", is_focus)); 149 } 150 if let Some(ref margin) = self.margin { 151 properties.push(("margin", margin)); 152 } 153 if let Some(ref margin_bottom) = self.margin_bottom { 154 properties.push(("margin-bottom", margin_bottom)); 155 } 156 if let Some(ref margin_end) = self.margin_end { 157 properties.push(("margin-end", margin_end)); 158 } 159 if let Some(ref margin_start) = self.margin_start { 160 properties.push(("margin-start", margin_start)); 161 } 162 if let Some(ref margin_top) = self.margin_top { 163 properties.push(("margin-top", margin_top)); 164 } 165 if let Some(ref name) = self.name { 166 properties.push(("name", name)); 167 } 168 if let Some(ref no_show_all) = self.no_show_all { 169 properties.push(("no-show-all", no_show_all)); 170 } 171 if let Some(ref opacity) = self.opacity { 172 properties.push(("opacity", opacity)); 173 } 174 if let Some(ref parent) = self.parent { 175 properties.push(("parent", parent)); 176 } 177 if let Some(ref receives_default) = self.receives_default { 178 properties.push(("receives-default", receives_default)); 179 } 180 if let Some(ref sensitive) = self.sensitive { 181 properties.push(("sensitive", sensitive)); 182 } 183 if let Some(ref tooltip_markup) = self.tooltip_markup { 184 properties.push(("tooltip-markup", tooltip_markup)); 185 } 186 if let Some(ref tooltip_text) = self.tooltip_text { 187 properties.push(("tooltip-text", tooltip_text)); 188 } 189 if let Some(ref valign) = self.valign { 190 properties.push(("valign", valign)); 191 } 192 if let Some(ref vexpand) = self.vexpand { 193 properties.push(("vexpand", vexpand)); 194 } 195 if let Some(ref vexpand_set) = self.vexpand_set { 196 properties.push(("vexpand-set", vexpand_set)); 197 } 198 if let Some(ref visible) = self.visible { 199 properties.push(("visible", visible)); 200 } 201 if let Some(ref width_request) = self.width_request { 202 properties.push(("width-request", width_request)); 203 } 204 glib::Object::new(FlowBoxChild::static_type(), &properties) 205 .expect("object new") 206 .downcast() 207 .expect("downcast") 208 } 209 border_width(mut self, border_width: u32) -> Self210 pub fn border_width(mut self, border_width: u32) -> Self { 211 self.border_width = Some(border_width); 212 self 213 } 214 child<P: IsA<Widget>>(mut self, child: &P) -> Self215 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 216 self.child = Some(child.clone().upcast()); 217 self 218 } 219 resize_mode(mut self, resize_mode: ResizeMode) -> Self220 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 221 self.resize_mode = Some(resize_mode); 222 self 223 } 224 app_paintable(mut self, app_paintable: bool) -> Self225 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 226 self.app_paintable = Some(app_paintable); 227 self 228 } 229 can_default(mut self, can_default: bool) -> Self230 pub fn can_default(mut self, can_default: bool) -> Self { 231 self.can_default = Some(can_default); 232 self 233 } 234 can_focus(mut self, can_focus: bool) -> Self235 pub fn can_focus(mut self, can_focus: bool) -> Self { 236 self.can_focus = Some(can_focus); 237 self 238 } 239 events(mut self, events: gdk::EventMask) -> Self240 pub fn events(mut self, events: gdk::EventMask) -> Self { 241 self.events = Some(events); 242 self 243 } 244 expand(mut self, expand: bool) -> Self245 pub fn expand(mut self, expand: bool) -> Self { 246 self.expand = Some(expand); 247 self 248 } 249 250 #[cfg(any(feature = "v3_20", feature = "dox"))] focus_on_click(mut self, focus_on_click: bool) -> Self251 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 252 self.focus_on_click = Some(focus_on_click); 253 self 254 } 255 halign(mut self, halign: Align) -> Self256 pub fn halign(mut self, halign: Align) -> Self { 257 self.halign = Some(halign); 258 self 259 } 260 has_default(mut self, has_default: bool) -> Self261 pub fn has_default(mut self, has_default: bool) -> Self { 262 self.has_default = Some(has_default); 263 self 264 } 265 has_focus(mut self, has_focus: bool) -> Self266 pub fn has_focus(mut self, has_focus: bool) -> Self { 267 self.has_focus = Some(has_focus); 268 self 269 } 270 has_tooltip(mut self, has_tooltip: bool) -> Self271 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 272 self.has_tooltip = Some(has_tooltip); 273 self 274 } 275 height_request(mut self, height_request: i32) -> Self276 pub fn height_request(mut self, height_request: i32) -> Self { 277 self.height_request = Some(height_request); 278 self 279 } 280 hexpand(mut self, hexpand: bool) -> Self281 pub fn hexpand(mut self, hexpand: bool) -> Self { 282 self.hexpand = Some(hexpand); 283 self 284 } 285 hexpand_set(mut self, hexpand_set: bool) -> Self286 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 287 self.hexpand_set = Some(hexpand_set); 288 self 289 } 290 is_focus(mut self, is_focus: bool) -> Self291 pub fn is_focus(mut self, is_focus: bool) -> Self { 292 self.is_focus = Some(is_focus); 293 self 294 } 295 margin(mut self, margin: i32) -> Self296 pub fn margin(mut self, margin: i32) -> Self { 297 self.margin = Some(margin); 298 self 299 } 300 margin_bottom(mut self, margin_bottom: i32) -> Self301 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 302 self.margin_bottom = Some(margin_bottom); 303 self 304 } 305 margin_end(mut self, margin_end: i32) -> Self306 pub fn margin_end(mut self, margin_end: i32) -> Self { 307 self.margin_end = Some(margin_end); 308 self 309 } 310 margin_start(mut self, margin_start: i32) -> Self311 pub fn margin_start(mut self, margin_start: i32) -> Self { 312 self.margin_start = Some(margin_start); 313 self 314 } 315 margin_top(mut self, margin_top: i32) -> Self316 pub fn margin_top(mut self, margin_top: i32) -> Self { 317 self.margin_top = Some(margin_top); 318 self 319 } 320 name(mut self, name: &str) -> Self321 pub fn name(mut self, name: &str) -> Self { 322 self.name = Some(name.to_string()); 323 self 324 } 325 no_show_all(mut self, no_show_all: bool) -> Self326 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 327 self.no_show_all = Some(no_show_all); 328 self 329 } 330 opacity(mut self, opacity: f64) -> Self331 pub fn opacity(mut self, opacity: f64) -> Self { 332 self.opacity = Some(opacity); 333 self 334 } 335 parent<P: IsA<Container>>(mut self, parent: &P) -> Self336 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 337 self.parent = Some(parent.clone().upcast()); 338 self 339 } 340 receives_default(mut self, receives_default: bool) -> Self341 pub fn receives_default(mut self, receives_default: bool) -> Self { 342 self.receives_default = Some(receives_default); 343 self 344 } 345 sensitive(mut self, sensitive: bool) -> Self346 pub fn sensitive(mut self, sensitive: bool) -> Self { 347 self.sensitive = Some(sensitive); 348 self 349 } 350 tooltip_markup(mut self, tooltip_markup: &str) -> Self351 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 352 self.tooltip_markup = Some(tooltip_markup.to_string()); 353 self 354 } 355 tooltip_text(mut self, tooltip_text: &str) -> Self356 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 357 self.tooltip_text = Some(tooltip_text.to_string()); 358 self 359 } 360 valign(mut self, valign: Align) -> Self361 pub fn valign(mut self, valign: Align) -> Self { 362 self.valign = Some(valign); 363 self 364 } 365 vexpand(mut self, vexpand: bool) -> Self366 pub fn vexpand(mut self, vexpand: bool) -> Self { 367 self.vexpand = Some(vexpand); 368 self 369 } 370 vexpand_set(mut self, vexpand_set: bool) -> Self371 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 372 self.vexpand_set = Some(vexpand_set); 373 self 374 } 375 visible(mut self, visible: bool) -> Self376 pub fn visible(mut self, visible: bool) -> Self { 377 self.visible = Some(visible); 378 self 379 } 380 width_request(mut self, width_request: i32) -> Self381 pub fn width_request(mut self, width_request: i32) -> Self { 382 self.width_request = Some(width_request); 383 self 384 } 385 } 386 387 pub const NONE_FLOW_BOX_CHILD: Option<&FlowBoxChild> = None; 388 389 pub trait FlowBoxChildExt: 'static { changed(&self)390 fn changed(&self); 391 get_index(&self) -> i32392 fn get_index(&self) -> i32; 393 is_selected(&self) -> bool394 fn is_selected(&self) -> bool; 395 connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId396 fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 397 emit_activate(&self)398 fn emit_activate(&self); 399 } 400 401 impl<O: IsA<FlowBoxChild>> FlowBoxChildExt for O { changed(&self)402 fn changed(&self) { 403 unsafe { 404 gtk_sys::gtk_flow_box_child_changed(self.as_ref().to_glib_none().0); 405 } 406 } 407 get_index(&self) -> i32408 fn get_index(&self) -> i32 { 409 unsafe { gtk_sys::gtk_flow_box_child_get_index(self.as_ref().to_glib_none().0) } 410 } 411 is_selected(&self) -> bool412 fn is_selected(&self) -> bool { 413 unsafe { 414 from_glib(gtk_sys::gtk_flow_box_child_is_selected( 415 self.as_ref().to_glib_none().0, 416 )) 417 } 418 } 419 connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId420 fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 421 unsafe extern "C" fn activate_trampoline<P, F: Fn(&P) + 'static>( 422 this: *mut gtk_sys::GtkFlowBoxChild, 423 f: glib_sys::gpointer, 424 ) where 425 P: IsA<FlowBoxChild>, 426 { 427 let f: &F = &*(f as *const F); 428 f(&FlowBoxChild::from_glib_borrow(this).unsafe_cast()) 429 } 430 unsafe { 431 let f: Box_<F> = Box_::new(f); 432 connect_raw( 433 self.as_ptr() as *mut _, 434 b"activate\0".as_ptr() as *const _, 435 Some(transmute(activate_trampoline::<Self, F> as usize)), 436 Box_::into_raw(f), 437 ) 438 } 439 } 440 emit_activate(&self)441 fn emit_activate(&self) { 442 let _ = unsafe { 443 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject) 444 .emit("activate", &[]) 445 .unwrap() 446 }; 447 } 448 } 449 450 impl fmt::Display for FlowBoxChild { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result451 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 452 write!(f, "FlowBoxChild") 453 } 454 } 455