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 CheckMenuItem;
24 use Container;
25 use Menu;
26 use MenuItem;
27 use ResizeMode;
28 use Widget;
29 
30 glib_wrapper! {
31     pub struct RadioMenuItem(Object<gtk_sys::GtkRadioMenuItem, gtk_sys::GtkRadioMenuItemClass, RadioMenuItemClass>) @extends CheckMenuItem, MenuItem, Bin, Container, Widget, @implements Buildable, Actionable;
32 
33     match fn {
34         get_type => || gtk_sys::gtk_radio_menu_item_get_type(),
35     }
36 }
37 
38 impl RadioMenuItem {
new_from_widget<P: IsA<RadioMenuItem>>(group: &P) -> RadioMenuItem39     pub fn new_from_widget<P: IsA<RadioMenuItem>>(group: &P) -> RadioMenuItem {
40         skip_assert_initialized!();
41         unsafe {
42             Widget::from_glib_none(gtk_sys::gtk_radio_menu_item_new_from_widget(
43                 group.as_ref().to_glib_none().0,
44             ))
45             .unsafe_cast()
46         }
47     }
48 
new_with_label_from_widget<P: IsA<RadioMenuItem>>( group: &P, label: Option<&str>, ) -> RadioMenuItem49     pub fn new_with_label_from_widget<P: IsA<RadioMenuItem>>(
50         group: &P,
51         label: Option<&str>,
52     ) -> RadioMenuItem {
53         skip_assert_initialized!();
54         unsafe {
55             Widget::from_glib_none(gtk_sys::gtk_radio_menu_item_new_with_label_from_widget(
56                 group.as_ref().to_glib_none().0,
57                 label.to_glib_none().0,
58             ))
59             .unsafe_cast()
60         }
61     }
62 
new_with_mnemonic_from_widget<P: IsA<RadioMenuItem>>( group: &P, label: Option<&str>, ) -> RadioMenuItem63     pub fn new_with_mnemonic_from_widget<P: IsA<RadioMenuItem>>(
64         group: &P,
65         label: Option<&str>,
66     ) -> RadioMenuItem {
67         skip_assert_initialized!();
68         unsafe {
69             Widget::from_glib_none(gtk_sys::gtk_radio_menu_item_new_with_mnemonic_from_widget(
70                 group.as_ref().to_glib_none().0,
71                 label.to_glib_none().0,
72             ))
73             .unsafe_cast()
74         }
75     }
76 }
77 
78 #[derive(Clone, Default)]
79 pub struct RadioMenuItemBuilder {
80     active: Option<bool>,
81     draw_as_radio: Option<bool>,
82     inconsistent: Option<bool>,
83     accel_path: Option<String>,
84     label: Option<String>,
85     right_justified: Option<bool>,
86     submenu: Option<Menu>,
87     use_underline: Option<bool>,
88     border_width: Option<u32>,
89     child: Option<Widget>,
90     resize_mode: Option<ResizeMode>,
91     app_paintable: Option<bool>,
92     can_default: Option<bool>,
93     can_focus: Option<bool>,
94     events: Option<gdk::EventMask>,
95     expand: Option<bool>,
96     #[cfg(any(feature = "v3_20", feature = "dox"))]
97     focus_on_click: Option<bool>,
98     halign: Option<Align>,
99     has_default: Option<bool>,
100     has_focus: Option<bool>,
101     has_tooltip: Option<bool>,
102     height_request: Option<i32>,
103     hexpand: Option<bool>,
104     hexpand_set: Option<bool>,
105     is_focus: Option<bool>,
106     margin: Option<i32>,
107     margin_bottom: Option<i32>,
108     margin_end: Option<i32>,
109     margin_start: Option<i32>,
110     margin_top: Option<i32>,
111     name: Option<String>,
112     no_show_all: Option<bool>,
113     opacity: Option<f64>,
114     parent: Option<Container>,
115     receives_default: Option<bool>,
116     sensitive: Option<bool>,
117     tooltip_markup: Option<String>,
118     tooltip_text: Option<String>,
119     valign: Option<Align>,
120     vexpand: Option<bool>,
121     vexpand_set: Option<bool>,
122     visible: Option<bool>,
123     width_request: Option<i32>,
124     action_name: Option<String>,
125     action_target: Option<glib::Variant>,
126 }
127 
128 impl RadioMenuItemBuilder {
new() -> Self129     pub fn new() -> Self {
130         Self::default()
131     }
132 
build(self) -> RadioMenuItem133     pub fn build(self) -> RadioMenuItem {
134         let mut properties: Vec<(&str, &dyn ToValue)> = vec![];
135         if let Some(ref active) = self.active {
136             properties.push(("active", active));
137         }
138         if let Some(ref draw_as_radio) = self.draw_as_radio {
139             properties.push(("draw-as-radio", draw_as_radio));
140         }
141         if let Some(ref inconsistent) = self.inconsistent {
142             properties.push(("inconsistent", inconsistent));
143         }
144         if let Some(ref accel_path) = self.accel_path {
145             properties.push(("accel-path", accel_path));
146         }
147         if let Some(ref label) = self.label {
148             properties.push(("label", label));
149         }
150         if let Some(ref right_justified) = self.right_justified {
151             properties.push(("right-justified", right_justified));
152         }
153         if let Some(ref submenu) = self.submenu {
154             properties.push(("submenu", submenu));
155         }
156         if let Some(ref use_underline) = self.use_underline {
157             properties.push(("use-underline", use_underline));
158         }
159         if let Some(ref border_width) = self.border_width {
160             properties.push(("border-width", border_width));
161         }
162         if let Some(ref child) = self.child {
163             properties.push(("child", child));
164         }
165         if let Some(ref resize_mode) = self.resize_mode {
166             properties.push(("resize-mode", resize_mode));
167         }
168         if let Some(ref app_paintable) = self.app_paintable {
169             properties.push(("app-paintable", app_paintable));
170         }
171         if let Some(ref can_default) = self.can_default {
172             properties.push(("can-default", can_default));
173         }
174         if let Some(ref can_focus) = self.can_focus {
175             properties.push(("can-focus", can_focus));
176         }
177         if let Some(ref events) = self.events {
178             properties.push(("events", events));
179         }
180         if let Some(ref expand) = self.expand {
181             properties.push(("expand", expand));
182         }
183         #[cfg(any(feature = "v3_20", feature = "dox"))]
184         {
185             if let Some(ref focus_on_click) = self.focus_on_click {
186                 properties.push(("focus-on-click", focus_on_click));
187             }
188         }
189         if let Some(ref halign) = self.halign {
190             properties.push(("halign", halign));
191         }
192         if let Some(ref has_default) = self.has_default {
193             properties.push(("has-default", has_default));
194         }
195         if let Some(ref has_focus) = self.has_focus {
196             properties.push(("has-focus", has_focus));
197         }
198         if let Some(ref has_tooltip) = self.has_tooltip {
199             properties.push(("has-tooltip", has_tooltip));
200         }
201         if let Some(ref height_request) = self.height_request {
202             properties.push(("height-request", height_request));
203         }
204         if let Some(ref hexpand) = self.hexpand {
205             properties.push(("hexpand", hexpand));
206         }
207         if let Some(ref hexpand_set) = self.hexpand_set {
208             properties.push(("hexpand-set", hexpand_set));
209         }
210         if let Some(ref is_focus) = self.is_focus {
211             properties.push(("is-focus", is_focus));
212         }
213         if let Some(ref margin) = self.margin {
214             properties.push(("margin", margin));
215         }
216         if let Some(ref margin_bottom) = self.margin_bottom {
217             properties.push(("margin-bottom", margin_bottom));
218         }
219         if let Some(ref margin_end) = self.margin_end {
220             properties.push(("margin-end", margin_end));
221         }
222         if let Some(ref margin_start) = self.margin_start {
223             properties.push(("margin-start", margin_start));
224         }
225         if let Some(ref margin_top) = self.margin_top {
226             properties.push(("margin-top", margin_top));
227         }
228         if let Some(ref name) = self.name {
229             properties.push(("name", name));
230         }
231         if let Some(ref no_show_all) = self.no_show_all {
232             properties.push(("no-show-all", no_show_all));
233         }
234         if let Some(ref opacity) = self.opacity {
235             properties.push(("opacity", opacity));
236         }
237         if let Some(ref parent) = self.parent {
238             properties.push(("parent", parent));
239         }
240         if let Some(ref receives_default) = self.receives_default {
241             properties.push(("receives-default", receives_default));
242         }
243         if let Some(ref sensitive) = self.sensitive {
244             properties.push(("sensitive", sensitive));
245         }
246         if let Some(ref tooltip_markup) = self.tooltip_markup {
247             properties.push(("tooltip-markup", tooltip_markup));
248         }
249         if let Some(ref tooltip_text) = self.tooltip_text {
250             properties.push(("tooltip-text", tooltip_text));
251         }
252         if let Some(ref valign) = self.valign {
253             properties.push(("valign", valign));
254         }
255         if let Some(ref vexpand) = self.vexpand {
256             properties.push(("vexpand", vexpand));
257         }
258         if let Some(ref vexpand_set) = self.vexpand_set {
259             properties.push(("vexpand-set", vexpand_set));
260         }
261         if let Some(ref visible) = self.visible {
262             properties.push(("visible", visible));
263         }
264         if let Some(ref width_request) = self.width_request {
265             properties.push(("width-request", width_request));
266         }
267         if let Some(ref action_name) = self.action_name {
268             properties.push(("action-name", action_name));
269         }
270         if let Some(ref action_target) = self.action_target {
271             properties.push(("action-target", action_target));
272         }
273         glib::Object::new(RadioMenuItem::static_type(), &properties)
274             .expect("object new")
275             .downcast()
276             .expect("downcast")
277     }
278 
active(mut self, active: bool) -> Self279     pub fn active(mut self, active: bool) -> Self {
280         self.active = Some(active);
281         self
282     }
283 
draw_as_radio(mut self, draw_as_radio: bool) -> Self284     pub fn draw_as_radio(mut self, draw_as_radio: bool) -> Self {
285         self.draw_as_radio = Some(draw_as_radio);
286         self
287     }
288 
inconsistent(mut self, inconsistent: bool) -> Self289     pub fn inconsistent(mut self, inconsistent: bool) -> Self {
290         self.inconsistent = Some(inconsistent);
291         self
292     }
293 
accel_path(mut self, accel_path: &str) -> Self294     pub fn accel_path(mut self, accel_path: &str) -> Self {
295         self.accel_path = Some(accel_path.to_string());
296         self
297     }
298 
label(mut self, label: &str) -> Self299     pub fn label(mut self, label: &str) -> Self {
300         self.label = Some(label.to_string());
301         self
302     }
303 
right_justified(mut self, right_justified: bool) -> Self304     pub fn right_justified(mut self, right_justified: bool) -> Self {
305         self.right_justified = Some(right_justified);
306         self
307     }
308 
submenu<P: IsA<Menu>>(mut self, submenu: &P) -> Self309     pub fn submenu<P: IsA<Menu>>(mut self, submenu: &P) -> Self {
310         self.submenu = Some(submenu.clone().upcast());
311         self
312     }
313 
use_underline(mut self, use_underline: bool) -> Self314     pub fn use_underline(mut self, use_underline: bool) -> Self {
315         self.use_underline = Some(use_underline);
316         self
317     }
318 
border_width(mut self, border_width: u32) -> Self319     pub fn border_width(mut self, border_width: u32) -> Self {
320         self.border_width = Some(border_width);
321         self
322     }
323 
child<P: IsA<Widget>>(mut self, child: &P) -> Self324     pub fn child<P: IsA<Widget>>(mut self, child: &P) -> Self {
325         self.child = Some(child.clone().upcast());
326         self
327     }
328 
resize_mode(mut self, resize_mode: ResizeMode) -> Self329     pub fn resize_mode(mut self, resize_mode: ResizeMode) -> Self {
330         self.resize_mode = Some(resize_mode);
331         self
332     }
333 
app_paintable(mut self, app_paintable: bool) -> Self334     pub fn app_paintable(mut self, app_paintable: bool) -> Self {
335         self.app_paintable = Some(app_paintable);
336         self
337     }
338 
can_default(mut self, can_default: bool) -> Self339     pub fn can_default(mut self, can_default: bool) -> Self {
340         self.can_default = Some(can_default);
341         self
342     }
343 
can_focus(mut self, can_focus: bool) -> Self344     pub fn can_focus(mut self, can_focus: bool) -> Self {
345         self.can_focus = Some(can_focus);
346         self
347     }
348 
events(mut self, events: gdk::EventMask) -> Self349     pub fn events(mut self, events: gdk::EventMask) -> Self {
350         self.events = Some(events);
351         self
352     }
353 
expand(mut self, expand: bool) -> Self354     pub fn expand(mut self, expand: bool) -> Self {
355         self.expand = Some(expand);
356         self
357     }
358 
359     #[cfg(any(feature = "v3_20", feature = "dox"))]
focus_on_click(mut self, focus_on_click: bool) -> Self360     pub fn focus_on_click(mut self, focus_on_click: bool) -> Self {
361         self.focus_on_click = Some(focus_on_click);
362         self
363     }
364 
halign(mut self, halign: Align) -> Self365     pub fn halign(mut self, halign: Align) -> Self {
366         self.halign = Some(halign);
367         self
368     }
369 
has_default(mut self, has_default: bool) -> Self370     pub fn has_default(mut self, has_default: bool) -> Self {
371         self.has_default = Some(has_default);
372         self
373     }
374 
has_focus(mut self, has_focus: bool) -> Self375     pub fn has_focus(mut self, has_focus: bool) -> Self {
376         self.has_focus = Some(has_focus);
377         self
378     }
379 
has_tooltip(mut self, has_tooltip: bool) -> Self380     pub fn has_tooltip(mut self, has_tooltip: bool) -> Self {
381         self.has_tooltip = Some(has_tooltip);
382         self
383     }
384 
height_request(mut self, height_request: i32) -> Self385     pub fn height_request(mut self, height_request: i32) -> Self {
386         self.height_request = Some(height_request);
387         self
388     }
389 
hexpand(mut self, hexpand: bool) -> Self390     pub fn hexpand(mut self, hexpand: bool) -> Self {
391         self.hexpand = Some(hexpand);
392         self
393     }
394 
hexpand_set(mut self, hexpand_set: bool) -> Self395     pub fn hexpand_set(mut self, hexpand_set: bool) -> Self {
396         self.hexpand_set = Some(hexpand_set);
397         self
398     }
399 
is_focus(mut self, is_focus: bool) -> Self400     pub fn is_focus(mut self, is_focus: bool) -> Self {
401         self.is_focus = Some(is_focus);
402         self
403     }
404 
margin(mut self, margin: i32) -> Self405     pub fn margin(mut self, margin: i32) -> Self {
406         self.margin = Some(margin);
407         self
408     }
409 
margin_bottom(mut self, margin_bottom: i32) -> Self410     pub fn margin_bottom(mut self, margin_bottom: i32) -> Self {
411         self.margin_bottom = Some(margin_bottom);
412         self
413     }
414 
margin_end(mut self, margin_end: i32) -> Self415     pub fn margin_end(mut self, margin_end: i32) -> Self {
416         self.margin_end = Some(margin_end);
417         self
418     }
419 
margin_start(mut self, margin_start: i32) -> Self420     pub fn margin_start(mut self, margin_start: i32) -> Self {
421         self.margin_start = Some(margin_start);
422         self
423     }
424 
margin_top(mut self, margin_top: i32) -> Self425     pub fn margin_top(mut self, margin_top: i32) -> Self {
426         self.margin_top = Some(margin_top);
427         self
428     }
429 
name(mut self, name: &str) -> Self430     pub fn name(mut self, name: &str) -> Self {
431         self.name = Some(name.to_string());
432         self
433     }
434 
no_show_all(mut self, no_show_all: bool) -> Self435     pub fn no_show_all(mut self, no_show_all: bool) -> Self {
436         self.no_show_all = Some(no_show_all);
437         self
438     }
439 
opacity(mut self, opacity: f64) -> Self440     pub fn opacity(mut self, opacity: f64) -> Self {
441         self.opacity = Some(opacity);
442         self
443     }
444 
parent<P: IsA<Container>>(mut self, parent: &P) -> Self445     pub fn parent<P: IsA<Container>>(mut self, parent: &P) -> Self {
446         self.parent = Some(parent.clone().upcast());
447         self
448     }
449 
receives_default(mut self, receives_default: bool) -> Self450     pub fn receives_default(mut self, receives_default: bool) -> Self {
451         self.receives_default = Some(receives_default);
452         self
453     }
454 
sensitive(mut self, sensitive: bool) -> Self455     pub fn sensitive(mut self, sensitive: bool) -> Self {
456         self.sensitive = Some(sensitive);
457         self
458     }
459 
tooltip_markup(mut self, tooltip_markup: &str) -> Self460     pub fn tooltip_markup(mut self, tooltip_markup: &str) -> Self {
461         self.tooltip_markup = Some(tooltip_markup.to_string());
462         self
463     }
464 
tooltip_text(mut self, tooltip_text: &str) -> Self465     pub fn tooltip_text(mut self, tooltip_text: &str) -> Self {
466         self.tooltip_text = Some(tooltip_text.to_string());
467         self
468     }
469 
valign(mut self, valign: Align) -> Self470     pub fn valign(mut self, valign: Align) -> Self {
471         self.valign = Some(valign);
472         self
473     }
474 
vexpand(mut self, vexpand: bool) -> Self475     pub fn vexpand(mut self, vexpand: bool) -> Self {
476         self.vexpand = Some(vexpand);
477         self
478     }
479 
vexpand_set(mut self, vexpand_set: bool) -> Self480     pub fn vexpand_set(mut self, vexpand_set: bool) -> Self {
481         self.vexpand_set = Some(vexpand_set);
482         self
483     }
484 
visible(mut self, visible: bool) -> Self485     pub fn visible(mut self, visible: bool) -> Self {
486         self.visible = Some(visible);
487         self
488     }
489 
width_request(mut self, width_request: i32) -> Self490     pub fn width_request(mut self, width_request: i32) -> Self {
491         self.width_request = Some(width_request);
492         self
493     }
494 
action_name(mut self, action_name: &str) -> Self495     pub fn action_name(mut self, action_name: &str) -> Self {
496         self.action_name = Some(action_name.to_string());
497         self
498     }
499 
action_target(mut self, action_target: &glib::Variant) -> Self500     pub fn action_target(mut self, action_target: &glib::Variant) -> Self {
501         self.action_target = Some(action_target.clone());
502         self
503     }
504 }
505 
506 pub const NONE_RADIO_MENU_ITEM: Option<&RadioMenuItem> = None;
507 
508 pub trait RadioMenuItemExt: 'static {
get_group(&self) -> Vec<RadioMenuItem>509     fn get_group(&self) -> Vec<RadioMenuItem>;
510 
511     #[cfg(any(feature = "v3_18", feature = "dox"))]
join_group<P: IsA<RadioMenuItem>>(&self, group_source: Option<&P>)512     fn join_group<P: IsA<RadioMenuItem>>(&self, group_source: Option<&P>);
513 
connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId514     fn connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId;
515 }
516 
517 impl<O: IsA<RadioMenuItem>> RadioMenuItemExt for O {
get_group(&self) -> Vec<RadioMenuItem>518     fn get_group(&self) -> Vec<RadioMenuItem> {
519         unsafe {
520             FromGlibPtrContainer::from_glib_none(gtk_sys::gtk_radio_menu_item_get_group(
521                 self.as_ref().to_glib_none().0,
522             ))
523         }
524     }
525 
526     #[cfg(any(feature = "v3_18", feature = "dox"))]
join_group<P: IsA<RadioMenuItem>>(&self, group_source: Option<&P>)527     fn join_group<P: IsA<RadioMenuItem>>(&self, group_source: Option<&P>) {
528         unsafe {
529             gtk_sys::gtk_radio_menu_item_join_group(
530                 self.as_ref().to_glib_none().0,
531                 group_source.map(|p| p.as_ref()).to_glib_none().0,
532             );
533         }
534     }
535 
connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId536     fn connect_group_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
537         unsafe extern "C" fn group_changed_trampoline<P, F: Fn(&P) + 'static>(
538             this: *mut gtk_sys::GtkRadioMenuItem,
539             f: glib_sys::gpointer,
540         ) where
541             P: IsA<RadioMenuItem>,
542         {
543             let f: &F = &*(f as *const F);
544             f(&RadioMenuItem::from_glib_borrow(this).unsafe_cast())
545         }
546         unsafe {
547             let f: Box_<F> = Box_::new(f);
548             connect_raw(
549                 self.as_ptr() as *mut _,
550                 b"group-changed\0".as_ptr() as *const _,
551                 Some(transmute(group_changed_trampoline::<Self, F> as usize)),
552                 Box_::into_raw(f),
553             )
554         }
555     }
556 }
557 
558 impl fmt::Display for RadioMenuItem {
fmt(&self, f: &mut fmt::Formatter) -> fmt::Result559     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
560         write!(f, "RadioMenuItem")
561     }
562 }
563