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