Skip to content

Commit

Permalink
feat: add sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
amrbashir committed Oct 5, 2021
1 parent 2fdc444 commit f667d6f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 35 deletions.
4 changes: 4 additions & 0 deletions .changes/sounds.md
@@ -0,0 +1,4 @@
---
"win7-notifications": minor
---
Add sounds
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -12,7 +12,7 @@ This crate requires a win32 event loop to be running, otherwise the notification
### TODO:
- [X] Move old notifications above new ones.
- [ ] Animations
- [ ] Sounds
- [X] Sounds
- [X] Shadows
- [ ] Change close button color when mouse hovers.
- [ ] Callbacks for when close button or body of notification is clicked.
3 changes: 2 additions & 1 deletion build.rs
Expand Up @@ -7,8 +7,9 @@ fn main() {
Windows::Win32::Foundation::{HWND, LPARAM, LRESULT, PWSTR, WPARAM, POINT},
Windows::Win32::System::LibraryLoader::{GetModuleHandleW},
Windows::Win32::System::Com::{CoCreateInstance, CoInitialize},
Windows::Win32::System::Diagnostics::Debug::MessageBeep,
Windows::Win32::Graphics::Gdi::*,
Windows::Win32::Graphics::Dwm::*,
Windows::Win32::Graphics::Dwm::{DwmExtendFrameIntoClientArea},
Windows::Win32::UI::Shell::{ITaskbarList, TaskbarList},
Windows::Win32::UI::Controls::*,
Windows::Win32::UI::WindowsAndMessaging::*,
Expand Down
42 changes: 10 additions & 32 deletions examples/multiple.rs
Expand Up @@ -9,38 +9,16 @@ fn main() {

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 1.")
.icon(icon.to_vec())
.timeout(Timeout::Never)
.show()
.unwrap();
Notification::new()
.appname("App name")
.summary("Critical Error")
.body("Just kidding, this is just the notification example 2.")
.icon(icon.to_vec())
.timeout(Timeout::Default)
.show()
.unwrap();
Notification::new()
.appname("App name")
.summary("Critical Error")
.body("Just kidding, this is just the notification example 3.")
.icon(icon.to_vec())
.timeout(Timeout::Never)
.show()
.unwrap();
Notification::new()
.appname("App name")
.summary("Critical Error")
.body("Just kidding, this is just the notification example 4.")
.icon(icon.to_vec())
.timeout(Timeout::Default)
.show()
.unwrap();
for i in 1..4 {
Notification::new()
.appname("App name")
.summary("Critical Error")
.body(format!("Just kidding, this is just the notification example {}.", i).as_str())
.icon(icon.to_vec())
.timeout(Timeout::Default)
.show()
.unwrap();
}
}
_ => (),
});
Expand Down
3 changes: 2 additions & 1 deletion src/notification.rs
Expand Up @@ -12,7 +12,7 @@ use crate::Windows::Win32::{
Foundation as w32f,
Graphics::Dwm,
Graphics::Gdi,
System::LibraryLoader,
System::{Diagnostics::Debug, LibraryLoader},
UI::{Controls, WindowsAndMessaging as w32wm},
};
use crate::{
Expand Down Expand Up @@ -186,6 +186,7 @@ impl Notification {

util::skip_taskbar(hwnd)?;
w32wm::ShowWindow(hwnd, w32wm::SW_SHOWDEFAULT);
Debug::MessageBeep(w32wm::MB_OK.0);

let timeout = self.timeout;
spawn(move || {
Expand Down

0 comments on commit f667d6f

Please sign in to comment.