Skip to main content

gtk/auto/
recent_chooser_widget.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    Align, BaselinePosition, Box, Buildable, Container, Orientable, Orientation, RecentChooser,
7    RecentFilter, RecentManager, RecentSortType, ResizeMode, Widget, ffi,
8};
9use glib::{prelude::*, translate::*};
10
11glib::wrapper! {
12    /// [`RecentChooserWidget`][crate::RecentChooserWidget] is a widget suitable for selecting recently used
13    /// files. It is the main building block of a [`RecentChooserDialog`][crate::RecentChooserDialog]. Most
14    /// applications will only need to use the latter; you can use
15    /// [`RecentChooserWidget`][crate::RecentChooserWidget] as part of a larger window if you have special needs.
16    ///
17    /// Note that [`RecentChooserWidget`][crate::RecentChooserWidget] does not have any methods of its own.
18    /// Instead, you should use the functions that work on a [`RecentChooser`][crate::RecentChooser].
19    ///
20    /// Recently used files are supported since GTK+ 2.10.
21    ///
22    /// # Implements
23    ///
24    /// [`BoxExt`][trait@crate::prelude::BoxExt], [`ContainerExt`][trait@crate::prelude::ContainerExt], [`WidgetExt`][trait@crate::prelude::WidgetExt], [`trait@glib::ObjectExt`], [`BuildableExt`][trait@crate::prelude::BuildableExt], [`OrientableExt`][trait@crate::prelude::OrientableExt], [`RecentChooserExt`][trait@crate::prelude::RecentChooserExt], [`ContainerExtManual`][trait@crate::prelude::ContainerExtManual], [`WidgetExtManual`][trait@crate::prelude::WidgetExtManual], [`BuildableExtManual`][trait@crate::prelude::BuildableExtManual]
25    #[doc(alias = "GtkRecentChooserWidget")]
26    pub struct RecentChooserWidget(Object<ffi::GtkRecentChooserWidget, ffi::GtkRecentChooserWidgetClass>) @extends Box, Container, Widget, @implements Buildable, Orientable, RecentChooser;
27
28    match fn {
29        type_ => || ffi::gtk_recent_chooser_widget_get_type(),
30    }
31}
32
33impl RecentChooserWidget {
34    pub const NONE: Option<&'static RecentChooserWidget> = None;
35
36    /// Creates a new [`RecentChooserWidget`][crate::RecentChooserWidget] object. This is an embeddable widget
37    /// used to access the recently used resources list.
38    ///
39    /// # Returns
40    ///
41    /// a new [`RecentChooserWidget`][crate::RecentChooserWidget]
42    #[doc(alias = "gtk_recent_chooser_widget_new")]
43    pub fn new() -> RecentChooserWidget {
44        assert_initialized_main_thread!();
45        unsafe { Widget::from_glib_none(ffi::gtk_recent_chooser_widget_new()).unsafe_cast() }
46    }
47
48    /// Creates a new [`RecentChooserWidget`][crate::RecentChooserWidget] with a specified recent manager.
49    ///
50    /// This is useful if you have implemented your own recent manager, or if you
51    /// have a customized instance of a [`RecentManager`][crate::RecentManager] object.
52    /// ## `manager`
53    /// a [`RecentManager`][crate::RecentManager]
54    ///
55    /// # Returns
56    ///
57    /// a new [`RecentChooserWidget`][crate::RecentChooserWidget]
58    #[doc(alias = "gtk_recent_chooser_widget_new_for_manager")]
59    #[doc(alias = "new_for_manager")]
60    pub fn for_manager(manager: &impl IsA<RecentManager>) -> RecentChooserWidget {
61        skip_assert_initialized!();
62        unsafe {
63            Widget::from_glib_none(ffi::gtk_recent_chooser_widget_new_for_manager(
64                manager.as_ref().to_glib_none().0,
65            ))
66            .unsafe_cast()
67        }
68    }
69
70    // rustdoc-stripper-ignore-next
71    /// Creates a new builder-pattern struct instance to construct [`RecentChooserWidget`] objects.
72    ///
73    /// This method returns an instance of [`RecentChooserWidgetBuilder`](crate::builders::RecentChooserWidgetBuilder) which can be used to create [`RecentChooserWidget`] objects.
74    pub fn builder() -> RecentChooserWidgetBuilder {
75        RecentChooserWidgetBuilder::new()
76    }
77}
78
79impl Default for RecentChooserWidget {
80    fn default() -> Self {
81        Self::new()
82    }
83}
84
85// rustdoc-stripper-ignore-next
86/// A [builder-pattern] type to construct [`RecentChooserWidget`] objects.
87///
88/// [builder-pattern]: https://doc.rust-lang.org/1.0.0/style/ownership/builders.html
89#[must_use = "The builder must be built to be used"]
90pub struct RecentChooserWidgetBuilder {
91    builder: glib::object::ObjectBuilder<'static, RecentChooserWidget>,
92}
93
94impl RecentChooserWidgetBuilder {
95    fn new() -> Self {
96        Self {
97            builder: glib::object::Object::builder(),
98        }
99    }
100
101    pub fn baseline_position(self, baseline_position: BaselinePosition) -> Self {
102        Self {
103            builder: self
104                .builder
105                .property("baseline-position", baseline_position),
106        }
107    }
108
109    pub fn homogeneous(self, homogeneous: bool) -> Self {
110        Self {
111            builder: self.builder.property("homogeneous", homogeneous),
112        }
113    }
114
115    pub fn spacing(self, spacing: i32) -> Self {
116        Self {
117            builder: self.builder.property("spacing", spacing),
118        }
119    }
120
121    pub fn border_width(self, border_width: u32) -> Self {
122        Self {
123            builder: self.builder.property("border-width", border_width),
124        }
125    }
126
127    pub fn child(self, child: &impl IsA<Widget>) -> Self {
128        Self {
129            builder: self.builder.property("child", child.clone().upcast()),
130        }
131    }
132
133    pub fn resize_mode(self, resize_mode: ResizeMode) -> Self {
134        Self {
135            builder: self.builder.property("resize-mode", resize_mode),
136        }
137    }
138
139    pub fn app_paintable(self, app_paintable: bool) -> Self {
140        Self {
141            builder: self.builder.property("app-paintable", app_paintable),
142        }
143    }
144
145    pub fn can_default(self, can_default: bool) -> Self {
146        Self {
147            builder: self.builder.property("can-default", can_default),
148        }
149    }
150
151    pub fn can_focus(self, can_focus: bool) -> Self {
152        Self {
153            builder: self.builder.property("can-focus", can_focus),
154        }
155    }
156
157    pub fn events(self, events: gdk::EventMask) -> Self {
158        Self {
159            builder: self.builder.property("events", events),
160        }
161    }
162
163    /// Whether to expand in both directions. Setting this sets both [`hexpand`][struct@crate::Widget#hexpand] and [`vexpand`][struct@crate::Widget#vexpand]
164    pub fn expand(self, expand: bool) -> Self {
165        Self {
166            builder: self.builder.property("expand", expand),
167        }
168    }
169
170    /// Whether the widget should grab focus when it is clicked with the mouse.
171    ///
172    /// This property is only relevant for widgets that can take focus.
173    ///
174    /// Before 3.20, several widgets (GtkButton, GtkFileChooserButton,
175    /// GtkComboBox) implemented this property individually.
176    pub fn focus_on_click(self, focus_on_click: bool) -> Self {
177        Self {
178            builder: self.builder.property("focus-on-click", focus_on_click),
179        }
180    }
181
182    /// How to distribute horizontal space if widget gets extra space, see [`Align`][crate::Align]
183    pub fn halign(self, halign: Align) -> Self {
184        Self {
185            builder: self.builder.property("halign", halign),
186        }
187    }
188
189    pub fn has_default(self, has_default: bool) -> Self {
190        Self {
191            builder: self.builder.property("has-default", has_default),
192        }
193    }
194
195    pub fn has_focus(self, has_focus: bool) -> Self {
196        Self {
197            builder: self.builder.property("has-focus", has_focus),
198        }
199    }
200
201    /// Enables or disables the emission of [`query-tooltip`][struct@crate::Widget#query-tooltip] on `widget`.
202    /// A value of [`true`] indicates that `widget` can have a tooltip, in this case
203    /// the widget will be queried using [`query-tooltip`][struct@crate::Widget#query-tooltip] to determine
204    /// whether it will provide a tooltip or not.
205    ///
206    /// Note that setting this property to [`true`] for the first time will change
207    /// the event masks of the GdkWindows of this widget to include leave-notify
208    /// and motion-notify events. This cannot and will not be undone when the
209    /// property is set to [`false`] again.
210    pub fn has_tooltip(self, has_tooltip: bool) -> Self {
211        Self {
212            builder: self.builder.property("has-tooltip", has_tooltip),
213        }
214    }
215
216    pub fn height_request(self, height_request: i32) -> Self {
217        Self {
218            builder: self.builder.property("height-request", height_request),
219        }
220    }
221
222    /// Whether to expand horizontally. See [`WidgetExt::set_hexpand()`][crate::prelude::WidgetExt::set_hexpand()].
223    pub fn hexpand(self, hexpand: bool) -> Self {
224        Self {
225            builder: self.builder.property("hexpand", hexpand),
226        }
227    }
228
229    /// Whether to use the [`hexpand`][struct@crate::Widget#hexpand] property. See [`WidgetExt::is_hexpand_set()`][crate::prelude::WidgetExt::is_hexpand_set()].
230    pub fn hexpand_set(self, hexpand_set: bool) -> Self {
231        Self {
232            builder: self.builder.property("hexpand-set", hexpand_set),
233        }
234    }
235
236    pub fn is_focus(self, is_focus: bool) -> Self {
237        Self {
238            builder: self.builder.property("is-focus", is_focus),
239        }
240    }
241
242    /// Sets all four sides' margin at once. If read, returns max
243    /// margin on any side.
244    pub fn margin(self, margin: i32) -> Self {
245        Self {
246            builder: self.builder.property("margin", margin),
247        }
248    }
249
250    /// Margin on bottom side of widget.
251    ///
252    /// This property adds margin outside of the widget's normal size
253    /// request, the margin will be added in addition to the size from
254    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
255    pub fn margin_bottom(self, margin_bottom: i32) -> Self {
256        Self {
257            builder: self.builder.property("margin-bottom", margin_bottom),
258        }
259    }
260
261    /// Margin on end of widget, horizontally. This property supports
262    /// left-to-right and right-to-left text directions.
263    ///
264    /// This property adds margin outside of the widget's normal size
265    /// request, the margin will be added in addition to the size from
266    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
267    pub fn margin_end(self, margin_end: i32) -> Self {
268        Self {
269            builder: self.builder.property("margin-end", margin_end),
270        }
271    }
272
273    /// Margin on start of widget, horizontally. This property supports
274    /// left-to-right and right-to-left text directions.
275    ///
276    /// This property adds margin outside of the widget's normal size
277    /// request, the margin will be added in addition to the size from
278    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
279    pub fn margin_start(self, margin_start: i32) -> Self {
280        Self {
281            builder: self.builder.property("margin-start", margin_start),
282        }
283    }
284
285    /// Margin on top side of widget.
286    ///
287    /// This property adds margin outside of the widget's normal size
288    /// request, the margin will be added in addition to the size from
289    /// [`WidgetExt::set_size_request()`][crate::prelude::WidgetExt::set_size_request()] for example.
290    pub fn margin_top(self, margin_top: i32) -> Self {
291        Self {
292            builder: self.builder.property("margin-top", margin_top),
293        }
294    }
295
296    pub fn name(self, name: impl Into<glib::GString>) -> Self {
297        Self {
298            builder: self.builder.property("name", name.into()),
299        }
300    }
301
302    pub fn no_show_all(self, no_show_all: bool) -> Self {
303        Self {
304            builder: self.builder.property("no-show-all", no_show_all),
305        }
306    }
307
308    /// The requested opacity of the widget. See [`WidgetExt::set_opacity()`][crate::prelude::WidgetExt::set_opacity()] for
309    /// more details about window opacity.
310    ///
311    /// Before 3.8 this was only available in GtkWindow
312    pub fn opacity(self, opacity: f64) -> Self {
313        Self {
314            builder: self.builder.property("opacity", opacity),
315        }
316    }
317
318    pub fn parent(self, parent: &impl IsA<Container>) -> Self {
319        Self {
320            builder: self.builder.property("parent", parent.clone().upcast()),
321        }
322    }
323
324    pub fn receives_default(self, receives_default: bool) -> Self {
325        Self {
326            builder: self.builder.property("receives-default", receives_default),
327        }
328    }
329
330    pub fn sensitive(self, sensitive: bool) -> Self {
331        Self {
332            builder: self.builder.property("sensitive", sensitive),
333        }
334    }
335
336    /// Sets the text of tooltip to be the given string, which is marked up
337    /// with the [Pango text markup language][PangoMarkupFormat].
338    /// Also see [`Tooltip::set_markup()`][crate::Tooltip::set_markup()].
339    ///
340    /// This is a convenience property which will take care of getting the
341    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
342    /// will automatically be set to [`true`] and there will be taken care of
343    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
344    ///
345    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
346    /// are set, the last one wins.
347    pub fn tooltip_markup(self, tooltip_markup: impl Into<glib::GString>) -> Self {
348        Self {
349            builder: self
350                .builder
351                .property("tooltip-markup", tooltip_markup.into()),
352        }
353    }
354
355    /// Sets the text of tooltip to be the given string.
356    ///
357    /// Also see [`Tooltip::set_text()`][crate::Tooltip::set_text()].
358    ///
359    /// This is a convenience property which will take care of getting the
360    /// tooltip shown if the given string is not [`None`]: [`has-tooltip`][struct@crate::Widget#has-tooltip]
361    /// will automatically be set to [`true`] and there will be taken care of
362    /// [`query-tooltip`][struct@crate::Widget#query-tooltip] in the default signal handler.
363    ///
364    /// Note that if both [`tooltip-text`][struct@crate::Widget#tooltip-text] and [`tooltip-markup`][struct@crate::Widget#tooltip-markup]
365    /// are set, the last one wins.
366    pub fn tooltip_text(self, tooltip_text: impl Into<glib::GString>) -> Self {
367        Self {
368            builder: self.builder.property("tooltip-text", tooltip_text.into()),
369        }
370    }
371
372    /// How to distribute vertical space if widget gets extra space, see [`Align`][crate::Align]
373    pub fn valign(self, valign: Align) -> Self {
374        Self {
375            builder: self.builder.property("valign", valign),
376        }
377    }
378
379    /// Whether to expand vertically. See [`WidgetExt::set_vexpand()`][crate::prelude::WidgetExt::set_vexpand()].
380    pub fn vexpand(self, vexpand: bool) -> Self {
381        Self {
382            builder: self.builder.property("vexpand", vexpand),
383        }
384    }
385
386    /// Whether to use the [`vexpand`][struct@crate::Widget#vexpand] property. See [`WidgetExt::is_vexpand_set()`][crate::prelude::WidgetExt::is_vexpand_set()].
387    pub fn vexpand_set(self, vexpand_set: bool) -> Self {
388        Self {
389            builder: self.builder.property("vexpand-set", vexpand_set),
390        }
391    }
392
393    pub fn visible(self, visible: bool) -> Self {
394        Self {
395            builder: self.builder.property("visible", visible),
396        }
397    }
398
399    pub fn width_request(self, width_request: i32) -> Self {
400        Self {
401            builder: self.builder.property("width-request", width_request),
402        }
403    }
404
405    /// The orientation of the orientable.
406    pub fn orientation(self, orientation: Orientation) -> Self {
407        Self {
408            builder: self.builder.property("orientation", orientation),
409        }
410    }
411
412    /// The [`RecentFilter`][crate::RecentFilter] object to be used when displaying
413    /// the recently used resources.
414    pub fn filter(self, filter: &RecentFilter) -> Self {
415        Self {
416            builder: self.builder.property("filter", filter.clone()),
417        }
418    }
419
420    /// The maximum number of recently used resources to be displayed,
421    /// or -1 to display all items.
422    pub fn limit(self, limit: i32) -> Self {
423        Self {
424            builder: self.builder.property("limit", limit),
425        }
426    }
427
428    /// Whether this [`RecentChooser`][crate::RecentChooser] should display only local (file:)
429    /// resources.
430    pub fn local_only(self, local_only: bool) -> Self {
431        Self {
432            builder: self.builder.property("local-only", local_only),
433        }
434    }
435
436    /// The [`RecentManager`][crate::RecentManager] instance used by the [`RecentChooser`][crate::RecentChooser] to
437    /// display the list of recently used resources.
438    pub fn recent_manager(self, recent_manager: &impl IsA<RecentManager>) -> Self {
439        Self {
440            builder: self
441                .builder
442                .property("recent-manager", recent_manager.clone().upcast()),
443        }
444    }
445
446    /// Allow the user to select multiple resources.
447    pub fn select_multiple(self, select_multiple: bool) -> Self {
448        Self {
449            builder: self.builder.property("select-multiple", select_multiple),
450        }
451    }
452
453    /// Whether this [`RecentChooser`][crate::RecentChooser] should display an icon near the item.
454    pub fn show_icons(self, show_icons: bool) -> Self {
455        Self {
456            builder: self.builder.property("show-icons", show_icons),
457        }
458    }
459
460    /// Whether this [`RecentChooser`][crate::RecentChooser] should display the recently used resources
461    /// even if not present anymore. Setting this to [`false`] will perform a
462    /// potentially expensive check on every local resource (every remote
463    /// resource will always be displayed).
464    pub fn show_not_found(self, show_not_found: bool) -> Self {
465        Self {
466            builder: self.builder.property("show-not-found", show_not_found),
467        }
468    }
469
470    pub fn show_private(self, show_private: bool) -> Self {
471        Self {
472            builder: self.builder.property("show-private", show_private),
473        }
474    }
475
476    /// Whether this [`RecentChooser`][crate::RecentChooser] should display a tooltip containing the
477    /// full path of the recently used resources.
478    pub fn show_tips(self, show_tips: bool) -> Self {
479        Self {
480            builder: self.builder.property("show-tips", show_tips),
481        }
482    }
483
484    /// Sorting order to be used when displaying the recently used resources.
485    pub fn sort_type(self, sort_type: RecentSortType) -> Self {
486        Self {
487            builder: self.builder.property("sort-type", sort_type),
488        }
489    }
490
491    // rustdoc-stripper-ignore-next
492    /// Build the [`RecentChooserWidget`].
493    #[must_use = "Building the object from the builder is usually expensive and is not expected to have side effects"]
494    pub fn build(self) -> RecentChooserWidget {
495        assert_initialized_main_thread!();
496        self.builder.build()
497    }
498}