Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the Titlebaricon solve #715 #717

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pcap = "2.2.0"
etherparse = "0.17.0"
chrono = { version = "0.4.39", default-features = false, features = ["clock"] }
plotters = { version = "0.3.7", default-features = false, features = ["area_series"] }
iced = { version = "0.13.1", features = ["tokio", "svg", "advanced", "lazy"] }
iced = { version = "0.13.1", features = ["tokio", "svg", "advanced", "lazy", "image"] }
plotters-iced = "0.11.0"
maxminddb = "0.24.0"
confy = "0.6.1"
Expand Down
Binary file added src/app_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 14 additions & 8 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ mod utils;
pub const SNIFFNET_LOWERCASE: &str = "sniffnet";
pub const SNIFFNET_TITLECASE: &str = "Sniffnet";

// Load the icon file as raw bytes
const APP_ICON_BYTES: &[u8] = include_bytes!("app_icon.png");

/// Entry point of application execution
///
/// It initializes shared variables and loads configuration parameters
Expand All @@ -74,15 +77,15 @@ pub fn main() -> iced::Result {
let newer_release_available1 = Arc::new(Mutex::new(None));
let newer_release_available2 = newer_release_available1.clone();

// kill the main thread as soon as a secondary thread panics
// Kill the main thread as soon as a secondary thread panics
let orig_hook = panic::take_hook();
panic::set_hook(Box::new(move |panic_info| {
// invoke the default handler and exit the process
// Invoke the default handler and exit the process
orig_hook(panic_info);
process::exit(1);
}));

// gracefully close the app when receiving SIGINT, SIGTERM, or SIGHUP
// Gracefully close the app when receiving SIGINT, SIGTERM, or SIGHUP
ctrlc::set_handler(move || {
configs2.lock().unwrap().clone().store();
process::exit(130);
Expand All @@ -100,9 +103,12 @@ pub fn main() -> iced::Result {

let ConfigWindow { size, position, .. } = configs1.lock().unwrap().window;

// Load the application icon
let app_icon = window::icon::from_file_data(APP_ICON_BYTES, None).expect("Failed to load app icon");

application(SNIFFNET_TITLECASE, Sniffer::update, Sniffer::view)
.settings(Settings {
// id needed for Linux Wayland; should match StartupWMClass in .desktop file; see issue #292
// ID needed for Linux Wayland; should match StartupWMClass in .desktop file; see issue #292
id: Some(String::from(SNIFFNET_LOWERCASE)),
fonts: vec![
Cow::Borrowed(SARASA_MONO_BYTES),
Expand All @@ -114,15 +120,15 @@ pub fn main() -> iced::Result {
antialiasing: false,
})
.window(window::Settings {
size: size.to_size(), // start size
size: size.to_size(), // Start size
position: position.to_position(),
min_size: None, // Some(ConfigWindow::MIN_SIZE.to_size()), // min size allowed
min_size: None, // Some(ConfigWindow::MIN_SIZE.to_size()), // Min size allowed
max_size: None,
visible: true,
resizable: true,
decorations: true,
transparent: false,
icon: None,
icon: Some(app_icon), // Set the application icon here
#[cfg(target_os = "linux")]
platform_specific: PlatformSpecific {
application_id: String::from(SNIFFNET_LOWERCASE),
Expand All @@ -140,4 +146,4 @@ pub fn main() -> iced::Result {
boot_task_chain,
)
})
}
}
Loading