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
use Error;
use CssProvider;
use ffi;
use glib::object::IsA;
use glib::translate::*;
use std::ptr;
use libc::ssize_t;
pub trait CssProviderExtManual {
fn load_from_data(&self, data: &str) -> Result<(), Error>;
}
impl<O: IsA<CssProvider>> CssProviderExtManual for O {
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)) }
}
}
}