mirror of
https://github.com/szymon-jozef/libnotify-rs.git
synced 2026-10-27 19:20:43 +01:00
Compare commits
5 Commits
feat/clap
...
fix/compil
| Author | SHA1 | Date | |
|---|---|---|---|
| 6d8672537f | |||
| 0e2e97bf66 | |||
| 025ab6af68 | |||
| 034a302f3b | |||
|
|
987cd449c5 |
@@ -27,9 +27,11 @@ Available at [github pages](https://szymon-jozef.github.io/libnotify-rs/libnotif
|
|||||||
## Add to project
|
## Add to project
|
||||||
Type in:
|
Type in:
|
||||||
```bash
|
```bash
|
||||||
cargo add --git "https://github.com/szymon-jozef/libnotify-rs"
|
cargo add --git "https://github.com/szymon-jozef/libnotify-rs" --tag <desired version>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Tag argument is optional, but encouraged.
|
||||||
|
|
||||||
### Nix flake
|
### Nix flake
|
||||||
For nix users, there is also a flake inside. If you want to use it add this to your flake:
|
For nix users, there is also a flake inside. If you want to use it add this to your flake:
|
||||||
|
|
||||||
|
|||||||
7
build.rs
7
build.rs
@@ -2,7 +2,9 @@ use std::env;
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let library = pkg_config::Config::new().probe("libnotify").unwrap();
|
let library = pkg_config::Config::new()
|
||||||
|
.probe("libnotify")
|
||||||
|
.expect("Cannot locate libnotify. Is it installed?");
|
||||||
|
|
||||||
let paths = library
|
let paths = library
|
||||||
.include_paths
|
.include_paths
|
||||||
@@ -17,7 +19,8 @@ fn main() {
|
|||||||
.generate()
|
.generate()
|
||||||
.expect("Unable to generate bindings");
|
.expect("Unable to generate bindings");
|
||||||
|
|
||||||
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
|
let out_path =
|
||||||
|
PathBuf::from(env::var("OUT_DIR").expect("Out $OUT_DIR not set. Perhaps a bindgen error?"));
|
||||||
|
|
||||||
bindings
|
bindings
|
||||||
.write_to_file(out_path.join("bindings.rs"))
|
.write_to_file(out_path.join("bindings.rs"))
|
||||||
|
|||||||
@@ -47,7 +47,6 @@ pub enum HintValue {
|
|||||||
|
|
||||||
/// Notification timeout, until close
|
/// Notification timeout, until close
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
#[cfg_attr(feature = "clap", derive(clap::ValueEnum))]
|
|
||||||
pub enum Timeout {
|
pub enum Timeout {
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
Default,
|
Default,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
//!
|
//!
|
||||||
//! # Features
|
//! # Features
|
||||||
//!
|
//!
|
||||||
//! - clap – enables [clap] support for `Urgency` and `Timeout` enums
|
//! - clap – enables [clap] support for `Urgency`
|
||||||
//!
|
//!
|
||||||
#![allow(non_upper_case_globals)]
|
#![allow(non_upper_case_globals)]
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types)]
|
||||||
|
|||||||
@@ -34,42 +34,62 @@ impl<'a> NotificationBuilder<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Sets app name for this specific notification.
|
/// Sets app name for this specific notification.
|
||||||
pub fn set_app_name(mut self, app_name: &str) -> Result<Self, LibnotifyError> {
|
pub fn set_app_name<T: Into<Option<&'a str>>>(
|
||||||
self.notification.set_app_name(app_name)?;
|
mut self,
|
||||||
|
app_name: T,
|
||||||
|
) -> Result<Self, LibnotifyError> {
|
||||||
|
if let Some(app_name) = app_name.into() {
|
||||||
|
self.notification.set_app_name(app_name)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets app icon fot this specific notification.
|
/// Sets app icon fot this specific notification.
|
||||||
pub fn set_app_icon(mut self, app_icon: &str) -> Result<Self, LibnotifyError> {
|
pub fn set_app_icon<T: Into<Option<&'a str>>>(
|
||||||
self.notification.set_app_icon(app_icon)?;
|
mut self,
|
||||||
|
app_icon: T,
|
||||||
|
) -> Result<Self, LibnotifyError> {
|
||||||
|
if let Some(app_icon) = app_icon.into() {
|
||||||
|
self.notification.set_app_icon(app_icon)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets category for this specific notification
|
/// Sets category for this specific notification
|
||||||
pub fn set_category(mut self, category: &str) -> Result<Self, LibnotifyError> {
|
pub fn set_category<T: Into<Option<&'a str>>>(
|
||||||
self.notification.set_category(category)?;
|
mut self,
|
||||||
|
category: T,
|
||||||
|
) -> Result<Self, LibnotifyError> {
|
||||||
|
if let Some(category) = category.into() {
|
||||||
|
self.notification.set_category(category)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set hint for this specific notification
|
/// Set hint for this specific notification
|
||||||
pub fn set_hint(
|
pub fn set_hint(mut self, key: &str, value: HintValue) -> Result<Self, LibnotifyError> {
|
||||||
mut self,
|
|
||||||
key: &str,
|
|
||||||
value: HintValue,
|
|
||||||
) -> Result<Self, Box<dyn std::error::Error>> {
|
|
||||||
self.notification.set_hint(key, value)?;
|
self.notification.set_hint(key, value)?;
|
||||||
Ok(self)
|
Ok(self)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set timeout until close
|
/// Set timeout until close
|
||||||
pub fn set_timeout(mut self, timeout: Timeout) -> Self {
|
pub fn set_timeout<T: Into<Option<Timeout>>>(mut self, timeout: T) -> Self {
|
||||||
self.notification.set_timeout(timeout);
|
if let Some(timeout) = timeout.into() {
|
||||||
|
self.notification.set_timeout(timeout);
|
||||||
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Set notification urgency level
|
/// Set notification urgency level
|
||||||
pub fn set_urgency(mut self, urgency: Urgency) -> Self {
|
pub fn set_urgency<T: Into<Option<Urgency>>>(mut self, urgency: T) -> Self {
|
||||||
self.notification.set_urgency(urgency);
|
if let Some(urgency) = urgency.into() {
|
||||||
|
self.notification.set_urgency(urgency);
|
||||||
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user