1
0
Fork 0
mirror of https://github.com/Zedfrigg/ironbar.git synced 2025-09-15 19:26:58 +02:00

chore(deps): update system-tray

This commit is contained in:
Jake Stanger 2025-07-14 19:27:51 +01:00
commit b68e4b4af9
No known key found for this signature in database
GPG key ID: C51FC8F9CB0BEA61
4 changed files with 13 additions and 11 deletions

5
Cargo.lock generated
View file

@ -3348,10 +3348,11 @@ dependencies = [
[[package]]
name = "system-tray"
version = "0.7.0"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c3397841ed755bf361606a845779e0f7333d35fb4e39627ef6f656d7cdad4c73"
checksum = "90d5d024b1573d22079347055d817863c21ea0903df404668095499c08800e4a"
dependencies = [
"cfg-if",
"dbusmenu-gtk3-sys",
"futures-lite",
"gtk",

View file

@ -177,7 +177,7 @@ futures-signals = { version = "0.3.34", optional = true }
sysinfo = { version = "0.36.0", optional = true }
# tray
system-tray = { version = "0.7.0", features = ["dbusmenu-gtk3"], optional = true }
system-tray = { version = "0.8.1", features = ["dbusmenu-gtk3"], optional = true }
# volume
libpulse-binding = { version = "2.30.1", optional = true }

View file

@ -11,6 +11,7 @@ use std::collections::HashSet;
use std::ffi::CStr;
use std::os::raw::{c_char, c_int};
use std::ptr;
use system_tray::item::IconPixmap;
/// Gets the GTK icon theme search paths by calling the FFI function.
/// Conveniently returns the result as a `HashSet`.
@ -45,10 +46,10 @@ pub fn get_image(
icon_theme: &IconTheme,
) -> Result<Image> {
if !prefer_icons && item.icon_pixmap.is_some() {
get_image_from_pixmap(item, size)
get_image_from_pixmap(item.icon_pixmap.as_deref(), size)
} else {
get_image_from_icon_name(item, size, icon_theme)
.or_else(|_| get_image_from_pixmap(item, size))
.or_else(|_| get_image_from_pixmap(item.icon_pixmap.as_deref(), size))
}
}
@ -81,12 +82,10 @@ fn get_image_from_icon_name(item: &TrayMenu, size: u32, icon_theme: &IconTheme)
/// which has 8 bits per sample and a bit stride of `4*width`.
/// The Pixbuf expects RGBA32 format, so some channel shuffling
/// is required.
fn get_image_from_pixmap(item: &TrayMenu, size: u32) -> Result<Image> {
fn get_image_from_pixmap(item: Option<&[IconPixmap]>, size: u32) -> Result<Image> {
const BITS_PER_SAMPLE: i32 = 8;
let pixmap = item
.icon_pixmap
.as_ref()
.and_then(|pixmap| pixmap.first())
.ok_or_else(|| Report::msg("Failed to get pixmap from tray icon"))?;

View file

@ -181,9 +181,11 @@ fn on_update(
UpdateEvent::AttentionIcon(_icon) => {
warn!("received unimplemented NewAttentionIcon event");
}
UpdateEvent::Icon(icon) => {
if icon.as_ref() != menu_item.icon_name() {
menu_item.set_icon_name(icon);
UpdateEvent::Icon { icon_name, icon_pixmap} => {
menu_item.icon_pixmap = icon_pixmap;
if icon_name.as_ref() != menu_item.icon_name() {
menu_item.set_icon_name(icon_name);
match icon::get_image(menu_item, icon_size, prefer_icons, icon_theme) {
Ok(image) => menu_item.set_image(&image),
Err(_) => menu_item.show_label(),