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, ffi,
8};
9use glib::{
10 prelude::*,
11 signal::{SignalHandlerId, connect_raw},
12 translate::*,
13};
14use std::boxed::Box as Box_;
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 | Writable
44 /// <details><summary><h4>Menu</h4></summary>
45 ///
46 ///
47 /// #### `accel-group`
48 /// The accel group holding accelerators for the menu.
49 ///
50 /// Readable | Writable
51 ///
52 ///
53 /// #### `accel-path`
54 /// An accel path used to conveniently construct accel paths of child items.
55 ///
56 /// Readable | Writable
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 | Writable
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 /// 
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 | Writable | 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 | Writable
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 | Writable | Construct
101 ///
102 ///
103 /// #### `monitor`
104 /// The monitor the menu will be popped up on.
105 ///
106 /// Readable | Writable
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 | Writable | 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 | Writable | 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 | Writable
140 ///
141 ///
142 /// #### `tearoff-state`
143 /// A boolean that indicates whether the menu is torn-off.
144 ///
145 /// Readable | Writable
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 | Writable
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 | Writable
163 /// </details>
164 /// <details><summary><h4>Container</h4></summary>
165 ///
166 ///
167 /// #### `border-width`
168 /// Readable | Writable
169 ///
170 ///
171 /// #### `child`
172 /// Writable
173 ///
174 ///
175 /// #### `resize-mode`
176 /// Readable | Writable
177 /// </details>
178 /// <details><summary><h4>Widget</h4></summary>
179 ///
180 ///
181 /// #### `app-paintable`
182 /// Readable | Writable
183 ///
184 ///
185 /// #### `can-default`
186 /// Readable | Writable
187 ///
188 ///
189 /// #### `can-focus`
190 /// Readable | Writable
191 ///
192 ///
193 /// #### `composite-child`
194 /// Readable
195 ///
196 ///
197 /// #### `double-buffered`
198 /// Whether the widget is double buffered.
199 ///
200 /// Readable | Writable
201 ///
202 ///
203 /// #### `events`
204 /// Readable | Writable
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 | Writable
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 | Writable
222 ///
223 ///
224 /// #### `halign`
225 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
226 ///
227 /// Readable | Writable
228 ///
229 ///
230 /// #### `has-default`
231 /// Readable | Writable
232 ///
233 ///
234 /// #### `has-focus`
235 /// Readable | Writable
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 | Writable
250 ///
251 ///
252 /// #### `height-request`
253 /// Readable | Writable
254 ///
255 ///
256 /// #### `hexpand`
257 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
258 ///
259 /// Readable | Writable
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 | Writable
266 ///
267 ///
268 /// #### `is-focus`
269 /// Readable | Writable
270 ///
271 ///
272 /// #### `margin`
273 /// Sets all four sides' margin at once. If read, returns max
274 /// margin on any side.
275 ///
276 /// Readable | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
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 | Writable
339 ///
340 ///
341 /// #### `name`
342 /// Readable | Writable
343 ///
344 ///
345 /// #### `no-show-all`
346 /// Readable | Writable
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 | Writable
356 ///
357 ///
358 /// #### `parent`
359 /// Readable | Writable
360 ///
361 ///
362 /// #### `receives-default`
363 /// Readable | Writable
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 | Writable
375 ///
376 ///
377 /// #### `style`
378 /// The style of the widget, which contains information about how it will look (colors, etc).
379 ///
380 /// Readable | Writable
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 | Writable
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 | Writable
413 ///
414 ///
415 /// #### `valign`
416 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
417 ///
418 /// Readable | Writable
419 ///
420 ///
421 /// #### `vexpand`
422 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
423 ///
424 /// Readable | Writable
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 | Writable
431 ///
432 ///
433 /// #### `visible`
434 /// Readable | Writable
435 ///
436 ///
437 /// #### `width-request`
438 /// Readable | Writable
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 /// call `gtk_activatable_do_set_related_action()` when it changes.
451 ///
452 /// Readable | Writable
453 ///
454 ///
455 /// #### `use-action-appearance`
456 /// widget when it changes.
457 ///
458 /// Readable | Writable
459 /// </details>
460 /// <details><summary><h4>RecentChooser</h4></summary>
461 ///
462 ///
463 /// #### `filter`
464 /// The [`RecentFilter`][crate::RecentFilter] object to be used when displaying
465 /// the recently used resources.
466 ///
467 /// Readable | Writable
468 ///
469 ///
470 /// #### `limit`
471 /// The maximum number of recently used resources to be displayed,
472 /// or -1 to display all items.
473 ///
474 /// Readable | Writable
475 ///
476 ///
477 /// #### `local-only`
478 /// Whether this [`RecentChooser`][crate::RecentChooser] should display only local (file:)
479 /// resources.
480 ///
481 /// Readable | Writable
482 ///
483 ///
484 /// #### `recent-manager`
485 /// The [`RecentManager`][crate::RecentManager] instance used by the [`RecentChooser`][crate::RecentChooser] to
486 /// display the list of recently used resources.
487 ///
488 /// Writable | Construct Only
489 ///
490 ///
491 /// #### `select-multiple`
492 /// Allow the user to select multiple resources.
493 ///
494 /// Readable | Writable
495 ///
496 ///
497 /// #### `show-icons`
498 /// Whether this [`RecentChooser`][crate::RecentChooser] should display an icon near the item.
499 ///
500 /// Readable | Writable
501 ///
502 ///
503 /// #### `show-not-found`
504 /// Whether this [`RecentChooser`][crate::RecentChooser] should display the recently used resources
505 /// even if not present anymore. Setting this to [`false`] will perform a
506 /// potentially expensive check on every local resource (every remote
507 /// resource will always be displayed).
508 ///
509 /// Readable | Writable
510 ///
511 ///
512 /// #### `show-private`
513 /// Readable | Writable
514 ///
515 ///
516 /// #### `show-tips`
517 /// Whether this [`RecentChooser`][crate::RecentChooser] should display a tooltip containing the
518 /// full path of the recently used resources.
519 ///
520 /// Readable | Writable
521 ///
522 ///
523 /// #### `sort-type`
524 /// Sorting order to be used when displaying the recently used resources.
525 ///
526 /// Readable | Writable
527 /// </details>
528 ///
529 /// # Implements
530 ///
531 /// [`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]
532 #[doc(alias = "GtkRecentChooserMenu")]
533 pub struct RecentChooserMenu(Object<ffi::GtkRecentChooserMenu, ffi::GtkRecentChooserMenuClass>) @extends Menu, MenuShell, Container, Widget, @implements Buildable, RecentChooser;
534
535 match fn {
536 type_ => || ffi::gtk_recent_chooser_menu_get_type(),
537 }
538}
539
540impl RecentChooserMenu {
541 pub const NONE: Option<&'static RecentChooserMenu> = None;
542
543 /// Creates a new [`RecentChooserMenu`][crate::RecentChooserMenu] widget.
544 ///
545 /// This kind of widget shows the list of recently used resources as
546 /// a menu, each item as a menu item. Each item inside the menu might
547 /// have an icon, representing its MIME type, and a number, for mnemonic
548 /// access.
549 ///
550 /// This widget implements the [`RecentChooser`][crate::RecentChooser] interface.
551 ///
552 /// This widget creates its own [`RecentManager`][crate::RecentManager] object. See the
553 /// [`for_manager()`][Self::for_manager()] function to know how to create
554 /// a [`RecentChooserMenu`][crate::RecentChooserMenu] widget bound to another [`RecentManager`][crate::RecentManager] object.
555 ///
556 /// # Returns
557 ///
558 /// a new [`RecentChooserMenu`][crate::RecentChooserMenu]
559 #[doc(alias = "gtk_recent_chooser_menu_new")]
560 pub fn new() -> RecentChooserMenu {
561 assert_initialized_main_thread!();
562 unsafe { Widget::from_glib_none(ffi::gtk_recent_chooser_menu_new()).unsafe_cast() }
563 }
564
565 /// Creates a new [`RecentChooserMenu`][crate::RecentChooserMenu] widget using `manager` as
566 /// the underlying recently used resources manager.
567 ///
568 /// This is useful if you have implemented your own recent manager,
569 /// or if you have a customized instance of a [`RecentManager`][crate::RecentManager]
570 /// object or if you wish to share a common [`RecentManager`][crate::RecentManager] object
571 /// among multiple [`RecentChooser`][crate::RecentChooser] widgets.
572 /// ## `manager`
573 /// a [`RecentManager`][crate::RecentManager]
574 ///
575 /// # Returns
576 ///
577 /// a new [`RecentChooserMenu`][crate::RecentChooserMenu], bound to `manager`.
578 #[doc(alias = "gtk_recent_chooser_menu_new_for_manager")]
579 #[doc(alias = "new_for_manager")]
580 pub fn for_manager(manager: &impl IsA<RecentManager>) -> RecentChooserMenu {
581 skip_assert_initialized!();
582 unsafe {
583 Widget::from_glib_none(ffi::gtk_recent_chooser_menu_new_for_manager(
584 manager.as_ref().to_glib_none().0,
585 ))
586 .unsafe_cast()
587 }
588 }
589
590 // rustdoc-stripper-ignore-next
591 /// Creates a new builder-pattern struct instance to construct [`RecentChooserMenu`] objects.
592 ///
593 /// This method returns an instance of [`RecentChooserMenuBuilder`](crate::builders::RecentChooserMenuBuilder) which can be used to create [`RecentChooserMenu`] objects.
594 pub fn builder() -> RecentChooserMenuBuilder {
595 RecentChooserMenuBuilder::new()
596 }
597}
598
599impl Default for RecentChooserMenu {
600 fn default() -> Self {
601 Self::new()
602 }
603}
604
605// rustdoc-stripper-ignore-next
606/// A [builder-pattern] type to construct [`RecentChooserMenu`] objects.
607///
608/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
609#[must_use = "The builder must be built to be used"]
610pub struct RecentChooserMenuBuilder {
611 builder: glib::object::ObjectBuilder<'static, RecentChooserMenu>,
612}
613
614impl RecentChooserMenuBuilder {
615 fn new() -> Self {
616 Self {
617 builder: glib::object::Object::builder(),
618 }
619 }
620
621 /// Whether the first ten items in the menu should be prepended by
622 /// a number acting as a unique mnemonic.
623 pub fn show_numbers(self, show_numbers: bool) -> Self {
624 Self {
625 builder: self.builder.property("show-numbers", show_numbers),
626 }
627 }
628
629 /// The accel group holding accelerators for the menu.
630 pub fn accel_group(self, accel_group: &impl IsA<AccelGroup>) -> Self {
631 Self {
632 builder: self
633 .builder
634 .property("accel-group", accel_group.clone().upcast()),
635 }
636 }
637
638 /// An accel path used to conveniently construct accel paths of child items.
639 pub fn accel_path(self, accel_path: impl Into<glib::GString>) -> Self {
640 Self {
641 builder: self.builder.property("accel-path", accel_path.into()),
642 }
643 }
644
645 /// The index of the currently selected menu item, or -1 if no
646 /// menu item is selected.
647 pub fn active(self, active: i32) -> Self {
648 Self {
649 builder: self.builder.property("active", active),
650 }
651 }
652
653 /// Positioning hints for aligning the menu relative to a rectangle.
654 ///
655 /// These hints determine how the menu should be positioned in the case that
656 /// the menu would fall off-screen if placed in its ideal position.
657 ///
658 /// 
659 ///
660 /// For example, [`gdk::AnchorHints::FLIP_Y`][crate::gdk::AnchorHints::FLIP_Y] will replace [`gdk::Gravity::NorthWest`][crate::gdk::Gravity::NorthWest] with
661 /// [`gdk::Gravity::SouthWest`][crate::gdk::Gravity::SouthWest] and vice versa if the menu extends beyond the
662 /// bottom edge of the monitor.
663 ///
664 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
665 /// gtk_menu_popup_at_pointer (), [`rect-anchor-dx`][struct@crate::Menu#rect-anchor-dx],
666 /// [`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].
667 pub fn anchor_hints(self, anchor_hints: gdk::AnchorHints) -> Self {
668 Self {
669 builder: self.builder.property("anchor-hints", anchor_hints),
670 }
671 }
672
673 /// The widget the menu is attached to. Setting this property attaches
674 /// the menu without a `GtkMenuDetachFunc`. If you need to use a detacher,
675 /// use `gtk_menu_attach_to_widget()` directly.
676 pub fn attach_widget(self, attach_widget: &impl IsA<Widget>) -> Self {
677 Self {
678 builder: self
679 .builder
680 .property("attach-widget", attach_widget.clone().upcast()),
681 }
682 }
683
684 /// The [`gdk::WindowTypeHint`][crate::gdk::WindowTypeHint] to use for the menu's [`gdk::Window`][crate::gdk::Window].
685 ///
686 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
687 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
688 /// [`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].
689 pub fn menu_type_hint(self, menu_type_hint: gdk::WindowTypeHint) -> Self {
690 Self {
691 builder: self.builder.property("menu-type-hint", menu_type_hint),
692 }
693 }
694
695 /// The monitor the menu will be popped up on.
696 pub fn monitor(self, monitor: i32) -> Self {
697 Self {
698 builder: self.builder.property("monitor", monitor),
699 }
700 }
701
702 /// Horizontal offset to apply to the menu, i.e. the rectangle or widget
703 /// anchor.
704 ///
705 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
706 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
707 /// [`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].
708 pub fn rect_anchor_dx(self, rect_anchor_dx: i32) -> Self {
709 Self {
710 builder: self.builder.property("rect-anchor-dx", rect_anchor_dx),
711 }
712 }
713
714 /// Vertical offset to apply to the menu, i.e. the rectangle or widget anchor.
715 ///
716 /// See gtk_menu_popup_at_rect (), gtk_menu_popup_at_widget (),
717 /// gtk_menu_popup_at_pointer (), [`anchor-hints`][struct@crate::Menu#anchor-hints],
718 /// [`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].
719 pub fn rect_anchor_dy(self, rect_anchor_dy: i32) -> Self {
720 Self {
721 builder: self.builder.property("rect-anchor-dy", rect_anchor_dy),
722 }
723 }
724
725 /// A boolean that indicates whether the menu reserves space for
726 /// toggles and icons, regardless of their actual presence.
727 ///
728 /// This property should only be changed from its default value
729 /// for special-purposes such as tabular menus. Regular menus that
730 /// are connected to a menu bar or context menus should reserve
731 /// toggle space for consistency.
732 pub fn reserve_toggle_size(self, reserve_toggle_size: bool) -> Self {
733 Self {
734 builder: self
735 .builder
736 .property("reserve-toggle-size", reserve_toggle_size),
737 }
738 }
739
740 /// A boolean that determines whether the menu and its submenus grab the
741 /// keyboard focus. See [`MenuShellExt::set_take_focus()`][crate::prelude::MenuShellExt::set_take_focus()] and
742 /// [`MenuShellExt::takes_focus()`][crate::prelude::MenuShellExt::takes_focus()].
743 pub fn take_focus(self, take_focus: bool) -> Self {
744 Self {
745 builder: self.builder.property("take-focus", take_focus),
746 }
747 }
748
749 pub fn border_width(self, border_width: u32) -> Self {
750 Self {
751 builder: self.builder.property("border-width", border_width),
752 }
753 }
754
755 pub fn child(self, child: &impl IsA<Widget>) -> Self {
756 Self {
757 builder: self.builder.property("child", child.clone().upcast()),
758 }
759 }
760
761 pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
762 Self {
763 builder: self.builder.property("resize-mode", resize_mode),
764 }
765 }
766
767 pub fn app_paintable(self, app_paintable: bool) -> Self {
768 Self {
769 builder: self.builder.property("app-paintable", app_paintable),
770 }
771 }
772
773 pub fn can_default(self, can_default: bool) -> Self {
774 Self {
775 builder: self.builder.property("can-default", can_default),
776 }
777 }
778
779 pub fn can_focus(self, can_focus: bool) -> Self {
780 Self {
781 builder: self.builder.property("can-focus", can_focus),
782 }
783 }
784
785 pub fn events(self, events: gdk::EventMask) -> Self {
786 Self {
787 builder: self.builder.property("events", events),
788 }
789 }
790
791 /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
792 pub fn expand(self, expand: bool) -> Self {
793 Self {
794 builder: self.builder.property("expand", expand),
795 }
796 }
797
798 /// Whether the widget should grab focus when it is clicked with the mouse.
799 ///
800 /// This property is only relevant for widgets that can take focus.
801 ///
802 /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
803 /// GtkComboBox) implemented this property individually.
804 pub fn focus_on_click(self, focus_on_click: bool) -> Self {
805 Self {
806 builder: self.builder.property("focus-on-click", focus_on_click),
807 }
808 }
809
810 /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
811 pub fn halign(self, halign: Align) -> Self {
812 Self {
813 builder: self.builder.property("halign", halign),
814 }
815 }
816
817 pub fn has_default(self, has_default: bool) -> Self {
818 Self {
819 builder: self.builder.property("has-default", has_default),
820 }
821 }
822
823 pub fn has_focus(self, has_focus: bool) -> Self {
824 Self {
825 builder: self.builder.property("has-focus", has_focus),
826 }
827 }
828
829 /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
830 /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
831 /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
832 /// whether it will provide a tooltip or not.
833 ///
834 /// Note that setting this property to [`true`] for the first time will change
835 /// the event masks of the GdkWindows of this widget to include leave-notify
836 /// and motion-notify events. This cannot and will not be undone when the
837 /// property is set to [`false`] again.
838 pub fn has_tooltip(self, has_tooltip: bool) -> Self {
839 Self {
840 builder: self.builder.property("has-tooltip", has_tooltip),
841 }
842 }
843
844 pub fn height_request(self, height_request: i32) -> Self {
845 Self {
846 builder: self.builder.property("height-request", height_request),
847 }
848 }
849
850 /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
851 pub fn hexpand(self, hexpand: bool) -> Self {
852 Self {
853 builder: self.builder.property("hexpand", hexpand),
854 }
855 }
856
857 /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
858 pub fn hexpand_set(self, hexpand_set: bool) -> Self {
859 Self {
860 builder: self.builder.property("hexpand-set", hexpand_set),
861 }
862 }
863
864 pub fn is_focus(self, is_focus: bool) -> Self {
865 Self {
866 builder: self.builder.property("is-focus", is_focus),
867 }
868 }
869
870 /// Sets all four sides' margin at once. If read, returns max
871 /// margin on any side.
872 pub fn margin(self, margin: i32) -> Self {
873 Self {
874 builder: self.builder.property("margin", margin),
875 }
876 }
877
878 /// Margin on bottom side of widget.
879 ///
880 /// This property adds margin outside of the widget's normal size
881 /// request, the margin will be added in addition to the size from
882 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
883 pub fn margin_bottom(self, margin_bottom: i32) -> Self {
884 Self {
885 builder: self.builder.property("margin-bottom", margin_bottom),
886 }
887 }
888
889 /// Margin on end of widget, horizontally. This property supports
890 /// left-to-right and right-to-left text directions.
891 ///
892 /// This property adds margin outside of the widget's normal size
893 /// request, the margin will be added in addition to the size from
894 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
895 pub fn margin_end(self, margin_end: i32) -> Self {
896 Self {
897 builder: self.builder.property("margin-end", margin_end),
898 }
899 }
900
901 /// Margin on start of widget, horizontally. This property supports
902 /// left-to-right and right-to-left text directions.
903 ///
904 /// This property adds margin outside of the widget's normal size
905 /// request, the margin will be added in addition to the size from
906 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
907 pub fn margin_start(self, margin_start: i32) -> Self {
908 Self {
909 builder: self.builder.property("margin-start", margin_start),
910 }
911 }
912
913 /// Margin on top side of widget.
914 ///
915 /// This property adds margin outside of the widget's normal size
916 /// request, the margin will be added in addition to the size from
917 /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
918 pub fn margin_top(self, margin_top: i32) -> Self {
919 Self {
920 builder: self.builder.property("margin-top", margin_top),
921 }
922 }
923
924 pub fn name(self, name: impl Into<glib::GString>) -> Self {
925 Self {
926 builder: self.builder.property("name", name.into()),
927 }
928 }
929
930 pub fn no_show_all(self, no_show_all: bool) -> Self {
931 Self {
932 builder: self.builder.property("no-show-all", no_show_all),
933 }
934 }
935
936 /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
937 /// more details about window opacity.
938 ///
939 /// Before 3.8 this was only available in GtkWindow
940 pub fn opacity(self, opacity: f64) -> Self {
941 Self {
942 builder: self.builder.property("opacity", opacity),
943 }
944 }
945
946 pub fn parent(self, parent: &impl IsA<Container>) -> Self {
947 Self {
948 builder: self.builder.property("parent", parent.clone().upcast()),
949 }
950 }
951
952 pub fn receives_default(self, receives_default: bool) -> Self {
953 Self {
954 builder: self.builder.property("receives-default", receives_default),
955 }
956 }
957
958 pub fn sensitive(self, sensitive: bool) -> Self {
959 Self {
960 builder: self.builder.property("sensitive", sensitive),
961 }
962 }
963
964 /// Sets the text of tooltip to be the given string, which is marked up
965 /// with the [Pango text markup language][PangoMarkupFormat].
966 /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
967 ///
968 /// This is a convenience property which will take care of getting the
969 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
970 /// will automatically be set to [`true`] and there will be taken care of
971 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
972 ///
973 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
974 /// are set, the last one wins.
975 pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
976 Self {
977 builder: self
978 .builder
979 .property("tooltip-markup", tooltip_markup.into()),
980 }
981 }
982
983 /// Sets the text of tooltip to be the given string.
984 ///
985 /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
986 ///
987 /// This is a convenience property which will take care of getting the
988 /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
989 /// will automatically be set to [`true`] and there will be taken care of
990 /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
991 ///
992 /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
993 /// are set, the last one wins.
994 pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
995 Self {
996 builder: self.builder.property("tooltip-text", tooltip_text.into()),
997 }
998 }
999
1000 /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
1001 pub fn valign(self, valign: Align) -> Self {
1002 Self {
1003 builder: self.builder.property("valign", valign),
1004 }
1005 }
1006
1007 /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
1008 pub fn vexpand(self, vexpand: bool) -> Self {
1009 Self {
1010 builder: self.builder.property("vexpand", vexpand),
1011 }
1012 }
1013
1014 /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
1015 pub fn vexpand_set(self, vexpand_set: bool) -> Self {
1016 Self {
1017 builder: self.builder.property("vexpand-set", vexpand_set),
1018 }
1019 }
1020
1021 pub fn visible(self, visible: bool) -> Self {
1022 Self {
1023 builder: self.builder.property("visible", visible),
1024 }
1025 }
1026
1027 pub fn width_request(self, width_request: i32) -> Self {
1028 Self {
1029 builder: self.builder.property("width-request", width_request),
1030 }
1031 }
1032
1033 /// The [`RecentFilter`][crate::RecentFilter] object to be used when displaying
1034 /// the recently used resources.
1035 pub fn filter(self, filter: &RecentFilter) -> Self {
1036 Self {
1037 builder: self.builder.property("filter", filter.clone()),
1038 }
1039 }
1040
1041 /// The maximum number of recently used resources to be displayed,
1042 /// or -1 to display all items.
1043 pub fn limit(self, limit: i32) -> Self {
1044 Self {
1045 builder: self.builder.property("limit", limit),
1046 }
1047 }
1048
1049 /// Whether this [`RecentChooser`][crate::RecentChooser] should display only local (file:)
1050 /// resources.
1051 pub fn local_only(self, local_only: bool) -> Self {
1052 Self {
1053 builder: self.builder.property("local-only", local_only),
1054 }
1055 }
1056
1057 /// The [`RecentManager`][crate::RecentManager] instance used by the [`RecentChooser`][crate::RecentChooser] to
1058 /// display the list of recently used resources.
1059 pub fn recent_manager(self, recent_manager: &impl IsA<RecentManager>) -> Self {
1060 Self {
1061 builder: self
1062 .builder
1063 .property("recent-manager", recent_manager.clone().upcast()),
1064 }
1065 }
1066
1067 /// Allow the user to select multiple resources.
1068 pub fn select_multiple(self, select_multiple: bool) -> Self {
1069 Self {
1070 builder: self.builder.property("select-multiple", select_multiple),
1071 }
1072 }
1073
1074 /// Whether this [`RecentChooser`][crate::RecentChooser] should display an icon near the item.
1075 pub fn show_icons(self, show_icons: bool) -> Self {
1076 Self {
1077 builder: self.builder.property("show-icons", show_icons),
1078 }
1079 }
1080
1081 /// Whether this [`RecentChooser`][crate::RecentChooser] should display the recently used resources
1082 /// even if not present anymore. Setting this to [`false`] will perform a
1083 /// potentially expensive check on every local resource (every remote
1084 /// resource will always be displayed).
1085 pub fn show_not_found(self, show_not_found: bool) -> Self {
1086 Self {
1087 builder: self.builder.property("show-not-found", show_not_found),
1088 }
1089 }
1090
1091 pub fn show_private(self, show_private: bool) -> Self {
1092 Self {
1093 builder: self.builder.property("show-private", show_private),
1094 }
1095 }
1096
1097 /// Whether this [`RecentChooser`][crate::RecentChooser] should display a tooltip containing the
1098 /// full path of the recently used resources.
1099 pub fn show_tips(self, show_tips: bool) -> Self {
1100 Self {
1101 builder: self.builder.property("show-tips", show_tips),
1102 }
1103 }
1104
1105 /// Sorting order to be used when displaying the recently used resources.
1106 pub fn sort_type(self, sort_type: RecentSortType) -> Self {
1107 Self {
1108 builder: self.builder.property("sort-type", sort_type),
1109 }
1110 }
1111
1112 // rustdoc-stripper-ignore-next
1113 /// Build the [`RecentChooserMenu`].
1114 #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
1115 pub fn build(self) -> RecentChooserMenu {
1116 assert_initialized_main_thread!();
1117 self.builder.build()
1118 }
1119}
1120
1121/// Trait containing all [`struct@RecentChooserMenu`] methods.
1122///
1123/// # Implementors
1124///
1125/// [`RecentChooserMenu`][struct@crate::RecentChooserMenu]
1126pub trait RecentChooserMenuExt: IsA<RecentChooserMenu> + 'static {
1127 /// Returns the value set by [`set_show_numbers()`][Self::set_show_numbers()].
1128 ///
1129 /// # Returns
1130 ///
1131 /// [`true`] if numbers should be shown.
1132 #[doc(alias = "gtk_recent_chooser_menu_get_show_numbers")]
1133 #[doc(alias = "get_show_numbers")]
1134 #[doc(alias = "show-numbers")]
1135 fn shows_numbers(&self) -> bool {
1136 unsafe {
1137 from_glib(ffi::gtk_recent_chooser_menu_get_show_numbers(
1138 self.as_ref().to_glib_none().0,
1139 ))
1140 }
1141 }
1142
1143 /// Sets whether a number should be added to the items of `self`. The
1144 /// numbers are shown to provide a unique character for a mnemonic to
1145 /// be used inside ten menu item’s label. Only the first the items
1146 /// get a number to avoid clashes.
1147 /// ## `show_numbers`
1148 /// whether to show numbers
1149 #[doc(alias = "gtk_recent_chooser_menu_set_show_numbers")]
1150 #[doc(alias = "show-numbers")]
1151 fn set_show_numbers(&self, show_numbers: bool) {
1152 unsafe {
1153 ffi::gtk_recent_chooser_menu_set_show_numbers(
1154 self.as_ref().to_glib_none().0,
1155 show_numbers.into_glib(),
1156 );
1157 }
1158 }
1159
1160 #[doc(alias = "show-numbers")]
1161 fn connect_show_numbers_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
1162 unsafe extern "C" fn notify_show_numbers_trampoline<
1163 P: IsA<RecentChooserMenu>,
1164 F: Fn(&P) + 'static,
1165 >(
1166 this: *mut ffi::GtkRecentChooserMenu,
1167 _param_spec: glib::ffi::gpointer,
1168 f: glib::ffi::gpointer,
1169 ) {
1170 unsafe {
1171 let f: &F = &*(f as *const F);
1172 f(RecentChooserMenu::from_glib_borrow(this).unsafe_cast_ref())
1173 }
1174 }
1175 unsafe {
1176 let f: Box_<F> = Box_::new(f);
1177 connect_raw(
1178 self.as_ptr() as *mut _,
1179 c"notify::show-numbers".as_ptr(),
1180 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
1181 notify_show_numbers_trampoline::<Self, F> as *const (),
1182 )),
1183 Box_::into_raw(f),
1184 )
1185 }
1186 }
1187}
1188
1189impl<O: IsA<RecentChooserMenu>> RecentChooserMenuExt for O {}