1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
// Copyright 2013-2015, The Gtk-rs Project Developers.
// See the COPYRIGHT file at the top-level directory of this distribution.
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
#![allow(unused_imports)]
use ffi;
use cast::{GTK_APP_INFO, GTK_APP_LAUNCH_CONTEXT};
use glib;
use glib::GlibContainer;
use std::str;
use std::string;
struct_Widget!(AppInfo);
impl AppInfo {/*
pub fn create_from_commandline(commande_line: &str, application_name: &str, flag: ::AppInfoCreateFlags, error: &mut glib::Error) -> Option<AppInfo> {
assert_initialized_main_thread!();
let tmp_pointer = unsafe {
commande_line.with_c_str(|c_command_line| {
application_name.with_c_str(|c_application_name| {
ffi::g_app_info_create_from_commandline(c_command_line, c_application_name, flag, &mut error.unwrap())
})
})
};
if tmp_pointer.is_null() {
None
} else {
Some(::FFIWidget::wrap_widget(tmp_pointer as *mut ::ffi::GtkWidget))
}
}
pub fn equals(&self, other: &AppInfo) -> bool {
unsafe { to_bool(ffi::g_app_info_equal(GTK_APP_INFO(self.unwrap_widget()), GTK_APP_INFO(other.unwrap_widget()))) }
}
pub fn get_id(&self) -> Option<String> {
let tmp_pointer = unsafe { ffi::g_app_info_get_id(GTK_APP_INFO(self.unwrap_widget())) };
if tmp_pointer.is_null() {
None
} else {
Some(unsafe {FromCStr::from_raw_buf(tmp_pointer) })
}
}
pub fn get_name(&self) -> Option<String> {
let tmp_pointer = unsafe { ffi::g_app_info_get_name(GTK_APP_INFO(self.unwrap_widget())) };
if tmp_pointer.is_null() {
None
} else {
Some(unsafe { FromCStr::from_raw_buf(tmp_pointer) })
}
}
pub fn get_display_name(&self) -> Option<String> {
let tmp_pointer = unsafe { ffi::g_app_info_get_display_name(GTK_APP_INFO(self.unwrap_widget())) };
if tmp_pointer.is_null() {
None
} else {
Some(unsafe { FromCStr::from_raw_buf(tmp_pointer) })
}
}
pub fn get_description(&self) -> Option<String> {
let tmp_pointer = unsafe { ffi::g_app_info_get_description(GTK_APP_INFO(self.unwrap_widget())) };
if tmp_pointer.is_null() {
None
} else {
Some(unsafe { FromCStr::from_raw_buf(tmp_pointer) })
}
}
pub fn get_executable(&self) -> Option<String> {
let tmp_pointer = unsafe { ffi::g_app_info_get_executable(GTK_APP_INFO(self.unwrap_widget())) };
if tmp_pointer.is_null() {
None
} else {
Some(unsafe { FromCStr::from_raw_buf(tmp_pointer) })
}
}
pub fn get_commandline(&self) -> Option<String> {
let tmp_pointer = unsafe { ffi::g_app_info_get_commandline(GTK_APP_INFO(self.unwrap_widget())) };
if tmp_pointer.is_null() {
None
} else {
Some(unsafe { FromCStr::from_raw_buf(tmp_pointer) })
}
}
pub fn launch(&self, files: &mut glib::List, launch_context: &mut ::AppLaunchContext, error: &mut glib::Error) -> bool {
unsafe { to_bool({ ffi::g_app_info_launch(GTK_APP_INFO(self.unwrap_widget()),
files.unwrap(),
GTK_APP_LAUNCH_CONTEXT(launch_context.unwrap_widget()),
&mut error.unwrap()) }) }
}
pub fn supports_files(&self) -> bool {
unsafe { to_bool(ffi::g_app_info_supports_files(GTK_APP_INFO(self.unwrap_widget()))) }
}
pub fn supports_uris(&self) -> bool {
unsafe { to_bool(ffi::g_app_info_supports_uris(GTK_APP_INFO(self.unwrap_widget()))) }
}
pub fn launch_uris(&self, uris: &mut glib::List, launch_context: &mut ::AppLaunchContext, error: &mut glib::Error) -> bool {
unsafe { to_bool({ ffi::g_app_info_launch_uris(GTK_APP_INFO(self.unwrap_widget()),
uris.unwrap(),
GTK_APP_LAUNCH_CONTEXT(launch_context.unwrap_widget()),
&mut error.unwrap()) }) }
}
pub fn should_show(&self) -> bool {
unsafe { to_bool(ffi::g_app_info_should_show(GTK_APP_INFO(self.unwrap_widget()))) }
}
pub fn can_delete(&self) -> bool {
unsafe { to_bool(ffi::g_app_info_can_delete(GTK_APP_INFO(self.unwrap_widget()))) }
}
pub fn delete(&self) -> bool {
unsafe { to_bool(ffi::g_app_info_delete(GTK_APP_INFO(self.unwrap_widget()))) }
}
pub fn reset_type_associations(&self, content_type: &str) -> () {
unsafe {
let c_str = CString::from_slice(content_type.as_bytes());
ffi::g_app_info_reset_type_associations(c_str)
})
}
}
pub fn set_as_default_for_type(&self, content_type: &str, error: &mut glib::Error) -> bool {
unsafe { to_bool({
content_type.with_c_str(|c_str| {
ffi::g_app_info_set_as_default_for_type(GTK_APP_INFO(self.unwrap_widget()), c_str, &mut error.unwrap())
})
}) }
}
pub fn set_as_default_for_extension(&self, extension: &str, error: &mut glib::Error) -> bool {
unsafe { to_bool({
extension.with_c_str(|c_str| {
ffi::g_app_info_set_as_default_for_extension(GTK_APP_INFO(self.unwrap_widget()), c_str, &mut error.unwrap())
})
}) }
}
pub fn set_as_last_used_for_type(&self, content_type: &str, error: &mut glib::Error) -> bool {
unsafe { to_bool({
content_type.with_c_str(|c_str| {
ffi::g_app_info_set_as_last_used_for_type(GTK_APP_INFO(self.unwrap_widget()), c_str, &mut error.unwrap())
})
}) }
}
pub fn add_supports_type(&self, content_type: &str, error: &mut glib::Error) -> bool {
unsafe { to_bool({
content_type.with_c_str(|c_str| {
ffi::g_app_info_add_supports_type(GTK_APP_INFO(self.unwrap_widget()), c_str, &mut error.unwrap())
})
}) }
}
pub fn can_remove_supports_type(&self) -> bool {
unsafe { to_bool(ffi::g_app_info_can_remove_supports_type(GTK_APP_INFO(self.unwrap_widget()))) }
}
pub fn remove_supports_type(&self, content_type: &str, error: &mut glib::Error) -> bool {
unsafe { to_bool({
content_type.with_c_str(|c_str| {
ffi::g_app_info_remove_supports_type(GTK_APP_INFO(self.unwrap_widget()), c_str, &mut error.unwrap())
})
}) }
}
pub fn get_supported_types(&self) -> Vec<String> {
let types = unsafe { ffi::g_app_info_get_supported_types(GTK_APP_INFO(self.unwrap_widget())) };
let mut ret = Vec::new();
if types.is_not_null() {
let mut it = 0;
unsafe {
loop {
let tmp = types.offset(it);
if tmp.is_null() {
break;
}
ret.push(FromCStr::from_raw_buf(*tmp));
it += 1;
}
}
}
ret
}
pub fn get_all() -> Option<glib::List> {
assert_initialized_main_thread!();
let tmp_pointer = unsafe { ffi::g_app_info_get_all() };
if tmp_pointer.is_null() {
None
} else {
glib::GlibContainer::wrap(tmp_pointer)
}
}
pub fn get_all_for_type() -> Option<glib::List> {
assert_initialized_main_thread!();
let tmp_pointer = unsafe { ffi::g_app_info_get_all_for_type() };
if tmp_pointer.is_null() {
None
} else {
glib::GlibContainer::wrap(tmp_pointer)
}
}
pub fn get_default_for_type(content_type: &str, must_support_uris: bool) -> Option<AppInfo> {
assert_initialized_main_thread!();
let tmp_pointer = unsafe {
content_type.with_c_str(|c_str| {
ffi::g_app_info_get_default_for_type(c_str, to_gboolean(must_support_uris)) })
};
if tmp_pointer.is_null() {
None
} else {
Some(::FFIWidget::wrap_widget(tmp_pointer as *mut ::ffi::GtkWidget))
}
}
pub fn get_default_for_uri_scheme(uri_scheme: &str) -> Option<AppInfo> {
assert_initialized_main_thread!();
let tmp_pointer = unsafe {
uri_scheme.with_c_str(|c_str| {
ffi::g_app_info_get_default_for_uri_scheme(c_str)
})
};
if tmp_pointer.is_null() {
None
} else {
Some(::FFIWidget::wrap_widget(tmp_pointer as *mut ::ffi::GtkWidget))
}
}
pub fn get_fallback_for_type(content_type: &str) -> Option<glib::List> {
assert_initialized_main_thread!();
let tmp_pointer = unsafe {
content_type.with_c_str(|c_str| {
ffi::g_app_info_get_fallback_for_type(c_str)
})
};
if tmp_pointer.is_null() {
None
} else {
glib::GlibContainer::wrap(tmp_pointer)
}
}
pub fn get_recommended_for_type(content_type: &str) -> Option<glib::List> {
assert_initialized_main_thread!();
let tmp_pointer = unsafe {
content_type.with_c_str(|c_str| {
ffi::g_app_info_get_recommended_for_type(c_str)
})
};
if tmp_pointer.is_null() {
None
} else {
glib::GlibContainer::wrap(tmp_pointer)
}
}
pub fn launch_default_for_uri(uri: &str, launch_context: &::AppLaunchContext, error: &glib::Error) -> bool {
assert_initialized_main_thread!();
unsafe { to_bool({
uri.with_c_str(|c_str| {
ffi::g_app_info_launch_default_for_uri(c_str, GTK_APP_LAUNCH_CONTEXT(launch_context.unwrap_widget()), &mut error.unwrap())
}) }
}*/
}
/*impl Clone for AppInfo {
fn clone(&self) -> AppInfo {
let tmp_pointer = unsafe { ffi::g_app_info_dup(GTK_APP_INFO(self.unwrap_widget())) };
::FFIWidget::wrap_widget(tmp_pointer as *mut ::ffi::GtkWidget)
}
}
impl PartialEq for AppInfo {
fn eq(&self, other: &AppInfo) -> bool {
self.equals(other)
}
fn ne(&self, other: &AppInfo) -> bool {
!self.equals(other)
}
}*/
impl_drop!(AppInfo);
impl_TraitWidget!(AppInfo);