gio/
desktop_app_info.rs

1// Copyright 2017, 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_sys;
6use glib::translate::*;
7use glib::GString;
8use glib_sys;
9use libc;
10use DesktopAppInfo;
11
12impl DesktopAppInfo {
13    pub fn search(search_string: &str) -> Vec<Vec<GString>> {
14        unsafe {
15            let out = gio_sys::g_desktop_app_info_search(search_string.to_glib_none().0);
16
17            if out.is_null() {
18                return Vec::new();
19            }
20
21            let mut ret = Vec::new();
22            let mut it = 0;
23            loop {
24                let tmp: *mut *mut libc::c_char = *out.offset(it);
25
26                if tmp.is_null() {
27                    break;
28                }
29                let v: Vec<GString> = FromGlibPtrContainer::from_glib_full(tmp);
30                ret.push(v);
31                it += 1;
32            }
33
34            glib_sys::g_free(out as *mut libc::c_void);
35            ret
36        }
37    }
38}