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