13 Commits

Author SHA1 Message Date
Mika Attila
d19aadb4d2 Version bump 2015-10-24 14:55:05 +02:00
Mika Attila
7556615e78 Specify exact versions of dependencies 2015-10-24 14:54:47 +02:00
Mika Attila
1636812abc Merge pull request #1 from mzabaluev/rename-glib-sys
Renaming of glib packages
2015-10-23 22:51:28 +02:00
Mikhail Zabaluev
d979d8a2d1 Renamed glib packages
I'm going to normalize the package names in gi-rust, while also switching
to generated code that provides nearly all of the library API. This
package is one of the few that depends on the current name.
2015-10-23 23:34:09 +03:00
Mika Attila
d23eabffea Version bump 2015-09-19 09:42:31 +02:00
Mika Attila
ffd99b67e2 Depend on gtypes 2015-09-19 09:42:17 +02:00
Mika Attila
72df2c0adb Version bump 2015-03-27 08:34:00 +01:00
Mika Attila
dac1075025 Update to new crate naming rules 2015-03-25 19:04:43 +01:00
Mika Attila
d3ad5323fb Update doc example 2015-03-10 19:18:44 +01:00
Mika Attila
445f0b6d13 Implement std::fmt::Display for the error types 2015-03-10 19:14:18 +01:00
Mika Attila
a0955acabd Add example to the documentation 2015-03-10 08:46:54 +01:00
Mika Attila
e9665b08c2 Version bump 2015-03-09 21:18:05 +01:00
Mika Attila
c66aec1c86 Add documentation link 2015-03-09 21:17:41 +01:00
3 changed files with 57 additions and 10 deletions

View File

@@ -1,14 +1,16 @@
[package]
name = "libnotify"
version = "0.0.1"
version = "0.1.0"
authors = ["Mika Attila <radiantstatue@gmail.com>"]
license = "MIT"
description = "Rust bindings to libnotify"
readme = "README.md"
repository = "https://github.com/crumblingstatue/rust-libnotify"
documentation = "http://crumblingstatue.github.io/doc/libnotify/libnotify/"
keywords = ["libnotify", "notification"]
[dependencies]
libnotify-sys = "*"
glib-2_0-sys = "*"
libnotify-sys = "0.2.0"
glib-2-0-sys = "0.46.0"
gtypes = "0.1.2"

View File

@@ -1,9 +1,12 @@
extern crate libnotify;
fn main() {
let notify = libnotify::Context::new("hello").unwrap();
let notify = libnotify::Context::new("hello").unwrap_or_else(|e| {
panic!("{}", e);
});
let body_text = Some("This is the optional body text.");
let n = notify.new_notification("This is the summary.",
Some("This is the optional body text."),
None).unwrap();
n.show().unwrap();
body_text,
None).unwrap_or_else(|e| panic!("{}", e));
n.show().ok().expect("Failed to show notification");
}

View File

@@ -1,10 +1,31 @@
extern crate "libnotify-sys" as sys;
extern crate "glib-2_0-sys" as glib;
//! Rustic bindings to [libnotify](https://developer.gnome.org/libnotify/)
//!
//! ```rust
//! extern crate libnotify;
//!
//! fn main() {
//! let notify = libnotify::Context::new("hello").unwrap_or_else(|e| {
//! panic!("{}", e);
//! });
//! let body_text = Some("This is the optional body text.");
//! let n = notify.new_notification("This is the summary.",
//! body_text,
//! None).unwrap_or_else(|e| {
//! panic!("{}", e);
//! });
//! n.show().ok().expect("Failed to show notification");
//! }
//! ```
extern crate libnotify_sys as sys;
extern crate glib_2_0_sys as glib;
extern crate gtypes;
use std::ffi::CString;
use std::marker::PhantomData;
use std::fmt;
use glib::types::{
use gtypes::{
TRUE,
FALSE
};
@@ -18,12 +39,33 @@ pub enum ContextCreationError {
NulError
}
impl fmt::Display for ContextCreationError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
use ContextCreationError::*;
match *self {
AlreadyExists => write!(f, "A Libnotify context already exists."),
InitFailure => write!(f, "Failed to initialize libnotify."),
NulError => write!(f, "Argument contains a nul character.")
}
}
}
#[derive(Debug)]
pub enum NotificationCreationError {
NulError,
Unknown
}
impl fmt::Display for NotificationCreationError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
use NotificationCreationError::*;
match *self {
NulError => write!(f, "Argument contains a nul character."),
Unknown => write!(f, "Unknown error")
}
}
}
/// The context which within libnotify operates.
///
/// Only one context can exist at a time.