1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
// 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>

use Error;
use CssProvider;
use ffi;
use glib::translate::*;
use std::ptr;
use libc::ssize_t;

//Other functions autogenerated in src\auto\css_provider.rs
impl CssProvider {
    pub fn load_from_data(&self, data: &str) -> Result<(), Error> {
        unsafe {
            let mut error = ptr::null_mut();
            let _ = ffi::gtk_css_provider_load_from_data(self.to_glib_none().0, mut_override(data.as_bytes().as_ptr()),
                    data.len() as ssize_t, &mut error);
            if error.is_null() { Ok(()) } else { Err(from_glib_full(error)) }
        }
    }
}