gtk/
app_chooser.rs

1// Copyright 2013-2015, The Gtk-rs Project Developers.
2// See the COPYRIGHT file at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4
5use gio::AppInfo;
6use glib::object::IsA;
7use glib::translate::*;
8use gtk_sys;
9use Widget;
10
11glib_wrapper! {
12    pub struct AppChooser(Interface<gtk_sys::GtkAppChooser>) @requires Widget;
13
14    match fn {
15        get_type => || gtk_sys::gtk_app_chooser_get_type(),
16    }
17}
18
19pub trait AppChooserExt: 'static {
20    fn get_app_info(&self) -> Option<AppInfo>;
21    fn get_content_type(&self) -> Option<String>;
22    fn refresh(&self);
23}
24
25impl<O: IsA<AppChooser>> AppChooserExt for O {
26    fn get_app_info(&self) -> Option<AppInfo> {
27        unsafe {
28            from_glib_full(gtk_sys::gtk_app_chooser_get_app_info(
29                self.as_ref().to_glib_none().0,
30            ))
31        }
32    }
33
34    fn get_content_type(&self) -> Option<String> {
35        unsafe {
36            from_glib_full(gtk_sys::gtk_app_chooser_get_content_type(
37                self.as_ref().to_glib_none().0,
38            ))
39        }
40    }
41
42    fn refresh(&self) {
43        unsafe { gtk_sys::gtk_app_chooser_refresh(self.as_ref().to_glib_none().0) }
44    }
45}