gtk/auto/
radio_menu_item.rs

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