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::CheckMenuItem;
10 use crate::Container;
11 use crate::Menu;
12 use crate::MenuItem;
13 use crate::ResizeMode;
14 use crate::Widget;
15 use glib::object::Cast;
16 use glib::object::IsA;
17 use glib::signal::connect_raw;
18 use glib::signal::SignalHandlerId;
19 use glib::translate::*;
20 use glib::StaticType;
21 use glib::ToValue;
22 use std::boxed::Box as Box_;
23 use std::fmt;
24 use std::mem::transmute;
25 
26 glib::wrapper! {
27     #[doc(alias = "GtkRadioMenuItem")]
28     pub struct RadioMenuItem(Object<ffi::GtkRadioMenuItem, ffi::GtkRadioMenuItemClass>) @extends CheckMenuItem, MenuItem, Bin, Container, Widget, @implements Buildable, Actionable;
29 
30     match fn {
31         type_ => || ffi::gtk_radio_menu_item_get_type(),
32     }
33 }
34 
35 impl RadioMenuItem {
36     #[doc(alias = "gtk_radio_menu_item_new_from_widget")]
37     #[doc(alias = "new_from_widget")]
from_widget<P: IsA<RadioMenuItem>>(group: &P) -> RadioMenuItem38     pub fn from_widget<P: IsA<RadioMenuItem>>(group: &P) -> RadioMenuItem {
39         skip_assert_initialized!();
40         unsafe {
41             Widget::from_glib_none(ffi::gtk_radio_menu_item_new_from_widget(
42                 group.as_ref().to_glib_none().0,
43             ))
44             .unsafe_cast()
45         }
46     }
47 
48     #[doc(alias = "gtk_radio_menu_item_new_with_label_from_widget")]
49     #[doc(alias = "new_with_label_from_widget")]
with_label_from_widget<P: IsA<RadioMenuItem>>( group: &P, label: Option<&str>, ) -> RadioMenuItem50     pub fn with_label_from_widget<P: IsA<RadioMenuItem>>(
51         group: &P,
52         label: Option<&str>,
53     ) -> RadioMenuItem {
54         skip_assert_initialized!();
55         unsafe {
56             Widget::from_glib_none(ffi::gtk_radio_menu_item_new_with_label_from_widget(
57                 group.as_ref().to_glib_none().0,
58                 label.to_glib_none().0,
59             ))
60             .unsafe_cast()
61         }
62     }
63 
64     #[doc(alias = "gtk_radio_menu_item_new_with_mnemonic_from_widget")]
65     #[doc(alias = "new_with_mnemonic_from_widget")]
with_mnemonic_from_widget<P: IsA<RadioMenuItem>>( group: &P, label: Option<&str>, ) -> RadioMenuItem66     pub fn with_mnemonic_from_widget<P: IsA<RadioMenuItem>>(
67         group: &P,
68         label: Option<&str>,
69     ) -> RadioMenuItem {
70         skip_assert_initialized!();
71         unsafe {
72             Widget::from_glib_none(ffi::gtk_radio_menu_item_new_with_mnemonic_from_widget(
73                 group.as_ref().to_glib_none().0,
74                 label.to_glib_none().0,
75             ))
76             .unsafe_cast()
77         }
78     }
79 
80     // rustdoc-stripper-ignore-next
81     /// Creates a new builder-pattern struct instance to construct [`RadioMenuItem`] objects.
82     ///
83     /// This method returns an instance of [`RadioMenuItemBuilder`] which can be used to create [`RadioMenuItem`] objects.
builder() -> RadioMenuItemBuilder84     pub fn builder() -> RadioMenuItemBuilder {
85         RadioMenuItemBuilder::default()
86     }
87 }
88 
89 #[derive(Clone, Default)]
90 // rustdoc-stripper-ignore-next
91 /// A [builder-pattern] type to construct [`RadioMenuItem`] objects.
92 ///
93 /// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
94 pub struct RadioMenuItemBuilder {
95     active: Option<bool>,
96     draw_as_radio: Option<bool>,
97     inconsistent: Option<bool>,
98     accel_path: Option<String>,
99     label: Option<String>,
100     right_justified: Option<bool>,
101     submenu: Option<Menu>,
102     use_underline: Option<bool>,
103     border_width: Option<u32>,
104     child: Option<Widget>,
105     resize_mode: Option<ResizeMode>,
106     app_paintable: Option<bool>,
107     can_default: Option<bool>,
108     can_focus: Option<bool>,
109     events: Option<gdk::EventMask>,
110     expand: Option<bool>,
111     #[cfg(any(feature = "v3_20", feature = "dox"))]
112     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
113     focus_on_click: Option<bool>,
114     halign: Option<Align>,
115     has_default: Option<bool>,
116     has_focus: Option<bool>,
117     has_tooltip: Option<bool>,
118     height_request: Option<i32>,
119     hexpand: Option<bool>,
120     hexpand_set: Option<bool>,
121     is_focus: Option<bool>,
122     margin: Option<i32>,
123     margin_bottom: Option<i32>,
124     margin_end: Option<i32>,
125     margin_start: Option<i32>,
126     margin_top: Option<i32>,
127     name: Option<String>,
128     no_show_all: Option<bool>,
129     opacity: Option<f64>,
130     parent: Option<Container>,
131     receives_default: Option<bool>,
132     sensitive: Option<bool>,
133     tooltip_markup: Option<String>,
134     tooltip_text: Option<String>,
135     valign: Option<Align>,
136     vexpand: Option<bool>,
137     vexpand_set: Option<bool>,
138     visible: Option<bool>,
139     width_request: Option<i32>,
140     action_name: Option<String>,
141     action_target: Option<glib::Variant>,
142 }
143 
144 impl RadioMenuItemBuilder {
145     // rustdoc-stripper-ignore-next
146     /// Create a new [`RadioMenuItemBuilder`].
new() -> Self147     pub fn new() -> Self {
148         Self::default()
149     }
150 
151     // rustdoc-stripper-ignore-next
152     /// Build the [`RadioMenuItem`].
build(self) -> RadioMenuItem153     pub fn build(self) -> RadioMenuItem {
154         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
155         if let Some(ref active) = self.active {
156             properties.push(("active", active));
157         }
158         if let Some(ref draw_as_radio) = self.draw_as_radio {
159             properties.push(("draw-as-radio", draw_as_radio));
160         }
161         if let Some(ref inconsistent) = self.inconsistent {
162             properties.push(("inconsistent", inconsistent));
163         }
164         if let Some(ref accel_path) = self.accel_path {
165             properties.push(("accel-path", accel_path));
166         }
167         if let Some(ref label) = self.label {
168             properties.push(("label", label));
169         }
170         if let Some(ref right_justified) = self.right_justified {
171             properties.push(("right-justified", right_justified));
172         }
173         if let Some(ref submenu) = self.submenu {
174             properties.push(("submenu", submenu));
175         }
176         if let Some(ref use_underline) = self.use_underline {
177             properties.push(("use-underline", use_underline));
178         }
179         if let Some(ref border_width) = self.border_width {
180             properties.push(("border-width", border_width));
181         }
182         if let Some(ref child) = self.child {
183             properties.push(("child", child));
184         }
185         if let Some(ref resize_mode) = self.resize_mode {
186             properties.push(("resize-mode", resize_mode));
187         }
188         if let Some(ref app_paintable) = self.app_paintable {
189             properties.push(("app-paintable", app_paintable));
190         }
191         if let Some(ref can_default) = self.can_default {
192             properties.push(("can-default", can_default));
193         }
194         if let Some(ref can_focus) = self.can_focus {
195             properties.push(("can-focus", can_focus));
196         }
197         if let Some(ref events) = self.events {
198             properties.push(("events", events));
199         }
200         if let Some(ref expand) = self.expand {
201             properties.push(("expand", expand));
202         }
203         #[cfg(any(feature = "v3_20", feature = "dox"))]
204         if let Some(ref focus_on_click) = self.focus_on_click {
205             properties.push(("focus-on-click", focus_on_click));
206         }
207         if let Some(ref halign) = self.halign {
208             properties.push(("halign", halign));
209         }
210         if let Some(ref has_default) = self.has_default {
211             properties.push(("has-default", has_default));
212         }
213         if let Some(ref has_focus) = self.has_focus {
214             properties.push(("has-focus", has_focus));
215         }
216         if let Some(ref has_tooltip) = self.has_tooltip {
217             properties.push(("has-tooltip", has_tooltip));
218         }
219         if let Some(ref height_request) = self.height_request {
220             properties.push(("height-request", height_request));
221         }
222         if let Some(ref hexpand) = self.hexpand {
223             properties.push(("hexpand", hexpand));
224         }
225         if let Some(ref hexpand_set) = self.hexpand_set {
226             properties.push(("hexpand-set", hexpand_set));
227         }
228         if let Some(ref is_focus) = self.is_focus {
229             properties.push(("is-focus", is_focus));
230         }
231         if let Some(ref margin) = self.margin {
232             properties.push(("margin", margin));
233         }
234         if let Some(ref margin_bottom) = self.margin_bottom {
235             properties.push(("margin-bottom", margin_bottom));
236         }
237         if let Some(ref margin_end) = self.margin_end {
238             properties.push(("margin-end", margin_end));
239         }
240         if let Some(ref margin_start) = self.margin_start {
241             properties.push(("margin-start", margin_start));
242         }
243         if let Some(ref margin_top) = self.margin_top {
244             properties.push(("margin-top", margin_top));
245         }
246         if let Some(ref name) = self.name {
247             properties.push(("name", name));
248         }
249         if let Some(ref no_show_all) = self.no_show_all {
250             properties.push(("no-show-all", no_show_all));
251         }
252         if let Some(ref opacity) = self.opacity {
253             properties.push(("opacity", opacity));
254         }
255         if let Some(ref parent) = self.parent {
256             properties.push(("parent", parent));
257         }
258         if let Some(ref receives_default) = self.receives_default {
259             properties.push(("receives-default", receives_default));
260         }
261         if let Some(ref sensitive) = self.sensitive {
262             properties.push(("sensitive", sensitive));
263         }
264         if let Some(ref tooltip_markup) = self.tooltip_markup {
265             properties.push(("tooltip-markup", tooltip_markup));
266         }
267         if let Some(ref tooltip_text) = self.tooltip_text {
268             properties.push(("tooltip-text", tooltip_text));
269         }
270         if let Some(ref valign) = self.valign {
271             properties.push(("valign", valign));
272         }
273         if let Some(ref vexpand) = self.vexpand {
274             properties.push(("vexpand", vexpand));
275         }
276         if let Some(ref vexpand_set) = self.vexpand_set {
277             properties.push(("vexpand-set", vexpand_set));
278         }
279         if let Some(ref visible) = self.visible {
280             properties.push(("visible", visible));
281         }
282         if let Some(ref width_request) = self.width_request {
283             properties.push(("width-request", width_request));
284         }
285         if let Some(ref action_name) = self.action_name {
286             properties.push(("action-name", action_name));
287         }
288         if let Some(ref action_target) = self.action_target {
289             properties.push(("action-target", action_target));
290         }
291         glib::Object::new::<RadioMenuItem>(&properties)
292             .expect("Failed to create an instance of RadioMenuItem")
293     }
294 
active(mut self, active: bool) -> Self295     pub fn active(mut self, active: bool) -> Self {
296         self.active = Some(active);
297         self
298     }
299 
draw_as_radio(mut self, draw_as_radio: bool) -> Self300     pub fn draw_as_radio(mut self, draw_as_radio: bool) -> Self {
301         self.draw_as_radio = Some(draw_as_radio);
302         self
303     }
304 
inconsistent(mut self, inconsistent: bool) -> Self305     pub fn inconsistent(mut self, inconsistent: bool) -> Self {
306         self.inconsistent = Some(inconsistent);
307         self
308     }
309 
accel_path(mut self, accel_path: &str) -> Self310     pub fn accel_path(mut self, accel_path: &str) -> Self {
311         self.accel_path = Some(accel_path.to_string());
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 
right_justified(mut self, right_justified: bool) -> Self320     pub fn right_justified(mut self, right_justified: bool) -> Self {
321         self.right_justified = Some(right_justified);
322         self
323     }
324 
submenu<P: IsA<Menu>>(mut self, submenu: &P) -> Self325     pub fn submenu<P: IsA<Menu>>(mut self, submenu: &P) -> Self {
326         self.submenu = Some(submenu.clone().upcast());
327         self
328     }
329 
use_underline(mut self, use_underline: bool) -> Self330     pub fn use_underline(mut self, use_underline: bool) -> Self {
331         self.use_underline = Some(use_underline);
332         self
333     }
334 
border_width(mut self, border_width: u32) -> Self335     pub fn border_width(mut self, border_width: u32) -> Self {
336         self.border_width = Some(border_width);
337         self
338     }
339 
child<P: IsA<Widget>>(mut self, child: &P) -> Self340     pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self {
341         self.child = Some(child.clone().upcast());
342         self
343     }
344 
resize_mode(mut self, resize_mode: ResizeMode) -> Self345     pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
346         self.resize_mode = Some(resize_mode);
347         self
348     }
349 
app_paintable(mut self, app_paintable: bool) -> Self350     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
351         self.app_paintable = Some(app_paintable);
352         self
353     }
354 
can_default(mut self, can_default: bool) -> Self355     pub fn can_default(mut self, can_default: bool) -> Self {
356         self.can_default = Some(can_default);
357         self
358     }
359 
can_focus(mut self, can_focus: bool) -> Self360     pub fn can_focus(mut self, can_focus: bool) -> Self {
361         self.can_focus = Some(can_focus);
362         self
363     }
364 
events(mut self, events: gdk::EventMask) -> Self365     pub fn events(mut self, events: gdk::EventMask) -> Self {
366         self.events = Some(events);
367         self
368     }
369 
expand(mut self, expand: bool) -> Self370     pub fn expand(mut self, expand: bool) -> Self {
371         self.expand = Some(expand);
372         self
373     }
374 
375     #[cfg(any(feature = "v3_20", feature = "dox"))]
376     #[cfg_attr(feature = "dox", doc(cfg(feature = "v3_20")))]
focus_on_click(mut self, focus_on_click: bool) -> Self377     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
378         self.focus_on_click = Some(focus_on_click);
379         self
380     }
381 
halign(mut self, halign: Align) -> Self382     pub fn halign(mut self, halign: Align) -> Self {
383         self.halign = Some(halign);
384         self
385     }
386 
has_default(mut self, has_default: bool) -> Self387     pub fn has_default(mut self, has_default: bool) -> Self {
388         self.has_default = Some(has_default);
389         self
390     }
391 
has_focus(mut self, has_focus: bool) -> Self392     pub fn has_focus(mut self, has_focus: bool) -> Self {
393         self.has_focus = Some(has_focus);
394         self
395     }
396 
has_tooltip(mut self, has_tooltip: bool) -> Self397     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
398         self.has_tooltip = Some(has_tooltip);
399         self
400     }
401 
height_request(mut self, height_request: i32) -> Self402     pub fn height_request(mut self, height_request: i32) -> Self {
403         self.height_request = Some(height_request);
404         self
405     }
406 
hexpand(mut self, hexpand: bool) -> Self407     pub fn hexpand(mut self, hexpand: bool) -> Self {
408         self.hexpand = Some(hexpand);
409         self
410     }
411 
hexpand_set(mut self, hexpand_set: bool) -> Self412     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
413         self.hexpand_set = Some(hexpand_set);
414         self
415     }
416 
is_focus(mut self, is_focus: bool) -> Self417     pub fn is_focus(mut self, is_focus: bool) -> Self {
418         self.is_focus = Some(is_focus);
419         self
420     }
421 
margin(mut self, margin: i32) -> Self422     pub fn margin(mut self, margin: i32) -> Self {
423         self.margin = Some(margin);
424         self
425     }
426 
margin_bottom(mut self, margin_bottom: i32) -> Self427     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
428         self.margin_bottom = Some(margin_bottom);
429         self
430     }
431 
margin_end(mut self, margin_end: i32) -> Self432     pub fn margin_end(mut self, margin_end: i32) -> Self {
433         self.margin_end = Some(margin_end);
434         self
435     }
436 
margin_start(mut self, margin_start: i32) -> Self437     pub fn margin_start(mut self, margin_start: i32) -> Self {
438         self.margin_start = Some(margin_start);
439         self
440     }
441 
margin_top(mut self, margin_top: i32) -> Self442     pub fn margin_top(mut self, margin_top: i32) -> Self {
443         self.margin_top = Some(margin_top);
444         self
445     }
446 
name(mut self, name: &str) -> Self447     pub fn name(mut self, name: &str) -> Self {
448         self.name = Some(name.to_string());
449         self
450     }
451 
no_show_all(mut self, no_show_all: bool) -> Self452     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
453         self.no_show_all = Some(no_show_all);
454         self
455     }
456 
opacity(mut self, opacity: f64) -> Self457     pub fn opacity(mut self, opacity: f64) -> Self {
458         self.opacity = Some(opacity);
459         self
460     }
461 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self462     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
463         self.parent = Some(parent.clone().upcast());
464         self
465     }
466 
receives_default(mut self, receives_default: bool) -> Self467     pub fn receives_default(mut self, receives_default: bool) -> Self {
468         self.receives_default = Some(receives_default);
469         self
470     }
471 
sensitive(mut self, sensitive: bool) -> Self472     pub fn sensitive(mut self, sensitive: bool) -> Self {
473         self.sensitive = Some(sensitive);
474         self
475     }
476 
tooltip_markup(mut self, tooltip_markup: &str) -> Self477     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
478         self.tooltip_markup = Some(tooltip_markup.to_string());
479         self
480     }
481 
tooltip_text(mut self, tooltip_text: &str) -> Self482     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
483         self.tooltip_text = Some(tooltip_text.to_string());
484         self
485     }
486 
valign(mut self, valign: Align) -> Self487     pub fn valign(mut self, valign: Align) -> Self {
488         self.valign = Some(valign);
489         self
490     }
491 
vexpand(mut self, vexpand: bool) -> Self492     pub fn vexpand(mut self, vexpand: bool) -> Self {
493         self.vexpand = Some(vexpand);
494         self
495     }
496 
vexpand_set(mut self, vexpand_set: bool) -> Self497     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
498         self.vexpand_set = Some(vexpand_set);
499         self
500     }
501 
visible(mut self, visible: bool) -> Self502     pub fn visible(mut self, visible: bool) -> Self {
503         self.visible = Some(visible);
504         self
505     }
506 
width_request(mut self, width_request: i32) -> Self507     pub fn width_request(mut self, width_request: i32) -> Self {
508         self.width_request = Some(width_request);
509         self
510     }
511 
action_name(mut self, action_name: &str) -> Self512     pub fn action_name(mut self, action_name: &str) -> Self {
513         self.action_name = Some(action_name.to_string());
514         self
515     }
516 
action_target(mut self, action_target: &glib::Variant) -> Self517     pub fn action_target(mut self, action_target: &glib::Variant) -> Self {
518         self.action_target = Some(action_target.clone());
519         self
520     }
521 }
522 
523 pub const NONE_RADIO_MENU_ITEM: Option<&RadioMenuItem> = None;
524 
525 pub trait RadioMenuItemExt: 'static {
526     #[doc(alias = "gtk_radio_menu_item_get_group")]
527     #[doc(alias = "get_group")]
group(&self) -> Vec<RadioMenuItem>528     fn group(&self) -> Vec<RadioMenuItem>;
529 
530     #[doc(alias = "gtk_radio_menu_item_join_group")]
join_group<P: IsA<RadioMenuItem>>(&self, group_source: Option<&P>)531     fn join_group<P: IsA<RadioMenuItem>>(&self, group_source: Option<&P>);
532 
533     #[doc(alias = "group-changed")]
connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId534     fn connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
535 }
536 
537 impl<O: IsA<RadioMenuItem>> RadioMenuItemExt for O {
group(&self) -> Vec<RadioMenuItem>538     fn group(&self) -> Vec<RadioMenuItem> {
539         unsafe {
540             FromGlibPtrContainer::from_glib_none(ffi::gtk_radio_menu_item_get_group(
541                 self.as_ref().to_glib_none().0,
542             ))
543         }
544     }
545 
join_group<P: IsA<RadioMenuItem>>(&self, group_source: Option<&P>)546     fn join_group<P: IsA<RadioMenuItem>>(&self, group_source: Option<&P>) {
547         unsafe {
548             ffi::gtk_radio_menu_item_join_group(
549                 self.as_ref().to_glib_none().0,
550                 group_source.map(|p| p.as_ref()).to_glib_none().0,
551             );
552         }
553     }
554 
connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId555     fn connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
556         unsafe extern "C" fn group_changed_trampoline<
557             P: IsA<RadioMenuItem>,
558             F: Fn(&P) + 'static,
559         >(
560             this: *mut ffi::GtkRadioMenuItem,
561             f: glib::ffi::gpointer,
562         ) {
563             let f: &F = &*(f as *const F);
564             f(RadioMenuItem::from_glib_borrow(this).unsafe_cast_ref())
565         }
566         unsafe {
567             let f: Box_<F> = Box_::new(f);
568             connect_raw(
569                 self.as_ptr() as *mut _,
570                 b"group-changed\0".as_ptr() as *const _,
571                 Some(transmute::<_, unsafe extern "C" fn()>(
572                     group_changed_trampoline::<Self, F> as *const (),
573                 )),
574                 Box_::into_raw(f),
575             )
576         }
577     }
578 }
579 
580 impl fmt::Display for RadioMenuItem {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result581     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
582         f.write_str("RadioMenuItem")
583     }
584 }
585