1use crate::ffi;
6use glib::translate::*;
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 = std::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) -> glib::DateTime {
48 unsafe { from_glib_none(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, glib::DateTime)> {
60 unsafe {
61 let mut app_exec = std::ptr::null();
62 let mut count = std::mem::MaybeUninit::uninit();
63 let mut stamp = std::ptr::null_mut();
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 &mut stamp,
70 ));
71 if ret {
72 Some((
73 from_glib_none(app_exec),
74 count.assume_init(),
75 from_glib_none(stamp),
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 = std::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) -> 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) -> 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 = std::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_mime_type")]
128 #[doc(alias = "get_mime_type")]
129 pub fn mime_type(&self) -> glib::GString {
130 unsafe { from_glib_none(ffi::gtk_recent_info_get_mime_type(self.to_glib_none().0)) }
131 }
132
133 #[doc(alias = "gtk_recent_info_get_modified")]
134 #[doc(alias = "get_modified")]
135 pub fn modified(&self) -> glib::DateTime {
136 unsafe { from_glib_none(ffi::gtk_recent_info_get_modified(self.to_glib_none().0)) }
137 }
138
139 #[doc(alias = "gtk_recent_info_get_private_hint")]
140 #[doc(alias = "get_private_hint")]
141 pub fn is_private_hint(&self) -> bool {
142 unsafe { from_glib(ffi::gtk_recent_info_get_private_hint(self.to_glib_none().0)) }
143 }
144
145 #[doc(alias = "gtk_recent_info_get_short_name")]
146 #[doc(alias = "get_short_name")]
147 pub fn short_name(&self) -> glib::GString {
148 unsafe { from_glib_full(ffi::gtk_recent_info_get_short_name(self.to_glib_none().0)) }
149 }
150
151 #[doc(alias = "gtk_recent_info_get_uri")]
152 #[doc(alias = "get_uri")]
153 pub fn uri(&self) -> glib::GString {
154 unsafe { from_glib_none(ffi::gtk_recent_info_get_uri(self.to_glib_none().0)) }
155 }
156
157 #[doc(alias = "gtk_recent_info_get_uri_display")]
158 #[doc(alias = "get_uri_display")]
159 pub fn uri_display(&self) -> Option<glib::GString> {
160 unsafe { from_glib_full(ffi::gtk_recent_info_get_uri_display(self.to_glib_none().0)) }
161 }
162
163 #[doc(alias = "gtk_recent_info_get_visited")]
164 #[doc(alias = "get_visited")]
165 pub fn visited(&self) -> glib::DateTime {
166 unsafe { from_glib_none(ffi::gtk_recent_info_get_visited(self.to_glib_none().0)) }
167 }
168
169 #[doc(alias = "gtk_recent_info_has_application")]
170 pub fn has_application(&self, app_name: &str) -> bool {
171 unsafe {
172 from_glib(ffi::gtk_recent_info_has_application(
173 self.to_glib_none().0,
174 app_name.to_glib_none().0,
175 ))
176 }
177 }
178
179 #[doc(alias = "gtk_recent_info_has_group")]
180 pub fn has_group(&self, group_name: &str) -> bool {
181 unsafe {
182 from_glib(ffi::gtk_recent_info_has_group(
183 self.to_glib_none().0,
184 group_name.to_glib_none().0,
185 ))
186 }
187 }
188
189 #[doc(alias = "gtk_recent_info_is_local")]
190 pub fn is_local(&self) -> bool {
191 unsafe { from_glib(ffi::gtk_recent_info_is_local(self.to_glib_none().0)) }
192 }
193
194 #[doc(alias = "gtk_recent_info_last_application")]
195 pub fn last_application(&self) -> glib::GString {
196 unsafe { from_glib_full(ffi::gtk_recent_info_last_application(self.to_glib_none().0)) }
197 }
198
199 #[doc(alias = "gtk_recent_info_match")]
200 #[doc(alias = "match")]
201 pub fn match_(&self, info_b: &RecentInfo) -> bool {
202 unsafe {
203 from_glib(ffi::gtk_recent_info_match(
204 self.to_glib_none().0,
205 info_b.to_glib_none().0,
206 ))
207 }
208 }
209}