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::Actionable;
6 use crate::Align;
7 use crate::Bin;
8 use crate::Buildable;
9 use crate::Button;
10 use crate::CheckButton;
11 use crate::Container;
12 use crate::PositionType;
13 use crate::ReliefStyle;
14 use crate::ResizeMode;
15 use crate::ToggleButton;
16 use crate::Widget;
17 use glib::object::Cast;
18 use glib::object::IsA;
19 use glib::signal::connect_raw;
20 use glib::signal::SignalHandlerId;
21 use glib::translate::*;
22 use glib::StaticType;
23 use glib::ToValue;
24 use std::boxed::Box as Box_;
25 use std::fmt;
26 use std::mem::transmute;
27 
28 glib::wrapper! {
29     #[doc(alias = "GtkRadioButton")]
30     pub struct RadioButton(Object<ffi::GtkRadioButton, ffi::GtkRadioButtonClass>) @extends CheckButton, ToggleButton, Button, Bin, Container, Widget, @implements Buildable, Actionable;
31 
32     match fn {
33         type_ => || ffi::gtk_radio_button_get_type(),
34     }
35 }
36 
37 impl RadioButton {
38     #[doc(alias = "gtk_radio_button_new_from_widget")]
39     #[doc(alias = "new_from_widget")]
from_widget<P: IsA<RadioButton>>(radio_group_member: &P) -> RadioButton40     pub fn from_widget<P: IsA<RadioButton>>(radio_group_member: &P) -> RadioButton {
41         skip_assert_initialized!();
42         unsafe {
43             Widget::from_glib_none(ffi::gtk_radio_button_new_from_widget(
44                 radio_group_member.as_ref().to_glib_none().0,
45             ))
46             .unsafe_cast()
47         }
48     }
49 
50     #[doc(alias = "gtk_radio_button_new_with_label_from_widget")]
51     #[doc(alias = "new_with_label_from_widget")]
with_label_from_widget<P: IsA<RadioButton>>( radio_group_member: &P, label: &str, ) -> RadioButton52     pub fn with_label_from_widget<P: IsA<RadioButton>>(
53         radio_group_member: &P,
54         label: &str,
55     ) -> RadioButton {
56         skip_assert_initialized!();
57         unsafe {
58             Widget::from_glib_none(ffi::gtk_radio_button_new_with_label_from_widget(
59                 radio_group_member.as_ref().to_glib_none().0,
60                 label.to_glib_none().0,
61             ))
62             .unsafe_cast()
63         }
64     }
65 
66     #[doc(alias = "gtk_radio_button_new_with_mnemonic_from_widget")]
67     #[doc(alias = "new_with_mnemonic_from_widget")]
with_mnemonic_from_widget<P: IsA<RadioButton>>( radio_group_member: &P, label: &str, ) -> RadioButton68     pub fn with_mnemonic_from_widget<P: IsA<RadioButton>>(
69         radio_group_member: &P,
70         label: &str,
71     ) -> RadioButton {
72         skip_assert_initialized!();
73         unsafe {
74             Widget::from_glib_none(ffi::gtk_radio_button_new_with_mnemonic_from_widget(
75                 radio_group_member.as_ref().to_glib_none().0,
76                 label.to_glib_none().0,
77             ))
78             .unsafe_cast()
79         }
80     }
81 
82     // rustdoc-stripper-ignore-next
83     /// Creates a new builder-pattern struct instance to construct [`RadioButton`] objects.
84     ///
85     /// This method returns an instance of [`RadioButtonBuilder`] which can be used to create [`RadioButton`] objects.
builder() -> RadioButtonBuilder86     pub fn builder() -> RadioButtonBuilder {
87         RadioButtonBuilder::default()
88     }
89 }
90 
91 #[derive(Clone, Default)]
92 // rustdoc-stripper-ignore-next
93 /// A [builder-pattern] type to construct [`RadioButton`] objects.
94 ///
95 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
96 pub struct RadioButtonBuilder {
97     active: Option<bool>,
98     draw_indicator: Option<bool>,
99     inconsistent: Option<bool>,
100     always_show_image: Option<bool>,
101     image: Option<Widget>,
102     image_position: Option<PositionType>,
103     label: Option<String>,
104     relief: Option<ReliefStyle>,
105     use_underline: Option<bool>,
106     border_width: Option<u32>,
107     child: Option<Widget>,
108     resize_mode: Option<ResizeMode>,
109     app_paintable: Option<bool>,
110     can_default: Option<bool>,
111     can_focus: Option<bool>,
112     events: Option<gdk::EventMask>,
113     expand: Option<bool>,
114     #[cfg(any(feature = "v3_20", feature = "dox"))]
115     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
116     focus_on_click: Option<bool>,
117     halign: Option<Align>,
118     has_default: Option<bool>,
119     has_focus: Option<bool>,
120     has_tooltip: Option<bool>,
121     height_request: Option<i32>,
122     hexpand: Option<bool>,
123     hexpand_set: Option<bool>,
124     is_focus: Option<bool>,
125     margin: Option<i32>,
126     margin_bottom: Option<i32>,
127     margin_end: Option<i32>,
128     margin_start: Option<i32>,
129     margin_top: Option<i32>,
130     name: Option<String>,
131     no_show_all: Option<bool>,
132     opacity: Option<f64>,
133     parent: Option<Container>,
134     receives_default: Option<bool>,
135     sensitive: Option<bool>,
136     tooltip_markup: Option<String>,
137     tooltip_text: Option<String>,
138     valign: Option<Align>,
139     vexpand: Option<bool>,
140     vexpand_set: Option<bool>,
141     visible: Option<bool>,
142     width_request: Option<i32>,
143     action_name: Option<String>,
144     action_target: Option<glib::Variant>,
145 }
146 
147 impl RadioButtonBuilder {
148     // rustdoc-stripper-ignore-next
149     /// Create a new [`RadioButtonBuilder`].
new() -> Self150     pub fn new() -> Self {
151         Self::default()
152     }
153 
154     // rustdoc-stripper-ignore-next
155     /// Build the [`RadioButton`].
build(self) -> RadioButton156     pub fn build(self) -> RadioButton {
157         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
158         if let Some(ref active) = self.active {
159             properties.push(("active", active));
160         }
161         if let Some(ref draw_indicator) = self.draw_indicator {
162             properties.push(("draw-indicator", draw_indicator));
163         }
164         if let Some(ref inconsistent) = self.inconsistent {
165             properties.push(("inconsistent", inconsistent));
166         }
167         if let Some(ref always_show_image) = self.always_show_image {
168             properties.push(("always-show-image", always_show_image));
169         }
170         if let Some(ref image) = self.image {
171             properties.push(("image", image));
172         }
173         if let Some(ref image_position) = self.image_position {
174             properties.push(("image-position", image_position));
175         }
176         if let Some(ref label) = self.label {
177             properties.push(("label", label));
178         }
179         if let Some(ref relief) = self.relief {
180             properties.push(("relief", relief));
181         }
182         if let Some(ref use_underline) = self.use_underline {
183             properties.push(("use-underline", use_underline));
184         }
185         if let Some(ref border_width) = self.border_width {
186             properties.push(("border-width", border_width));
187         }
188         if let Some(ref child) = self.child {
189             properties.push(("child", child));
190         }
191         if let Some(ref resize_mode) = self.resize_mode {
192             properties.push(("resize-mode", resize_mode));
193         }
194         if let Some(ref app_paintable) = self.app_paintable {
195             properties.push(("app-paintable", app_paintable));
196         }
197         if let Some(ref can_default) = self.can_default {
198             properties.push(("can-default", can_default));
199         }
200         if let Some(ref can_focus) = self.can_focus {
201             properties.push(("can-focus", can_focus));
202         }
203         if let Some(ref events) = self.events {
204             properties.push(("events", events));
205         }
206         if let Some(ref expand) = self.expand {
207             properties.push(("expand", expand));
208         }
209         #[cfg(any(feature = "v3_20", feature = "dox"))]
210         if let Some(ref focus_on_click) = self.focus_on_click {
211             properties.push(("focus-on-click", focus_on_click));
212         }
213         if let Some(ref halign) = self.halign {
214             properties.push(("halign", halign));
215         }
216         if let Some(ref has_default) = self.has_default {
217             properties.push(("has-default", has_default));
218         }
219         if let Some(ref has_focus) = self.has_focus {
220             properties.push(("has-focus", has_focus));
221         }
222         if let Some(ref has_tooltip) = self.has_tooltip {
223             properties.push(("has-tooltip", has_tooltip));
224         }
225         if let Some(ref height_request) = self.height_request {
226             properties.push(("height-request", height_request));
227         }
228         if let Some(ref hexpand) = self.hexpand {
229             properties.push(("hexpand", hexpand));
230         }
231         if let Some(ref hexpand_set) = self.hexpand_set {
232             properties.push(("hexpand-set", hexpand_set));
233         }
234         if let Some(ref is_focus) = self.is_focus {
235             properties.push(("is-focus", is_focus));
236         }
237         if let Some(ref margin) = self.margin {
238             properties.push(("margin", margin));
239         }
240         if let Some(ref margin_bottom) = self.margin_bottom {
241             properties.push(("margin-bottom", margin_bottom));
242         }
243         if let Some(ref margin_end) = self.margin_end {
244             properties.push(("margin-end", margin_end));
245         }
246         if let Some(ref margin_start) = self.margin_start {
247             properties.push(("margin-start", margin_start));
248         }
249         if let Some(ref margin_top) = self.margin_top {
250             properties.push(("margin-top", margin_top));
251         }
252         if let Some(ref name) = self.name {
253             properties.push(("name", name));
254         }
255         if let Some(ref no_show_all) = self.no_show_all {
256             properties.push(("no-show-all", no_show_all));
257         }
258         if let Some(ref opacity) = self.opacity {
259             properties.push(("opacity", opacity));
260         }
261         if let Some(ref parent) = self.parent {
262             properties.push(("parent", parent));
263         }
264         if let Some(ref receives_default) = self.receives_default {
265             properties.push(("receives-default", receives_default));
266         }
267         if let Some(ref sensitive) = self.sensitive {
268             properties.push(("sensitive", sensitive));
269         }
270         if let Some(ref tooltip_markup) = self.tooltip_markup {
271             properties.push(("tooltip-markup", tooltip_markup));
272         }
273         if let Some(ref tooltip_text) = self.tooltip_text {
274             properties.push(("tooltip-text", tooltip_text));
275         }
276         if let Some(ref valign) = self.valign {
277             properties.push(("valign", valign));
278         }
279         if let Some(ref vexpand) = self.vexpand {
280             properties.push(("vexpand", vexpand));
281         }
282         if let Some(ref vexpand_set) = self.vexpand_set {
283             properties.push(("vexpand-set", vexpand_set));
284         }
285         if let Some(ref visible) = self.visible {
286             properties.push(("visible", visible));
287         }
288         if let Some(ref width_request) = self.width_request {
289             properties.push(("width-request", width_request));
290         }
291         if let Some(ref action_name) = self.action_name {
292             properties.push(("action-name", action_name));
293         }
294         if let Some(ref action_target) = self.action_target {
295             properties.push(("action-target", action_target));
296         }
297         glib::Object::new::<RadioButton>(&properties)
298             .expect("Failed to create an instance of RadioButton")
299     }
300 
active(mut self, active: bool) -> Self301     pub fn active(mut self, active: bool) -> Self {
302         self.active = Some(active);
303         self
304     }
305 
draw_indicator(mut self, draw_indicator: bool) -> Self306     pub fn draw_indicator(mut self, draw_indicator: bool) -> Self {
307         self.draw_indicator = Some(draw_indicator);
308         self
309     }
310 
inconsistent(mut self, inconsistent: bool) -> Self311     pub fn inconsistent(mut self, inconsistent: bool) -> Self {
312         self.inconsistent = Some(inconsistent);
313         self
314     }
315 
always_show_image(mut self, always_show_image: bool) -> Self316     pub fn always_show_image(mut self, always_show_image: bool) -> Self {
317         self.always_show_image = Some(always_show_image);
318         self
319     }
320 
image<P: IsA<Widget>>(mut self, image: &P) -> Self321     pub fn image<P: IsA<Widget>>(mut self, image: &P) -> Self {
322         self.image = Some(image.clone().upcast());
323         self
324     }
325 
image_position(mut self, image_position: PositionType) -> Self326     pub fn image_position(mut self, image_position: PositionType) -> Self {
327         self.image_position = Some(image_position);
328         self
329     }
330 
label(mut self, label: &str) -> Self331     pub fn label(mut self, label: &str) -> Self {
332         self.label = Some(label.to_string());
333         self
334     }
335 
relief(mut self, relief: ReliefStyle) -> Self336     pub fn relief(mut self, relief: ReliefStyle) -> Self {
337         self.relief = Some(relief);
338         self
339     }
340 
use_underline(mut self, use_underline: bool) -> Self341     pub fn use_underline(mut self, use_underline: bool) -> Self {
342         self.use_underline = Some(use_underline);
343         self
344     }
345 
border_width(mut self, border_width: u32) -> Self346     pub fn border_width(mut self, border_width: u32) -> Self {
347         self.border_width = Some(border_width);
348         self
349     }
350 
child<P: IsA<Widget>>(mut self, child: &P) -> Self351     pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self {
352         self.child = Some(child.clone().upcast());
353         self
354     }
355 
resize_mode(mut self, resize_mode: ResizeMode) -> Self356     pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
357         self.resize_mode = Some(resize_mode);
358         self
359     }
360 
app_paintable(mut self, app_paintable: bool) -> Self361     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
362         self.app_paintable = Some(app_paintable);
363         self
364     }
365 
can_default(mut self, can_default: bool) -> Self366     pub fn can_default(mut self, can_default: bool) -> Self {
367         self.can_default = Some(can_default);
368         self
369     }
370 
can_focus(mut self, can_focus: bool) -> Self371     pub fn can_focus(mut self, can_focus: bool) -> Self {
372         self.can_focus = Some(can_focus);
373         self
374     }
375 
events(mut self, events: gdk::EventMask) -> Self376     pub fn events(mut self, events: gdk::EventMask) -> Self {
377         self.events = Some(events);
378         self
379     }
380 
expand(mut self, expand: bool) -> Self381     pub fn expand(mut self, expand: bool) -> Self {
382         self.expand = Some(expand);
383         self
384     }
385 
386     #[cfg(any(feature = "v3_20", feature = "dox"))]
387     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
focus_on_click(mut self, focus_on_click: bool) -> Self388     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
389         self.focus_on_click = Some(focus_on_click);
390         self
391     }
392 
halign(mut self, halign: Align) -> Self393     pub fn halign(mut self, halign: Align) -> Self {
394         self.halign = Some(halign);
395         self
396     }
397 
has_default(mut self, has_default: bool) -> Self398     pub fn has_default(mut self, has_default: bool) -> Self {
399         self.has_default = Some(has_default);
400         self
401     }
402 
has_focus(mut self, has_focus: bool) -> Self403     pub fn has_focus(mut self, has_focus: bool) -> Self {
404         self.has_focus = Some(has_focus);
405         self
406     }
407 
has_tooltip(mut self, has_tooltip: bool) -> Self408     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
409         self.has_tooltip = Some(has_tooltip);
410         self
411     }
412 
height_request(mut self, height_request: i32) -> Self413     pub fn height_request(mut self, height_request: i32) -> Self {
414         self.height_request = Some(height_request);
415         self
416     }
417 
hexpand(mut self, hexpand: bool) -> Self418     pub fn hexpand(mut self, hexpand: bool) -> Self {
419         self.hexpand = Some(hexpand);
420         self
421     }
422 
hexpand_set(mut self, hexpand_set: bool) -> Self423     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
424         self.hexpand_set = Some(hexpand_set);
425         self
426     }
427 
is_focus(mut self, is_focus: bool) -> Self428     pub fn is_focus(mut self, is_focus: bool) -> Self {
429         self.is_focus = Some(is_focus);
430         self
431     }
432 
margin(mut self, margin: i32) -> Self433     pub fn margin(mut self, margin: i32) -> Self {
434         self.margin = Some(margin);
435         self
436     }
437 
margin_bottom(mut self, margin_bottom: i32) -> Self438     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
439         self.margin_bottom = Some(margin_bottom);
440         self
441     }
442 
margin_end(mut self, margin_end: i32) -> Self443     pub fn margin_end(mut self, margin_end: i32) -> Self {
444         self.margin_end = Some(margin_end);
445         self
446     }
447 
margin_start(mut self, margin_start: i32) -> Self448     pub fn margin_start(mut self, margin_start: i32) -> Self {
449         self.margin_start = Some(margin_start);
450         self
451     }
452 
margin_top(mut self, margin_top: i32) -> Self453     pub fn margin_top(mut self, margin_top: i32) -> Self {
454         self.margin_top = Some(margin_top);
455         self
456     }
457 
name(mut self, name: &str) -> Self458     pub fn name(mut self, name: &str) -> Self {
459         self.name = Some(name.to_string());
460         self
461     }
462 
no_show_all(mut self, no_show_all: bool) -> Self463     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
464         self.no_show_all = Some(no_show_all);
465         self
466     }
467 
opacity(mut self, opacity: f64) -> Self468     pub fn opacity(mut self, opacity: f64) -> Self {
469         self.opacity = Some(opacity);
470         self
471     }
472 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self473     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
474         self.parent = Some(parent.clone().upcast());
475         self
476     }
477 
receives_default(mut self, receives_default: bool) -> Self478     pub fn receives_default(mut self, receives_default: bool) -> Self {
479         self.receives_default = Some(receives_default);
480         self
481     }
482 
sensitive(mut self, sensitive: bool) -> Self483     pub fn sensitive(mut self, sensitive: bool) -> Self {
484         self.sensitive = Some(sensitive);
485         self
486     }
487 
tooltip_markup(mut self, tooltip_markup: &str) -> Self488     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
489         self.tooltip_markup = Some(tooltip_markup.to_string());
490         self
491     }
492 
tooltip_text(mut self, tooltip_text: &str) -> Self493     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
494         self.tooltip_text = Some(tooltip_text.to_string());
495         self
496     }
497 
valign(mut self, valign: Align) -> Self498     pub fn valign(mut self, valign: Align) -> Self {
499         self.valign = Some(valign);
500         self
501     }
502 
vexpand(mut self, vexpand: bool) -> Self503     pub fn vexpand(mut self, vexpand: bool) -> Self {
504         self.vexpand = Some(vexpand);
505         self
506     }
507 
vexpand_set(mut self, vexpand_set: bool) -> Self508     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
509         self.vexpand_set = Some(vexpand_set);
510         self
511     }
512 
visible(mut self, visible: bool) -> Self513     pub fn visible(mut self, visible: bool) -> Self {
514         self.visible = Some(visible);
515         self
516     }
517 
width_request(mut self, width_request: i32) -> Self518     pub fn width_request(mut self, width_request: i32) -> Self {
519         self.width_request = Some(width_request);
520         self
521     }
522 
action_name(mut self, action_name: &str) -> Self523     pub fn action_name(mut self, action_name: &str) -> Self {
524         self.action_name = Some(action_name.to_string());
525         self
526     }
527 
action_target(mut self, action_target: &glib::Variant) -> Self528     pub fn action_target(mut self, action_target: &glib::Variant) -> Self {
529         self.action_target = Some(action_target.clone());
530         self
531     }
532 }
533 
534 pub const NONE_RADIO_BUTTON: Option<&RadioButton> = None;
535 
536 pub trait RadioButtonExt: 'static {
537     #[doc(alias = "gtk_radio_button_get_group")]
538     #[doc(alias = "get_group")]
group(&self) -> Vec<RadioButton>539     fn group(&self) -> Vec<RadioButton>;
540 
541     #[doc(alias = "gtk_radio_button_join_group")]
join_group<P: IsA<RadioButton>>(&self, group_source: Option<&P>)542     fn join_group<P: IsA<RadioButton>>(&self, group_source: Option<&P>);
543 
544     #[doc(alias = "group-changed")]
connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId545     fn connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
546 }
547 
548 impl<O: IsA<RadioButton>> RadioButtonExt for O {
group(&self) -> Vec<RadioButton>549     fn group(&self) -> Vec<RadioButton> {
550         unsafe {
551             FromGlibPtrContainer::from_glib_none(ffi::gtk_radio_button_get_group(
552                 self.as_ref().to_glib_none().0,
553             ))
554         }
555     }
556 
join_group<P: IsA<RadioButton>>(&self, group_source: Option<&P>)557     fn join_group<P: IsA<RadioButton>>(&self, group_source: Option<&P>) {
558         unsafe {
559             ffi::gtk_radio_button_join_group(
560                 self.as_ref().to_glib_none().0,
561                 group_source.map(|p| p.as_ref()).to_glib_none().0,
562             );
563         }
564     }
565 
connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId566     fn connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
567         unsafe extern "C" fn group_changed_trampoline<P: IsA<RadioButton>, F: Fn(&P) + 'static>(
568             this: *mut ffi::GtkRadioButton,
569             f: glib::ffi::gpointer,
570         ) {
571             let f: &F = &*(f as *const F);
572             f(RadioButton::from_glib_borrow(this).unsafe_cast_ref())
573         }
574         unsafe {
575             let f: Box_<F> = Box_::new(f);
576             connect_raw(
577                 self.as_ptr() as *mut _,
578                 b"group-changed\0".as_ptr() as *const _,
579                 Some(transmute::<_, unsafe extern "C" fn()>(
580                     group_changed_trampoline::<Self, F> as *const (),
581                 )),
582                 Box_::into_raw(f),
583             )
584         }
585     }
586 }
587 
588 impl fmt::Display for RadioButton {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result589     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
590         f.write_str("RadioButton")
591     }
592 }
593