Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
125 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"win7-notifications": "minor" | ||
--- | ||
|
||
**Breaking change** Notification icon must be "32bpp RGBA data" and width and height must be specified now, check `Notification::icon` for more info. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,3 +38,4 @@ features = [ | |
|
||
[dev-dependencies] | ||
tao = "0.6.2" | ||
image = "0.24" |
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,35 @@ | ||
use std::path::Path; | ||
|
||
use tao::{ | ||
event::{Event, StartCause}, | ||
event_loop::EventLoop, | ||
}; | ||
use win7_notifications::{Notification, Timeout}; | ||
fn main() { | ||
let event_loop = EventLoop::new(); | ||
let icon = include_bytes!("icon.ico"); | ||
let path = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/icon.png"); | ||
let (icon, w, h) = load_icon(Path::new(path)); | ||
|
||
event_loop.run(move |event, _, _| match event { | ||
Event::NewEvents(e) if e == StartCause::Init => { | ||
Notification::new() | ||
.appname("App name") | ||
.summary("Critical Error") | ||
.body("Just kidding, this is just the notification example.") | ||
.icon(icon.to_vec()) | ||
.icon(icon.clone(), w, h) | ||
.timeout(Timeout::Default) | ||
.show() | ||
.unwrap(); | ||
} | ||
_ => (), | ||
}); | ||
} | ||
|
||
fn load_icon(path: &Path) -> (Vec<u8>, u32, u32) { | ||
let image = image::open(path) | ||
.expect("Failed to open icon path") | ||
.into_rgba8(); | ||
let (width, height) = image.dimensions(); | ||
let rgba = image.into_raw(); | ||
(rgba, width, height) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters