Remove BoolError occurences
Because currently depends on unpublished glib binding.
This commit is contained in:
parent
d939bee7ea
commit
091ee97b70
@ -1,6 +1,6 @@
|
||||
use ffi;
|
||||
use glib::translate::*;
|
||||
use glib;
|
||||
use glib_ffi;
|
||||
use std::ptr;
|
||||
|
||||
|
||||
@ -18,13 +18,18 @@ pub fn is_initted() -> bool {
|
||||
///
|
||||
/// # Returns
|
||||
///
|
||||
/// `Ok(())` if successful, `Err(err)` on error.
|
||||
pub fn init(app_name: &str) -> Result<(), glib::error::BoolError> {
|
||||
/// `Ok(())` if successful, `Err(str)` on error.
|
||||
// TODO: switch back to BoolError when it hits stable glib
|
||||
pub fn init(app_name: &str) -> Result<(), String> {
|
||||
unsafe {
|
||||
glib::error::BoolError::from_glib(
|
||||
ffi::notify_init(app_name.to_glib_none().0),
|
||||
"Failed to initialize libnotify",
|
||||
)
|
||||
let b = ffi::notify_init(app_name.to_glib_none().0);
|
||||
|
||||
match b {
|
||||
glib_ffi::GFALSE => Err(
|
||||
String::from("Failed to initialize libnotify"),
|
||||
),
|
||||
_ => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,8 @@ impl Notification {
|
||||
/// # Returns
|
||||
///
|
||||
/// `true`, unless an invalid parameter was passed.
|
||||
/// `Ok(())` on success, or `Err(err)` if an invalid parameter was passed
|
||||
/// `Ok(())` on success, or `Err(str)` if an invalid parameter was passed
|
||||
// TODO: switch back to BoolError when it hits stable glib
|
||||
pub fn update<
|
||||
'a,
|
||||
'b,
|
||||
@ -225,21 +226,24 @@ impl Notification {
|
||||
summary: &str,
|
||||
body: P,
|
||||
icon: Q,
|
||||
) -> Result<(), glib::error::BoolError> {
|
||||
) -> Result<(), String> {
|
||||
let body = body.into();
|
||||
let body = body.to_glib_none();
|
||||
let icon = icon.into();
|
||||
let icon = icon.to_glib_none();
|
||||
unsafe {
|
||||
glib::error::BoolError::from_glib(
|
||||
ffi::notify_notification_update(
|
||||
let b = ffi::notify_notification_update(
|
||||
self.to_glib_none().0,
|
||||
summary.to_glib_none().0,
|
||||
body.0,
|
||||
icon.0,
|
||||
);
|
||||
match b {
|
||||
glib_ffi::GFALSE => Err(
|
||||
String::from("Invalid parameter passed"),
|
||||
),
|
||||
"Invalid parameter passed",
|
||||
)
|
||||
_ => Ok(()),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user