gtk/
recent_data.rs

1// Copyright 2013-2015, 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 glib::translate::*;
6use gtk_sys;
7use libc::c_char;
8
9pub struct RecentData {
10    pub display_name: Option<String>,
11    pub description: Option<String>,
12    pub mime_type: String,
13    pub app_name: String,
14    pub app_exec: String,
15    pub groups: Vec<String>,
16    pub is_private: bool,
17}
18
19#[doc(hidden)]
20impl<'a> ToGlibPtr<'a, *mut gtk_sys::GtkRecentData> for RecentData {
21    type Storage = (
22        Box<gtk_sys::GtkRecentData>,
23        [Stash<'a, *mut c_char, Option<String>>; 2],
24        [Stash<'a, *mut c_char, String>; 3],
25        Stash<'a, *mut *mut c_char, [String]>,
26    );
27
28    fn to_glib_none(&'a self) -> Stash<'a, *mut gtk_sys::GtkRecentData, Self> {
29        let display_name = self.display_name.to_glib_none();
30        let description = self.description.to_glib_none();
31        let mime_type = self.mime_type.to_glib_none();
32        let app_name = self.app_name.to_glib_none();
33        let app_exec = self.app_exec.to_glib_none();
34        let groups = self.groups.to_glib_none();
35
36        let mut data = Box::new(gtk_sys::GtkRecentData {
37            display_name: display_name.0,
38            description: description.0,
39            mime_type: mime_type.0,
40            app_name: app_name.0,
41            app_exec: app_exec.0,
42            groups: groups.0,
43            is_private: self.is_private.to_glib(),
44        });
45
46        Stash(
47            &mut *data,
48            (
49                data,
50                [display_name, description],
51                [mime_type, app_name, app_exec],
52                groups,
53            ),
54        )
55    }
56}