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::signal::connect_raw; 10 use glib::signal::SignalHandlerId; 11 use glib::translate::*; 12 use glib::StaticType; 13 use glib::ToValue; 14 use glib_sys; 15 use gtk_sys; 16 use std::boxed::Box as Box_; 17 use std::fmt; 18 use std::mem::transmute; 19 use Actionable; 20 use Align; 21 use Bin; 22 use Buildable; 23 use Button; 24 use CheckButton; 25 use Container; 26 use PositionType; 27 use ReliefStyle; 28 use ResizeMode; 29 use ToggleButton; 30 use Widget; 31 32 glib_wrapper! { 33 pub struct RadioButton(Object<gtk_sys::GtkRadioButton, gtk_sys::GtkRadioButtonClass, RadioButtonClass>) @extends CheckButton, ToggleButton, Button, Bin, Container, Widget, @implements Buildable, Actionable; 34 35 match fn { 36 get_type => || gtk_sys::gtk_radio_button_get_type(), 37 } 38 } 39 40 impl RadioButton { new_from_widget<P: IsA<RadioButton>>(radio_group_member: &P) -> RadioButton41 pub fn new_from_widget<P: IsA<RadioButton>>(radio_group_member: &P) -> RadioButton { 42 skip_assert_initialized!(); 43 unsafe { 44 Widget::from_glib_none(gtk_sys::gtk_radio_button_new_from_widget( 45 radio_group_member.as_ref().to_glib_none().0, 46 )) 47 .unsafe_cast() 48 } 49 } 50 new_with_label_from_widget<P: IsA<RadioButton>>( radio_group_member: &P, label: &str, ) -> RadioButton51 pub fn new_with_label_from_widget<P: IsA<RadioButton>>( 52 radio_group_member: &P, 53 label: &str, 54 ) -> RadioButton { 55 skip_assert_initialized!(); 56 unsafe { 57 Widget::from_glib_none(gtk_sys::gtk_radio_button_new_with_label_from_widget( 58 radio_group_member.as_ref().to_glib_none().0, 59 label.to_glib_none().0, 60 )) 61 .unsafe_cast() 62 } 63 } 64 new_with_mnemonic_from_widget<P: IsA<RadioButton>>( radio_group_member: &P, label: &str, ) -> RadioButton65 pub fn new_with_mnemonic_from_widget<P: IsA<RadioButton>>( 66 radio_group_member: &P, 67 label: &str, 68 ) -> RadioButton { 69 skip_assert_initialized!(); 70 unsafe { 71 Widget::from_glib_none(gtk_sys::gtk_radio_button_new_with_mnemonic_from_widget( 72 radio_group_member.as_ref().to_glib_none().0, 73 label.to_glib_none().0, 74 )) 75 .unsafe_cast() 76 } 77 } 78 } 79 80 #[derive(Clone, Default)] 81 pub struct RadioButtonBuilder { 82 active: Option<bool>, 83 draw_indicator: Option<bool>, 84 inconsistent: Option<bool>, 85 always_show_image: Option<bool>, 86 image: Option<Widget>, 87 image_position: Option<PositionType>, 88 label: Option<String>, 89 relief: Option<ReliefStyle>, 90 use_underline: Option<bool>, 91 border_width: Option<u32>, 92 child: Option<Widget>, 93 resize_mode: Option<ResizeMode>, 94 app_paintable: Option<bool>, 95 can_default: Option<bool>, 96 can_focus: Option<bool>, 97 events: Option<gdk::EventMask>, 98 expand: Option<bool>, 99 #[cfg(any(feature = "v3_20", feature = "dox"))] 100 focus_on_click: Option<bool>, 101 halign: Option<Align>, 102 has_default: Option<bool>, 103 has_focus: Option<bool>, 104 has_tooltip: Option<bool>, 105 height_request: Option<i32>, 106 hexpand: Option<bool>, 107 hexpand_set: Option<bool>, 108 is_focus: Option<bool>, 109 margin: Option<i32>, 110 margin_bottom: Option<i32>, 111 margin_end: Option<i32>, 112 margin_start: Option<i32>, 113 margin_top: Option<i32>, 114 name: Option<String>, 115 no_show_all: Option<bool>, 116 opacity: Option<f64>, 117 parent: Option<Container>, 118 receives_default: Option<bool>, 119 sensitive: Option<bool>, 120 tooltip_markup: Option<String>, 121 tooltip_text: Option<String>, 122 valign: Option<Align>, 123 vexpand: Option<bool>, 124 vexpand_set: Option<bool>, 125 visible: Option<bool>, 126 width_request: Option<i32>, 127 action_name: Option<String>, 128 action_target: Option<glib::Variant>, 129 } 130 131 impl RadioButtonBuilder { new() -> Self132 pub fn new() -> Self { 133 Self::default() 134 } 135 build(self) -> RadioButton136 pub fn build(self) -> RadioButton { 137 let mut properties: Vec<(&str, &dyn ToValue)> = vec![]; 138 if let Some(ref active) = self.active { 139 properties.push(("active", active)); 140 } 141 if let Some(ref draw_indicator) = self.draw_indicator { 142 properties.push(("draw-indicator", draw_indicator)); 143 } 144 if let Some(ref inconsistent) = self.inconsistent { 145 properties.push(("inconsistent", inconsistent)); 146 } 147 if let Some(ref always_show_image) = self.always_show_image { 148 properties.push(("always-show-image", always_show_image)); 149 } 150 if let Some(ref image) = self.image { 151 properties.push(("image", image)); 152 } 153 if let Some(ref image_position) = self.image_position { 154 properties.push(("image-position", image_position)); 155 } 156 if let Some(ref label) = self.label { 157 properties.push(("label", label)); 158 } 159 if let Some(ref relief) = self.relief { 160 properties.push(("relief", relief)); 161 } 162 if let Some(ref use_underline) = self.use_underline { 163 properties.push(("use-underline", use_underline)); 164 } 165 if let Some(ref border_width) = self.border_width { 166 properties.push(("border-width", border_width)); 167 } 168 if let Some(ref child) = self.child { 169 properties.push(("child", child)); 170 } 171 if let Some(ref resize_mode) = self.resize_mode { 172 properties.push(("resize-mode", resize_mode)); 173 } 174 if let Some(ref app_paintable) = self.app_paintable { 175 properties.push(("app-paintable", app_paintable)); 176 } 177 if let Some(ref can_default) = self.can_default { 178 properties.push(("can-default", can_default)); 179 } 180 if let Some(ref can_focus) = self.can_focus { 181 properties.push(("can-focus", can_focus)); 182 } 183 if let Some(ref events) = self.events { 184 properties.push(("events", events)); 185 } 186 if let Some(ref expand) = self.expand { 187 properties.push(("expand", expand)); 188 } 189 #[cfg(any(feature = "v3_20", feature = "dox"))] 190 { 191 if let Some(ref focus_on_click) = self.focus_on_click { 192 properties.push(("focus-on-click", focus_on_click)); 193 } 194 } 195 if let Some(ref halign) = self.halign { 196 properties.push(("halign", halign)); 197 } 198 if let Some(ref has_default) = self.has_default { 199 properties.push(("has-default", has_default)); 200 } 201 if let Some(ref has_focus) = self.has_focus { 202 properties.push(("has-focus", has_focus)); 203 } 204 if let Some(ref has_tooltip) = self.has_tooltip { 205 properties.push(("has-tooltip", has_tooltip)); 206 } 207 if let Some(ref height_request) = self.height_request { 208 properties.push(("height-request", height_request)); 209 } 210 if let Some(ref hexpand) = self.hexpand { 211 properties.push(("hexpand", hexpand)); 212 } 213 if let Some(ref hexpand_set) = self.hexpand_set { 214 properties.push(("hexpand-set", hexpand_set)); 215 } 216 if let Some(ref is_focus) = self.is_focus { 217 properties.push(("is-focus", is_focus)); 218 } 219 if let Some(ref margin) = self.margin { 220 properties.push(("margin", margin)); 221 } 222 if let Some(ref margin_bottom) = self.margin_bottom { 223 properties.push(("margin-bottom", margin_bottom)); 224 } 225 if let Some(ref margin_end) = self.margin_end { 226 properties.push(("margin-end", margin_end)); 227 } 228 if let Some(ref margin_start) = self.margin_start { 229 properties.push(("margin-start", margin_start)); 230 } 231 if let Some(ref margin_top) = self.margin_top { 232 properties.push(("margin-top", margin_top)); 233 } 234 if let Some(ref name) = self.name { 235 properties.push(("name", name)); 236 } 237 if let Some(ref no_show_all) = self.no_show_all { 238 properties.push(("no-show-all", no_show_all)); 239 } 240 if let Some(ref opacity) = self.opacity { 241 properties.push(("opacity", opacity)); 242 } 243 if let Some(ref parent) = self.parent { 244 properties.push(("parent", parent)); 245 } 246 if let Some(ref receives_default) = self.receives_default { 247 properties.push(("receives-default", receives_default)); 248 } 249 if let Some(ref sensitive) = self.sensitive { 250 properties.push(("sensitive", sensitive)); 251 } 252 if let Some(ref tooltip_markup) = self.tooltip_markup { 253 properties.push(("tooltip-markup", tooltip_markup)); 254 } 255 if let Some(ref tooltip_text) = self.tooltip_text { 256 properties.push(("tooltip-text", tooltip_text)); 257 } 258 if let Some(ref valign) = self.valign { 259 properties.push(("valign", valign)); 260 } 261 if let Some(ref vexpand) = self.vexpand { 262 properties.push(("vexpand", vexpand)); 263 } 264 if let Some(ref vexpand_set) = self.vexpand_set { 265 properties.push(("vexpand-set", vexpand_set)); 266 } 267 if let Some(ref visible) = self.visible { 268 properties.push(("visible", visible)); 269 } 270 if let Some(ref width_request) = self.width_request { 271 properties.push(("width-request", width_request)); 272 } 273 if let Some(ref action_name) = self.action_name { 274 properties.push(("action-name", action_name)); 275 } 276 if let Some(ref action_target) = self.action_target { 277 properties.push(("action-target", action_target)); 278 } 279 glib::Object::new(RadioButton::static_type(), &properties) 280 .expect("object new") 281 .downcast() 282 .expect("downcast") 283 } 284 active(mut self, active: bool) -> Self285 pub fn active(mut self, active: bool) -> Self { 286 self.active = Some(active); 287 self 288 } 289 draw_indicator(mut self, draw_indicator: bool) -> Self290 pub fn draw_indicator(mut self, draw_indicator: bool) -> Self { 291 self.draw_indicator = Some(draw_indicator); 292 self 293 } 294 inconsistent(mut self, inconsistent: bool) -> Self295 pub fn inconsistent(mut self, inconsistent: bool) -> Self { 296 self.inconsistent = Some(inconsistent); 297 self 298 } 299 always_show_image(mut self, always_show_image: bool) -> Self300 pub fn always_show_image(mut self, always_show_image: bool) -> Self { 301 self.always_show_image = Some(always_show_image); 302 self 303 } 304 image<P: IsA<Widget>>(mut self, image: &P) -> Self305 pub fn image<P: IsA<Widget>>(mut self, image: &P) -> Self { 306 self.image = Some(image.clone().upcast()); 307 self 308 } 309 image_position(mut self, image_position: PositionType) -> Self310 pub fn image_position(mut self, image_position: PositionType) -> Self { 311 self.image_position = Some(image_position); 312 self 313 } 314 label(mut self, label: &str) -> Self315 pub fn label(mut self, label: &str) -> Self { 316 self.label = Some(label.to_string()); 317 self 318 } 319 relief(mut self, relief: ReliefStyle) -> Self320 pub fn relief(mut self, relief: ReliefStyle) -> Self { 321 self.relief = Some(relief); 322 self 323 } 324 use_underline(mut self, use_underline: bool) -> Self325 pub fn use_underline(mut self, use_underline: bool) -> Self { 326 self.use_underline = Some(use_underline); 327 self 328 } 329 border_width(mut self, border_width: u32) -> Self330 pub fn border_width(mut self, border_width: u32) -> Self { 331 self.border_width = Some(border_width); 332 self 333 } 334 child<P: IsA<Widget>>(mut self, child: &P) -> Self335 pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self { 336 self.child = Some(child.clone().upcast()); 337 self 338 } 339 resize_mode(mut self, resize_mode: ResizeMode) -> Self340 pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self { 341 self.resize_mode = Some(resize_mode); 342 self 343 } 344 app_paintable(mut self, app_paintable: bool) -> Self345 pub fn app_paintable(mut self, app_paintable: bool) -> Self { 346 self.app_paintable = Some(app_paintable); 347 self 348 } 349 can_default(mut self, can_default: bool) -> Self350 pub fn can_default(mut self, can_default: bool) -> Self { 351 self.can_default = Some(can_default); 352 self 353 } 354 can_focus(mut self, can_focus: bool) -> Self355 pub fn can_focus(mut self, can_focus: bool) -> Self { 356 self.can_focus = Some(can_focus); 357 self 358 } 359 events(mut self, events: gdk::EventMask) -> Self360 pub fn events(mut self, events: gdk::EventMask) -> Self { 361 self.events = Some(events); 362 self 363 } 364 expand(mut self, expand: bool) -> Self365 pub fn expand(mut self, expand: bool) -> Self { 366 self.expand = Some(expand); 367 self 368 } 369 370 #[cfg(any(feature = "v3_20", feature = "dox"))] focus_on_click(mut self, focus_on_click: bool) -> Self371 pub fn focus_on_click(mut self, focus_on_click: bool) -> Self { 372 self.focus_on_click = Some(focus_on_click); 373 self 374 } 375 halign(mut self, halign: Align) -> Self376 pub fn halign(mut self, halign: Align) -> Self { 377 self.halign = Some(halign); 378 self 379 } 380 has_default(mut self, has_default: bool) -> Self381 pub fn has_default(mut self, has_default: bool) -> Self { 382 self.has_default = Some(has_default); 383 self 384 } 385 has_focus(mut self, has_focus: bool) -> Self386 pub fn has_focus(mut self, has_focus: bool) -> Self { 387 self.has_focus = Some(has_focus); 388 self 389 } 390 has_tooltip(mut self, has_tooltip: bool) -> Self391 pub fn has_tooltip(mut self, has_tooltip: bool) -> Self { 392 self.has_tooltip = Some(has_tooltip); 393 self 394 } 395 height_request(mut self, height_request: i32) -> Self396 pub fn height_request(mut self, height_request: i32) -> Self { 397 self.height_request = Some(height_request); 398 self 399 } 400 hexpand(mut self, hexpand: bool) -> Self401 pub fn hexpand(mut self, hexpand: bool) -> Self { 402 self.hexpand = Some(hexpand); 403 self 404 } 405 hexpand_set(mut self, hexpand_set: bool) -> Self406 pub fn hexpand_set(mut self, hexpand_set: bool) -> Self { 407 self.hexpand_set = Some(hexpand_set); 408 self 409 } 410 is_focus(mut self, is_focus: bool) -> Self411 pub fn is_focus(mut self, is_focus: bool) -> Self { 412 self.is_focus = Some(is_focus); 413 self 414 } 415 margin(mut self, margin: i32) -> Self416 pub fn margin(mut self, margin: i32) -> Self { 417 self.margin = Some(margin); 418 self 419 } 420 margin_bottom(mut self, margin_bottom: i32) -> Self421 pub fn margin_bottom(mut self, margin_bottom: i32) -> Self { 422 self.margin_bottom = Some(margin_bottom); 423 self 424 } 425 margin_end(mut self, margin_end: i32) -> Self426 pub fn margin_end(mut self, margin_end: i32) -> Self { 427 self.margin_end = Some(margin_end); 428 self 429 } 430 margin_start(mut self, margin_start: i32) -> Self431 pub fn margin_start(mut self, margin_start: i32) -> Self { 432 self.margin_start = Some(margin_start); 433 self 434 } 435 margin_top(mut self, margin_top: i32) -> Self436 pub fn margin_top(mut self, margin_top: i32) -> Self { 437 self.margin_top = Some(margin_top); 438 self 439 } 440 name(mut self, name: &str) -> Self441 pub fn name(mut self, name: &str) -> Self { 442 self.name = Some(name.to_string()); 443 self 444 } 445 no_show_all(mut self, no_show_all: bool) -> Self446 pub fn no_show_all(mut self, no_show_all: bool) -> Self { 447 self.no_show_all = Some(no_show_all); 448 self 449 } 450 opacity(mut self, opacity: f64) -> Self451 pub fn opacity(mut self, opacity: f64) -> Self { 452 self.opacity = Some(opacity); 453 self 454 } 455 parent<P: IsA<Container>>(mut self, parent: &P) -> Self456 pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self { 457 self.parent = Some(parent.clone().upcast()); 458 self 459 } 460 receives_default(mut self, receives_default: bool) -> Self461 pub fn receives_default(mut self, receives_default: bool) -> Self { 462 self.receives_default = Some(receives_default); 463 self 464 } 465 sensitive(mut self, sensitive: bool) -> Self466 pub fn sensitive(mut self, sensitive: bool) -> Self { 467 self.sensitive = Some(sensitive); 468 self 469 } 470 tooltip_markup(mut self, tooltip_markup: &str) -> Self471 pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self { 472 self.tooltip_markup = Some(tooltip_markup.to_string()); 473 self 474 } 475 tooltip_text(mut self, tooltip_text: &str) -> Self476 pub fn tooltip_text(mut self, tooltip_text: &str) -> Self { 477 self.tooltip_text = Some(tooltip_text.to_string()); 478 self 479 } 480 valign(mut self, valign: Align) -> Self481 pub fn valign(mut self, valign: Align) -> Self { 482 self.valign = Some(valign); 483 self 484 } 485 vexpand(mut self, vexpand: bool) -> Self486 pub fn vexpand(mut self, vexpand: bool) -> Self { 487 self.vexpand = Some(vexpand); 488 self 489 } 490 vexpand_set(mut self, vexpand_set: bool) -> Self491 pub fn vexpand_set(mut self, vexpand_set: bool) -> Self { 492 self.vexpand_set = Some(vexpand_set); 493 self 494 } 495 visible(mut self, visible: bool) -> Self496 pub fn visible(mut self, visible: bool) -> Self { 497 self.visible = Some(visible); 498 self 499 } 500 width_request(mut self, width_request: i32) -> Self501 pub fn width_request(mut self, width_request: i32) -> Self { 502 self.width_request = Some(width_request); 503 self 504 } 505 action_name(mut self, action_name: &str) -> Self506 pub fn action_name(mut self, action_name: &str) -> Self { 507 self.action_name = Some(action_name.to_string()); 508 self 509 } 510 action_target(mut self, action_target: &glib::Variant) -> Self511 pub fn action_target(mut self, action_target: &glib::Variant) -> Self { 512 self.action_target = Some(action_target.clone()); 513 self 514 } 515 } 516 517 pub const NONE_RADIO_BUTTON: Option<&RadioButton> = None; 518 519 pub trait RadioButtonExt: 'static { get_group(&self) -> Vec<RadioButton>520 fn get_group(&self) -> Vec<RadioButton>; 521 join_group<P: IsA<RadioButton>>(&self, group_source: Option<&P>)522 fn join_group<P: IsA<RadioButton>>(&self, group_source: Option<&P>); 523 connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId524 fn connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; 525 } 526 527 impl<O: IsA<RadioButton>> RadioButtonExt for O { get_group(&self) -> Vec<RadioButton>528 fn get_group(&self) -> Vec<RadioButton> { 529 unsafe { 530 FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_radio_button_get_group( 531 self.as_ref().to_glib_none().0, 532 )) 533 } 534 } 535 join_group<P: IsA<RadioButton>>(&self, group_source: Option<&P>)536 fn join_group<P: IsA<RadioButton>>(&self, group_source: Option<&P>) { 537 unsafe { 538 gtk_sys::gtk_radio_button_join_group( 539 self.as_ref().to_glib_none().0, 540 group_source.map(|p| p.as_ref()).to_glib_none().0, 541 ); 542 } 543 } 544 connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId545 fn connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { 546 unsafe extern "C" fn group_changed_trampoline<P, F: Fn(&P) + 'static>( 547 this: *mut gtk_sys::GtkRadioButton, 548 f: glib_sys::gpointer, 549 ) where 550 P: IsA<RadioButton>, 551 { 552 let f: &F = &*(f as *const F); 553 f(&RadioButton::from_glib_borrow(this).unsafe_cast()) 554 } 555 unsafe { 556 let f: Box_<F> = Box_::new(f); 557 connect_raw( 558 self.as_ptr() as *mut _, 559 b"group-changed\0".as_ptr() as *const _, 560 Some(transmute(group_changed_trampoline::<Self, F> as usize)), 561 Box_::into_raw(f), 562 ) 563 } 564 } 565 } 566 567 impl fmt::Display for RadioButton { fmt(&self, f: &mut fmt::Formatter) -> fmt::Result568 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { 569 write!(f, "RadioButton") 570 } 571 } 572