Tested and fixed tray icon on Linux.
This commit is contained in:
@@ -26,7 +26,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
- name: Install dependencies
|
- 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')
|
if: contains(matrix.os, 'ubuntu')
|
||||||
|
|
||||||
- name: Update Rust
|
- name: Update Rust
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
sudo apt update
|
sudo apt update
|
||||||
sudo apt upgrade
|
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
|
cargo install cross
|
||||||
|
|
||||||
- name: Build and package deb packages
|
- name: Build and package deb packages
|
||||||
@@ -99,7 +99,7 @@ jobs:
|
|||||||
|
|
||||||
- name: install dependencies
|
- name: install dependencies
|
||||||
if: contains(matrix.os, 'ubuntu')
|
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
|
- name: Build release binaries
|
||||||
run: cargo build --release
|
run: cargo build --release
|
||||||
|
|||||||
Generated
+60
-2
@@ -56,6 +56,7 @@ dependencies = [
|
|||||||
"ecies-ed25519-ng",
|
"ecies-ed25519-ng",
|
||||||
"ed25519-dalek",
|
"ed25519-dalek",
|
||||||
"getopts",
|
"getopts",
|
||||||
|
"image",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"log",
|
"log",
|
||||||
"lru",
|
"lru",
|
||||||
@@ -222,12 +223,24 @@ version = "3.19.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bytemuck"
|
||||||
|
version = "1.24.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fbdf580320f38b612e485521afda1ee26d10cc9884efaaa750d383e13e3c5f4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder-lite"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.10.1"
|
version = "1.10.1"
|
||||||
@@ -1440,6 +1453,19 @@ dependencies = [
|
|||||||
"icu_properties",
|
"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]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "indexmap"
|
||||||
version = "2.12.0"
|
version = "2.12.0"
|
||||||
@@ -1741,6 +1767,16 @@ dependencies = [
|
|||||||
"windows-sys 0.61.2",
|
"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]]
|
[[package]]
|
||||||
name = "muda"
|
name = "muda"
|
||||||
version = "0.17.1"
|
version = "0.17.1"
|
||||||
@@ -1757,7 +1793,7 @@ dependencies = [
|
|||||||
"objc2-core-foundation",
|
"objc2-core-foundation",
|
||||||
"objc2-foundation",
|
"objc2-foundation",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"png",
|
"png 0.17.16",
|
||||||
"thiserror 2.0.17",
|
"thiserror 2.0.17",
|
||||||
"windows-sys 0.60.2",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
@@ -2225,6 +2261,19 @@ dependencies = [
|
|||||||
"miniz_oxide",
|
"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]]
|
[[package]]
|
||||||
name = "poly1305"
|
name = "poly1305"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
@@ -2346,6 +2395,15 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"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]]
|
[[package]]
|
||||||
name = "quote"
|
name = "quote"
|
||||||
version = "1.0.41"
|
version = "1.0.41"
|
||||||
@@ -3192,7 +3250,7 @@ dependencies = [
|
|||||||
"objc2-core-graphics",
|
"objc2-core-graphics",
|
||||||
"objc2-foundation",
|
"objc2-foundation",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"png",
|
"png 0.17.16",
|
||||||
"thiserror 2.0.17",
|
"thiserror 2.0.17",
|
||||||
"windows-sys 0.60.2",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -48,6 +48,9 @@ tray-icon = { version = "0.21.2", optional = true }
|
|||||||
tinyfiledialogs = { version = "3.9.1", optional = true }
|
tinyfiledialogs = { version = "3.9.1", optional = true }
|
||||||
open = { version = "5.3.0", 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]
|
[target.'cfg(windows)'.dependencies]
|
||||||
winapi = { version = "0.3.9", features = ["impl-default", "wincon", "shellscalingapi"] }
|
winapi = { version = "0.3.9", features = ["impl-default", "wincon", "shellscalingapi"] }
|
||||||
windows-service = "0.8.0"
|
windows-service = "0.8.0"
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ cargo build
|
|||||||
```
|
```
|
||||||
|
|
||||||
###  On Linux
|
###  On Linux
|
||||||
If you are building on Linux, you must ensure that you have `libwebkitgtk` library installed.
|
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` (on Debian/Ubuntu and derivatives).
|
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
|
####  On Arch Linux
|
||||||
|
|
||||||
|
|||||||
+23
-3
@@ -18,6 +18,7 @@ use alfis::eventbus::{post, register};
|
|||||||
use alfis::miner::Miner;
|
use alfis::miner::Miner;
|
||||||
use alfis::{keystore, Block, Bytes, Context, Keystore, Transaction};
|
use alfis::{keystore, Block, Bytes, Context, Keystore, Transaction};
|
||||||
use chrono::{Local, Utc};
|
use chrono::{Local, Utc};
|
||||||
|
use image::GenericImageView;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
use log::{debug, error, info, trace, warn, LevelFilter};
|
use log::{debug, error, info, trace, warn, LevelFilter};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -56,8 +57,10 @@ pub fn run_interface(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>, hid
|
|||||||
#[cfg(windows)]
|
#[cfg(windows)]
|
||||||
let icon = tray_icon::Icon::from_resource(1, None).unwrap();
|
let icon = tray_icon::Icon::from_resource(1, None).unwrap();
|
||||||
// Create tray icon
|
// Create tray icon
|
||||||
#[cfg(windows)]
|
#[cfg(not(target_os = "windows"))]
|
||||||
let _tray_icon = TrayIconBuilder::new()
|
let icon = load_icon_from_png();
|
||||||
|
|
||||||
|
let tray_icon = TrayIconBuilder::new()
|
||||||
.with_menu(Box::new(tray_menu))
|
.with_menu(Box::new(tray_menu))
|
||||||
.with_tooltip(&title)
|
.with_tooltip(&title)
|
||||||
.with_icon(icon)
|
.with_icon(icon)
|
||||||
@@ -370,7 +373,7 @@ pub fn run_interface(context: Arc<Mutex<Context>>, miner: Arc<Mutex<Miner>>, hid
|
|||||||
TrayIconEvent::Enter { .. } => {
|
TrayIconEvent::Enter { .. } => {
|
||||||
let nodes = connected_nodes.load(Ordering::SeqCst);
|
let nodes = connected_nodes.load(Ordering::SeqCst);
|
||||||
let title = format!("ALFIS {}\nConnected: {nodes}", env!("CARGO_PKG_VERSION"));
|
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)
|
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 {
|
fn check_record(data: &str) -> bool {
|
||||||
match serde_json::from_str::<DnsRecord>(data) {
|
match serde_json::from_str::<DnsRecord>(data) {
|
||||||
Ok(record) => {
|
Ok(record) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user