Skip to main content

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 crate::{
6    AccelGroup, Align, Buildable, Container, Menu, MenuShell, RecentChooser, RecentFilter,
7    RecentManager, RecentSortType, ResizeMode, Widget,
8};
9use glib::{
10    prelude::*,
11    signal::{connect_raw, SignalHandlerId},
12    translate::*,
13};
14use std::{boxed::Box as Box_, fmt, mem::transmute};
15
16glib::wrapper! {
17    /// [`RecentChooserMenu`][crate::RecentChooserMenu] is a widget suitable for displaying recently used files
18    /// inside a menu. It can be used to set a sub-menu of a [`MenuItem`][crate::MenuItem] using
19    /// [`GtkMenuItemExt::set_submenu()`][crate::prelude::GtkMenuItemExt::set_submenu()], or as the menu of a [`MenuToolButton`][crate::MenuToolButton].
20    ///
21    /// Note that [`RecentChooserMenu`][crate::RecentChooserMenu] does not have any methods of its own. Instead,
22    /// you should use the functions that work on a [`RecentChooser`][crate::RecentChooser].
23    ///
24    /// Note also that [`RecentChooserMenu`][crate::RecentChooserMenu] does not support multiple filters, as it
25    /// has no way to let the user choose between them as the [`RecentChooserWidget`][crate::RecentChooserWidget]
26    /// and [`RecentChooserDialog`][crate::RecentChooserDialog] widgets do. Thus using [`RecentChooserExt::add_filter()`][crate::prelude::RecentChooserExt::add_filter()]
27    /// on a [`RecentChooserMenu`][crate::RecentChooserMenu] widget will yield the same effects as using
28    /// [`RecentChooserExt::set_filter()`][crate::prelude::RecentChooserExt::set_filter()], replacing any currently set filter
29    /// with the supplied filter; [`RecentChooserExt::remove_filter()`][crate::prelude::RecentChooserExt::remove_filter()] will remove
30    /// any currently set [`RecentFilter`][crate::RecentFilter] object and will unset the current filter;
31    /// [`RecentChooserExt::list_filters()`][crate::prelude::RecentChooserExt::list_filters()] will return a list containing a single
32    /// [`RecentFilter`][crate::RecentFilter] object.
33    ///
34    /// Recently used files are supported since GTK+ 2.10.
35    ///
36    /// ## Properties
37    ///
38    ///
39    /// #### `show-numbers`
40    ///  Whether the first ten items in the menu should be prepended by
41    /// a number acting as a unique mnemonic.
42    ///
43    /// Readable | Writeable
44    /// <details><summary><h4>Menu</h4></summary>
45    ///
46    ///
47    /// #### `accel-group`
48    ///  The accel group holding accelerators for the menu.
49    ///
50    /// Readable | Writeable
51    ///
52    ///
53    /// #### `accel-path`
54    ///  An accel path used to conveniently construct accel paths of child items.
55    ///
56    /// Readable | Writeable
57    ///
58    ///
59    /// #### `active`
60    ///  The index of the currently selected menu item, or -1 if no
61    /// menu item is selected.
62    ///
63    /// Readable | Writeable
64    ///
65    ///
66    /// #### `anchor-hints`
67    ///  Positioning hints for aligning the menu relative to a rectangle.
68    ///
69    /// These hints determine how the menu should be positioned in the case that
70    /// the menu would fall off-screen if placed in its ideal position.
71    ///
72    /// ![](popup-flip.png)
73    ///
74    /// For example, [`gdk::AnchorHints::FLIP_Y`][crate::gdk::AnchorHints::FLIP_Y] will replace [`gdk::Gravity::NorthWest`][crate::gdk::Gravity::NorthWest] with
75    /// [`gdk::Gravity::SouthWest`][crate::gdk::Gravity::SouthWest] and vice versa if the menu extends beyond the
76    /// bottom edge of the monitor.
77    ///
78    /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
79    /// gtk_menu_popup_at_pointer (), [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx],
80    /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
81    ///
82    /// Readable | Writeable | Construct
83    ///
84    ///
85    /// #### `attach-widget`
86    ///  The widget the menu is attached to. Setting this property attaches
87    /// the menu without a `GtkMenuDetachFunc`. If you need to use a detacher,
88    /// use `gtk_menu_attach_to_widget()` directly.
89    ///
90    /// Readable | Writeable
91    ///
92    ///
93    /// #### `menu-type-hint`
94    ///  The [`gdk::WindowTypeHint`][crate::gdk::WindowTypeHint] to use for the menu's [`gdk::Window`][crate::gdk::Window].
95    ///
96    /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
97    /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
98    /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], and [`popped-up`][struct@crate::Menu#popped-up].
99    ///
100    /// Readable | Writeable | Construct
101    ///
102    ///
103    /// #### `monitor`
104    ///  The monitor the menu will be popped up on.
105    ///
106    /// Readable | Writeable
107    ///
108    ///
109    /// #### `rect-anchor-dx`
110    ///  Horizontal offset to apply to the menu, i.e. the rectangle or widget
111    /// anchor.
112    ///
113    /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
114    /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
115    /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
116    ///
117    /// Readable | Writeable | Construct
118    ///
119    ///
120    /// #### `rect-anchor-dy`
121    ///  Vertical offset to apply to the menu, i.e. the rectangle or widget anchor.
122    ///
123    /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
124    /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
125    /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
126    ///
127    /// Readable | Writeable | Construct
128    ///
129    ///
130    /// #### `reserve-toggle-size`
131    ///  A boolean that indicates whether the menu reserves space for
132    /// toggles and icons, regardless of their actual presence.
133    ///
134    /// This property should only be changed from its default value
135    /// for special-purposes such as tabular menus. Regular menus that
136    /// are connected to a menu bar or context menus should reserve
137    /// toggle space for consistency.
138    ///
139    /// Readable | Writeable
140    ///
141    ///
142    /// #### `tearoff-state`
143    ///  A boolean that indicates whether the menu is torn-off.
144    ///
145    /// Readable | Writeable
146    ///
147    ///
148    /// #### `tearoff-title`
149    ///  A title that may be displayed by the window manager when this
150    /// menu is torn-off.
151    ///
152    /// Readable | Writeable
153    /// </details>
154    /// <details><summary><h4>MenuShell</h4></summary>
155    ///
156    ///
157    /// #### `take-focus`
158    ///  A boolean that determines whether the menu and its submenus grab the
159    /// keyboard focus. See [`MenuShellExt::set_take_focus()`][crate::prelude::MenuShellExt::set_take_focus()] and
160    /// [`MenuShellExt::takes_focus()`][crate::prelude::MenuShellExt::takes_focus()].
161    ///
162    /// Readable | Writeable
163    /// </details>
164    /// <details><summary><h4>Container</h4></summary>
165    ///
166    ///
167    /// #### `border-width`
168    ///  Readable | Writeable
169    ///
170    ///
171    /// #### `child`
172    ///  Writeable
173    ///
174    ///
175    /// #### `resize-mode`
176    ///  Readable | Writeable
177    /// </details>
178    /// <details><summary><h4>Widget</h4></summary>
179    ///
180    ///
181    /// #### `app-paintable`
182    ///  Readable | Writeable
183    ///
184    ///
185    /// #### `can-default`
186    ///  Readable | Writeable
187    ///
188    ///
189    /// #### `can-focus`
190    ///  Readable | Writeable
191    ///
192    ///
193    /// #### `composite-child`
194    ///  Readable
195    ///
196    ///
197    /// #### `double-buffered`
198    ///  Whether the widget is double buffered.
199    ///
200    /// Readable | Writeable
201    ///
202    ///
203    /// #### `events`
204    ///  Readable | Writeable
205    ///
206    ///
207    /// #### `expand`
208    ///  Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
209    ///
210    /// Readable | Writeable
211    ///
212    ///
213    /// #### `focus-on-click`
214    ///  Whether the widget should grab focus when it is clicked with the mouse.
215    ///
216    /// This property is only relevant for widgets that can take focus.
217    ///
218    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
219    /// GtkComboBox) implemented this property individually.
220    ///
221    /// Readable | Writeable
222    ///
223    ///
224    /// #### `halign`
225    ///  How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
226    ///
227    /// Readable | Writeable
228    ///
229    ///
230    /// #### `has-default`
231    ///  Readable | Writeable
232    ///
233    ///
234    /// #### `has-focus`
235    ///  Readable | Writeable
236    ///
237    ///
238    /// #### `has-tooltip`
239    ///  Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
240    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
241    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
242    /// whether it will provide a tooltip or not.
243    ///
244    /// Note that setting this property to [`true`] for the first time will change
245    /// the event masks of the GdkWindows of this widget to include leave-notify
246    /// and motion-notify events. This cannot and will not be undone when the
247    /// property is set to [`false`] again.
248    ///
249    /// Readable | Writeable
250    ///
251    ///
252    /// #### `height-request`
253    ///  Readable | Writeable
254    ///
255    ///
256    /// #### `hexpand`
257    ///  Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
258    ///
259    /// Readable | Writeable
260    ///
261    ///
262    /// #### `hexpand-set`
263    ///  Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
264    ///
265    /// Readable | Writeable
266    ///
267    ///
268    /// #### `is-focus`
269    ///  Readable | Writeable
270    ///
271    ///
272    /// #### `margin`
273    ///  Sets all four sides' margin at once. If read, returns max
274    /// margin on any side.
275    ///
276    /// Readable | Writeable
277    ///
278    ///
279    /// #### `margin-bottom`
280    ///  Margin on bottom side of widget.
281    ///
282    /// This property adds margin outside of the widget's normal size
283    /// request, the margin will be added in addition to the size from
284    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
285    ///
286    /// Readable | Writeable
287    ///
288    ///
289    /// #### `margin-end`
290    ///  Margin on end of widget, horizontally. This property supports
291    /// left-to-right and right-to-left text directions.
292    ///
293    /// This property adds margin outside of the widget's normal size
294    /// request, the margin will be added in addition to the size from
295    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
296    ///
297    /// Readable | Writeable
298    ///
299    ///
300    /// #### `margin-left`
301    ///  Margin on left side of widget.
302    ///
303    /// This property adds margin outside of the widget's normal size
304    /// request, the margin will be added in addition to the size from
305    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
306    ///
307    /// Readable | Writeable
308    ///
309    ///
310    /// #### `margin-right`
311    ///  Margin on right side of widget.
312    ///
313    /// This property adds margin outside of the widget's normal size
314    /// request, the margin will be added in addition to the size from
315    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
316    ///
317    /// Readable | Writeable
318    ///
319    ///
320    /// #### `margin-start`
321    ///  Margin on start of widget, horizontally. This property supports
322    /// left-to-right and right-to-left text directions.
323    ///
324    /// This property adds margin outside of the widget's normal size
325    /// request, the margin will be added in addition to the size from
326    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
327    ///
328    /// Readable | Writeable
329    ///
330    ///
331    /// #### `margin-top`
332    ///  Margin on top side of widget.
333    ///
334    /// This property adds margin outside of the widget's normal size
335    /// request, the margin will be added in addition to the size from
336    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
337    ///
338    /// Readable | Writeable
339    ///
340    ///
341    /// #### `name`
342    ///  Readable | Writeable
343    ///
344    ///
345    /// #### `no-show-all`
346    ///  Readable | Writeable
347    ///
348    ///
349    /// #### `opacity`
350    ///  The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
351    /// more details about window opacity.
352    ///
353    /// Before 3.8 this was only available in GtkWindow
354    ///
355    /// Readable | Writeable
356    ///
357    ///
358    /// #### `parent`
359    ///  Readable | Writeable
360    ///
361    ///
362    /// #### `receives-default`
363    ///  Readable | Writeable
364    ///
365    ///
366    /// #### `scale-factor`
367    ///  The scale factor of the widget. See [`WidgetExt::scale_factor()`][crate::prelude::WidgetExt::scale_factor()] for
368    /// more details about widget scaling.
369    ///
370    /// Readable
371    ///
372    ///
373    /// #### `sensitive`
374    ///  Readable | Writeable
375    ///
376    ///
377    /// #### `style`
378    ///  The style of the widget, which contains information about how it will look (colors, etc).
379    ///
380    /// Readable | Writeable
381    ///
382    ///
383    /// #### `tooltip-markup`
384    ///  Sets the text of tooltip to be the given string, which is marked up
385    /// with the [Pango text markup language][PangoMarkupFormat].
386    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
387    ///
388    /// This is a convenience property which will take care of getting the
389    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
390    /// will automatically be set to [`true`] and there will be taken care of
391    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
392    ///
393    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
394    /// are set, the last one wins.
395    ///
396    /// Readable | Writeable
397    ///
398    ///
399    /// #### `tooltip-text`
400    ///  Sets the text of tooltip to be the given string.
401    ///
402    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
403    ///
404    /// This is a convenience property which will take care of getting the
405    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
406    /// will automatically be set to [`true`] and there will be taken care of
407    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
408    ///
409    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
410    /// are set, the last one wins.
411    ///
412    /// Readable | Writeable
413    ///
414    ///
415    /// #### `valign`
416    ///  How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
417    ///
418    /// Readable | Writeable
419    ///
420    ///
421    /// #### `vexpand`
422    ///  Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
423    ///
424    /// Readable | Writeable
425    ///
426    ///
427    /// #### `vexpand-set`
428    ///  Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
429    ///
430    /// Readable | Writeable
431    ///
432    ///
433    /// #### `visible`
434    ///  Readable | Writeable
435    ///
436    ///
437    /// #### `width-request`
438    ///  Readable | Writeable
439    ///
440    ///
441    /// #### `window`
442    ///  The widget's window if it is realized, [`None`] otherwise.
443    ///
444    /// Readable
445    /// </details>
446    /// <details><summary><h4>Activatable</h4></summary>
447    ///
448    ///
449    /// #### `related-action`
450    ///  The action that this activatable will activate and receive
451    /// updates from for various states and possibly appearance.
452    ///
453    /// > `GtkActivatable` implementors need to handle the this property and
454    /// > call `gtk_activatable_do_set_related_action()` when it changes.
455    ///
456    /// Readable | Writeable
457    ///
458    ///
459    /// #### `use-action-appearance`
460    ///  Whether this activatable should reset its layout
461    /// and appearance when setting the related action or when
462    /// the action changes appearance.
463    ///
464    /// See the `GtkAction` documentation directly to find which properties
465    /// should be ignored by the `GtkActivatable` when this property is [`false`].
466    ///
467    /// > `GtkActivatable` implementors need to handle this property
468    /// > and call `gtk_activatable_sync_action_properties()` on the activatable
469    /// > widget when it changes.
470    ///
471    /// Readable | Writeable
472    /// </details>
473    /// <details><summary><h4>RecentChooser</h4></summary>
474    ///
475    ///
476    /// #### `filter`
477    ///  The [`RecentFilter`][crate::RecentFilter] object to be used when displaying
478    /// the recently used resources.
479    ///
480    /// Readable | Writeable
481    ///
482    ///
483    /// #### `limit`
484    ///  The maximum number of recently used resources to be displayed,
485    /// or -1 to display all items.
486    ///
487    /// Readable | Writeable
488    ///
489    ///
490    /// #### `local-only`
491    ///  Whether this [`RecentChooser`][crate::RecentChooser] should display only local (file:)
492    /// resources.
493    ///
494    /// Readable | Writeable
495    ///
496    ///
497    /// #### `recent-manager`
498    ///  The [`RecentManager`][crate::RecentManager] instance used by the [`RecentChooser`][crate::RecentChooser] to
499    /// display the list of recently used resources.
500    ///
501    /// Writeable | Construct Only
502    ///
503    ///
504    /// #### `select-multiple`
505    ///  Allow the user to select multiple resources.
506    ///
507    /// Readable | Writeable
508    ///
509    ///
510    /// #### `show-icons`
511    ///  Whether this [`RecentChooser`][crate::RecentChooser] should display an icon near the item.
512    ///
513    /// Readable | Writeable
514    ///
515    ///
516    /// #### `show-not-found`
517    ///  Whether this [`RecentChooser`][crate::RecentChooser] should display the recently used resources
518    /// even if not present anymore. Setting this to [`false`] will perform a
519    /// potentially expensive check on every local resource (every remote
520    /// resource will always be displayed).
521    ///
522    /// Readable | Writeable
523    ///
524    ///
525    /// #### `show-private`
526    ///  Readable | Writeable
527    ///
528    ///
529    /// #### `show-tips`
530    ///  Whether this [`RecentChooser`][crate::RecentChooser] should display a tooltip containing the
531    /// full path of the recently used resources.
532    ///
533    /// Readable | Writeable
534    ///
535    ///
536    /// #### `sort-type`
537    ///  Sorting order to be used when displaying the recently used resources.
538    ///
539    /// Readable | Writeable
540    /// </details>
541    ///
542    /// # Implements
543    ///
544    /// [`RecentChooserMenuExt`][trait@crate::prelude::RecentChooserMenuExt], [`GtkMenuExt`][trait@crate::prelude::GtkMenuExt], [`MenuShellExt`][trait@crate::prelude::MenuShellExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`RecentChooserExt`][trait@crate::prelude::RecentChooserExt], [`GtkMenuExtManual`][trait@crate::prelude::GtkMenuExtManual], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
545    #[doc(alias = "GtkRecentChooserMenu")]
546    pub struct RecentChooserMenu(Object<ffi::GtkRecentChooserMenu, ffi::GtkRecentChooserMenuClass>) @extends Menu, MenuShell, Container, Widget, @implements Buildable, RecentChooser;
547
548    match fn {
549        type_ => || ffi::gtk_recent_chooser_menu_get_type(),
550    }
551}
552
553impl RecentChooserMenu {
554    pub const NONE: Option<&'static RecentChooserMenu> = None;
555
556    /// Creates a new [`RecentChooserMenu`][crate::RecentChooserMenu] widget.
557    ///
558    /// This kind of widget shows the list of recently used resources as
559    /// a menu, each item as a menu item. Each item inside the menu might
560    /// have an icon, representing its MIME type, and a number, for mnemonic
561    /// access.
562    ///
563    /// This widget implements the [`RecentChooser`][crate::RecentChooser] interface.
564    ///
565    /// This widget creates its own [`RecentManager`][crate::RecentManager] object. See the
566    /// [`for_manager()`][Self::for_manager()] function to know how to create
567    /// a [`RecentChooserMenu`][crate::RecentChooserMenu] widget bound to another [`RecentManager`][crate::RecentManager] object.
568    ///
569    /// # Returns
570    ///
571    /// a new [`RecentChooserMenu`][crate::RecentChooserMenu]
572    #[doc(alias = "gtk_recent_chooser_menu_new")]
573    pub fn new() -> RecentChooserMenu {
574        assert_initialized_main_thread!();
575        unsafe { Widget::from_glib_none(ffi::gtk_recent_chooser_menu_new()).unsafe_cast() }
576    }
577
578    /// Creates a new [`RecentChooserMenu`][crate::RecentChooserMenu] widget using `manager` as
579    /// the underlying recently used resources manager.
580    ///
581    /// This is useful if you have implemented your own recent manager,
582    /// or if you have a customized instance of a [`RecentManager`][crate::RecentManager]
583    /// object or if you wish to share a common [`RecentManager`][crate::RecentManager] object
584    /// among multiple [`RecentChooser`][crate::RecentChooser] widgets.
585    /// ## `manager`
586    /// a [`RecentManager`][crate::RecentManager]
587    ///
588    /// # Returns
589    ///
590    /// a new [`RecentChooserMenu`][crate::RecentChooserMenu], bound to `manager`.
591    #[doc(alias = "gtk_recent_chooser_menu_new_for_manager")]
592    #[doc(alias = "new_for_manager")]
593    pub fn for_manager(manager: &impl IsA<RecentManager>) -> RecentChooserMenu {
594        skip_assert_initialized!();
595        unsafe {
596            Widget::from_glib_none(ffi::gtk_recent_chooser_menu_new_for_manager(
597                manager.as_ref().to_glib_none().0,
598            ))
599            .unsafe_cast()
600        }
601    }
602
603    // rustdoc-stripper-ignore-next
604    /// Creates a new builder-pattern struct instance to construct [`RecentChooserMenu`] objects.
605    ///
606    /// This method returns an instance of [`RecentChooserMenuBuilder`](crate::builders::RecentChooserMenuBuilder) which can be used to create [`RecentChooserMenu`] objects.
607    pub fn builder() -> RecentChooserMenuBuilder {
608        RecentChooserMenuBuilder::new()
609    }
610}
611
612impl Default for RecentChooserMenu {
613    fn default() -> Self {
614        Self::new()
615    }
616}
617
618// rustdoc-stripper-ignore-next
619/// A [builder-pattern] type to construct [`RecentChooserMenu`] objects.
620///
621/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
622#[must_use = "The builder must be built to be used"]
623pub struct RecentChooserMenuBuilder {
624    builder: glib::object::ObjectBuilder<'static, RecentChooserMenu>,
625}
626
627impl RecentChooserMenuBuilder {
628    fn new() -> Self {
629        Self {
630            builder: glib::object::Object::builder(),
631        }
632    }
633
634    /// Whether the first ten items in the menu should be prepended by
635    /// a number acting as a unique mnemonic.
636    pub fn show_numbers(self, show_numbers: bool) -> Self {
637        Self {
638            builder: self.builder.property("show-numbers", show_numbers),
639        }
640    }
641
642    /// The accel group holding accelerators for the menu.
643    pub fn accel_group(self, accel_group: &impl IsA<AccelGroup>) -> Self {
644        Self {
645            builder: self
646                .builder
647                .property("accel-group", accel_group.clone().upcast()),
648        }
649    }
650
651    /// An accel path used to conveniently construct accel paths of child items.
652    pub fn accel_path(self, accel_path: impl Into<glib::GString>) -> Self {
653        Self {
654            builder: self.builder.property("accel-path", accel_path.into()),
655        }
656    }
657
658    /// The index of the currently selected menu item, or -1 if no
659    /// menu item is selected.
660    pub fn active(self, active: i32) -> Self {
661        Self {
662            builder: self.builder.property("active", active),
663        }
664    }
665
666    /// Positioning hints for aligning the menu relative to a rectangle.
667    ///
668    /// These hints determine how the menu should be positioned in the case that
669    /// the menu would fall off-screen if placed in its ideal position.
670    ///
671    /// ![](popup-flip.png)
672    ///
673    /// For example, [`gdk::AnchorHints::FLIP_Y`][crate::gdk::AnchorHints::FLIP_Y] will replace [`gdk::Gravity::NorthWest`][crate::gdk::Gravity::NorthWest] with
674    /// [`gdk::Gravity::SouthWest`][crate::gdk::Gravity::SouthWest] and vice versa if the menu extends beyond the
675    /// bottom edge of the monitor.
676    ///
677    /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
678    /// gtk_menu_popup_at_pointer (), [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx],
679    /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
680    pub fn anchor_hints(self, anchor_hints: gdk::AnchorHints) -> Self {
681        Self {
682            builder: self.builder.property("anchor-hints", anchor_hints),
683        }
684    }
685
686    /// The widget the menu is attached to. Setting this property attaches
687    /// the menu without a `GtkMenuDetachFunc`. If you need to use a detacher,
688    /// use `gtk_menu_attach_to_widget()` directly.
689    pub fn attach_widget(self, attach_widget: &impl IsA<Widget>) -> Self {
690        Self {
691            builder: self
692                .builder
693                .property("attach-widget", attach_widget.clone().upcast()),
694        }
695    }
696
697    /// The [`gdk::WindowTypeHint`][crate::gdk::WindowTypeHint] to use for the menu's [`gdk::Window`][crate::gdk::Window].
698    ///
699    /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
700    /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
701    /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], and [`popped-up`][struct@crate::Menu#popped-up].
702    pub fn menu_type_hint(self, menu_type_hint: gdk::WindowTypeHint) -> Self {
703        Self {
704            builder: self.builder.property("menu-type-hint", menu_type_hint),
705        }
706    }
707
708    /// The monitor the menu will be popped up on.
709    pub fn monitor(self, monitor: i32) -> Self {
710        Self {
711            builder: self.builder.property("monitor", monitor),
712        }
713    }
714
715    /// Horizontal offset to apply to the menu, i.e. the rectangle or widget
716    /// anchor.
717    ///
718    /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
719    /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
720    /// [`rect-anchor-dy`][struct@crate::Menu#rect-anchor-dy], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
721    pub fn rect_anchor_dx(self, rect_anchor_dx: i32) -> Self {
722        Self {
723            builder: self.builder.property("rect-anchor-dx", rect_anchor_dx),
724        }
725    }
726
727    /// Vertical offset to apply to the menu, i.e. the rectangle or widget anchor.
728    ///
729    /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
730    /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
731    /// [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx], [`menu-type-hint`][struct@crate::Menu#menu-type-hint], and [`popped-up`][struct@crate::Menu#popped-up].
732    pub fn rect_anchor_dy(self, rect_anchor_dy: i32) -> Self {
733        Self {
734            builder: self.builder.property("rect-anchor-dy", rect_anchor_dy),
735        }
736    }
737
738    /// A boolean that indicates whether the menu reserves space for
739    /// toggles and icons, regardless of their actual presence.
740    ///
741    /// This property should only be changed from its default value
742    /// for special-purposes such as tabular menus. Regular menus that
743    /// are connected to a menu bar or context menus should reserve
744    /// toggle space for consistency.
745    pub fn reserve_toggle_size(self, reserve_toggle_size: bool) -> Self {
746        Self {
747            builder: self
748                .builder
749                .property("reserve-toggle-size", reserve_toggle_size),
750        }
751    }
752
753    /// A boolean that determines whether the menu and its submenus grab the
754    /// keyboard focus. See [`MenuShellExt::set_take_focus()`][crate::prelude::MenuShellExt::set_take_focus()] and
755    /// [`MenuShellExt::takes_focus()`][crate::prelude::MenuShellExt::takes_focus()].
756    pub fn take_focus(self, take_focus: bool) -> Self {
757        Self {
758            builder: self.builder.property("take-focus", take_focus),
759        }
760    }
761
762    pub fn border_width(self, border_width: u32) -> Self {
763        Self {
764            builder: self.builder.property("border-width", border_width),
765        }
766    }
767
768    pub fn child(self, child: &impl IsA<Widget>) -> Self {
769        Self {
770            builder: self.builder.property("child", child.clone().upcast()),
771        }
772    }
773
774    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
775        Self {
776            builder: self.builder.property("resize-mode", resize_mode),
777        }
778    }
779
780    pub fn app_paintable(self, app_paintable: bool) -> Self {
781        Self {
782            builder: self.builder.property("app-paintable", app_paintable),
783        }
784    }
785
786    pub fn can_default(self, can_default: bool) -> Self {
787        Self {
788            builder: self.builder.property("can-default", can_default),
789        }
790    }
791
792    pub fn can_focus(self, can_focus: bool) -> Self {
793        Self {
794            builder: self.builder.property("can-focus", can_focus),
795        }
796    }
797
798    pub fn events(self, events: gdk::EventMask) -> Self {
799        Self {
800            builder: self.builder.property("events", events),
801        }
802    }
803
804    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
805    pub fn expand(self, expand: bool) -> Self {
806        Self {
807            builder: self.builder.property("expand", expand),
808        }
809    }
810
811    /// Whether the widget should grab focus when it is clicked with the mouse.
812    ///
813    /// This property is only relevant for widgets that can take focus.
814    ///
815    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
816    /// GtkComboBox) implemented this property individually.
817    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
818        Self {
819            builder: self.builder.property("focus-on-click", focus_on_click),
820        }
821    }
822
823    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
824    pub fn halign(self, halign: Align) -> Self {
825        Self {
826            builder: self.builder.property("halign", halign),
827        }
828    }
829
830    pub fn has_default(self, has_default: bool) -> Self {
831        Self {
832            builder: self.builder.property("has-default", has_default),
833        }
834    }
835
836    pub fn has_focus(self, has_focus: bool) -> Self {
837        Self {
838            builder: self.builder.property("has-focus", has_focus),
839        }
840    }
841
842    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
843    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
844    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
845    /// whether it will provide a tooltip or not.
846    ///
847    /// Note that setting this property to [`true`] for the first time will change
848    /// the event masks of the GdkWindows of this widget to include leave-notify
849    /// and motion-notify events. This cannot and will not be undone when the
850    /// property is set to [`false`] again.
851    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
852        Self {
853            builder: self.builder.property("has-tooltip", has_tooltip),
854        }
855    }
856
857    pub fn height_request(self, height_request: i32) -> Self {
858        Self {
859            builder: self.builder.property("height-request", height_request),
860        }
861    }
862
863    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
864    pub fn hexpand(self, hexpand: bool) -> Self {
865        Self {
866            builder: self.builder.property("hexpand", hexpand),
867        }
868    }
869
870    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
871    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
872        Self {
873            builder: self.builder.property("hexpand-set", hexpand_set),
874        }
875    }
876
877    pub fn is_focus(self, is_focus: bool) -> Self {
878        Self {
879            builder: self.builder.property("is-focus", is_focus),
880        }
881    }
882
883    /// Sets all four sides' margin at once. If read, returns max
884    /// margin on any side.
885    pub fn margin(self, margin: i32) -> Self {
886        Self {
887            builder: self.builder.property("margin", margin),
888        }
889    }
890
891    /// Margin on bottom side of widget.
892    ///
893    /// This property adds margin outside of the widget's normal size
894    /// request, the margin will be added in addition to the size from
895    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
896    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
897        Self {
898            builder: self.builder.property("margin-bottom", margin_bottom),
899        }
900    }
901
902    /// Margin on end of widget, horizontally. This property supports
903    /// left-to-right and right-to-left text directions.
904    ///
905    /// This property adds margin outside of the widget's normal size
906    /// request, the margin will be added in addition to the size from
907    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
908    pub fn margin_end(self, margin_end: i32) -> Self {
909        Self {
910            builder: self.builder.property("margin-end", margin_end),
911        }
912    }
913
914    /// Margin on start of widget, horizontally. This property supports
915    /// left-to-right and right-to-left text directions.
916    ///
917    /// This property adds margin outside of the widget's normal size
918    /// request, the margin will be added in addition to the size from
919    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
920    pub fn margin_start(self, margin_start: i32) -> Self {
921        Self {
922            builder: self.builder.property("margin-start", margin_start),
923        }
924    }
925
926    /// Margin on top side of widget.
927    ///
928    /// This property adds margin outside of the widget's normal size
929    /// request, the margin will be added in addition to the size from
930    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
931    pub fn margin_top(self, margin_top: i32) -> Self {
932        Self {
933            builder: self.builder.property("margin-top", margin_top),
934        }
935    }
936
937    pub fn name(self, name: impl Into<glib::GString>) -> Self {
938        Self {
939            builder: self.builder.property("name", name.into()),
940        }
941    }
942
943    pub fn no_show_all(self, no_show_all: bool) -> Self {
944        Self {
945            builder: self.builder.property("no-show-all", no_show_all),
946        }
947    }
948
949    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
950    /// more details about window opacity.
951    ///
952    /// Before 3.8 this was only available in GtkWindow
953    pub fn opacity(self, opacity: f64) -> Self {
954        Self {
955            builder: self.builder.property("opacity", opacity),
956        }
957    }
958
959    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
960        Self {
961            builder: self.builder.property("parent", parent.clone().upcast()),
962        }
963    }
964
965    pub fn receives_default(self, receives_default: bool) -> Self {
966        Self {
967            builder: self.builder.property("receives-default", receives_default),
968        }
969    }
970
971    pub fn sensitive(self, sensitive: bool) -> Self {
972        Self {
973            builder: self.builder.property("sensitive", sensitive),
974        }
975    }
976
977    /// Sets the text of tooltip to be the given string, which is marked up
978    /// with the [Pango text markup language][PangoMarkupFormat].
979    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
980    ///
981    /// This is a convenience property which will take care of getting the
982    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
983    /// will automatically be set to [`true`] and there will be taken care of
984    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
985    ///
986    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
987    /// are set, the last one wins.
988    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
989        Self {
990            builder: self
991                .builder
992                .property("tooltip-markup", tooltip_markup.into()),
993        }
994    }
995
996    /// Sets the text of tooltip to be the given string.
997    ///
998    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
999    ///
1000    /// This is a convenience property which will take care of getting the
1001    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
1002    /// will automatically be set to [`true`] and there will be taken care of
1003    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
1004    ///
1005    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
1006    /// are set, the last one wins.
1007    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
1008        Self {
1009            builder: self.builder.property("tooltip-text", tooltip_text.into()),
1010        }
1011    }
1012
1013    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1014    pub fn valign(self, valign: Align) -> Self {
1015        Self {
1016            builder: self.builder.property("valign", valign),
1017        }
1018    }
1019
1020    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1021    pub fn vexpand(self, vexpand: bool) -> Self {
1022        Self {
1023            builder: self.builder.property("vexpand", vexpand),
1024        }
1025    }
1026
1027    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1028    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1029        Self {
1030            builder: self.builder.property("vexpand-set", vexpand_set),
1031        }
1032    }
1033
1034    pub fn visible(self, visible: bool) -> Self {
1035        Self {
1036            builder: self.builder.property("visible", visible),
1037        }
1038    }
1039
1040    pub fn width_request(self, width_request: i32) -> Self {
1041        Self {
1042            builder: self.builder.property("width-request", width_request),
1043        }
1044    }
1045
1046    /// The [`RecentFilter`][crate::RecentFilter] object to be used when displaying
1047    /// the recently used resources.
1048    pub fn filter(self, filter: &RecentFilter) -> Self {
1049        Self {
1050            builder: self.builder.property("filter", filter.clone()),
1051        }
1052    }
1053
1054    /// The maximum number of recently used resources to be displayed,
1055    /// or -1 to display all items.
1056    pub fn limit(self, limit: i32) -> Self {
1057        Self {
1058            builder: self.builder.property("limit", limit),
1059        }
1060    }
1061
1062    /// Whether this [`RecentChooser`][crate::RecentChooser] should display only local (file:)
1063    /// resources.
1064    pub fn local_only(self, local_only: bool) -> Self {
1065        Self {
1066            builder: self.builder.property("local-only", local_only),
1067        }
1068    }
1069
1070    /// The [`RecentManager`][crate::RecentManager] instance used by the [`RecentChooser`][crate::RecentChooser] to
1071    /// display the list of recently used resources.
1072    pub fn recent_manager(self, recent_manager: &impl IsA<RecentManager>) -> Self {
1073        Self {
1074            builder: self
1075                .builder
1076                .property("recent-manager", recent_manager.clone().upcast()),
1077        }
1078    }
1079
1080    /// Allow the user to select multiple resources.
1081    pub fn select_multiple(self, select_multiple: bool) -> Self {
1082        Self {
1083            builder: self.builder.property("select-multiple", select_multiple),
1084        }
1085    }
1086
1087    /// Whether this [`RecentChooser`][crate::RecentChooser] should display an icon near the item.
1088    pub fn show_icons(self, show_icons: bool) -> Self {
1089        Self {
1090            builder: self.builder.property("show-icons", show_icons),
1091        }
1092    }
1093
1094    /// Whether this [`RecentChooser`][crate::RecentChooser] should display the recently used resources
1095    /// even if not present anymore. Setting this to [`false`] will perform a
1096    /// potentially expensive check on every local resource (every remote
1097    /// resource will always be displayed).
1098    pub fn show_not_found(self, show_not_found: bool) -> Self {
1099        Self {
1100            builder: self.builder.property("show-not-found", show_not_found),
1101        }
1102    }
1103
1104    pub fn show_private(self, show_private: bool) -> Self {
1105        Self {
1106            builder: self.builder.property("show-private", show_private),
1107        }
1108    }
1109
1110    /// Whether this [`RecentChooser`][crate::RecentChooser] should display a tooltip containing the
1111    /// full path of the recently used resources.
1112    pub fn show_tips(self, show_tips: bool) -> Self {
1113        Self {
1114            builder: self.builder.property("show-tips", show_tips),
1115        }
1116    }
1117
1118    /// Sorting order to be used when displaying the recently used resources.
1119    pub fn sort_type(self, sort_type: RecentSortType) -> Self {
1120        Self {
1121            builder: self.builder.property("sort-type", sort_type),
1122        }
1123    }
1124
1125    // rustdoc-stripper-ignore-next
1126    /// Build the [`RecentChooserMenu`].
1127    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1128    pub fn build(self) -> RecentChooserMenu {
1129        self.builder.build()
1130    }
1131}
1132
1133mod sealed {
1134    pub trait Sealed {}
1135    impl<T: super::IsA<super::RecentChooserMenu>> Sealed for T {}
1136}
1137
1138/// Trait containing all [`struct@RecentChooserMenu`] methods.
1139///
1140/// # Implementors
1141///
1142/// [`RecentChooserMenu`][struct@crate::RecentChooserMenu]
1143pub trait RecentChooserMenuExt: IsA<RecentChooserMenu> + sealed::Sealed + 'static {
1144    /// Returns the value set by [`set_show_numbers()`][Self::set_show_numbers()].
1145    ///
1146    /// # Returns
1147    ///
1148    /// [`true`] if numbers should be shown.
1149    #[doc(alias = "gtk_recent_chooser_menu_get_show_numbers")]
1150    #[doc(alias = "get_show_numbers")]
1151    fn shows_numbers(&self) -> bool {
1152        unsafe {
1153            from_glib(ffi::gtk_recent_chooser_menu_get_show_numbers(
1154                self.as_ref().to_glib_none().0,
1155            ))
1156        }
1157    }
1158
1159    /// Sets whether a number should be added to the items of `self`. The
1160    /// numbers are shown to provide a unique character for a mnemonic to
1161    /// be used inside ten menu item’s label. Only the first the items
1162    /// get a number to avoid clashes.
1163    /// ## `show_numbers`
1164    /// whether to show numbers
1165    #[doc(alias = "gtk_recent_chooser_menu_set_show_numbers")]
1166    fn set_show_numbers(&self, show_numbers: bool) {
1167        unsafe {
1168            ffi::gtk_recent_chooser_menu_set_show_numbers(
1169                self.as_ref().to_glib_none().0,
1170                show_numbers.into_glib(),
1171            );
1172        }
1173    }
1174
1175    #[doc(alias = "show-numbers")]
1176    fn connect_show_numbers_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1177        unsafe extern "C" fn notify_show_numbers_trampoline<
1178            P: IsA<RecentChooserMenu>,
1179            F: Fn(&P) + 'static,
1180        >(
1181            this: *mut ffi::GtkRecentChooserMenu,
1182            _param_spec: glib::ffi::gpointer,
1183            f: glib::ffi::gpointer,
1184        ) {
1185            let f: &F = &*(f as *const F);
1186            f(RecentChooserMenu::from_glib_borrow(this).unsafe_cast_ref())
1187        }
1188        unsafe {
1189            let f: Box_<F> = Box_::new(f);
1190            connect_raw(
1191                self.as_ptr() as *mut _,
1192                b"notify::show-numbers\0".as_ptr() as *const _,
1193                Some(transmute::<_, unsafe extern "C" fn()>(
1194                    notify_show_numbers_trampoline::<Self, F> as *const (),
1195                )),
1196                Box_::into_raw(f),
1197            )
1198        }
1199    }
1200}
1201
1202impl<O: IsA<RecentChooserMenu>> RecentChooserMenuExt for O {}
1203
1204impl fmt::Display for RecentChooserMenu {
1205    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1206        f.write_str("RecentChooserMenu")
1207    }
1208}