mirror of
https://github.com/MeexReay/bRAC.git
synced 2025-06-23 18:32:58 +03:00
notify-rust
This commit is contained in:
parent
78e0caa641
commit
d2ad18ba89
771
Cargo.lock
generated
771
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -17,6 +17,7 @@ chrono = "0.4.40"
|
||||
serde_default = "0.2.0"
|
||||
socks = "0.3.4"
|
||||
libnotify = { version = "1.0.3", optional = true }
|
||||
notify-rust = { version = "4.11.7", optional = true }
|
||||
gdk-pixbuf = { version = "0.3.0", optional = true } # DO NOT UPDATE
|
||||
winapi = { version = "0.3.9", optional = true, features = ["wincon", "winuser"] }
|
||||
tungstenite = "0.27.0"
|
||||
@ -24,6 +25,7 @@ tungstenite = "0.27.0"
|
||||
[features]
|
||||
default = []
|
||||
libnotify = ["dep:libnotify", "dep:gdk-pixbuf"]
|
||||
notify-rust = ["dep:notify-rust"]
|
||||
winapi = ["dep:winapi"]
|
||||
|
||||
[build-dependencies]
|
||||
|
@ -13,7 +13,7 @@
|
||||
- Add `C:\gtk\lib` to the Lib variable (or create one if doesnt exist)
|
||||
- Apply and close the window (maybe restart PC)
|
||||
5. Open the repository directory in console (download it from github or with `git clone https://github.com/MeexReay/bRAC.git`)
|
||||
6. Run `cargo build -r -F winapi`
|
||||
6. Run `cargo build -r -F winapi,notify-rust`
|
||||
7. Done! Your finished binary is in the `target/release` folder.
|
||||
|
||||
## Linux / MacOS
|
||||
@ -31,22 +31,25 @@
|
||||
|
||||
Black frame appears on connecting to the server or when bRAC just freezes. Be patient.
|
||||
|
||||
### Notifications dont work
|
||||
|
||||
As GNotifications dont work on Windows, we need to send notifications through winapi.
|
||||
Development of this feature is active, you can participate in it by making a pull requests.
|
||||
|
||||
## MacOS
|
||||
|
||||
### Notifications dont work
|
||||
|
||||
Switch to `libnotify` by adding the feature to cargo: `cargo build -r -F libnotify`
|
||||
There are two solutions:
|
||||
|
||||
- Switch to `libnotify`:
|
||||
|
||||
Add the feature `libnotify` to cargo: `cargo build -r -F libnotify`
|
||||
|
||||
- Switch to `notify-rust`:
|
||||
|
||||
Add the feature `notify-rust` to cargo: `cargo build -r -F notify-rust`
|
||||
|
||||
## Linux
|
||||
|
||||
### Notifications dont work
|
||||
|
||||
There are Two solutions:
|
||||
There are two solutions:
|
||||
|
||||
- Switch to `libnotify`:
|
||||
|
||||
|
@ -41,7 +41,7 @@ struct UiModel {
|
||||
window: ApplicationWindow,
|
||||
#[cfg(feature = "libnotify")]
|
||||
notifications: Arc<RwLock<Vec<libnotify::Notification>>>,
|
||||
#[cfg(not(feature = "libnotify"))]
|
||||
#[cfg(all(not(feature = "libnotify"), not(feature = "notify-rust")))]
|
||||
notifications: Arc<RwLock<Vec<String>>>,
|
||||
}
|
||||
|
||||
@ -777,7 +777,7 @@ fn build_ui(ctx: Arc<Context>, app: &Application) -> UiModel {
|
||||
window: window.clone(),
|
||||
#[cfg(feature = "libnotify")]
|
||||
notifications: Arc::new(RwLock::new(Vec::<libnotify::Notification>::new())),
|
||||
#[cfg(not(feature = "libnotify"))]
|
||||
#[cfg(all(not(feature = "libnotify"), not(feature = "notify-rust")))]
|
||||
notifications: Arc::new(RwLock::new(Vec::<String>::new())),
|
||||
}
|
||||
}
|
||||
@ -805,6 +805,7 @@ fn setup(_: &Application, ctx: Arc<Context>, ui: UiModel) {
|
||||
}
|
||||
});
|
||||
|
||||
#[cfg(not(feature = "notify-rust"))]
|
||||
GLOBAL.with(|global| {
|
||||
if let Some(ui) = &*global.borrow() {
|
||||
#[cfg(feature = "libnotify")]
|
||||
@ -868,6 +869,20 @@ fn load_css(is_dark_theme: bool) {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(feature = "notify-rust")]
|
||||
fn send_notification(_: Arc<Context>, _: &UiModel, title: &str, message: &str) {
|
||||
use notify_rust::{Notification, Timeout};
|
||||
|
||||
Notification::new()
|
||||
.summary(title)
|
||||
.body(message)
|
||||
.auto_icon()
|
||||
.appname("bRAC")
|
||||
.timeout(Timeout::Default) // this however is
|
||||
.show()
|
||||
.expect("notify-rust send error");
|
||||
}
|
||||
|
||||
#[cfg(feature = "libnotify")]
|
||||
fn send_notification(_: Arc<Context>, ui: &UiModel, title: &str, message: &str) {
|
||||
use libnotify::Notification;
|
||||
@ -885,7 +900,7 @@ fn send_notification(_: Arc<Context>, ui: &UiModel, title: &str, message: &str)
|
||||
ui.notifications.write().unwrap().push(notification);
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "libnotify"))]
|
||||
#[cfg(all(not(feature = "libnotify"), not(feature = "notify-rust")))]
|
||||
fn send_notification(_: Arc<Context>, ui: &UiModel, title: &str, message: &str) {
|
||||
use std::{
|
||||
hash::{DefaultHasher, Hasher},
|
||||
@ -915,7 +930,13 @@ fn send_notification(_: Arc<Context>, ui: &UiModel, title: &str, message: &str)
|
||||
}
|
||||
|
||||
fn on_add_message(ctx: Arc<Context>, ui: &UiModel, message: String, notify: bool) {
|
||||
let Some(message) = sanitize_message(message) else {
|
||||
let formatting_enabled = ctx.config(|c| c.formatting_enabled);
|
||||
|
||||
let Some(message) = (if formatting_enabled {
|
||||
sanitize_message(message)
|
||||
} else {
|
||||
Some(message)
|
||||
}) else {
|
||||
return;
|
||||
};
|
||||
|
||||
@ -933,7 +954,9 @@ fn on_add_message(ctx: Arc<Context>, ui: &UiModel, message: String, notify: bool
|
||||
|
||||
let mut label = String::new();
|
||||
|
||||
if let Some((date, ip, content, nick)) = parse_message(message.clone()) {
|
||||
if let (true, Some((date, ip, content, nick))) =
|
||||
(formatting_enabled, parse_message(message.clone()))
|
||||
{
|
||||
if let Some(ip) = ip {
|
||||
if ctx.config(|o| o.show_other_ip) {
|
||||
label.push_str(&format!(
|
||||
|
Loading…
x
Reference in New Issue
Block a user