gtk/recent_chooser_dialog.rs
1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::RecentChooserDialog;
4use crate::RecentManager;
5use crate::Widget;
6use crate::Window;
7use glib::object::{Cast, IsA};
8use glib::translate::*;
9use std::ptr;
10
11impl RecentChooserDialog {
12 /// Creates a new [`RecentChooserDialog`][crate::RecentChooserDialog]. This function is analogous to
13 /// `gtk_dialog_new_with_buttons()`.
14 /// ## `title`
15 /// Title of the dialog, or [`None`]
16 /// ## `parent`
17 /// Transient parent of the dialog, or [`None`],
18 /// ## `first_button_text`
19 /// stock ID or text to go in the first button, or [`None`]
20 ///
21 /// # Returns
22 ///
23 /// a new [`RecentChooserDialog`][crate::RecentChooserDialog]
24 #[doc(alias = "gtk_recent_chooser_dialog_new")]
25 pub fn new<T: IsA<Window>>(title: Option<&str>, parent: Option<&T>) -> RecentChooserDialog {
26 assert_initialized_main_thread!();
27 unsafe {
28 Widget::from_glib_none(ffi::gtk_recent_chooser_dialog_new(
29 title.to_glib_none().0,
30 parent.map(|p| p.as_ref()).to_glib_none().0,
31 ptr::null_mut(),
32 ))
33 .unsafe_cast()
34 }
35 }
36
37 /// Creates a new [`RecentChooserDialog`][crate::RecentChooserDialog] with a specified recent manager.
38 ///
39 /// This is useful if you have implemented your own recent manager, or if you
40 /// have a customized instance of a [`RecentManager`][crate::RecentManager] object.
41 /// ## `title`
42 /// Title of the dialog, or [`None`]
43 /// ## `parent`
44 /// Transient parent of the dialog, or [`None`],
45 /// ## `manager`
46 /// a [`RecentManager`][crate::RecentManager]
47 /// ## `first_button_text`
48 /// stock ID or text to go in the first button, or [`None`]
49 ///
50 /// # Returns
51 ///
52 /// a new [`RecentChooserDialog`][crate::RecentChooserDialog]
53 #[doc(alias = "gtk_recent_chooser_dialog_new_for_manager")]
54 #[doc(alias = "new_for_manager")]
55 pub fn for_manager<T: IsA<Window>>(
56 title: Option<&str>,
57 parent: Option<&T>,
58 manager: &RecentManager,
59 ) -> RecentChooserDialog {
60 assert_initialized_main_thread!();
61 unsafe {
62 Widget::from_glib_none(ffi::gtk_recent_chooser_dialog_new_for_manager(
63 title.to_glib_none().0,
64 parent.map(|p| p.as_ref()).to_glib_none().0,
65 manager.to_glib_none().0,
66 ptr::null_mut(),
67 ))
68 .unsafe_cast()
69 }
70 }
71}