Tested and fixed tray icon on Linux.
This commit is contained in:
@@ -26,7 +26,7 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: Install dependencies
|
||||
run: sudo apt update && sudo apt install libwebkit2gtk-4.1-dev libsoup-3.0-dev
|
||||
run: sudo apt update && sudo apt install libwebkit2gtk-4.1-dev libxdo-dev libsoup-3.0-dev
|
||||
if: contains(matrix.os, 'ubuntu')
|
||||
|
||||
- name: Update Rust
|
||||
|
||||
@@ -67,7 +67,7 @@ jobs:
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt upgrade
|
||||
sudo apt install libwebkit2gtk-4.1-dev libsoup-3.0-dev upx-ucl
|
||||
sudo apt install libwebkit2gtk-4.1-dev libxdo-dev libsoup-3.0-dev upx-ucl
|
||||
cargo install cross
|
||||
|
||||
- name: Build and package deb packages
|
||||
@@ -99,7 +99,7 @@ jobs:
|
||||
|
||||
- name: install dependencies
|
||||
if: contains(matrix.os, 'ubuntu')
|
||||
run: sudo apt update && sudo apt install --no-install-recommends libwebkit2gtk-4.1-dev libsoup-3.0-dev upx-ucl
|
||||
run: sudo apt update && sudo apt install --no-install-recommends libwebkit2gtk-4.1-dev libxdo-dev libsoup-3.0-dev upx-ucl
|
||||
|
||||
- name: Build release binaries
|
||||
run: cargo build --release
|
||||
|
||||
Generated
+60
-2
@@ -56,6 +56,7 @@ dependencies = [
|
||||
"ecies-ed25519-ng",
|
||||
"ed25519-dalek",
|
||||
"getopts",
|
||||
"image",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"lru",
|
||||
@@ -222,12 +223,24 @@ version = "3.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
||||
|
||||
[[package]]
|
||||
name = "bytemuck"
|
||||
version = "1.24.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder-lite"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
|
||||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.10.1"
|
||||
@@ -1440,6 +1453,19 @@ dependencies = [
|
||||
"icu_properties",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "image"
|
||||
version = "0.25.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "529feb3e6769d234375c4cf1ee2ce713682b8e76538cb13f9fc23e1400a591e7"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder-lite",
|
||||
"moxcms",
|
||||
"num-traits",
|
||||
"png 0.18.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.12.0"
|
||||
@@ -1741,6 +1767,16 @@ dependencies = [
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "moxcms"
|
||||
version = "0.7.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fbdd3d7436f8b5e892b8b7ea114271ff0fa00bc5acae845d53b07d498616ef6"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
"pxfm",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "muda"
|
||||
version = "0.17.1"
|
||||
@@ -1757,7 +1793,7 @@ dependencies = [
|
||||
"objc2-core-foundation",
|
||||
"objc2-foundation",
|
||||
"once_cell",
|
||||
"png",
|
||||
"png 0.17.16",
|
||||
"thiserror 2.0.17",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
@@ -2225,6 +2261,19 @@ dependencies = [
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "png"
|
||||
version = "0.18.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97baced388464909d42d89643fe4361939af9b7ce7a31ee32a168f832a70f2a0"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"crc32fast",
|
||||
"fdeflate",
|
||||
"flate2",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "poly1305"
|
||||
version = "0.8.0"
|
||||
@@ -2346,6 +2395,15 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pxfm"
|
||||
version = "0.1.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3cbdf373972bf78df4d3b518d07003938e2c7d1fb5891e55f9cb6df57009d84"
|
||||
dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.41"
|
||||
@@ -3192,7 +3250,7 @@ dependencies = [
|
||||
"objc2-core-graphics",
|
||||
"objc2-foundation",
|
||||
"once_cell",
|
||||
"png",
|
||||
"png 0.17.16",
|
||||
"thiserror 2.0.17",
|
||||
"windows-sys 0.60.2",
|
||||
]
|
||||
|
||||
@@ -48,6 +48,9 @@ tray-icon = { version = "0.21.2", optional = true }
|
||||
tinyfiledialogs = { version = "3.9.1", optional = true }
|
||||
open = { version = "5.3.0", optional = true }
|
||||
|
||||
[target.'cfg(not(target_os = "windows"))'.dependencies]
|
||||
image = { version = "0.25", default-features = false, features = ["png"] }
|
||||
|
||||
[target.'cfg(windows)'.dependencies]
|
||||
winapi = { version = "0.3.9", features = ["impl-default", "wincon", "shellscalingapi"] }
|
||||
windows-service = "0.8.0"
|
||||
|
||||
@@ -58,8 +58,8 @@ cargo build
|
||||
```
|
||||
|
||||
###  On Linux
|
||||
If you are building on Linux, you must ensure that you have `libwebkitgtk` library installed.
|
||||
You can do it by issuing this command: `sudo apt install libwebkit2gtk-4.1-dev` (on Debian/Ubuntu and derivatives).
|
||||
If you are building on Linux, you must ensure that you have `libwebkitgtk` and `libxdo` libraries installed (for UI and tray icon respectively).
|
||||
You can do it by issuing this command: `sudo apt install libwebkit2gtk-4.1-dev libxdo-dev` (on Debian/Ubuntu and derivatives).
|
||||
|
||||
####  On Arch Linux
|
||||
|
||||
|
||||
+23
-3
@@ -18,6 +18,7 @@ use alfis::eventbus::{post, register};
|
||||
use alfis::miner::Miner;
|
||||
use alfis::{keystore, Block, Bytes, Context, Keystore, Transaction};
|
||||
use chrono::{Local, Utc};
|
||||
use image::GenericImageView;
|
||||
#[allow(unused_imports)]
|
||||
use log::{debug, error, info, trace, warn, LevelFilter};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -56,8 +57,10 @@ pub fn run_interface(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>, hid
|
||||
#[cfg(windows)]
|
||||
let icon = tray_icon::Icon::from_resource(1, None).unwrap();
|
||||
// Create tray icon
|
||||
#[cfg(windows)]
|
||||
let _tray_icon = TrayIconBuilder::new()
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
let icon = load_icon_from_png();
|
||||
|
||||
let tray_icon = TrayIconBuilder::new()
|
||||
.with_menu(Box::new(tray_menu))
|
||||
.with_tooltip(&title)
|
||||
.with_icon(icon)
|
||||
@@ -370,7 +373,7 @@ pub fn run_interface(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>, hid
|
||||
TrayIconEvent::Enter { .. } => {
|
||||
let nodes = connected_nodes.load(Ordering::SeqCst);
|
||||
let title = format!("ALFIS {}\nConnected: {nodes}", env!("CARGO_PKG_VERSION"));
|
||||
let _ = _tray_icon.set_tooltip(Some(title));
|
||||
let _ = tray_icon.set_tooltip(Some(title));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
@@ -403,6 +406,23 @@ enum UserEvent {
|
||||
MenuEvent(MenuEvent)
|
||||
}
|
||||
|
||||
/// Load icon from embedded in binary PNG file. Only needed in Linux/macOS builds.
|
||||
#[cfg(not(target_os = "windows"))]
|
||||
fn load_icon_from_png() -> tray_icon::Icon {
|
||||
// Include PNG in binary
|
||||
const ICON_BYTES: &[u8] = include_bytes!("../img/logo/alfis_icon32.png");
|
||||
|
||||
// decode image by crate `image`
|
||||
let image = image::load_from_memory(ICON_BYTES)
|
||||
.expect("Error loading image from png");
|
||||
let rgba = image.to_rgba8();
|
||||
let (width, height) = image.dimensions();
|
||||
|
||||
// Convert to format for tray_icon
|
||||
tray_icon::Icon::from_rgba(rgba.into_vec(), width, height)
|
||||
.expect("Error loading icon")
|
||||
}
|
||||
|
||||
fn check_record(data: &str) -> bool {
|
||||
match serde_json::from_str::<DnsRecord>(data) {
|
||||
Ok(record) => {
|
||||
|
||||
Reference in New Issue
Block a user