gtk/
recent_chooser_dialog.rs

1// Copyright 2013-2016, The Gtk-rs Project Developers.
2// See the COPYRIGHT recent at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE recent or <http://opensource.org/licenses/MIT>
4
5use glib::object::{Cast, IsA};
6use glib::translate::*;
7use gtk_sys;
8use std::ptr;
9use RecentChooserDialog;
10use RecentManager;
11use Widget;
12use Window;
13
14impl RecentChooserDialog {
15    pub fn new<T: IsA<Window>>(title: Option<&str>, parent: Option<&T>) -> RecentChooserDialog {
16        assert_initialized_main_thread!();
17        unsafe {
18            Widget::from_glib_none(gtk_sys::gtk_recent_chooser_dialog_new(
19                title.to_glib_none().0,
20                parent.map(|p| p.as_ref()).to_glib_none().0,
21                ptr::null_mut(),
22            ))
23            .unsafe_cast()
24        }
25    }
26
27    pub fn new_for_manager<T: IsA<Window>>(
28        title: Option<&str>,
29        parent: Option<&T>,
30        manager: &RecentManager,
31    ) -> RecentChooserDialog {
32        assert_initialized_main_thread!();
33        unsafe {
34            Widget::from_glib_none(gtk_sys::gtk_recent_chooser_dialog_new_for_manager(
35                title.to_glib_none().0,
36                parent.map(|p| p.as_ref()).to_glib_none().0,
37                manager.to_glib_none().0,
38                ptr::null_mut(),
39            ))
40            .unsafe_cast()
41        }
42    }
43}