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