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 Actionable; 22 use Align; 23 use Bin; 24 use Buildable; 25 use Container; 26 use ResizeMode; 27 use Widget; 28 29 glib_wrapper! { 30 pub struct ListBoxRow(Object<gtk_sys::GtkListBoxRow, gtk_sys::GtkListBoxRowClass, ListBoxRowClass>) @extends Bin, Container, Widget, @implements Buildable, Actionable; 31 32 match fn { 33 get_type => || gtk_sys::gtk_list_box_row_get_type(), 34 } 35 } 36 37 impl ListBoxRow { new() -> ListBoxRow38 pub fn new() -> ListBoxRow { 39 assert_initialized_main_thread!(); 40 unsafe { Widget::from_glib_none(gtk_sys::gtk_list_box_row_new()).unsafe_cast() } 41 } 42 } 43 44 impl Default for ListBoxRow { default() -> Self45 fn default() -> Self { 46 Self::new() 47 } 48 } 49 50 #[derive(Clone, Default)] 51 pub struct ListBoxRowBuilder { 52 activatable: Option<bool>, 53 selectable: Option<bool>, 54 border_width: Option<u32>, 55 child: Option<Widget>, 56 resize_mode: Option<ResizeMode>, 57 app_paintable: Option<bool>, 58 can_default: Option<bool>, 59 can_focus: Option<bool>, 60 events: Option<gdk::EventMask>, 61 expand: Option<bool>, 62 #[cfg(any(feature = "v3_20", feature = "dox"))] 63 focus_on_click: Option<bool>, 64 halign: Option<Align>, 65 has_default: Option<bool>, 66 has_focus: Option<bool>, 67 has_tooltip: Option<bool>, 68 height_request: Option<i32>, 69 hexpand: Option<bool>, 70 hexpand_set: Option<bool>, 71 is_focus: Option<bool>, 72 margin: Option<i32>, 73 margin_bottom: Option<i32>, 74 margin_end: Option<i32>, 75 margin_start: Option<i32>, 76 margin_top: Option<i32>, 77 name: Option<String>, 78 no_show_all: Option<bool>, 79 opacity: Option<f64>, 80 parent: Option<Container>, 81 receives_default: Option<bool>, 82 sensitive: Option<bool>, 83 tooltip_markup: Option<String>, 84 tooltip_text: Option<String>, 85 valign: Option<Align>, 86 vexpand: Option<bool>, 87 vexpand_set: Option<bool>, 88 visible: Option<bool>, 89 width_request: Option<i32>, 90 action_name: Option<String>, 91 action_target: Option<glib::Variant>, 92 } 93 94 impl ListBoxRowBuilder { new() -> Self95 pub fn new() -> Self { 96 Self::default() 97 } 98 build(self) -> ListBoxRow99 pub fn build(self) -> ListBoxRow { 100 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 101 if let Some(ref activatable) = self.activatable { 102 properties.push(("activatable", activatable)); 103 } 104 if let Some(ref selectable) = self.selectable { 105 properties.push(("selectable", selectable)); 106 } 107 if let Some(ref border_width) = self.border_width { 108 properties.push(("border-width", border_width)); 109 } 110 if let Some(ref child) = self.child { 111 properties.push(("child", child)); 112 } 113 if let Some(ref resize_mode) = self.resize_mode { 114 properties.push(("resize-mode", resize_mode)); 115 } 116 if let Some(ref app_paintable) = self.app_paintable { 117 properties.push(("app-paintable", app_paintable)); 118 } 119 if let Some(ref can_default) = self.can_default { 120 properties.push(("can-default", can_default)); 121 } 122 if let Some(ref can_focus) = self.can_focus { 123 properties.push(("can-focus", can_focus)); 124 } 125 if let Some(ref events) = self.events { 126 properties.push(("events", events)); 127 } 128 if let Some(ref expand) = self.expand { 129 properties.push(("expand", expand)); 130 } 131 #[cfg(any(feature = "v3_20", feature = "dox"))] 132 { 133 if let Some(ref focus_on_click) = self.focus_on_click { 134 properties.push(("focus-on-click", focus_on_click)); 135 } 136 } 137 if let Some(ref halign) = self.halign { 138 properties.push(("halign", halign)); 139 } 140 if let Some(ref has_default) = self.has_default { 141 properties.push(("has-default", has_default)); 142 } 143 if let Some(ref has_focus) = self.has_focus { 144 properties.push(("has-focus", has_focus)); 145 } 146 if let Some(ref has_tooltip) = self.has_tooltip { 147 properties.push(("has-tooltip", has_tooltip)); 148 } 149 if let Some(ref height_request) = self.height_request { 150 properties.push(("height-request", height_request)); 151 } 152 if let Some(ref hexpand) = self.hexpand { 153 properties.push(("hexpand", hexpand)); 154 } 155 if let Some(ref hexpand_set) = self.hexpand_set { 156 properties.push(("hexpand-set", hexpand_set)); 157 } 158 if let Some(ref is_focus) = self.is_focus { 159 properties.push(("is-focus", is_focus)); 160 } 161 if let Some(ref margin) = self.margin { 162 properties.push(("margin", margin)); 163 } 164 if let Some(ref margin_bottom) = self.margin_bottom { 165 properties.push(("margin-bottom", margin_bottom)); 166 } 167 if let Some(ref margin_end) = self.margin_end { 168 properties.push(("margin-end", margin_end)); 169 } 170 if let Some(ref margin_start) = self.margin_start { 171 properties.push(("margin-start", margin_start)); 172 } 173 if let Some(ref margin_top) = self.margin_top { 174 properties.push(("margin-top", margin_top)); 175 } 176 if let Some(ref name) = self.name { 177 properties.push(("name", name)); 178 } 179 if let Some(ref no_show_all) = self.no_show_all { 180 properties.push(("no-show-all", no_show_all)); 181 } 182 if let Some(ref opacity) = self.opacity { 183 properties.push(("opacity", opacity)); 184 } 185 if let Some(ref parent) = self.parent { 186 properties.push(("parent", parent)); 187 } 188 if let Some(ref receives_default) = self.receives_default { 189 properties.push(("receives-default", receives_default)); 190 } 191 if let Some(ref sensitive) = self.sensitive { 192 properties.push(("sensitive", sensitive)); 193 } 194 if let Some(ref tooltip_markup) = self.tooltip_markup { 195 properties.push(("tooltip-markup", tooltip_markup)); 196 } 197 if let Some(ref tooltip_text) = self.tooltip_text { 198 properties.push(("tooltip-text", tooltip_text)); 199 } 200 if let Some(ref valign) = self.valign { 201 properties.push(("valign", valign)); 202 } 203 if let Some(ref vexpand) = self.vexpand { 204 properties.push(("vexpand", vexpand)); 205 } 206 if let Some(ref vexpand_set) = self.vexpand_set { 207 properties.push(("vexpand-set", vexpand_set)); 208 } 209 if let Some(ref visible) = self.visible { 210 properties.push(("visible", visible)); 211 } 212 if let Some(ref width_request) = self.width_request { 213 properties.push(("width-request", width_request)); 214 } 215 if let Some(ref action_name) = self.action_name { 216 properties.push(("action-name", action_name)); 217 } 218 if let Some(ref action_target) = self.action_target { 219 properties.push(("action-target", action_target)); 220 } 221 glib::Object::new(ListBoxRow::static_type(), &properties) 222 .expect("object new") 223 .downcast() 224 .expect("downcast") 225 } 226 activatable(mut self, activatable: bool) -> Self227 pub fn activatable(mut self, activatable: bool) -> Self { 228 self.activatable = Some(activatable); 229 self 230 } 231 selectable(mut self, selectable: bool) -> Self232 pub fn selectable(mut self, selectable: bool) -> Self { 233 self.selectable = Some(selectable); 234 self 235 } 236 border_width(mut self, border_width: u32) -> Self237 pub fn border_width(mut self, border_width: u32) -> Self { 238 self.border_width = Some(border_width); 239 self 240 } 241 child<P: IsA<Widget>>(mut self, child: &P) -> Self242 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 243 self.child = Some(child.clone().upcast()); 244 self 245 } 246 resize_mode(mut self, resize_mode: ResizeMode) -> Self247 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 248 self.resize_mode = Some(resize_mode); 249 self 250 } 251 app_paintable(mut self, app_paintable: bool) -> Self252 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 253 self.app_paintable = Some(app_paintable); 254 self 255 } 256 can_default(mut self, can_default: bool) -> Self257 pub fn can_default(mut self, can_default: bool) -> Self { 258 self.can_default = Some(can_default); 259 self 260 } 261 can_focus(mut self, can_focus: bool) -> Self262 pub fn can_focus(mut self, can_focus: bool) -> Self { 263 self.can_focus = Some(can_focus); 264 self 265 } 266 events(mut self, events: gdk::EventMask) -> Self267 pub fn events(mut self, events: gdk::EventMask) -> Self { 268 self.events = Some(events); 269 self 270 } 271 expand(mut self, expand: bool) -> Self272 pub fn expand(mut self, expand: bool) -> Self { 273 self.expand = Some(expand); 274 self 275 } 276 277 #[cfg(any(feature = "v3_20", feature = "dox"))] focus_on_click(mut self, focus_on_click: bool) -> Self278 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 279 self.focus_on_click = Some(focus_on_click); 280 self 281 } 282 halign(mut self, halign: Align) -> Self283 pub fn halign(mut self, halign: Align) -> Self { 284 self.halign = Some(halign); 285 self 286 } 287 has_default(mut self, has_default: bool) -> Self288 pub fn has_default(mut self, has_default: bool) -> Self { 289 self.has_default = Some(has_default); 290 self 291 } 292 has_focus(mut self, has_focus: bool) -> Self293 pub fn has_focus(mut self, has_focus: bool) -> Self { 294 self.has_focus = Some(has_focus); 295 self 296 } 297 has_tooltip(mut self, has_tooltip: bool) -> Self298 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 299 self.has_tooltip = Some(has_tooltip); 300 self 301 } 302 height_request(mut self, height_request: i32) -> Self303 pub fn height_request(mut self, height_request: i32) -> Self { 304 self.height_request = Some(height_request); 305 self 306 } 307 hexpand(mut self, hexpand: bool) -> Self308 pub fn hexpand(mut self, hexpand: bool) -> Self { 309 self.hexpand = Some(hexpand); 310 self 311 } 312 hexpand_set(mut self, hexpand_set: bool) -> Self313 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 314 self.hexpand_set = Some(hexpand_set); 315 self 316 } 317 is_focus(mut self, is_focus: bool) -> Self318 pub fn is_focus(mut self, is_focus: bool) -> Self { 319 self.is_focus = Some(is_focus); 320 self 321 } 322 margin(mut self, margin: i32) -> Self323 pub fn margin(mut self, margin: i32) -> Self { 324 self.margin = Some(margin); 325 self 326 } 327 margin_bottom(mut self, margin_bottom: i32) -> Self328 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 329 self.margin_bottom = Some(margin_bottom); 330 self 331 } 332 margin_end(mut self, margin_end: i32) -> Self333 pub fn margin_end(mut self, margin_end: i32) -> Self { 334 self.margin_end = Some(margin_end); 335 self 336 } 337 margin_start(mut self, margin_start: i32) -> Self338 pub fn margin_start(mut self, margin_start: i32) -> Self { 339 self.margin_start = Some(margin_start); 340 self 341 } 342 margin_top(mut self, margin_top: i32) -> Self343 pub fn margin_top(mut self, margin_top: i32) -> Self { 344 self.margin_top = Some(margin_top); 345 self 346 } 347 name(mut self, name: &str) -> Self348 pub fn name(mut self, name: &str) -> Self { 349 self.name = Some(name.to_string()); 350 self 351 } 352 no_show_all(mut self, no_show_all: bool) -> Self353 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 354 self.no_show_all = Some(no_show_all); 355 self 356 } 357 opacity(mut self, opacity: f64) -> Self358 pub fn opacity(mut self, opacity: f64) -> Self { 359 self.opacity = Some(opacity); 360 self 361 } 362 parent<P: IsA<Container>>(mut self, parent: &P) -> Self363 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 364 self.parent = Some(parent.clone().upcast()); 365 self 366 } 367 receives_default(mut self, receives_default: bool) -> Self368 pub fn receives_default(mut self, receives_default: bool) -> Self { 369 self.receives_default = Some(receives_default); 370 self 371 } 372 sensitive(mut self, sensitive: bool) -> Self373 pub fn sensitive(mut self, sensitive: bool) -> Self { 374 self.sensitive = Some(sensitive); 375 self 376 } 377 tooltip_markup(mut self, tooltip_markup: &str) -> Self378 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 379 self.tooltip_markup = Some(tooltip_markup.to_string()); 380 self 381 } 382 tooltip_text(mut self, tooltip_text: &str) -> Self383 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 384 self.tooltip_text = Some(tooltip_text.to_string()); 385 self 386 } 387 valign(mut self, valign: Align) -> Self388 pub fn valign(mut self, valign: Align) -> Self { 389 self.valign = Some(valign); 390 self 391 } 392 vexpand(mut self, vexpand: bool) -> Self393 pub fn vexpand(mut self, vexpand: bool) -> Self { 394 self.vexpand = Some(vexpand); 395 self 396 } 397 vexpand_set(mut self, vexpand_set: bool) -> Self398 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 399 self.vexpand_set = Some(vexpand_set); 400 self 401 } 402 visible(mut self, visible: bool) -> Self403 pub fn visible(mut self, visible: bool) -> Self { 404 self.visible = Some(visible); 405 self 406 } 407 width_request(mut self, width_request: i32) -> Self408 pub fn width_request(mut self, width_request: i32) -> Self { 409 self.width_request = Some(width_request); 410 self 411 } 412 action_name(mut self, action_name: &str) -> Self413 pub fn action_name(mut self, action_name: &str) -> Self { 414 self.action_name = Some(action_name.to_string()); 415 self 416 } 417 action_target(mut self, action_target: &glib::Variant) -> Self418 pub fn action_target(mut self, action_target: &glib::Variant) -> Self { 419 self.action_target = Some(action_target.clone()); 420 self 421 } 422 } 423 424 pub const NONE_LIST_BOX_ROW: Option<&ListBoxRow> = None; 425 426 pub trait ListBoxRowExt: 'static { changed(&self)427 fn changed(&self); 428 get_activatable(&self) -> bool429 fn get_activatable(&self) -> bool; 430 get_header(&self) -> Option<Widget>431 fn get_header(&self) -> Option<Widget>; 432 get_index(&self) -> i32433 fn get_index(&self) -> i32; 434 get_selectable(&self) -> bool435 fn get_selectable(&self) -> bool; 436 is_selected(&self) -> bool437 fn is_selected(&self) -> bool; 438 set_activatable(&self, activatable: bool)439 fn set_activatable(&self, activatable: bool); 440 set_header<P: IsA<Widget>>(&self, header: Option<&P>)441 fn set_header<P: IsA<Widget>>(&self, header: Option<&P>); 442 set_selectable(&self, selectable: bool)443 fn set_selectable(&self, selectable: bool); 444 connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId445 fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 446 emit_activate(&self)447 fn emit_activate(&self); 448 connect_property_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId449 fn connect_property_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 450 connect_property_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId451 fn connect_property_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 452 } 453 454 impl<O: IsA<ListBoxRow>> ListBoxRowExt for O { changed(&self)455 fn changed(&self) { 456 unsafe { 457 gtk_sys::gtk_list_box_row_changed(self.as_ref().to_glib_none().0); 458 } 459 } 460 get_activatable(&self) -> bool461 fn get_activatable(&self) -> bool { 462 unsafe { 463 from_glib(gtk_sys::gtk_list_box_row_get_activatable( 464 self.as_ref().to_glib_none().0, 465 )) 466 } 467 } 468 get_header(&self) -> Option<Widget>469 fn get_header(&self) -> Option<Widget> { 470 unsafe { 471 from_glib_none(gtk_sys::gtk_list_box_row_get_header( 472 self.as_ref().to_glib_none().0, 473 )) 474 } 475 } 476 get_index(&self) -> i32477 fn get_index(&self) -> i32 { 478 unsafe { gtk_sys::gtk_list_box_row_get_index(self.as_ref().to_glib_none().0) } 479 } 480 get_selectable(&self) -> bool481 fn get_selectable(&self) -> bool { 482 unsafe { 483 from_glib(gtk_sys::gtk_list_box_row_get_selectable( 484 self.as_ref().to_glib_none().0, 485 )) 486 } 487 } 488 is_selected(&self) -> bool489 fn is_selected(&self) -> bool { 490 unsafe { 491 from_glib(gtk_sys::gtk_list_box_row_is_selected( 492 self.as_ref().to_glib_none().0, 493 )) 494 } 495 } 496 set_activatable(&self, activatable: bool)497 fn set_activatable(&self, activatable: bool) { 498 unsafe { 499 gtk_sys::gtk_list_box_row_set_activatable( 500 self.as_ref().to_glib_none().0, 501 activatable.to_glib(), 502 ); 503 } 504 } 505 set_header<P: IsA<Widget>>(&self, header: Option<&P>)506 fn set_header<P: IsA<Widget>>(&self, header: Option<&P>) { 507 unsafe { 508 gtk_sys::gtk_list_box_row_set_header( 509 self.as_ref().to_glib_none().0, 510 header.map(|p| p.as_ref()).to_glib_none().0, 511 ); 512 } 513 } 514 set_selectable(&self, selectable: bool)515 fn set_selectable(&self, selectable: bool) { 516 unsafe { 517 gtk_sys::gtk_list_box_row_set_selectable( 518 self.as_ref().to_glib_none().0, 519 selectable.to_glib(), 520 ); 521 } 522 } 523 connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId524 fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 525 unsafe extern "C" fn activate_trampoline<P, F: Fn(&P) + 'static>( 526 this: *mut gtk_sys::GtkListBoxRow, 527 f: glib_sys::gpointer, 528 ) where 529 P: IsA<ListBoxRow>, 530 { 531 let f: &F = &*(f as *const F); 532 f(&ListBoxRow::from_glib_borrow(this).unsafe_cast()) 533 } 534 unsafe { 535 let f: Box_<F> = Box_::new(f); 536 connect_raw( 537 self.as_ptr() as *mut _, 538 b"activate\0".as_ptr() as *const _, 539 Some(transmute(activate_trampoline::<Self, F> as usize)), 540 Box_::into_raw(f), 541 ) 542 } 543 } 544 emit_activate(&self)545 fn emit_activate(&self) { 546 let _ = unsafe { 547 glib::Object::from_glib_borrow(self.to_glib_none().0 as *mut gobject_sys::GObject) 548 .emit("activate", &[]) 549 .unwrap() 550 }; 551 } 552 connect_property_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId553 fn connect_property_activatable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 554 unsafe extern "C" fn notify_activatable_trampoline<P, F: Fn(&P) + 'static>( 555 this: *mut gtk_sys::GtkListBoxRow, 556 _param_spec: glib_sys::gpointer, 557 f: glib_sys::gpointer, 558 ) where 559 P: IsA<ListBoxRow>, 560 { 561 let f: &F = &*(f as *const F); 562 f(&ListBoxRow::from_glib_borrow(this).unsafe_cast()) 563 } 564 unsafe { 565 let f: Box_<F> = Box_::new(f); 566 connect_raw( 567 self.as_ptr() as *mut _, 568 b"notify::activatable\0".as_ptr() as *const _, 569 Some(transmute(notify_activatable_trampoline::<Self, F> as usize)), 570 Box_::into_raw(f), 571 ) 572 } 573 } 574 connect_property_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId575 fn connect_property_selectable_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 576 unsafe extern "C" fn notify_selectable_trampoline<P, F: Fn(&P) + 'static>( 577 this: *mut gtk_sys::GtkListBoxRow, 578 _param_spec: glib_sys::gpointer, 579 f: glib_sys::gpointer, 580 ) where 581 P: IsA<ListBoxRow>, 582 { 583 let f: &F = &*(f as *const F); 584 f(&ListBoxRow::from_glib_borrow(this).unsafe_cast()) 585 } 586 unsafe { 587 let f: Box_<F> = Box_::new(f); 588 connect_raw( 589 self.as_ptr() as *mut _, 590 b"notify::selectable\0".as_ptr() as *const _, 591 Some(transmute(notify_selectable_trampoline::<Self, F> as usize)), 592 Box_::into_raw(f), 593 ) 594 } 595 } 596 } 597 598 impl fmt::Display for ListBoxRow { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result599 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 600 write!(f, "ListBoxRow") 601 } 602 } 603