tyush 7c19ca4541 feat: add on_activated (#9)
* Expose Activated event

Allows users to set an ToastNotification.Activated callback. Currently requires the callback to be 'static; this likely can be fixed by some lifetime and boxing trickery at the cost of readability.

* Show callback functionality in example.

* Revert "Show callback functionality in example."

This reverts commit 62fc7a0bc6.

* Simplify callback in example.

May be a candidate for a new example instead of polluting the "simple" example.

* Change FnMut requirement to FnOnce

Loosens the requirements on `on_activated.` Turns out I had my Fn trait hierarchies wrong :(

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>

* Change callback back to FnMut, don't send params to callback

* Whoops that's not how closures move

* Remove callback params from simple.rs

* cargo fmt

* Create on-activated.md

* Update examples/simple.rs
2023-07-01 20:26:45 +03:00
2023-07-01 20:26:45 +03:00
2023-07-01 20:26:45 +03:00
2017-09-23 22:11:37 -07:00
2023-07-01 20:26:45 +03:00
2017-09-23 22:11:37 -07:00
2023-06-15 17:17:07 +03:00
2023-06-15 17:17:07 +03:00
2022-08-28 14:52:15 -03:00
2022-08-28 14:52:15 -03:00
2022-08-28 14:52:15 -03:00
2022-01-11 14:23:38 -08:00
2023-03-25 00:20:06 +02:00

winrt-notification

license version Build Status

An incomplete wrapper over the WinRT toast api

Tested in Windows 10 and 8.1. Untested in Windows 8, might work.

0.5 Documentation

0.2 Documentation

Todo:

  • Add support for Adaptive Content
  • Add support for Actions

Known Issues:

  • Will not work for Windows 7.

Limitations:

  • Windows 8.1 only supports a single image, the last image (icon, hero, image) will be the one on the toast

Usage

#Cargo.toml
[dependencies]
winrt-notification = "0.5.1"

Examples

extern crate winrt_notification;
use winrt_notification::{Duration, Sound, Toast};

fn main() {
    Toast::new(Toast::POWERSHELL_APP_ID)
        .title("Look at this flip!")
        .text1("(╯°□°)╯︵ ┻━┻")
        .sound(Some(Sound::SMS))
        .duration(Duration::Short)
        .show()
        .expect("unable to toast");
}
extern crate winrt_notification;
use std::path::Path;
use winrt_notification::{IconCrop, Toast};

fn main() {
    Toast::new("Your AppUserModeId")
        .hero(&Path::new("C:\\absolute\\path\\to\\image.jpeg"), "alt text")
        .icon(
            &Path::new("c:/this/style/works/too/image.png"),
            IconCrop::Circular,
            "alt text",
        )
        .title("Lots of pictures here")
        .text1("One above the text as the hero")
        .text2("One to the left as an icon, and several below")
        .image(&Path::new("c:/photos/sun.png"), "the sun")
        .image(&Path::new("c:/photos/moon.png"), "the moon")
        .sound(None) // will be silent
        .show()
        .expect("unable to toast");
}
Description
⚠️ ARCHIVED: Original GitHub repository no longer exists. Preserved as backup on 2026-01-31T05:34:44.328Z
Readme 1.1 MiB
Languages
Rust 100%