gtk/auto/
recent_info.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 gdk_pixbuf;
6use gio;
7use glib::translate::*;
8use glib::GString;
9use gtk_sys;
10use libc;
11use std::mem;
12use std::ptr;
13use Error;
14
15glib_wrapper! {
16    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
17    pub struct RecentInfo(Shared<gtk_sys::GtkRecentInfo>);
18
19    match fn {
20        ref => |ptr| gtk_sys::gtk_recent_info_ref(ptr),
21        unref => |ptr| gtk_sys::gtk_recent_info_unref(ptr),
22        get_type => || gtk_sys::gtk_recent_info_get_type(),
23    }
24}
25
26impl RecentInfo {
27    pub fn create_app_info(&self, app_name: Option<&str>) -> Result<Option<gio::AppInfo>, Error> {
28        unsafe {
29            let mut error = ptr::null_mut();
30            let ret = gtk_sys::gtk_recent_info_create_app_info(
31                self.to_glib_none().0,
32                app_name.to_glib_none().0,
33                &mut error,
34            );
35            if error.is_null() {
36                Ok(from_glib_full(ret))
37            } else {
38                Err(from_glib_full(error))
39            }
40        }
41    }
42
43    pub fn exists(&self) -> bool {
44        unsafe { from_glib(gtk_sys::gtk_recent_info_exists(self.to_glib_none().0)) }
45    }
46
47    pub fn get_added(&self) -> libc::c_long {
48        unsafe { gtk_sys::gtk_recent_info_get_added(self.to_glib_none().0) }
49    }
50
51    pub fn get_age(&self) -> i32 {
52        unsafe { gtk_sys::gtk_recent_info_get_age(self.to_glib_none().0) }
53    }
54
55    pub fn get_application_info(&self, app_name: &str) -> Option<(GString, u32, libc::c_long)> {
56        unsafe {
57            let mut app_exec = ptr::null();
58            let mut count = mem::uninitialized();
59            let mut time_ = mem::uninitialized();
60            let ret = from_glib(gtk_sys::gtk_recent_info_get_application_info(
61                self.to_glib_none().0,
62                app_name.to_glib_none().0,
63                &mut app_exec,
64                &mut count,
65                &mut time_,
66            ));
67            if ret {
68                Some((from_glib_none(app_exec), count, time_))
69            } else {
70                None
71            }
72        }
73    }
74
75    pub fn get_applications(&self) -> Vec<GString> {
76        unsafe {
77            let mut length = mem::uninitialized();
78            let ret = FromGlibContainer::from_glib_full_num(
79                gtk_sys::gtk_recent_info_get_applications(self.to_glib_none().0, &mut length),
80                length as usize,
81            );
82            ret
83        }
84    }
85
86    pub fn get_description(&self) -> Option<GString> {
87        unsafe {
88            from_glib_none(gtk_sys::gtk_recent_info_get_description(
89                self.to_glib_none().0,
90            ))
91        }
92    }
93
94    pub fn get_display_name(&self) -> Option<GString> {
95        unsafe {
96            from_glib_none(gtk_sys::gtk_recent_info_get_display_name(
97                self.to_glib_none().0,
98            ))
99        }
100    }
101
102    pub fn get_gicon(&self) -> Option<gio::Icon> {
103        unsafe { from_glib_full(gtk_sys::gtk_recent_info_get_gicon(self.to_glib_none().0)) }
104    }
105
106    pub fn get_groups(&self) -> Vec<GString> {
107        unsafe {
108            let mut length = mem::uninitialized();
109            let ret = FromGlibContainer::from_glib_full_num(
110                gtk_sys::gtk_recent_info_get_groups(self.to_glib_none().0, &mut length),
111                length as usize,
112            );
113            ret
114        }
115    }
116
117    pub fn get_icon(&self, size: i32) -> Option<gdk_pixbuf::Pixbuf> {
118        unsafe {
119            from_glib_full(gtk_sys::gtk_recent_info_get_icon(
120                self.to_glib_none().0,
121                size,
122            ))
123        }
124    }
125
126    pub fn get_mime_type(&self) -> Option<GString> {
127        unsafe {
128            from_glib_none(gtk_sys::gtk_recent_info_get_mime_type(
129                self.to_glib_none().0,
130            ))
131        }
132    }
133
134    pub fn get_modified(&self) -> libc::c_long {
135        unsafe { gtk_sys::gtk_recent_info_get_modified(self.to_glib_none().0) }
136    }
137
138    pub fn get_private_hint(&self) -> bool {
139        unsafe {
140            from_glib(gtk_sys::gtk_recent_info_get_private_hint(
141                self.to_glib_none().0,
142            ))
143        }
144    }
145
146    pub fn get_short_name(&self) -> Option<GString> {
147        unsafe {
148            from_glib_full(gtk_sys::gtk_recent_info_get_short_name(
149                self.to_glib_none().0,
150            ))
151        }
152    }
153
154    pub fn get_uri(&self) -> Option<GString> {
155        unsafe { from_glib_none(gtk_sys::gtk_recent_info_get_uri(self.to_glib_none().0)) }
156    }
157
158    pub fn get_uri_display(&self) -> Option<GString> {
159        unsafe {
160            from_glib_full(gtk_sys::gtk_recent_info_get_uri_display(
161                self.to_glib_none().0,
162            ))
163        }
164    }
165
166    pub fn get_visited(&self) -> libc::c_long {
167        unsafe { gtk_sys::gtk_recent_info_get_visited(self.to_glib_none().0) }
168    }
169
170    pub fn has_application(&self, app_name: &str) -> bool {
171        unsafe {
172            from_glib(gtk_sys::gtk_recent_info_has_application(
173                self.to_glib_none().0,
174                app_name.to_glib_none().0,
175            ))
176        }
177    }
178
179    pub fn has_group(&self, group_name: &str) -> bool {
180        unsafe {
181            from_glib(gtk_sys::gtk_recent_info_has_group(
182                self.to_glib_none().0,
183                group_name.to_glib_none().0,
184            ))
185        }
186    }
187
188    pub fn is_local(&self) -> bool {
189        unsafe { from_glib(gtk_sys::gtk_recent_info_is_local(self.to_glib_none().0)) }
190    }
191
192    pub fn last_application(&self) -> Option<GString> {
193        unsafe {
194            from_glib_full(gtk_sys::gtk_recent_info_last_application(
195                self.to_glib_none().0,
196            ))
197        }
198    }
199
200    pub fn match_(&self, info_b: &RecentInfo) -> bool {
201        unsafe {
202            from_glib(gtk_sys::gtk_recent_info_match(
203                self.to_glib_none().0,
204                info_b.to_glib_none().0,
205            ))
206        }
207    }
208}